/* Chess Openings Personal Coach — site styles.
   Tokens mirror the app (lib/theme.ts): violet is the product, gold is Premium only. */
:root {
  --bg: #F6F5F2;
  --surface: #FFFFFF;
  --surface-alt: #EDECE7;
  --border: #E4E1DA;
  --text: #181820;
  --muted: #62626B;
  --primary: #6E56CF;
  --primary-ink: #FFFFFF;
  --primary-soft: rgba(110, 86, 207, 0.11);
  --premium: #9A6C12;
  --premium-soft: rgba(184, 134, 42, 0.12);
  --success: #2E8355;
  --danger: #C4442F;
  --board-light: #EFEDF7;
  --board-dark: #8A82C0;
  --shadow: 0 10px 30px rgba(27, 24, 48, 0.09);
  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --sans: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --page: 1080px;
  --gutter: clamp(16px, 4vw, 32px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131419;
    --surface: #1B1D24;
    --surface-alt: #23262F;
    --border: #2D313B;
    --text: #F3F3F6;
    --muted: #A2A6B4;
    --primary: #8674E8;
    --primary-ink: #0E1216;
    --primary-soft: rgba(134, 116, 232, 0.16);
    --premium: #E0B15C;
    --premium-soft: rgba(224, 177, 92, 0.13);
    --success: #5EC78A;
    --danger: #EB7C6C;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { animation: none !important; transition: none !important; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { display: block; max-width: 100%; height: auto; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; border-radius: 6px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 10px 14px; border-radius: 10px; z-index: 10; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.eyebrow { font: 700 12px/1.3 var(--sans); letter-spacing: 0.09em; text-transform: uppercase; color: var(--primary); }
h1 { font: 600 clamp(36px, 6.4vw, 60px)/1.04 var(--serif); letter-spacing: -0.015em; text-wrap: balance; }
h2 { font: 600 clamp(28px, 4.2vw, 40px)/1.1 var(--serif); letter-spacing: -0.01em; text-wrap: balance; }
h3 { font: 700 18px/1.3 var(--sans); }
h4 { font: 700 17px/1.3 var(--sans); }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 24px; border-radius: 999px; border: 0;
  font: 700 16px/1 var(--sans); text-decoration: none; cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.12s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--primary); color: var(--primary-ink); }
.btn--primary:hover { opacity: 0.92; }
.btn--quiet { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1.5px var(--border); }
.btn--quiet:hover { background: var(--surface-alt); }
.btn--small { min-height: 40px; padding: 0 16px; font-size: 14px; }
.btn--wide { width: min(100%, 340px); }
.btn[disabled] { opacity: 0.55; cursor: progress; }

/* ── Nav ─────────────────────────────────────────────── */
.nav {
  max-width: var(--page); margin: 0 auto; padding: 16px var(--gutter);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; min-width: 0; }
.brand__mark {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center; background: var(--primary); color: #fff; font-size: 24px; line-height: 1;
}
.brand__name { font: 700 16px/1.15 var(--sans); }
.brand__sub { display: block; font-weight: 500; font-size: 13px; color: var(--muted); }

/* ── Hero ────────────────────────────────────────────── */
.hero {
  max-width: var(--page); margin: 0 auto; padding: clamp(20px, 5vw, 56px) var(--gutter) clamp(32px, 6vw, 72px);
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: clamp(24px, 5vw, 64px); align-items: center;
}
.hero__copy { display: grid; gap: 18px; }
.lede { font-size: clamp(17px, 2vw, 20px); color: var(--muted); max-width: 34em; }

