/* Rei da Quadra — página inicial: scrollytelling e movimento.
   Tudo o que anima fica sob .motion (JS ligado e sem "reduzir movimento").
   Sem JS ou com movimento reduzido, o layout abaixo continua completo e estático. */

:root { --ease-out: cubic-bezier(0.16, 1, 0.3, 1); }

/* ---------- Como funciona: layout base (vale também sem JS) ---------- */
.story-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr);
  gap: clamp(32px, 6vw, 96px); align-items: center;
}
.rally.story-steps { grid-template-columns: minmax(0, 1fr); gap: 28px; }
.rally.story-steps::before { left: 43px; right: auto; top: 0; bottom: 0; width: 2px; height: auto; }
.rally.story-steps li { display: grid; grid-template-columns: 88px minmax(0, 1fr); column-gap: 24px; padding: 0; }
.rally.story-steps li > *:not(.stop) { grid-column: 2; }
.rally.story-steps .stop { grid-row: span 3; }
.rally.story-steps h3 { margin-top: 6px; }

.story-device {
  position: relative; justify-self: center;
  height: min(600px, 72vh); aspect-ratio: 9 / 18.5;
  border-radius: 14% / 7%;
  background: var(--board-bg);
  box-shadow: 0 40px 80px -30px rgba(28, 8, 0, 0.45), 0 0 0 1px rgba(0, 0, 0, 0.08);
  /* Tudo dentro do aparelho escala pela largura dele (cqi), de 320 px ao desktop. */
  container-type: inline-size;
}
.story-notch { display: block; position: absolute; top: 3.6%; left: 50%; width: 30%; height: 3%; translate: -50% 0; border-radius: 999px; background: var(--board-bg); z-index: 2; }
.story-screen {
  position: absolute; inset: 2.2% 4.5%; border-radius: 11cqi; overflow: hidden;
  padding: 19cqi 6cqi 6cqi; background: var(--surface); color: var(--ink);
  display: flex; flex-direction: column; gap: 3.4cqi;
  font-size: clamp(8.5px, 6cqi, 16px);
  opacity: 0;
}
.story-screen:first-of-type { opacity: 1; }
.story-screen > * { min-width: 0; }
.sc-title { font: 900 1.3em/1.1 var(--font-display); text-transform: uppercase; letter-spacing: -0.02em; }
.sc-map {
  position: relative; flex: none; height: 34%; border-radius: 0.9em; overflow: hidden;
  background:
    linear-gradient(90deg, transparent 49%, rgba(255,255,255,.55) 49% 51%, transparent 51%),
    linear-gradient(0deg, transparent 49%, rgba(255,255,255,.55) 49% 51%, transparent 51%),
    var(--clay-500);
}
.pin { position: absolute; width: 1em; height: 1em; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--crown-300); box-shadow: 0 0 0 0.2em rgba(0,0,0,.25); }
.pin.p1 { left: 22%; top: 30%; } .pin.p2 { left: 62%; top: 52%; } .pin.p3 { left: 40%; top: 72%; background: #fff; }
.sc-row { display: grid; gap: 0.15em; padding: 0.6em 0.8em; border-radius: 0.8em; background: var(--surface-alt); }
.sc-row b, .sc-row span, .sc-card div b, .sc-card div span, .sc-rank b, .sc-score span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-row b, .sc-card div b { font-size: 1em; }
.sc-row span, .sc-card div span { font-size: 0.78em; color: var(--ink-3); }
.sc-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.6em; align-items: center; padding: 0.7em; border-radius: 0.9em; background: var(--surface-alt); }
.sc-card div { display: grid; min-width: 0; }
.sc-avatar { display: grid; place-items: center; width: 2.6em; height: 2.6em; border-radius: 50%; background: var(--court-600); color: #fff; font: 800 0.85em/1 var(--font-display); }
.sc-match { font: 900 1.1em/1 var(--font-display); color: var(--win); }
.sc-chips { display: flex; flex-wrap: wrap; gap: 0.4em; }
.sc-chips span { padding: 0.4em 0.7em; border-radius: 999px; border: 1.5px solid var(--line); font: 600 0.78em/1 var(--font-body); white-space: nowrap; }
.sc-btn {
  margin-top: auto; padding: 0.85em 0.6em; border-radius: 0.9em; text-align: center;
  background: var(--accent); color: var(--accent-ink); font: 800 0.9em/1.1 var(--font-body);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sc-btn .sc-short { display: none; }
@container (max-width: 250px) {
  .sc-btn .sc-long { display: none; }
  .sc-btn .sc-short { display: inline; }
}
.sc-score {
  display: grid; grid-template-columns: minmax(0, 1fr) 1.6em 1.6em; gap: 0.5em 0.6em; align-items: center;
  padding: 0.8em 0.9em; border-radius: 0.9em; background: var(--board-bg); color: var(--board-ink);
  font-variant-numeric: tabular-nums;
}
.sc-score span { font: 700 0.85em/1.2 var(--font-body); }
.sc-score b { font: 900 1.7em/1 var(--font-display); text-align: center; }
.sc-keys { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.4em; }
.sc-keys span { display: grid; place-items: center; height: 2.3em; border-radius: 0.55em; background: var(--surface-alt); font: 800 1.1em/1 var(--font-display); }
.sc-keys span.on { background: var(--accent); color: var(--accent-ink); }
.sc-rank { display: grid; grid-template-columns: 1.3em minmax(0, 1fr) auto; gap: 0.55em; align-items: center; padding: 0.65em 0.75em; border-radius: 0.75em; background: var(--surface-alt); font-size: 0.92em; }
.sc-rank span { font: 900 1.1em/1 var(--font-display); color: var(--ink-3); }
.sc-rank em { font: 800 0.85em/1 var(--font-display); font-style: normal; white-space: nowrap; }
.sc-rank.you { background: var(--accent-soft); color: var(--accent); }
.sc-rank.you span { color: var(--accent); }

@media (max-width: 860px) {
  .story-grid { grid-template-columns: minmax(0, 1fr); }
  /* Sem trilha presa no celular, o celular ilustrativo só ocupa espaço. */
  .story:not(.is-pinned) .story-device { display: none; }
}

/* ---------- Clubes: base (sem JS = grade original) ---------- */
.hband-viewport { position: relative; }

/* ---------- Botão de som (criado pelo JS) ---------- */
.sound-toggle {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 60;
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px;
  border: 1.5px solid var(--line-strong); border-radius: 999px;
  background: var(--surface); color: var(--ink);
  font: 700 0.8125rem/1 var(--font-body); cursor: pointer;
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.35);
}
.sound-toggle svg { width: 18px; height: 18px; }
.sound-toggle[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.sound-toggle .wave { opacity: 0; }
.sound-toggle[aria-pressed="true"] .wave { opacity: 1; }
.sound-toggle .mute { opacity: 1; }
.sound-toggle[aria-pressed="true"] .mute { opacity: 0; }
.sound-toggle:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
@media (max-width: 860px), (pointer: coarse) {
  .sound-toggle {
    width: 44px; height: 44px; min-height: 44px; padding: 0; justify-content: center; border-radius: 50%;
    right: max(12px, env(safe-area-inset-right)); bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .sound-toggle svg { width: 20px; height: 20px; }
  /* Rótulo continua para leitores de tela. */
  .sound-toggle span {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
  }
}
/* Espaço no fim da página para o botão flutuante não cobrir o rodapé. */
.has-sound-toggle .site-footer { padding-bottom: calc(32px + 64px + env(safe-area-inset-bottom)); }

/* =====================================================================
   A partir daqui: só com movimento (.motion)
   ===================================================================== */

/* ---------- Herói ---------- */
.motion .hero-glow {
  position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: 0;
  background: radial-gradient(520px circle at var(--gx, 70%) var(--gy, 30%), rgba(255, 221, 102, 0.24), rgba(255, 221, 102, 0.06) 40%, transparent 65%);
  transition: opacity 500ms var(--ease);
}
.motion .hero.is-pointer .hero-glow { opacity: 1; }
.motion .hero-court svg {
  translate: calc(var(--mx, 0) * -22px) calc(var(--my, 0) * -14px);
  transform-origin: 72% 45%;
}
.motion .hero h1 { translate: calc(var(--mx, 0) * 8px) calc(var(--my, 0) * 5px); transform-origin: 0 100%; }
.motion .hero h1 .ball {
  translate: calc(var(--mx, 0) * 16px) calc(var(--my, 0) * 12px);
  cursor: pointer; will-change: transform;
}
.motion .hero h1 .ball::after {
  content: ""; position: absolute; left: 10%; right: 10%; bottom: -0.16em; height: 0.08em; border-radius: 50%;
  background: rgba(40, 10, 0, 0.35); filter: blur(2px);
  translate: calc(var(--mx, 0) * -6px) 0;
}
.motion .hero h1 .ball.is-serve { animation: rq-serve 1100ms var(--ease-out); }
@keyframes rq-serve {
  0% { transform: none; }
  18% { transform: translate(-0.08em, 0.12em) scale(1.05, 0.9); }
  42% { transform: translate(0.9em, -1.6em) scale(0.8); }
  70% { transform: translate(0.25em, 0) scale(1.08, 0.86); }
  84% { transform: translate(0.08em, -0.28em) scale(0.96); }
  100% { transform: none; }
}
.motion .hero-board .board {
  transform: perspective(1000px) rotateY(calc(var(--mx, 0) * 9deg)) rotateX(calc(var(--my, 0) * -7deg));
  transform-style: preserve-3d; position: relative;
}
.motion .hero-board .board::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(240px circle at calc(50% + var(--mx, 0) * 40%) calc(30% + var(--my, 0) * 40%), rgba(255, 255, 255, 0.12), transparent 70%);
}
.motion [data-magnetic] { transition: background 200ms var(--ease), color 200ms var(--ease); will-change: translate; }

/* Rolagem do herói: título encolhe e esmaece, linhas de quadra dão "zoom".
   Nativo quando o navegador suporta scroll-driven animations; senão o JS define --hp. */
.motion.no-sdt .hero-court svg { scale: calc(1.03 + var(--hp, 0) * 0.55); opacity: calc(1 - var(--hp, 0) * 0.5); }
.motion.no-sdt .hero h1 { scale: calc(1 - var(--hp, 0) * 0.12); opacity: calc(1 - var(--hp, 0) * 1.1); }
@supports (animation-timeline: scroll()) {
  .motion:not(.no-sdt) .hero-court svg { animation: rq-court-zoom linear both; animation-timeline: scroll(root block); animation-range: 0 90vh; }
  .motion:not(.no-sdt) .hero h1 { animation: rq-title-out linear both; animation-timeline: scroll(root block); animation-range: 0 80vh; }
  .motion:not(.no-sdt) .clubs-court svg { animation: rq-drift linear both; animation-timeline: view(); }
}
@keyframes rq-court-zoom { from { scale: 1.03; opacity: 1; } to { scale: 1.6; opacity: 0.45; } }
@keyframes rq-title-out { from { scale: 1; opacity: 1; } to { scale: 0.88; opacity: 0.05; } }
@keyframes rq-drift { from { translate: 0 -6%; } to { translate: 0 6%; } }

/* Entrada do título do herói, linha a linha */
.motion .hero h1:not(.intro-done) .line { clip-path: inset(0 0 -0.2em 0); }
.motion .hero h1 .line > .lw { display: inline-block; animation: rq-rise 1000ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 110ms + 120ms); }
@keyframes rq-rise { from { transform: translateY(105%); } to { transform: none; } }

/* ---------- Tipografia cinética (títulos de seção) ---------- */
.motion .kinetic .kw { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: 0.1em; margin-bottom: -0.1em; }
.motion .kinetic .kwi { display: inline-block; transform: translateY(110%); transition: transform 900ms var(--ease-out); transition-delay: calc(var(--i, 0) * 55ms); }
.motion .kinetic.is-in .kwi { transform: none; }

/* Entrada escalonada dos blocos */
.motion .reveal { transition-delay: calc(var(--stagger, 0) * 90ms); }

/* Números do ticker virando como placar */
.motion .ticker b.is-flipping { animation: rq-flip 140ms linear; }
@keyframes rq-flip { 0% { transform: translateY(0); opacity: 1; } 50% { transform: translateY(-30%); opacity: 0.2; } 51% { transform: translateY(30%); opacity: 0.2; } 100% { transform: none; opacity: 1; } }

/* ---------- Como funciona: trilha presa ---------- */
.motion .story.is-pinned .story-track { height: 420vh; position: relative; }
.motion .story.is-pinned .story-sticky {
  position: sticky; top: 0; height: 100vh; height: 100dvh; box-sizing: border-box;
  padding-top: var(--header-h, 64px);
  display: flex; align-items: center; overflow: hidden;
}
.motion .story.is-pinned .rally.story-steps { gap: clamp(10px, 2.2vh, 22px); }
.motion .story.is-pinned .rally.story-steps::before { left: 31px; }
.motion .story.is-pinned .rally.story-steps li { grid-template-columns: 64px minmax(0, 1fr); }
.motion .story.is-pinned .story-steps .stop { width: 64px; height: 64px; font-size: 1.5rem; }
.motion .story.is-pinned .story-steps h3 { font-size: 1.25rem; margin-top: 2px; }
.motion .story.is-pinned .story-steps p { margin-top: 6px; font-size: 0.9375rem; }
.motion .story.is-pinned .story-steps .tag { margin-top: 8px; }
.motion .story.is-pinned .story-device { height: min(580px, calc(100vh - var(--header-h, 64px) - 64px)); }
.motion .story.is-pinned .story-sticky > .wrap { width: 100%; }
.motion .story.is-pinned .rally.story-steps::after {
  content: ""; position: absolute; left: 31px; top: 0; bottom: 0; width: 2px; background: var(--accent);
  transform: scaleY(var(--story-p, 0)); transform-origin: top;
}
.motion .story.is-pinned .story-steps li { opacity: 0.32; transition: opacity 400ms var(--ease); }
.motion .story.is-pinned .story-steps li.reveal { transform: none; }
.motion .story.is-pinned .story-steps li .stop { transition: background 300ms var(--ease), color 300ms var(--ease), border-color 300ms var(--ease), transform 500ms var(--ease-out); }
.motion .story.is-pinned[data-active="0"] .story-steps li:nth-child(1),
.motion .story.is-pinned[data-active="1"] .story-steps li:nth-child(2),
.motion .story.is-pinned[data-active="2"] .story-steps li:nth-child(3),
.motion .story.is-pinned[data-active="3"] .story-steps li:nth-child(4) { opacity: 1; }
.motion .story.is-pinned[data-active="0"] .story-steps li:nth-child(1) .stop,
.motion .story.is-pinned[data-active="1"] .story-steps li:nth-child(2) .stop,
.motion .story.is-pinned[data-active="2"] .story-steps li:nth-child(3) .stop,
.motion .story.is-pinned[data-active="3"] .story-steps li:nth-child(4) .stop {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent); transform: scale(1.08);
}
.motion .story .story-screen { transition: opacity 500ms var(--ease), transform 600ms var(--ease-out); transform: translateY(18px) scale(0.97); }
.motion .story .story-screen:first-of-type { opacity: 0; }
.motion .story[data-active="0"] .story-screen:nth-of-type(1),
.motion .story[data-active="1"] .story-screen:nth-of-type(2),
.motion .story[data-active="2"] .story-screen:nth-of-type(3),
.motion .story[data-active="3"] .story-screen:nth-of-type(4) { opacity: 1; transform: none; }
.motion .story.is-pinned .story-device { rotate: calc((var(--story-p, 0) - 0.5) * -6deg); }

