/* ==========================================================================
   Gramofon 3D — sekcja #przyklady (flaga LANDING_SLUCHALNIA)
   Wszystko pod prefiksem vs- (vinyl stage). Kolory/fonty wyłącznie z tokenów
   main.css. Bez backdrop-filter nad płótnem (koszt GPU przy każdej klatce):
   pasek i podpowiedź mają pełne tło z cieniem.
   ========================================================================== */

/* Caveat (OFL, app/static/fonts/caveat-OFL.txt) — odręczne pismo: tekst piosenki
   w pasku i dopisek „Chcę taką piosenkę”. Ładowany tylko z tym arkuszem. */
@font-face {
  font-family: 'Caveat';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/caveat-600-normal-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Caveat';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/caveat-600-normal-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

.vs-section {
  --vs-hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --vs-room: #f3e6e1;            /* tło sceny = kolor „pokoju” płótna (czytany przez JS) */
  --vs-table: #e9d9d1;           /* blat pod gramofonem */
  position: relative;
  padding-bottom: 0;
  background:
    var(--grain),
    linear-gradient(180deg, var(--bg) 0%, var(--vs-room) 34%, var(--vs-room) 100%);
  border-top: 1px solid rgba(176, 141, 87, .22);
}
.vs-section .section-head { margin-bottom: var(--sp-3); }

/* Scena na całą szerokość i prawie cały ekran wysokości — gramofon ma
   wypełnić sekcję (kadr kamery dopasowuje się do tych wymiarów). */
.vs-stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  width: 100%;
  height: clamp(640px, 92svh, 1040px);
  background: var(--vs-room);
  outline: none;
  contain: layout paint;
}
.vs-stage:focus-visible { box-shadow: inset 0 0 0 3px var(--accent-ring); }
@media (max-width: 760px) {
  .vs-stage { height: clamp(660px, 185vw, 900px); }
}

/* Plakat (statyczny zrzut sceny) do czasu wczytania 3D; potem przenika w płótno. */
.vs-poster,
.vs-poster img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.vs-poster { z-index: 2; transition: opacity .6s ease; pointer-events: none; }
.vs-stage[data-state="ready"] .vs-poster { opacity: 0; }

.vs-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  /* Przewijanie pionowe i zoom zostają przeglądarce; JS blokuje gest
     (preventDefault w touchstart) tylko, gdy dotyk zaczyna się na płycie. */
  touch-action: pan-y pinch-zoom;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.vs-stage.is-dragging,
.vs-stage.is-dragging * { cursor: grabbing !important; }

/* Miękkie wejście/wyjście sceny w tło sekcji (sam gradient — tani). */
.vs-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    linear-gradient(to bottom, var(--vs-room) 0%, transparent 4%, transparent 94%, var(--vs-room) 100%);
}

/* Podpowiedź nad sceną (w zwykłym układzie), stała wysokość jednej-dwóch linii,
   żeby komunikat głośności nie przesuwał sceny. */
.vs-hint {
  margin: 0 auto;
  padding: 0 var(--sp-4);
  max-width: 34em;
  min-height: calc(2 * var(--lh-snug) * 1em);
  text-align: center;
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
  color: var(--ink-soft);
}
.vs-hint.is-nudge { animation: vs-nudge .7s cubic-bezier(.3, .7, .2, 1); }
.vs-hint.is-volume { color: var(--accent); font-weight: 700; }
@keyframes vs-nudge {
  0%, 100% { transform: none; }
  25% { transform: translateX(-6px); }
  55% { transform: translateX(5px); }
  80% { transform: translateX(-2px); }
}

