/* One stylesheet for the whole site.
 *
 * Shared rather than inlined per page, because there are three pages now and
 * a policy whose colours drift from the support page it links to reads as two
 * different companies. It is small enough that the extra request costs
 * nothing next to that.
 *
 * The palette is the game's own — GamePalette in lib/game/game_config.dart —
 * so the page a player lands on from inside the app looks like the app they
 * left. Light and dark both, because a legal page opened at midnight should
 * not be a white rectangle.
 */
:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #16202e;
  --muted: #55637a;
  --line: #dfe4ec;
  --accent: #8a6d00;
  --panel: #f6f8fb;

  /* Brand art colours — the ball and the three brick tiers from the app icon
   * and feature graphic. Decorative, not text, so they stay constant across
   * light and dark rather than adapting like the tokens above. */
  --ball-hi: #dff1fa;
  --ball-fill: #7fb6d0;
  --ball-lo: #3f6f8a;
  --brick-red-hi: #ff6b6f;
  --brick-red: #ed1b23;
  --brick-red-lo: #9c1116;
  --brick-orange-hi: #ffc46b;
  --brick-orange: #f2a93b;
  --brick-orange-lo: #a86c14;
  --brick-yellow-hi: #fff29a;
  --brick-yellow: #ffd400;
  --brick-yellow-lo: #b99b00;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0e1c;
    --fg: #e6edf3;
    --muted: #a3b4cc;
    --line: #26324b;
    --accent: #ffd400;
    --panel: #131a2e;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  padding: 0 20px 80px;
  -webkit-text-size-adjust: 100%;
}

main { max-width: 720px; margin: 0 auto; }

header {
  padding: 56px 0 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 32px;
}

h1 { font-size: 30px; margin: 0 0 8px; letter-spacing: -0.01em; }
h2 { font-size: 19px; margin: 40px 0 10px; letter-spacing: -0.005em; }
h3 {
  font-size: 15px; margin: 24px 0 6px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}

.lede { color: var(--muted); font-size: 15px; margin: 0; }
ul { padding-left: 20px; }
li { margin: 6px 0; }
a { color: var(--accent); }
a:hover { text-decoration: none; }

table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 15px; }
th, td {
  text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--line); vertical-align: top;
}
th {
  color: var(--muted); font-weight: 600; font-size: 13px;
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* Wide content scrolls inside its own box rather than pushing the page
 * sideways — a table that makes the body scroll horizontally on a phone is
 * the fastest way to make a legal page unreadable on the device most people
 * will open it on. */
.scroll { overflow-x: auto; }

.box {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 16px 18px; margin: 20px 0;
}
.box p:first-child { margin-top: 0; }
.box p:last-child { margin-bottom: 0; }

nav { margin: 28px 0 0; font-size: 15px; }
nav a { margin-right: 18px; }

footer {
  margin-top: 56px; padding-top: 20px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 14px;
}

code {
  background: var(--panel); padding: 1px 5px; border-radius: 4px;
  font-size: 0.9em;
}

/* Site-wide top bar — present on every page (including the plain legal
 * pages) so a reader who lands on /privacy.html directly still recognises
 * whose policy it is and can get back to the game in one tap. Full-bleed,
 * unlike <main>, so it reads as a fixed strip rather than part of the prose
 * column beneath it. */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  transition: box-shadow 0.25s ease;
}
.topbar.is-scrolled { box-shadow: 0 8px 24px -14px rgba(0, 0, 0, 0.45); }
.topbar-inner {
  max-width: 1120px; margin: 0 auto; width: 100%;
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 8px 16px;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  color: var(--fg); text-decoration: none; font-weight: 700; font-size: 16px;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand svg { display: block; flex: none; transition: transform 0.2s ease; }
.brand:hover svg { transform: scale(1.12); }
.topnav { margin: 0; font-size: 14px; display: flex; flex-wrap: wrap; align-items: center; }
.topnav a {
  position: relative; color: var(--muted); margin-left: 22px; margin-right: 0;
  padding-bottom: 2px; transition: color 0.2s ease;
}
.topnav a::after {
  content: ""; position: absolute; left: 0; right: 100%; bottom: -3px;
  height: 2px; background: var(--accent); transition: right 0.25s ease;
}
.topnav a:hover { color: var(--fg); }
.topnav a:hover::after { right: 0; }

/* --- Landing page (index.html) ------------------------------------------
 * Everything below is scoped to body.landing so the legal pages keep the
 * plain, narrow-column prose style above untouched. */
body.landing main { max-width: 1120px; }
body.landing header { display: none; } /* the hero replaces it */

.hero {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  align-items: center; gap: 32px; padding: 64px 0 56px;
}

/* Hero entrance — each child fades and rises in on load, staggered so the
 * eye is led from the eyebrow down to the store badges. */
@keyframes heroUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}
.hero-copy > * { animation: heroUp 0.7s ease both; }
.hero-copy > .eyebrow { animation-delay: 0s; }
.hero-copy > h1 { animation-delay: 0.06s; }
.hero-copy > .lede { animation-delay: 0.12s; }
.hero-copy > .store-badges { animation-delay: 0.26s; }

@keyframes pillPulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 35%, transparent); }
  50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 0%, transparent); }
}
.eyebrow {
  display: inline-block; margin: 0 0 16px; padding: 5px 12px;
  border-radius: 999px; background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  animation: heroUp 0.7s ease both, pillPulse 2.6s ease-out 0.7s infinite;
}
.hero h1 { font-size: 48px; margin: 0 0 6px; letter-spacing: -0.02em; }
.hero .lede { font-size: 20px; margin: 0 0 18px; }
.hero-copy > p:not(.lede) { max-width: 46ch; animation-delay: 0.18s; }
.hero-art {
  display: flex; align-items: center; justify-content: center;
  animation: heroUp 0.8s ease 0.1s both;
}
.hero-art svg { width: 100%; max-width: 380px; height: auto; }