@media (max-width: 860px) {
  .motion .story.is-pinned .story-track { height: 340vh; }
  .motion .story.is-pinned .story-grid { grid-template-rows: auto auto; gap: 18px; }
  .motion .story.is-pinned .story-device { order: -1; height: min(44vh, 420px); }
  /* Reserva a faixa do botão de som para ele não cobrir o texto do passo. */
  .has-sound-toggle.motion .story.is-pinned .story-sticky { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
  /* Só o passo ativo aparece; os quatro dividem a mesma área. */
  .motion .story.is-pinned .rally.story-steps { display: grid; grid-template-columns: minmax(0, 1fr); }
  .motion .story.is-pinned .rally.story-steps::before, .motion .story.is-pinned .rally.story-steps::after { display: none; }
  .motion .story.is-pinned .story-steps li { grid-area: 1 / 1; opacity: 0; grid-template-columns: 56px minmax(0, 1fr); column-gap: 14px; }
  .motion .story.is-pinned .story-steps .stop { width: 56px; height: 56px; font-size: 1.25rem; }
  .motion .story.is-pinned .story-steps h3 { font-size: 1.125rem; }
  .motion .story.is-pinned .story-steps p { font-size: 0.9375rem; }
}

/* ---------- Ranking guiado pela rolagem ---------- */
.motion [data-motion-ladder] li { will-change: transform; transition: none; }
.motion [data-motion-ladder] li.is-you { position: relative; z-index: 1; box-shadow: 0 10px 24px -14px rgba(0, 0, 0, 0.45); }
.motion [data-motion-ladder] .crown-icon { transition: none; }
.motion .scopes button { transition: background 300ms var(--ease), color 300ms var(--ease); }

/* ---------- Clubes: faixa horizontal ---------- */
@media (min-width: 861px) {
  .motion .hband.is-pinned { padding-top: 0; padding-bottom: 0; }
  .motion .hband.is-pinned .hband-track { position: relative; }
  .motion .hband.is-pinned .hband-sticky {
    position: sticky; top: 0; height: 100vh; height: 100dvh; overflow: hidden; box-sizing: border-box;
    padding-top: var(--header-h, 64px);
    display: flex; flex-direction: column; justify-content: center;
  }
  .motion .hband.is-pinned .section-head { margin-bottom: clamp(24px, 4vh, 48px); }
  .motion .hband.is-pinned .club-list {
    display: flex; gap: 20px; border-top: 0; width: max-content; will-change: transform;
  }
  .motion .hband.is-pinned .club-list li {
    width: clamp(280px, 26vw, 360px); min-height: clamp(220px, 32vh, 300px);
    grid-template-columns: minmax(0, 1fr); align-content: space-between;
    padding: 28px; border: 1px solid rgba(255, 255, 255, 0.22); border-radius: 10px;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  }
  .motion .hband.is-pinned .club-list li:nth-child(odd),
  .motion .hband.is-pinned .club-list li:nth-child(even) { border-right: 1px solid rgba(255, 255, 255, 0.22); padding-left: 28px; }
  .motion .hband.is-pinned .club-list li b { font-size: clamp(2.5rem, 4vw, 3.5rem); color: var(--clay-400); }
  .motion .hband.is-pinned .clubs-cta { margin-top: clamp(20px, 4vh, 40px); }
}

/* ---------- Cursor (anel que segue, só mouse) ---------- */
.cursor-ring {
  position: fixed; left: 0; top: 0; z-index: 70; pointer-events: none;
  width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%;
  border: 1.5px solid #fff; mix-blend-mode: difference; opacity: 0;
  transition: opacity 300ms var(--ease), scale 300ms var(--ease-out);
}
.cursor-ring.is-on { opacity: 0.85; }
.cursor-ring.is-hover { scale: 1.9; }

@media (prefers-reduced-motion: reduce) {
  .cursor-ring { display: none; }
}
