/* ==========================================================================
   Sportova hero — four-beat dot scene (hero → lonely player → map of Poland → crew)
   Ported from the design handoff (sportova-hero.component.scss), namespaced under `.sh`
   for the static landing. Copy blocks, buttons and colours reuse the landing tokens.

   @pattern Progressive enhancement — the same markup has two layouts:
     • static story (default): no JS, no WebGL2, or the engine failed (`.sh-nogl`).
       The four beats render as normal flowing content, so crawlers and every visitor
       still get the whole message and the CTAs.
     • live scene (`html.webgl2 .sh:not(.sh-nogl)`): a 660vh scroll track with a sticky
       full-viewport canvas driven by sportova-hero.engine.js. `html.webgl2` is set by the
       inline <head> script, i.e. before first paint, so neither path shifts the layout.

   ⚠️ Sticky + engine constraints. No ancestor of `.sh__track` (that is `.sh`, `main`,
   `body`, `html`) may set `overflow: hidden|auto|scroll`, `transform`, `filter`,
   `contain: paint` or `position` — the first four break `position: sticky`, and the
   engine reads `track.offsetTop` against `window.scrollY` (a positioned ancestor would
   change what offsetTop is relative to). The window must stay the scroll container.

   The track height and the engine's scene stops are coupled: `STOPS=[0,0.205,0.6,0.955]`
   in the engine assume 660vh. Change one, re-check the other.
   ========================================================================== */

.sh {
  --sh-ink-dim: #93a4a3;
  --sh-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  display: block;
  color: var(--color-heading);
  background:
    radial-gradient(60% 50% at 85% 30%, rgba(var(--accent-rgb), 0.1) 0%, transparent 70%),
    radial-gradient(50% 60% at 10% 90%, rgba(var(--primary-rgb), 0.12) 0%, transparent 70%), var(--background);
}

/* ── Static story (default) ───────────────────────────────────────────── */

.sh__sticky {
  width: var(--wrap);
  margin-inline: auto;
  padding-block: calc(var(--topbar-h) + clamp(48px, 8vw, 104px)) clamp(48px, 7vw, 88px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(32px, 4vw, 56px) clamp(24px, 3vw, 40px);
}

.sh__canvas,
.sh__scrim,
.sh__labels,
.sh__hint,
.sh__nav {
  display: none;
}

.sh__copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 22px;
}

.sh__copy--hero {
  grid-column: 1 / -1;
  max-width: 640px;
  padding-bottom: clamp(16px, 3vw, 40px);
}

.sh__copy--beat {
  gap: 14px;
  padding-top: 24px;
  border-top: 1px solid var(--border-glass);
}

/* ── Copy ─────────────────────────────────────────────────────────────── */

.sh__chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-glass-strong);
  color: var(--sh-ink-dim);
  font-size: 0.8125rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.sh__pulse {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.6);
  animation: sh-pulse 1.8s infinite;
}

@keyframes sh-pulse {
  70% {
    box-shadow: 0 0 0 9px rgba(var(--accent-rgb), 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0);
  }
}

/* Short laptop screens: the vh term keeps a 3-line title + lead + CTAs inside the viewport. */
.sh__title,
.sh__heading {
  hyphens: auto;
  overflow-wrap: break-word;
}

