/* Public site styles.

   Palette comes from lib/theme/app_tokens.dart so the site and the app are
   recognisably one product: brand violet #A855F7 on the near-black brandInk /
   brandDeep, coral action, and the six feature accents.

   Two hard constraints, both from the hosting CSP (`default-src 'none'`):
     - no JavaScript, so every animation here is CSS;
     - no webfonts at all (font-src has no allowance), so the system stack is
       not a preference, it is the only option.

   The legal documents keep the typography of lib/screens/legal_text.dart —
   15px/700 headers, body at line-height 1.55 — so the in-app and web copies
   read the same. Hand-written; tool/gen_legal_web.mjs never touches this file. */

:root {
  /* brand — fixed in both themes, as in AppTokens */
  --brand: #a855f7;
  --brand-ink: #0e0716;
  --brand-deep: #1a0b2e;
  --ball-glow: #e9d5ff;
  --coral: #ff6b6b;

  /* surfaces — these are the ones that flip */
  --bg: #ffffff;
  --surface: #f7f7f9;
  --text-hi: #101418;
  --text-mid: #333c45;
  --text-lo: #6b7681;
  --rule: #e3e7eb;
  --link: #7c3aed;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d0d;
    --surface: #1a1a1a;
    --text-hi: #f2f5f7;
    --text-mid: #c3ccd4;
    --text-lo: #8b96a1;
    --rule: #242b32;
    --link: #c4a0ff;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-mid);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

header,
main,
footer {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── document header ─────────────────────────────────────────────────────── */

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-top: 20px;
  padding-bottom: 20px;
}

.home {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text-hi);
  text-decoration: none;
  letter-spacing: 0.01em;
}

.mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: block;
}

.lang { font-size: 13px; color: var(--text-lo); }

a { color: var(--link); }
a:hover { text-decoration: underline; }

/* ── typography ──────────────────────────────────────────────────────────── */

h1 {
  color: var(--text-hi);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
  margin: 8px 0 16px;
}

h2 {
  color: var(--text-hi);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
  margin: 32px 0 8px;
}

h3 {
  color: var(--text-hi);
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 4px;
}

p { margin: 0 0 12px; }

.caption {
  color: var(--text-lo);
  font-size: 13px;
  font-style: italic;
  margin-bottom: 20px;
}

/* ── hero ────────────────────────────────────────────────────────────────── */

/* Always dark, in both themes — this is the app's own header band (AppTokens
   scopes the brand violet to exactly this one surface). */
.hero {
  background:
    radial-gradient(120% 90% at 50% 0%, var(--brand-deep) 0%, var(--brand-ink) 62%),
    var(--brand-ink);
  border-bottom: 1px solid #2a1b3d;
  overflow: hidden;
}

.hero-inner {
  max-width: 46rem;
  margin: 0 auto;
  padding: 56px 20px 40px;
  text-align: center;
}

.hero-logo {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  box-shadow: 0 0 0 1px #3b2a55, 0 12px 40px rgba(168, 85, 247, 0.35);
}

.hero h1 {
  color: #fff;
  font-size: 40px;
  letter-spacing: -0.02em;
  margin: 20px 0 6px;
}

.hero .tagline {
  color: var(--ball-glow);
  font-size: 14px;
  letter-spacing: 0.02em;
  margin-bottom: 18px;
}

.hero .lead {
  color: #cfc4dd;
  font-size: 17px;
  line-height: 1.5;
  max-width: 34rem;
  margin: 0 auto 8px;
}