.lookup { display: grid; gap: 12px; margin-top: 6px; }
.lookup__sites { border: 0; padding: 4px; margin: 0; display: inline-flex; gap: 4px; background: var(--surface-alt); border-radius: 999px; width: fit-content; }
.site { position: relative; cursor: pointer; }
.site input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.site span { display: block; min-height: 40px; padding: 10px 18px; border-radius: 999px; font: 600 15px/20px var(--sans); color: var(--muted); }
.site input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.site input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }
.lookup__row { display: flex; gap: 10px; flex-wrap: wrap; }
.lookup__row input {
  flex: 1 1 220px; min-width: 0; min-height: 52px; padding: 0 20px;
  border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  font: 500 17px/1 var(--sans);
}
.lookup__row input::placeholder { color: var(--muted); opacity: 0.85; }
.lookup__row input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.lookup__status { min-height: 24px; font: 600 15px/1.4 var(--sans); color: var(--primary); }
.lookup__status.is-error { color: var(--danger); }
.is-working .lookup__status::before {
  content: ''; display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px;
  border-radius: 50%; border: 2px solid var(--primary-soft); border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.lookup__fine { font-size: 14px; color: var(--muted); }

.phone {
  width: min(100%, 300px); margin: 0 auto; padding: 10px; border-radius: 44px;
  background: #101116; box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
}
.phone img { border-radius: 34px; width: 100%; aspect-ratio: 390 / 844; object-fit: cover; object-position: top; background: var(--surface); }
.hero__phone { transform: rotate(2deg); }

/* ── Report ──────────────────────────────────────────── */
.report {
  max-width: 760px; margin: 0 auto clamp(40px, 7vw, 80px); padding: clamp(20px, 4vw, 36px);
  background: var(--surface); border-radius: 28px; box-shadow: var(--shadow); border: 1px solid var(--border);
  display: grid; gap: 28px; scroll-margin-top: 16px;
  width: calc(100% - 2 * var(--gutter));
}
/* `display: grid` above would otherwise show the empty card before a report exists. */
.report[hidden] { display: none; }
.report__head { display: grid; gap: 6px; }
.report__head h3 { font: 600 clamp(24px, 4vw, 32px)/1.15 var(--serif); overflow-wrap: anywhere; }
.report__label { font: 700 12px/1.3 var(--sans); letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.report__empty { color: var(--muted); }
.finding { padding: 16px 18px; border-radius: 18px; background: var(--bg); border: 1px solid var(--border); display: grid; gap: 10px; }
.finding + .finding { margin-top: 10px; }
.finding__head { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.finding__rank {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  font: 600 18px/1 var(--serif); background: rgba(196, 68, 47, 0.13); color: var(--danger);
}
.finding__rank--star { background: rgba(46, 131, 85, 0.14); color: var(--success); font-size: 15px; }
.finding__meta { font-size: 14px; color: var(--muted); }
.finding__score { font: 600 28px/1 var(--serif); font-variant-numeric: tabular-nums; }
.finding--leak .finding__score { color: var(--danger); }
.finding--weapon .finding__score { color: var(--success); }
.meter { position: relative; height: 8px; border-radius: 999px; background: var(--surface-alt); }
.meter__fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--danger); }
.finding--weapon .meter__fill { background: var(--success); }
.meter__avg { position: absolute; top: -4px; width: 2px; height: 16px; background: var(--text); border-radius: 2px; transform: translateX(-1px); }
.finding__note { font-size: 15px; }
.finding__course { font: 600 14px/1.4 var(--sans); color: var(--primary); }
.played { display: grid; gap: 0; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.played li { display: grid; grid-template-columns: 1fr auto 52px; gap: 12px; align-items: center; padding: 12px 16px; font-size: 15px; }
.played li + li { border-top: 1px solid var(--border); }
.played__name { min-width: 0; font-weight: 600; }
.played__games { color: var(--muted); font-variant-numeric: tabular-nums; }
.played__score { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.report__cta { padding: 22px; border-radius: 20px; background: var(--primary-soft); display: grid; gap: 10px; }
.report__cta h4 { font: 600 22px/1.2 var(--serif); }
.report__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }

/* ── Steps ───────────────────────────────────────────── */
.steps, .plans, .faq { max-width: var(--page); margin: 0 auto; padding: clamp(36px, 7vw, 80px) var(--gutter); }
.steps h2, .plans h2 { margin-top: 8px; }
.steps__list { margin-top: 28px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.steps__list li { background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 22px; display: grid; gap: 8px; align-content: start; box-shadow: var(--shadow); }
.steps__num { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font: 600 22px/1 var(--serif); margin-bottom: 4px; }
.steps__list p, .ladder p { color: var(--muted); font-size: 16px; }

/* ── Feature ─────────────────────────────────────────── */
.feature {
  max-width: var(--page); margin: 0 auto; padding: clamp(24px, 5vw, 56px) var(--gutter);
  display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: clamp(24px, 6vw, 72px); align-items: center;
}
.feature__copy { display: grid; gap: 18px; }
.feature__phone { transform: rotate(-2deg); }
.ladder { display: grid; gap: 10px; }
.ladder li { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 14px 16px; }
.ladder li:nth-child(2) { margin-left: clamp(0px, 3vw, 22px); }
.ladder li:nth-child(3) { margin-left: clamp(0px, 6vw, 44px); }
.ladder li > span { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font: 600 19px/1 var(--serif); }
.feature__note { color: var(--muted); }

/* ── Plans ───────────────────────────────────────────── */
.plans { display: grid; justify-items: start; gap: 6px; }
.plans__grid { margin: 22px 0 26px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; width: 100%; }
.plan { background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 24px; display: grid; gap: 12px; align-content: start; }
.plan--premium { background: var(--premium-soft); border-color: color-mix(in srgb, var(--premium) 40%, transparent); }
.plan h3 { font: 600 24px/1.1 var(--serif); }
.plan--premium h3 { color: var(--premium); }
.plan ul { display: grid; gap: 8px; }
.plan li { position: relative; padding-left: 26px; }
.plan li::before { content: ''; position: absolute; left: 2px; top: 0.5em; width: 12px; height: 7px; border-left: 2.5px solid var(--success); border-bottom: 2.5px solid var(--success); transform: rotate(-45deg); }
.plan--premium li::before { border-color: var(--premium); }
.plan__fine { font-size: 14px; color: var(--muted); }
.plans__android { margin-top: 12px; color: var(--muted); font-size: 15px; }

/* ── FAQ ─────────────────────────────────────────────── */
.faq { max-width: 760px; }
.faq h2 { margin-bottom: 16px; }
.faq details { border-top: 1px solid var(--border); }
.faq details:last-child { border-bottom: 1px solid var(--border); }
.faq summary { cursor: pointer; padding: 18px 28px 18px 0; font-weight: 700; list-style: none; position: relative; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; position: absolute; right: 4px; top: 14px; font: 400 26px/1 var(--sans); color: var(--muted); }
.faq details[open] summary::after { content: '–'; }
.faq details p { padding: 0 0 18px; color: var(--muted); max-width: 60ch; }

/* ── Footer ──────────────────────────────────────────── */
.footer { border-top: 1px solid var(--border); padding: 28px var(--gutter) 40px; display: grid; gap: 10px; justify-items: center; text-align: center; font-size: 15px; }
.footer nav { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; }
.footer a { color: var(--muted); }
.footer__fine { color: var(--muted); font-size: 13px; max-width: 46ch; }

/* ── Small screens ───────────────────────────────────── */
@media (max-width: 820px) {
  .hero, .feature { grid-template-columns: minmax(0, 1fr); }
  .hero__phone { order: 2; transform: none; }
  /* On a phone the picture sits between the form and the answer — step aside once there is one. */
  .has-report .hero__phone { display: none; }
  .feature__phone { order: 2; transform: none; }
  .phone { width: min(78%, 280px); }
  .steps__list, .plans__grid { grid-template-columns: minmax(0, 1fr); }
  .lookup__row .btn { flex: 1 1 100%; }
  .brand__sub { display: none; }
}
@media (max-width: 420px) {
  .finding__head { grid-template-columns: auto 1fr; }
  .finding__score { grid-column: 2; }
  .played li { grid-template-columns: 1fr auto; }
  .played__games { display: none; }
}

/* ── Nav links (guide pages) ─────────────────────────── */
.nav__links { display: flex; align-items: center; gap: 18px; }
.nav__links > a:not(.btn) { color: var(--text); font: 600 15px/1 var(--sans); text-decoration: none; }
.nav__links > a:not(.btn):hover { color: var(--primary); }

/* ── Opening guides ──────────────────────────────────── */
.guide { max-width: 980px; margin: 0 auto; padding: 8px var(--gutter) clamp(40px, 7vw, 80px); display: grid; gap: clamp(32px, 6vw, 60px); }
.crumbs { font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.guide__head { display: grid; gap: 14px; }
.guide__head h1 { font-size: clamp(32px, 5.6vw, 52px); }
.notation { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 0.92em; font-weight: 600; white-space: nowrap; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 10px; }
.facts li { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 8px 14px; font-size: 14px; }
.guide__section { display: grid; gap: 12px; }
.guide__lede { color: var(--muted); max-width: 60ch; }
.guide__line { display: grid; gap: 8px; margin-top: 22px; }
.guide__line h3 { font: 600 22px/1.25 var(--serif); display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.pill { font: 600 13px/1 var(--sans); padding: 6px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); white-space: nowrap; }

.viewer { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 8px; }
.viewer__stage { position: sticky; top: 16px; display: grid; gap: 10px; }
.board { display: grid; grid-template-columns: repeat(8, 1fr); aspect-ratio: 1; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.sq { position: relative; aspect-ratio: 1; }
.sq--l { background: var(--board-light); }
.sq--d { background: var(--board-dark); }
.sq--hit::after { content: ''; position: absolute; inset: 0; background: rgba(240, 190, 80, 0.55); }
.sq img { position: absolute; inset: 4%; width: 92%; height: 92%; z-index: 1; }
.viewer__controls { display: grid; grid-template-columns: 52px 1fr 52px; align-items: center; gap: 8px; }
.viewer__controls button {
  min-height: 46px; border-radius: 14px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  font: 600 20px/1 var(--sans); cursor: pointer;
}
.viewer__controls button:hover:not([disabled]) { background: var(--surface-alt); }
.viewer__controls button[disabled] { opacity: 0.4; cursor: default; }
.viewer__pos { text-align: center; font: 700 15px/1 var(--sans); font-variant-numeric: tabular-nums; }
.moves { display: grid; gap: 6px; counter-reset: none; }
.move {
  width: 100%; text-align: left; display: grid; grid-template-columns: 78px 1fr; gap: 12px; align-items: baseline;
  padding: 12px 14px; border-radius: 14px; border: 1px solid transparent; background: transparent; color: var(--text);
  font: inherit; cursor: pointer;
}
.move:hover { background: var(--surface); }
.move.is-active { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow); }
.move__san { font: 700 16px/1.4 ui-monospace, 'SF Mono', Menlo, Consolas, monospace; }
.move--mine .move__san { color: var(--primary); }
.move--opp .move__note { color: var(--muted); }
.move__note { font-size: 16px; line-height: 1.5; }

.deeper { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 20px; }
.deeper li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 15px; }
.guide__cta { padding: clamp(22px, 4vw, 36px); border-radius: 26px; background: var(--primary-soft); display: grid; gap: 12px; }
.related, .home-guides { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.related a, .home-guides a {
  display: grid; gap: 2px; padding: 14px 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none; font-size: 16px;
}
.related a:hover, .home-guides a:hover, .dir__list a:hover { border-color: var(--primary); }
.home-guides .muted, .related .muted { font-size: 14px; }

/* Index */
.dir__filter {
  width: min(100%, 420px); min-height: 52px; padding: 0 20px; border-radius: 999px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text); font: 500 17px/1 var(--sans);
}
.dir__filter:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.dir { display: grid; gap: 14px; }
.dir__list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.dir__list a { display: grid; gap: 3px; padding: 14px 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none; }
.dir__name { font-weight: 700; }
.dir__meta { font-size: 14px; color: var(--muted); }
.guides-home { max-width: var(--page); margin: 0 auto; padding: clamp(36px, 7vw, 80px) var(--gutter); display: grid; gap: 14px; }
.guides-home__all { font-weight: 700; }

@media (max-width: 820px) {
  .viewer { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  /* The board stays in view while the moves scroll under it. */
  .viewer__stage { top: 0; z-index: 2; background: var(--bg); padding: 8px 0 10px; margin: 0 calc(-1 * var(--gutter)); padding-inline: var(--gutter); }
  .board { width: min(100%, 46vh); margin: 0 auto; }
  .viewer__controls { width: min(100%, 46vh); margin: 0 auto; }
  .move { grid-template-columns: 70px 1fr; padding: 12px 10px; }
  .deeper, .related, .home-guides, .dir__list { grid-template-columns: minmax(0, 1fr); }
  .nav__links > a:not(.btn) { display: none; }
}

/* ── Android waitlist ────────────────────────────────── */
.waitlist { margin-top: 26px; padding: 22px; border-radius: 22px; background: var(--surface); border: 1px solid var(--border); display: grid; gap: 10px; width: 100%; max-width: 560px; scroll-margin-top: 16px; }
.waitlist h3 { font: 600 22px/1.2 var(--serif); }
.waitlist p { color: var(--muted); font-size: 16px; }
.waitlist__row { display: flex; gap: 10px; flex-wrap: wrap; }
.waitlist__row input {
  flex: 1 1 220px; min-width: 0; min-height: 50px; padding: 0 18px; border-radius: 999px; border: 1.5px solid var(--border);
  background: var(--bg); color: var(--text); font: 500 16px/1 var(--sans);
}
.waitlist__row input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.waitlist__note { min-height: 22px; font: 600 14px/1.4 var(--sans); color: var(--success); }
.waitlist__note.is-error { color: var(--danger); }
.waitlist.is-done .waitlist__row { display: none; }

/* ── Private numbers page ────────────────────────────── */
.stats { display: grid; gap: 22px; }
.stats h2 { font-size: clamp(22px, 3vw, 28px); margin-top: 8px; }
.stats__cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stats__card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 18px; display: grid; gap: 4px; }
.stats__card strong { font: 600 34px/1 var(--serif); font-variant-numeric: tabular-nums; }
.stats__card span { color: var(--muted); font-size: 14px; }
.stats__table { overflow-x: auto; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.stats table { border-collapse: collapse; width: 100%; font-size: 15px; }
.stats th, .stats td { padding: 12px 16px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats th:first-child, .stats td:first-child { text-align: left; }
.stats thead th { font: 700 12px/1.3 var(--sans); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.stats tbody tr { border-top: 1px solid var(--border); }
@media (max-width: 820px) { .stats__cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