.sh__title {
  font-size: clamp(2.875rem, min(7.2vw, 10.5vh), 6rem);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.sh__heading {
  font-size: clamp(2rem, min(5.2vw, 8vh), 4.75rem);
  font-weight: 800;
  line-height: 0.98;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.sh__copy--beat .sh__heading {
  font-size: clamp(1.75rem, 2.6vw, 2.4rem);
}

.sh__lead {
  font-size: clamp(1rem, 1.4vw, 1.1875rem);
  color: var(--sh-ink-dim);
  max-width: 46ch;
  text-wrap: pretty;
}

.sh__lead strong {
  color: var(--color-heading);
  font-weight: 500;
}

.sh__ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.sh__sports {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.sh__sports span {
  font-size: 0.8125rem;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--sh-ink-dim);
  transition:
    color 0.3s,
    border-color 0.3s,
    background-color 0.3s,
    transform 0.5s var(--sh-spring);
}

/* `.on` is toggled by the engine (not BEM — the class name is part of the engine contract). */
.sh__sports .on {
  color: var(--color-heading);
  border-color: var(--border-strong);
  background: var(--bg-glass-strong);
  transform: translateY(-2px);
}

.sh__sports .sh__sports-more {
  opacity: 0.7;
}

.sh__proof {
  font-size: 0.85rem;
  color: var(--sh-ink-dim);
}

.sh__hint {
  font-size: 0.8125rem;
  color: var(--sh-ink-dim);
  align-items: center;
  gap: 8px;
}

.sh__hint > :first-child {
  color: var(--color-accent);
}

/* ── Live scene (WebGL2) ──────────────────────────────────────────────── */

.webgl2 .sh:not(.sh-nogl) {
  background: var(--background);
}

.webgl2 .sh:not(.sh-nogl) .sh__track {
  position: relative;
  height: 660vh;
}

.webgl2 .sh:not(.sh-nogl) .sh__sticky {
  position: sticky;
  top: 0;
  display: block;
  width: auto;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.webgl2 .sh:not(.sh-nogl) .sh__canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  /* Vertical swipes scroll the page; horizontal drags rotate the scene (engine pointer handlers). */
  touch-action: pan-y;
}

.webgl2 .sh:not(.sh-nogl) .sh__scrim {
  position: absolute;
  inset: 0;
  display: block;
  pointer-events: none;
  background: radial-gradient(120% 90% at 0% 50%, rgba(5, 9, 9, 0.85) 0%, rgba(5, 9, 9, 0.35) 45%, transparent 70%);
}

.webgl2 .sh:not(.sh-nogl) .sh__labels {
  position: absolute;
  inset: 0;
  display: block;
  pointer-events: none;
  opacity: 0;
}

/* City labels are created by the engine at runtime. */
.sh__labels span {
  position: absolute;
  top: 0;
  left: 0;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(5, 9, 9, 0.55);
  color: var(--color-heading);
  font: 500 0.6875rem var(--font-ui);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* Copy blocks: aligned with the topbar's content column; the engine fades/slides them
   with inline `opacity` / `visibility` / `translate` (which composes with `transform`). */
.webgl2 .sh:not(.sh-nogl) .sh__copy {
  position: absolute;
  top: 50%;
  left: calc((100% - var(--wrap)) / 2);
  width: min(580px, var(--wrap));
  max-width: none;
  padding: 0;
  border: 0;
  transform: translateY(-46%);
  will-change: opacity, transform;
}

/* The three later beats start invisible (and out of the accessibility tree) until the engine
   reveals them; the engine then owns these properties inline. */
.webgl2 .sh:not(.sh-nogl) .sh__copy--beat {
  gap: 22px;
  opacity: 0;
  visibility: hidden;
}

.webgl2 .sh:not(.sh-nogl) .sh__copy--beat .sh__heading {
  font-size: clamp(2.5rem, min(5.6vw, 9vh), 4.75rem);
}

.webgl2 .sh:not(.sh-nogl) .sh__copy--map {
  top: auto;
  bottom: 9vh;
  width: min(480px, var(--wrap));
  transform: none;
}

.webgl2 .sh:not(.sh-nogl) .sh__copy--map .sh__heading {
  font-size: clamp(2.125rem, min(4.6vw, 7.5vh), 3.75rem);
  line-height: 1;
}

.webgl2 .sh:not(.sh-nogl) .sh__hint {
  display: inline-flex;
}

/* Scene arrows — glass circles like the app's icon buttons; the brand gradient lights up on hover. They sit
   bottom-centre, below the scene (never over the athlete or the map); an arrow with nowhere to go is removed, so the
   remaining one stays centred. */
.webgl2 .sh:not(.sh-nogl) .sh__nav {
  position: absolute;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  z-index: 2;
  display: flex;
  gap: 12px;
  transform: translateX(-50%);
}

.sh__arrow {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--bg-glass-strong);
  color: var(--color-heading);
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition:
    opacity 0.25s ease,
    transform 0.45s var(--sh-spring),
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    color var(--transition-fast);
}

.sh__arrow svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sh__arrow:hover {
  border-color: transparent;
  background: var(--gradient-brand);
  color: var(--color-on-brand);
  box-shadow: 0 10px 30px -10px rgba(var(--accent-rgb), 0.55);
  transform: scale(1.08);
}

.sh__arrow:active {
  transform: scale(0.94);
}

.sh__arrow:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

.sh__arrow:disabled {
  display: none;
}

/* Last scene: ↓ continues to the page below — filled like a primary button and gently pulsing, so the end of the
   animation never reads as the end of the page. */
.sh__arrow.is-exit {
  border-color: transparent;
  background: var(--gradient-brand);
  color: var(--color-on-brand);
  animation: sh-exit-pulse 2s ease-out infinite;
}

@keyframes sh-exit-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.55);
  }

  70%,
  100% {
    box-shadow: 0 0 0 14px rgba(var(--accent-rgb), 0);
  }
}

/* ── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .sh__sticky {
    grid-template-columns: 1fr;
  }
}

/* Phones / narrow tablets: the athlete keeps the upper half, copy sits on a bottom scrim. */
@media (max-width: 820px) {
  .sh__lead {
    font-size: 0.9375rem;
  }

  .sh__sports span {
    font-size: 0.75rem;
    padding: 4px 9px;
  }

  /* Keeps the chip row to one line so the athlete keeps the upper half of the screen. */
  .sh__sports .sh__sports-more {
    display: none;
  }

  .sh__title {
    font-size: clamp(2.625rem, 12vw, 4rem);
  }

  .webgl2 .sh:not(.sh-nogl) .sh__scrim {
    background: linear-gradient(to top, rgba(5, 9, 9, 0.95) 0%, rgba(5, 9, 9, 0.7) 40%, transparent 70%);
  }

  .webgl2 .sh:not(.sh-nogl) .sh__copy {
    top: auto;
    bottom: calc(28px + env(safe-area-inset-bottom, 0px));
    gap: 16px;
    transform: none;
  }

  .webgl2 .sh:not(.sh-nogl) .sh__copy--beat {
    gap: 16px;
  }

  .webgl2 .sh:not(.sh-nogl) .sh__copy--map {
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 56px 16px calc(24px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to top, var(--background) 62%, transparent);
  }

  /* The copy owns the bottom of the screen on phones — the arrows stack top-right, under the topbar. */
  .webgl2 .sh:not(.sh-nogl) .sh__nav {
    top: calc(var(--topbar-h) + 16px);
    right: calc((100% - var(--wrap)) / 2);
    bottom: auto;
    left: auto;
    flex-direction: column;
    gap: 10px;
    transform: none;
  }

  .sh__arrow {
    width: 42px;
    height: 42px;
  }
}

/* Very short viewports (landscape phones, small laptops with toolbars): trim secondary copy so
   the CTAs never fall under the fold of the sticky scene. */
@media (max-height: 640px) {
  .webgl2 .sh:not(.sh-nogl) .sh__copy--hero .sh__sports,
  .webgl2 .sh:not(.sh-nogl) .sh__copy--hero .sh__proof {
    display: none;
  }

  .webgl2 .sh:not(.sh-nogl) .sh__copy {
    gap: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sh__pulse {
    animation: none;
  }

  .sh__sports span,
  .sh__arrow {
    transition: none;
  }

  .sh__arrow.is-exit {
    animation: none;
  }
}