/* ---------- pasek odtwarzacza ---------- */
.vs-player {
  position: absolute;
  left: 50%;
  bottom: clamp(14px, 3.4vh, 30px);
  z-index: 6;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: var(--sp-3);
  width: min(560px, calc(100% - 28px));
  padding: 8px 10px 8px 8px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translate(-50%, 18px);
  pointer-events: none;
  transition: opacity .45s ease, transform .6s var(--ease-out);
}
.vs-player.is-shown { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.vs-player__thumb { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; background: var(--border); display: block; }
.vs-player__meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
/* Typografia odtwarzacza: tytuł kursywą DM Serif, linijka tekstu piosenki
   odręcznym Caveat (jak tekst zapisany ręcznie), stan drobnymi kapitalikami. */
.vs-player__state {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--brass-ink);
}
.vs-player__title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 1.3rem;
  line-height: 1.1;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vs-player__kara {
  margin: 0;
  min-height: 1.3em;
  font-family: var(--vs-hand);
  font-weight: 600;
  font-size: 1.12rem;
  line-height: 1.2;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vs-player__kara .is-on { color: var(--accent); }
.vs-player__time { font-size: var(--fs-xs); font-variant-numeric: tabular-nums; color: var(--ink-soft); min-width: 3.2em; text-align: right; }
.vs-icon-btn {
  appearance: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color var(--dur-2);
}
.vs-icon-btn:hover { background: var(--accent-soft); }
.vs-icon-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.vs-icon-btn svg { width: 15px; height: 15px; fill: currentColor; }
.vs-icon-btn .vs-i-pause,
.vs-icon-btn.is-on .vs-i-play { display: none; }
.vs-icon-btn.is-on .vs-i-pause { display: block; }
/* Pasek postępu = suwak przewijania: strefa kliknięcia 18 px nad dolną
   krawędzią paska, sama belka 3 px — po najechaniu pogrubia się do 6 px. */
.vs-seek {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: -9px;
  height: 18px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
  outline: none;
}
.vs-seek__track {
  position: relative;
  display: block;
  width: 100%;
  height: 3px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--border);
  transition: height var(--dur-2) var(--ease-out);
}
.vs-seek:hover .vs-seek__track,
.vs-seek:focus-visible .vs-seek__track,
.vs-seek.is-seeking .vs-seek__track { height: 6px; }
.vs-seek:focus-visible .vs-seek__track { box-shadow: var(--focus-ring); }
.vs-seek__fill { display: block; height: 100%; background: var(--grad-accent); transform-origin: 0 50%; transform: scaleX(0); }
@media (max-width: 560px) {
  .vs-player { grid-template-columns: 42px minmax(0, 1fr) auto auto; gap: 10px; }
  .vs-player__time { display: none; }
  .vs-player__thumb { width: 42px; height: 42px; }
}

/* ---------- podpowiedź nad obiektem (tylko mysz) ---------- */
.vs-tip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 7;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 12px 10px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, calc(-100% - 4px));
  transition: opacity .2s ease, transform .25s ease;
}
.vs-tip.is-shown { opacity: 1; transform: translate(-50%, calc(-100% - 12px)); }
.vs-tip strong { font-family: var(--font-display); font-weight: 400; font-size: var(--fs-base); color: var(--ink); }
.vs-tip span { font-size: var(--fs-xs); color: var(--ink-soft); }
.vs-tip em { font-style: normal; font-size: var(--fs-xs); color: var(--accent); margin-top: 2px; }
.vs-tip span:empty,
.vs-tip em:empty { display: none; }

/* ---------- przyciski płyt: zapas bez 3D + sterowanie klawiaturą ---------- */
.vs-keys {
  position: absolute;
  left: 50%;
  bottom: clamp(96px, 15vh, 130px);
  z-index: 8;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-2);
  width: max-content;
  max-width: calc(100% - 28px);
}
/* Po wczytaniu 3D przyciski chowają się wizualnie, ale zostają w kolejności
   tabulacji — pojawiają się przy fokusie (klawiatura, czytnik ekranu). */
.vs-stage[data-state="ready"] .vs-keys { opacity: 0; pointer-events: none; transition: opacity .2s; }
.vs-stage[data-state="ready"] .vs-keys:focus-within { opacity: 1; pointer-events: auto; }
.vs-key {
  appearance: none;
  display: inline-flex;
  align-items: baseline;
  gap: .45em;
  min-height: var(--touch);
  padding: 10px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
}
.vs-key:hover { border-color: var(--accent); }
.vs-key:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.vs-key.is-on { border-color: var(--accent); background: var(--accent-soft); }
.vs-key__n { font-weight: 700; color: var(--accent); }
.vs-key__tag { font-size: var(--fs-xs); color: var(--ink-faint); }
@media (max-width: 560px) { .vs-key__tag { display: none; } }

.vs-start {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 9;
  transform: translate(-50%, -50%);
  min-height: var(--touch);
  padding: 12px 22px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 700;
  box-shadow: var(--shadow-md);
  cursor: pointer;
}
.vs-start:hover { background: var(--accent-hover); }
.vs-start[hidden] { display: none; }