/* The ball actually bounces — a settling drop-and-rebound loop, with a
 * shadow beneath it that flattens and fades as the ball rises. This is,
 * after all, what the app is called. */
@keyframes ballBounce {
  0%, 100% { transform: translateY(0); }
  15% { transform: translateY(-50px); }
  30% { transform: translateY(0); }
  40% { transform: translateY(-16px); }
  50% { transform: translateY(0); }
  58% { transform: translateY(-6px); }
  64% { transform: translateY(0); }
}
@keyframes ballShadowPulse {
  0%, 100% { transform: scaleX(1); opacity: 0.35; }
  15% { transform: scaleX(0.55); opacity: 0.12; }
  30% { transform: scaleX(1); opacity: 0.35; }
  40% { transform: scaleX(0.75); opacity: 0.2; }
  50% { transform: scaleX(1); opacity: 0.35; }
  58% { transform: scaleX(0.9); opacity: 0.28; }
  64% { transform: scaleX(1); opacity: 0.35; }
}
.ball-anim {
  animation: ballBounce 2.4s ease-in-out infinite;
  transform-box: fill-box; transform-origin: 50% 100%;
}
.ball-shadow {
  animation: ballShadowPulse 2.4s ease-in-out infinite;
  transform-box: fill-box; transform-origin: 50% 50%;
}

.store-badges { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.badge {
  display: flex; align-items: center; gap: 11px;
  border: 1px solid var(--line); background: var(--panel);
  border-radius: 12px; padding: 9px 18px 9px 14px; font-size: 14px; font-weight: 600;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.badge:hover { transform: translateY(-2px); border-color: var(--muted); }
.badge-icon { width: 24px; height: 24px; flex: none; fill: var(--fg); }
.badge-text { display: flex; flex-direction: column; gap: 2px; }
.badge-text small {
  font-size: 11px; font-weight: 500; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}

body.landing section { padding: 48px 0; border-top: 1px solid var(--line); }
body.landing section > h2 { font-size: 26px; margin: 0 0 8px; letter-spacing: -0.01em; }
.section-lede { color: var(--muted); font-size: 15px; margin: 0 0 28px; max-width: 60ch; }

.feature-grid, .perk-grid {
  display: grid; gap: 18px; margin-top: 24px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.feature, .perk {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 22px;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.feature:hover, .perk:hover {
  transform: translateY(-4px);
  border-color: var(--accent-c, var(--accent));
  box-shadow: 0 16px 32px -18px rgba(0, 0, 0, 0.5);
}

/* Cards fade up into place as they cross into view — see site.js. Purely
 * additive: with JS disabled, .reveal-init is never applied and every card
 * is simply visible from the start. */
.reveal-init { opacity: 0; transform: translateY(20px); }
.reveal-init.reveal-visible {
  opacity: 1; transform: none;
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.feature h3, .perk h3 {
  color: var(--fg); text-transform: none; letter-spacing: -0.005em;
  font-size: 17px; margin: 0 0 8px;
}
.feature p, .perk p { margin: 0; color: var(--muted); font-size: 14.5px; }
.feature-icon {
  width: 40px; height: 40px; border-radius: 10px; margin-bottom: 14px;
  background: color-mix(in srgb, var(--icon-c, var(--accent)) 16%, transparent);
  display: flex; align-items: center; justify-content: center;
}
.feature-icon svg { width: 20px; height: 20px; }

.perk { border-top: 3px solid var(--accent-c, var(--accent)); }
.perk .kicker {
  display: block; font-size: 11px; font-weight: 700; color: var(--accent-c, var(--accent));
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px;
}

@keyframes ctaGlow {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}
.cta-band {
  position: relative; overflow: hidden;
  text-align: center; border-radius: 20px; margin: 48px 0;
  background: var(--panel);
  border: 1px solid var(--line); padding: 48px 24px;
}
.cta-band::before {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background: radial-gradient(60% 120% at 50% 0%,
    color-mix(in srgb, var(--accent) 16%, transparent), transparent);
  animation: ctaGlow 4s ease-in-out infinite;
}
.cta-band > * { position: relative; z-index: 1; }
.cta-band h2 { margin: 0 0 8px; }
.cta-band p { color: var(--muted); margin: 0 auto 8px; max-width: 48ch; }
.cta-band .store-badges { justify-content: center; margin-top: 24px; }

body.landing footer { border-top: none; margin-top: 0; padding-top: 0; }
.footer-grid {
  display: flex; flex-wrap: wrap; gap: 24px; justify-content: space-between;
  padding-top: 24px; border-top: 1px solid var(--line);
}
.footer-note { margin: 20px 0 0; color: var(--muted); font-size: 13px; max-width: 60ch; }

@media (max-width: 760px) {
  .hero { grid-template-columns: minmax(0, 1fr); padding-top: 40px; }
  .hero-art { order: -1; }
  .hero-art svg { max-width: 260px; }
  .hero h1 { font-size: 36px; }
  .hero .lede { font-size: 18px; }
  .topnav a { margin-left: 14px; }
}
@media (max-width: 420px) {
  .topnav a:first-child { margin-left: 0; }
}

html { scroll-behavior: smooth; }

/* Every animation and transition on the site funnels through here. One
 * rule, rather than a media guard on each keyframe, so nothing new added
 * above can accidentally skip it. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
