/* 140.6 homepage: carbon race engineering composition.
   Layout truth lives in HTML; this file only styles it. Static flow is the
   default. `html.cinematic` (set by an inline head script and confirmed by
   scripts/race-motion.js) switches the hero + race sequence into one pinned,
   scroll-scrubbed stage on capable desktop viewports without reduced motion. */

body { overflow-x: clip; }
main { padding-top: var(--header-h); }
:root { --header-h: 72px; }

.wrap { width: min(var(--max), calc(100% - 2 * var(--gutter))); margin-inline: auto; }
section { scroll-margin-top: var(--header-h); }

.kicker {
  margin-bottom: 14px;
  color: var(--violet-light);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.kicker-index { color: var(--faint); font-variant-numeric: tabular-nums; }
.section { padding: clamp(72px, 9vw, 116px) 0; border-top: 1px solid var(--line-soft); }
.section-head { max-width: 720px; margin-bottom: clamp(34px, 5vw, 56px); }
.section h2 { margin-bottom: 14px; font-size: clamp(1.9rem, 3.6vw, 2.9rem); line-height: 1.04; letter-spacing: -.035em; }
.section-intro { max-width: 58ch; margin: 0; color: var(--muted); font-size: 1.05rem; line-height: 1.6; }
.mono {
  font-feature-settings: var(--tabular);
  font-variant-numeric: tabular-nums;
}

/* ---------- Header ---------- */
.site-header {
  position: fixed;
  z-index: 40;
  top: 0;
  right: 0;
  left: 0;
  height: var(--header-h);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(4, 8, 18, .78);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  backdrop-filter: blur(18px) saturate(1.2);
}
.nav { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand-lockup { min-height: 44px; display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand-mark-image { width: 32px; height: 32px; display: block; border: 1px solid rgba(168, 151, 240, .38); border-radius: 8px; background: #1a0c3a; }
.brand-copy { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font-size: 1.02rem; font-weight: 800; letter-spacing: -.045em; }
.brand-subtitle { margin-top: 4px; color: var(--faint); font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.nav-links { display: flex; align-items: center; gap: 4px 22px; margin: 0; padding: 0; list-style: none; }
.nav-links a { min-height: 44px; display: inline-flex; align-items: center; color: var(--muted); text-decoration: none; font-size: .85rem; font-weight: 600; }
.nav-links a:hover { color: var(--ink); }
.nav-download {
  padding: 0 14px;
  border: 1px solid rgba(168, 151, 240, .38);
  border-radius: 999px;
  color: var(--ink) !important;
  background: var(--selected);
  white-space: nowrap;
}
.nav-download:hover { background: var(--selection-fill); }

/* ---------- Cinema stage (hero + race) ---------- */
.cinema {
  position: relative;
  isolation: isolate;
  background: var(--bg);
}
.cinema::before,
.stage-lines { display: none; }

/* ---------- Hero ---------- */
.hero { padding: clamp(48px, 7vw, 92px) 0 clamp(40px, 6vw, 72px); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(300px, .95fr); align-items: center; gap: clamp(32px, 6vw, 88px); }
.hero-copy { max-width: 600px; }
.hero-copy h1 { margin-bottom: 20px; font-size: clamp(2.7rem, 5.6vw, 4.6rem); line-height: .98; letter-spacing: -.05em; }
.hero-lede { max-width: 540px; margin-bottom: 26px; color: var(--muted); font-size: clamp(1.02rem, 1.5vw, 1.18rem); line-height: 1.55; }
.hero-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 14px 22px; }
.app-store-link { min-height: 48px; display: inline-flex; align-items: center; border-radius: 9px; }
.app-store-badge { width: 168px; height: auto; display: block; }
.hero-qr { display: none; align-items: center; gap: 12px; color: var(--faint); font-size: .85rem; line-height: 1.4; }
.hero-qr img { width: 64px; height: 64px; display: block; border-radius: 6px; }
.hero-qr span { max-width: 130px; }

/* Two independent phones. No shared backdrop; each is its own object. */
.hero-phones { position: relative; width: 100%; aspect-ratio: 1 / 1.3; }
.phone {
  --phone-w: 300px;
  position: relative;
  width: var(--phone-w);
  padding: 8px;
  border-radius: calc(var(--phone-w) * .17);
  background: linear-gradient(155deg, #202a48 0%, #0a1024 38%, #070c1a 70%, #1a2340 100%);
  box-shadow:
    inset 0 0 0 1px rgba(174, 200, 235, .26),
    inset 0 1px 0 rgba(255, 255, 255, .18),
    0 50px 90px -30px rgba(0, 0, 0, .85),
    0 20px 40px -20px rgba(0, 0, 0, .7),
    0 0 0 1px rgba(0, 0, 0, .7);
  will-change: transform;
}
.phone::before, .phone::after {
  content: "";
  position: absolute;
  width: 2px;
  border-radius: 2px;
  background: rgba(174, 200, 235, .35);
}
.phone::before { left: -3px; top: 22%; height: 11%; }
.phone::after { right: -3px; top: 26%; height: 16%; }
.phone-screen {
  position: relative;
  overflow: hidden;
  border-radius: calc(var(--phone-w) * .145);
  background: var(--bg);
}
.screen { display: block; margin: 0; }
.screen img { width: 100%; height: auto; display: block; }
.screen + .screen { position: absolute; inset: 0; opacity: 0; }
.hero-phone-primary { position: absolute; top: 0; right: 0; z-index: 2; --phone-w: 58%; rotate: -4deg; transform-origin: center; }
.hero-phone-secondary { position: absolute; bottom: 0; left: 0; z-index: 1; --phone-w: 44%; rotate: 5deg; transform-origin: center; }
.hero-phones .phone { padding: 2.2%; }

/* ---------- Race sequence ---------- */
.race { padding: clamp(40px, 6vw, 72px) 0 clamp(64px, 8vw, 100px); border-top: 1px solid var(--line-soft); }
.race-head { max-width: 680px; margin-bottom: 30px; }
.race-head h2 { margin-bottom: 10px; font-size: clamp(1.7rem, 3.1vw, 2.5rem); line-height: 1.05; letter-spacing: -.035em; }
.race-head p { max-width: 58ch; margin: 0; color: var(--muted); font-size: 1rem; }

/* Proportional course rail: flex-basis carries the exact mile share. */
.rail { position: relative; margin: 0 0 34px; }
.rail-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.rail-legend li { display: inline-flex; align-items: center; gap: 8px; }
.rail-legend li::before { content: ""; width: 9px; height: 9px; border-radius: 2px; background: var(--dot, var(--muted)); }
.rail-legend .is-swim { --dot: var(--swim); }
.rail-legend .is-bike { --dot: var(--bike); }
.rail-legend .is-run { --dot: var(--run); }
.rail-legend .is-total { margin-left: auto; color: var(--ink); }
.rail-legend .is-total::before { display: none; }
.rail-legend data { color: var(--ink); font-variant-numeric: tabular-nums; }
.rail-bar { position: relative; display: flex; height: 6px; border-radius: 3px; overflow: visible; background: rgba(174, 200, 235, .08); }
.rail-seg { flex: var(--share) 0 0; min-width: 6px; height: 100%; background: var(--seg); opacity: .55; }
.rail-seg:first-child { border-radius: 3px 0 0 3px; }
.rail-seg:last-child { border-radius: 0 3px 3px 0; }
.rail-seg.is-swim { --seg: var(--swim); }
.rail-seg.is-bike { --seg: var(--bike); margin-inline: 2px; }
.rail-seg.is-run { --seg: var(--run); }
.rail-ticks { position: absolute; inset: -6px 0 auto; height: 18px; pointer-events: none; }
.rail-ticks span { position: absolute; top: 0; width: 1px; height: 18px; background: rgba(174, 200, 235, .45); }
.rail-ticks .t1 { left: calc(2.4 / 140.6 * 100%); }
.rail-ticks .t2 { left: calc(114.4 / 140.6 * 100%); }
.rail-ticks i { position: absolute; top: 20px; left: 4px; color: var(--faint); font-size: .58rem; font-style: normal; font-weight: 700; letter-spacing: .1em; }
.rail-marker {
  position: absolute;
  top: 50%;
  left: 0;
  width: 14px;
  height: 14px;
  border: 3px solid var(--violet);
  border-radius: 50%;
  background: var(--ink);
  translate: -50% -50%;
  box-shadow: 0 0 0 2px rgba(174, 200, 235, .34);
  display: none;
}

.race-icon-stage { display: none; }

.phases { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; counter-reset: phase; }
.phase {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 132px;
  gap: 20px 24px;
  align-items: center;
  padding: 22px 0;
  border-top: 1px solid var(--line);
}
.phase:last-child { border-bottom: 1px solid var(--line); }
.phase-glyph { width: 96px; height: 64px; display: block; --prop: var(--violet-light); }
.phase[data-phase="swim"] .phase-glyph { --prop: var(--swim); }
.phase[data-phase="bike"] .phase-glyph { --prop: var(--bike); }
.phase[data-phase="run"] .phase-glyph { --prop: var(--run); }
.phase-body { min-width: 0; }
.phase-index { display: block; margin-bottom: 8px; color: var(--faint); font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.phase h3 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin: 0 0 8px; font-size: clamp(1.35rem, 2.2vw, 1.8rem); line-height: 1.05; letter-spacing: -.035em; }
.phase[data-phase="swim"] { --phase-color: var(--swim); }
.phase[data-phase="bike"] { --phase-color: var(--bike); }
.phase[data-phase="run"] { --phase-color: var(--run); }
.phase p { max-width: 560px; margin: 0; color: var(--muted); font-size: .95rem; line-height: 1.55; }
.phase-phone { width: 132px; margin: 0; justify-self: end; }
.phase-phone .phone { --phone-w: 132px; padding: 4px; }

/* Flat race pictograms share one viewBox, stroke weight, and optical scale.
   The symbols carry their own presentation styles so <use> clones inherit
   the phase's ink/accent variables in both the static list and stage. */
.phase-glyph, .race-icon { color: var(--ink); overflow: visible; }
.race-icon-layer { transform-box: fill-box; transform-origin: center; }
.phase[data-phase="swim"] .phase-glyph, .race-icon-layer[data-icon-layer="swim"] { --prop: var(--swim); }
.phase[data-phase="bike"] .phase-glyph, .race-icon-layer[data-icon-layer="bike"] { --prop: var(--bike); }
.phase[data-phase="run"] .phase-glyph, .race-icon-layer[data-icon-layer="run"] { --prop: var(--run); }

/* ---------- Product proof ---------- */
.proof-layout { display: grid; gap: clamp(28px, 5vw, 52px); }
.proof-layout .section-head { margin-bottom: 0; }
.surfaces { margin: 0; padding: 0; list-style: none; counter-reset: surface; border-top: 1px solid var(--line); }
.surface { display: grid; grid-template-columns: 52px minmax(120px, .42fr) minmax(0, 1fr); gap: 18px 22px; padding: 24px 0; border-bottom: 1px solid var(--line); }
.surface-index { color: var(--faint); font-size: .7rem; font-weight: 700; letter-spacing: .12em; font-variant-numeric: tabular-nums; padding-top: 6px; }
.surface h3 { margin: 0; font-size: clamp(1.3rem, 2vw, 1.7rem); line-height: 1.05; letter-spacing: -.035em; color: var(--ink); }
.surface p { max-width: 58ch; margin: 0; color: var(--muted); font-size: .92rem; line-height: 1.55; }
.surface[data-surface="plan"] { --surface-color: var(--violet-light); }
.surface[data-surface="log"] { --surface-color: var(--run); }
.surface[data-surface="fuel"] { --surface-color: var(--fuel); }
.surface[data-surface="recovery"] { --surface-color: #d5bfff; }
.surface[data-surface="stats"] { --surface-color: var(--swim); }

/* ---------- Personalized training ---------- */
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.step { padding: 26px 26px 28px 0; border-right: 1px solid var(--line); }
.step + .step { padding-left: 26px; }
.step:last-child { border-right: 0; padding-right: 0; }
.step-index { display: flex; align-items: center; gap: 10px; margin-bottom: 44px; color: var(--violet-light); font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.step-index::before { content: ""; width: 22px; height: 1px; background: var(--violet); }
.step h3 { margin-bottom: 10px; font-size: 1.22rem; line-height: 1.12; letter-spacing: -.025em; }
.step p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.55; }

/* ---------- FAQ ---------- */
.faq-shell { max-width: 860px; }
.faq-shell .section-head { margin: 0 auto 28px; text-align: center; }
.faq-shell .section-head h2 { margin-bottom: 0; }
.faq-list { border-top: 1px solid var(--line); }
.faq-item { border-bottom: 1px solid var(--line); }
.faq-item summary { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 56px; padding: 14px 0; cursor: pointer; list-style: none; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; flex: none; width: 28px; height: 28px; display: inline-grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--violet-light); font-size: 1.05rem; font-weight: 600; line-height: 1; transition: transform .2s ease; }
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item h3 { margin: 0; font-size: 1.02rem; font-weight: 600; letter-spacing: -.01em; }
.faq-body { padding: 0 44px 20px 0; }
.faq-body p { max-width: 58ch; margin: 0; color: var(--muted); font-size: .92rem; line-height: 1.6; }
.faq-body a { color: #c8c0f5; text-underline-offset: 4px; padding-block: 14px; }
.faq-legal { max-width: 60ch; margin: 18px 0 0; color: var(--faint); font-size: .9rem; line-height: 1.5; }

/* ---------- Download ---------- */
.download { text-align: center; background: var(--surface); }
.download-mark { width: 96px; height: 96px; display: block; margin: 0 auto 24px; border: 1px solid rgba(168, 151, 240, .45); border-radius: 16px; background: #1a0c3a; }
.download h2 { max-width: 640px; margin: 0 auto 14px; font-size: clamp(2rem, 4.2vw, 3.3rem); }
.download .section-intro { margin: 0 auto; }
.download-actions { display: flex; align-items: center; justify-content: center; gap: 24px; margin-top: 32px; }
.download-qr { width: 120px; height: 120px; display: block; border-radius: 10px; }
.download-cta { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; text-align: left; }
.download-cta p { margin: 0; color: var(--faint); font-size: .76rem; }
.download-cta .app-store-badge { width: 180px; }
.download-links { margin: 26px 0 0; color: var(--faint); font-size: .8rem; }
.download-links a { color: var(--muted); text-underline-offset: 4px; padding-block: 14px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line-soft); }
.footer-inner { display: grid; grid-template-columns: 1fr auto; gap: 22px 36px; align-items: center; padding: 34px 0; }
.footer-copy { margin: 8px 0 0; color: var(--faint); font-size: .76rem; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 20px; }
.footer-links a { min-height: 44px; display: inline-flex; align-items: center; color: var(--muted); font-size: .78rem; text-underline-offset: 5px; }
.footer-legal { grid-column: 1 / -1; max-width: 58ch; margin: 0; padding-top: 14px; border-top: 1px solid var(--line-soft); color: var(--faint); font-size: .8rem; line-height: 1.5; }

/* ---------- Static reveal (JS only, never hides content without JS) ---------- */
.js .reveal { opacity: 0; translate: 0 14px; transition: opacity .6s ease, translate .6s ease; }
.js .reveal.is-visible { opacity: 1; translate: 0 0; }

/* ---------- Cinematic stage (desktop, JS, motion allowed) ---------- */
.cinematic .cinema { height: calc(100vh - var(--header-h)); min-height: 640px; overflow: hidden; }
.cinematic .hero { position: absolute; inset: 0; display: grid; align-items: center; padding: 0; }
.cinematic .hero-grid { grid-template-columns: minmax(0, 1.05fr) minmax(300px, .95fr); }
.cinematic .hero-phones { aspect-ratio: auto; height: min(78vh, 720px); }
.cinematic .hero-phone-primary { --phone-w: min(300px, 21vw); rotate: 0deg; }
.cinematic .hero-phone-secondary { --phone-w: min(220px, 15.6vw); rotate: 0deg; bottom: 4%; }
.cinematic .hero-phones .phone { padding: 8px; }
.cinematic .race { position: absolute; inset: 0; padding: 0; border: 0; }
.cinematic .race > .wrap {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(280px, .78fr) minmax(0, 1.22fr) minmax(220px, 300px);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 0 clamp(24px, 4vw, 56px);
  align-items: center;
  padding: clamp(28px, 5vh, 56px) 0 clamp(24px, 4vh, 40px);
}
.cinematic .race-head { grid-area: 1 / 1; align-self: start; margin: 0; opacity: 0; }
.cinematic .race-head h2 { font-size: 1.15rem; letter-spacing: -.02em; }
.cinematic .race-head p { font-size: .84rem; }
.cinematic .rail { grid-area: 2 / 1 / 3 / -1; margin: 0; opacity: 0; }
.cinematic .rail-marker { display: block; }
.cinematic .race-icon-stage { grid-area: 1 / 2; display: block; position: relative; width: 100%; max-width: 520px; justify-self: center; opacity: 0; }
.cinematic .race-icon-stage::before { content: none; }
.cinematic .race-icon-stage .race-icon { width: 100%; height: auto; }
.cinematic .stage-slot { grid-area: 1 / 3; display: block; width: 100%; max-width: 300px; aspect-ratio: 393 / 852; justify-self: end; }
.cinematic .phases { grid-area: 1 / 1; position: relative; display: block; align-self: center; min-height: 260px; margin: 0; }
.cinematic .phase { position: absolute; inset: 0 auto auto 0; width: 100%; display: block; padding: 0; border: 0; opacity: 0; }
.cinematic .phase-glyph, .cinematic .phase-phone { display: none; }
.cinematic .phase h3 { font-size: clamp(1.7rem, 2.6vw, 2.4rem); }
.cinematic .phase p { font-size: 1rem; max-width: 460px; }
.stage-slot { display: none; }

/* ---------- Responsive ---------- */
@media (min-width: 1100px) {
  .hero-qr { display: inline-flex; }
}
@media (max-width: 980px) {
  .hero-grid { grid-template-columns: 1fr; gap: 36px; }
  .hero-phones { width: min(100%, 520px); margin-inline: auto; }
}
@media (max-width: 720px) {
  :root { --header-h: 64px; }
  body { font-size: 16px; }
  .brand-subtitle { display: none; }
  .nav-links { gap: 0 14px; }
  .nav-links li.nav-secondary { display: none; }
  .hero { padding-top: 40px; }
  .hero-copy h1 { font-size: clamp(2.35rem, 11vw, 3.4rem); }
  .hero-phones { aspect-ratio: 1 / 1.2; }
  .hero-phone-primary { --phone-w: 56%; }
  .hero-phone-secondary { --phone-w: 42%; }
  .section { padding: 64px 0; }
  .section-head { margin-bottom: 30px; }
  .race-head { margin-bottom: 22px; }
  .rail-legend { gap: 4px 14px; font-size: .64rem; }
  .rail-legend .is-total { margin-left: 0; flex-basis: 100%; }
  .phase { grid-template-columns: 64px minmax(0, 1fr); gap: 12px 16px; padding: 18px 0; }
  .phase-glyph { width: 64px; height: 44px; }
  .phase-phone { grid-column: 2; width: 116px; justify-self: start; }
  .phase-phone .phone { --phone-w: 116px; }
  .surface { grid-template-columns: 40px minmax(0, 1fr); gap: 10px 14px; padding: 20px 0; }
  .surface p { grid-column: 2; }
  .steps { grid-template-columns: 1fr; }
  .step { padding: 22px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .step + .step { padding-left: 0; }
  .step:last-child { border-bottom: 0; }
  .step-index { margin-bottom: 22px; }
  .faq-body { padding-right: 0; }
  .download-actions { flex-direction: column; gap: 16px; }
  .download-qr { display: none; }
  .download-cta { align-items: center; text-align: center; }
  .footer-inner { grid-template-columns: 1fr; gap: 16px; }
  .footer-links { justify-content: flex-start; gap: 2px 16px; }
}
@media (max-width: 400px) {
  .hero-actions { flex-direction: column; align-items: flex-start; gap: 10px; }
  .phase { grid-template-columns: 52px minmax(0, 1fr); }
  .phase-glyph { width: 52px; height: 36px; }
}

/* Reduced motion: immediate static states, no reveal delays, no scrub.
   The cinematic class is never applied when this query matches. */
@media (prefers-reduced-motion: reduce) {
  .js .reveal { opacity: 1; translate: 0 0; transition: none; }
  .faq-item summary::after { transition: none; }
}