/* ---------- dopisek ołówkiem „Chcę taką piosenkę” ---------- */
/* Wiersz nad sceną (stała wysokość): u góry podpowiedź / komunikat głośności,
   u dołu dopisek; strzałka wchodzi w górną krawędź sceny i celuje w płytę. */
.vs-lead {
  position: relative;
  z-index: 10;                                 /* strzałka nad płótnem sceny */
  height: clamp(100px, 8vw, 118px);
}
.vs-cta {
  --vs-pencil: #4a3f42;
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  pointer-events: none;
}
.vs-cta__link {
  position: relative;
  display: inline-flex;
  align-items: flex-start;
  gap: 2px;
  margin-left: -48px;
  color: var(--vs-pencil);
  text-decoration: none;
  pointer-events: none;
  visibility: hidden;
}
.vs-cta.is-drawn .vs-cta__link { visibility: visible; }
.vs-cta.is-live .vs-cta__link { pointer-events: auto; cursor: pointer; }
/* ołówkowa strzałka: ogon wychodzi od gramofonu (w dół, na scenę), łuk
   w górę i w prawo, grot wskazuje napis (koniec na wysokości środka tekstu) */
.vs-cta__arrow {
  width: clamp(78px, 7vw, 104px);
  height: auto;
  overflow: visible;
  margin-top: 2px;
  margin-bottom: calc(-1 * clamp(34px, 3.4vw, 48px));
}
.vs-cta__words { position: relative; display: inline-block; padding-bottom: 10px; }
.vs-cta__text {
  display: inline-block;
  font-family: var(--vs-hand);
  font-weight: 600;
  font-size: clamp(1.7rem, 1.25rem + 1.4vw, 2.35rem);
  line-height: 1;
  white-space: nowrap;
  transform: rotate(-2.5deg);
  transform-origin: left bottom;
  clip-path: inset(-20% 100% -30% 0);
}
.vs-cta__underline {
  position: absolute;
  left: -2%;
  bottom: 0;
  width: 104%;
  height: 14px;
  overflow: visible;
  transform: rotate(-2.5deg);
  transform-origin: left bottom;
}
.vs-cta__stroke {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  filter: url(#vsPencil);
}
/* kolejność: trzon strzałki → grot → tekst (nierówne tempo pisania) → podkreślenie */
.vs-cta.is-drawn .vs-cta__shaft { animation: vs-draw .85s cubic-bezier(.45, .05, .35, 1) forwards; }
.vs-cta.is-drawn .vs-cta__head { animation: vs-draw .3s ease-out .85s forwards; }
.vs-cta.is-drawn .vs-cta__text { animation: vs-write 1.6s linear 1.05s forwards; }
.vs-cta.is-drawn .vs-cta__underline .vs-cta__stroke { animation: vs-draw .5s cubic-bezier(.5, 0, .3, 1) 2.7s forwards; }
@keyframes vs-draw { to { stroke-dashoffset: 0; } }
@keyframes vs-write {
  0% { clip-path: inset(-20% 100% -30% 0); }
  18% { clip-path: inset(-20% 78% -30% 0); }
  30% { clip-path: inset(-20% 66% -30% 0); }   /* przerwa między słowami */
  52% { clip-path: inset(-20% 44% -30% 0); }
  62% { clip-path: inset(-20% 36% -30% 0); }
  100% { clip-path: inset(-20% -4% -30% 0); }
}
.vs-cta.is-live .vs-cta__link:hover,
.vs-cta.is-live .vs-cta__link:focus-visible { color: var(--accent); }
.vs-cta.is-live .vs-cta__link:focus-visible { outline: none; }
.vs-cta.is-live .vs-cta__link:focus-visible .vs-cta__text { text-shadow: 0 0 0.01px; box-shadow: var(--focus-ring); border-radius: 6px; }
@media (max-width: 560px) {
  .vs-cta__link { margin-left: -24px; }
}

@media (prefers-reduced-motion: reduce) {
  .vs-poster, .vs-player, .vs-tip, .vs-keys { transition: none; }
  .vs-hint.is-nudge { animation: none; }
  .vs-cta.is-drawn .vs-cta__stroke,
  .vs-cta.is-drawn .vs-cta__text { animation: none; stroke-dashoffset: 0; clip-path: none; }
}