/* entrance: each element a beat after the one above it */
.hero-logo,
.hero h1,
.hero .tagline,
.hero .lead,
.hero .art { animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both; }
.hero h1 { animation-delay: 0.06s; }
.hero .tagline { animation-delay: 0.12s; }
.hero .lead { animation-delay: 0.18s; }
.hero .art { animation-delay: 0.24s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ── hero artwork ────────────────────────────────────────────────────────── */

.art {
  display: block;
  width: 100%;
  max-width: 30rem;
  height: auto;
  margin: 8px auto 0;
  overflow: visible;
}

.art-table {
  fill: rgba(168, 85, 247, 0.10);
  stroke: #6d3fa8;
  stroke-width: 1.5;
}

.art-line {
  fill: none;
  stroke: #7c4dbe;
  stroke-width: 1.5;
}

/* posts + cord */
.art-net {
  fill: none;
  stroke: #9a6ede;
  stroke-width: 1.5;
  stroke-dasharray: 3 3;
}

/* flight path draws itself, then holds */
.art-path {
  fill: none;
  stroke: var(--brand);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 4 6;
  opacity: 0.65;
  animation: draw 4.4s linear infinite;
}

@keyframes draw {
  from { stroke-dashoffset: 80; }
  to { stroke-dashoffset: 0; }
}

/* the detected bounce: a ring that fires as the ball lands */
.art-bounce {
  fill: none;
  stroke: var(--coral);
  stroke-width: 2;
  transform-origin: 255px 108px;
  animation: bounce 4.4s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes bounce {
  0%, 48% { opacity: 0; transform: scale(0.4); }
  52% { opacity: 0.95; transform: scale(1); }
  70%, 100% { opacity: 0; transform: scale(1.9); }
}

/* Glow is geometry, not a CSS filter — see the note in tool/gen_legal_web.mjs. */
.art-ball .glow { fill: var(--ball-glow); opacity: 0.22; }
.art-ball .core { fill: #fff; }

/* Resting state = the finished frame: ball on the bounce, box locked on, ring
   fired. The animations below override it while they run, so if they never run
   — reduced motion, an engine that skips them, a stylesheet that loads without
   animation support — the artwork still reads as a tracked bounce instead of
   collapsing to an empty table. Animations must never be load-bearing for
   whether something is visible at all. */
.art-ball,
.art-box { transform: translate(255px, 108px); }
.art-bounce { opacity: 0.95; }

.art-box path {
  fill: none;
  stroke: var(--coral);
  stroke-width: 2;
  stroke-linecap: round;
}

/* Ball and tracking box share one flight, so the box stays locked on. The
   keyframes are sampled from .art-path: launch, apex, descent, bounce on the
   far half, then away. */
/* `flight` carries motion only; fading is a separate animation per element, so
   the ball can appear for the whole arc while the box latches on later and lets
   go earlier. Keeping opacity out of `flight` also means the two elements have
   the same animation shape, which is what keeps them exactly in step. */
.art-ball,
.art-box { animation: flight 4.4s cubic-bezier(0.4, 0, 0.6, 1) infinite; }

.art-ball { animation-name: flight, ballfade; }
.art-box { animation-name: flight, boxfade; }

@keyframes flight {
  0%   { transform: translate(55px, 140px) scale(1); }
  12%  { transform: translate(103px, 91px) scale(1); }
  25%  { transform: translate(152px, 70px) scale(1); }
  38%  { transform: translate(203px, 75px) scale(1); }
  50%  { transform: translate(255px, 108px) scale(1.18, 0.82); }
  75%  { transform: translate(325px, 79px) scale(1); }
  100% { transform: translate(395px, 52px) scale(1); }
}

@keyframes ballfade {
  0%, 100% { opacity: 0; }
  6%, 94% { opacity: 1; }
}

@keyframes boxfade {
  0%, 100% { opacity: 0; }
  18%, 82% { opacity: 0.9; }
}

/* ── feature cards ───────────────────────────────────────────────────────── */

.features {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 14px;
  margin: 16px 0 0;
  padding: 0;
}

/* AppTokens feature accents. These live here rather than in a `style` attribute
   on the card because the CSP (`style-src 'self'`) blocks inline styles — and
   blocks them silently, leaving the icon with no stroke at all. */
.f-ball { --accent: #ff6b6b; }     /* accentVideo */
.f-stroke { --accent: #4dd0e1; }   /* accentRacket */
.f-drills { --accent: #ffab40; }   /* accentDrill */
.f-stats { --accent: #b388ff; }    /* accentStats */
.f-club { --accent: #5c6bc0; }     /* accentClub */
.f-device { --accent: #69f0ae; }   /* accentFitness */

.feature {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 20px;               /* AppTokens.radiusCard */
  padding: 18px;
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1),
              border-color 0.32s ease, box-shadow 0.32s ease;
}

.feature:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 10px 30px -12px var(--accent);
}

.feature .ico {
  width: 26px;
  height: 26px;
  margin-bottom: 10px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.feature p {
  margin: 0;
  font-size: 14px;
  color: var(--text-lo);
}

/* ── download block ──────────────────────────────────────────────────────── */

.stores {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin: 16px 0 0;
  padding: 0;
}

.store {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.store a { font-weight: 600; text-decoration: none; }
.store a:hover { text-decoration: underline; }

/* The QR SVGs carry an opaque white ground so they stay scannable in dark
   mode; the padded card makes that read as deliberate rather than broken. */
.store img {
  display: block;
  width: 160px;
  height: auto;
  max-width: 100%;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 14px;               /* AppTokens.radiusChip */
}

.soon { color: var(--text-lo); font-size: 14px; margin-top: 12px; }

/* ── document index ──────────────────────────────────────────────────────── */

.index { padding-top: 8px; padding-bottom: 8px; }

.docs {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}

.docs li { border-bottom: 1px solid var(--rule); }

.docs a {
  display: inline-block;
  padding: 14px 0;
  text-decoration: none;
  font-weight: 600;
}

.docs a:hover { text-decoration: underline; }

.tag {
  color: var(--text-lo);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── footer ──────────────────────────────────────────────────────────────── */

footer {
  margin-top: 48px;
  padding-top: 20px;
  padding-bottom: 40px;
  border-top: 1px solid var(--rule);
  color: var(--text-lo);
  font-size: 13px;
}

/* ── narrow screens ──────────────────────────────────────────────────────── */

@media (max-width: 30rem) {
  .hero-inner { padding: 40px 20px 32px; }
  .hero h1 { font-size: 32px; }
  .hero .lead { font-size: 15px; }
  h1 { font-size: 21px; }
  h2 { font-size: 16px; }
}

/* ── reduced motion ──────────────────────────────────────────────────────── */

/* Everything above is decoration. Someone who has asked for less movement gets
   the finished frame: ball resting at the bounce, path drawn, nothing looping. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  /* the base rules above already are the parked frame; just stop the loops */
  .art-ball,
  .art-box,
  .art-bounce,
  .art-path { animation: none; }
  .art-box { opacity: 0.9; }
  .art-path { stroke-dashoffset: 0; }
}
