/* ==========================================================================
   Card Stack Optimizer — root landing site (version A)
   Brand: Precision / Sleek (design-system.md). Brand-kit colors, 12px
   radius, and 8px spacing unchanged; Manrope (self-hosted, /fonts/).
   Light theme only; flat surfaces, 1px Secondary rules, no shadows.
   ========================================================================== */

@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('/fonts/manrope-latin-wght-normal.woff2') format('woff2');
}

/* ---------- Brand tokens (kit: precision/light/tokens.css) ---------- */
:root {
  --brand-accent: #2069F5;
  --brand-text: #0B172B;
  --brand-muted: #637086;
  --brand-tint: #EAF0FF;
  --brand-surface: #FFFFFF;
  --brand-night: #081525;
  --brand-secondary: #ADCAFF;
  --font-display: 'Manrope', Arial, sans-serif;
  --font-body: 'Manrope', Arial, Helvetica, sans-serif;
  --radius: 12px;
  --space-unit: 8px;

  /* Derived site tokens */
  --on-night: #FFFFFF;
  --border: var(--brand-secondary);
  --shadow: none;
  --s1: calc(var(--space-unit) * 1);
  --s2: calc(var(--space-unit) * 2);
  --s3: calc(var(--space-unit) * 3);
  --s4: calc(var(--space-unit) * 4);
  --s6: calc(var(--space-unit) * 6);
  --s8: calc(var(--space-unit) * 8);
  --s12: calc(var(--space-unit) * 12);
  --container: 1120px;
  --gutter: 20px;
  color-scheme: light;
}


/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--brand-surface);
  color: var(--brand-text);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  overflow-x: hidden;
}
img, svg, iframe { display: block; max-width: 100%; }
img { height: auto; }
a { color: var(--brand-accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--brand-accent); outline-offset: 4px; }
.band-night :focus-visible, .site-footer :focus-visible { outline-color: var(--brand-secondary); }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -.035em;
  margin: 0 0 var(--s2);
  text-wrap: balance;
}
h1 { font-size: clamp(2.25rem, 5.5vw + .5rem, 4.25rem); }
h2 { font-size: clamp(1.75rem, 3vw + .5rem, 2.625rem); }
h3 { font-size: 1.25rem; }
p { margin: 0 0 var(--s2); }
.lead { font-size: 1.1875rem; color: var(--brand-muted); max-width: 62ch; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--brand-accent); color: var(--brand-surface); padding: var(--s1) var(--s2); z-index: 100;
}
.skip-link:focus { left: var(--s2); top: var(--s2); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; margin: -1px;
}

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter); }
.section { padding: var(--s12) 0; }
.section + .section, .section--tint { border-top: 1px solid var(--brand-secondary); }
.section-head { max-width: 720px; margin-bottom: var(--s6); }

/* Eyebrow — mirrors the "CARD STACK OPTIMIZER / 01" label on the kit thumbnails */
.eyebrow {
  display: inline-block;
  font-size: .8125rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--brand-accent);
  margin-bottom: var(--s2);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s1);
  font: 700 1rem/1.25 var(--font-body);
  min-height: 48px; padding: 12px 24px; border-radius: var(--radius); border: 2px solid transparent;
  text-decoration: none; cursor: pointer;
  transition: transform 160ms, background-color 160ms, border-color 160ms;
}
.btn:active { transform: translateY(1px); }
.btn--primary, .btn--highlight { background: var(--brand-accent); border-color: var(--brand-accent); color: var(--brand-surface); }
.btn--primary:hover, .btn--highlight:hover { background: var(--brand-text); border-color: var(--brand-text); }
.btn--ghost { border-color: currentColor; color: inherit; background: transparent; }
.btn--ghost:hover { background: var(--brand-tint); border-color: var(--brand-accent); color: var(--brand-text); }
.btn--block { width: 100%; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--brand-surface);
  border-bottom: 1px solid var(--brand-secondary);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; min-height: 68px; gap: var(--s2); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--brand-text); }
.brand svg { width: 34px; height: 34px; color: var(--brand-accent); flex: none; }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 1.0625rem; line-height: 1.05; }
.brand-name span { color: var(--brand-accent); }

.nav-toggle {
  display: none; background: none; border: 1px solid var(--border); color: var(--brand-text);
  border-radius: 8px; padding: 8px 10px; cursor: pointer; font: 700 .875rem var(--font-body);
}
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: var(--s3); }
.site-nav a { color: var(--brand-text); text-decoration: none; font-weight: 700; font-size: .9375rem; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--brand-accent); }
.site-nav .btn { padding: 12px 18px; font-size: .8125rem; color: var(--brand-surface); }

@media (max-width: 760px) {
  .nav-toggle { display: inline-block; }
  .site-nav { display: none; position: absolute; left: 0; right: 0; top: 100%;
    background: var(--brand-surface); border-bottom: 1px solid var(--border); padding: var(--s2) var(--gutter) var(--s3); }
  .site-nav.is-open { display: block; }
  .site-nav ul { flex-direction: column; align-items: stretch; gap: var(--s1); }
  .site-nav a { display: block; padding: 10px 0; }
  .site-nav .btn { margin-top: var(--s1); }
}

/* ---------- Night band (hero / page heads) — mirrors kit banner & thumbnail-1 ---------- */
.band-night {
  background: var(--brand-night); color: var(--on-night);
  position: relative; overflow: hidden;
}
.band-night .eyebrow { color: var(--brand-secondary); }
.band-night .lead { color: var(--brand-secondary); }
.band-night a:not(.btn) { color: var(--brand-secondary); }
.band-night .container { position: relative; z-index: 1; }
.hl { color: var(--brand-secondary); }

.hero { padding: var(--s12) 0 calc(var(--s12) + var(--s2)); }
.hero-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: var(--s8); align-items: center; }
.hero h1 { margin-bottom: var(--s3); }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4); }
.hero-note { font-size: .875rem; color: var(--brand-secondary); margin-top: var(--s2); }
.stack { position: relative; width: 100%; max-width: 380px; height: 300px; margin-inline: auto; }
.stack-card {
  position: absolute; width: 85%; aspect-ratio: 1.586; border-radius: var(--radius); padding: var(--s3);
  display: flex; flex-direction: column; justify-content: space-between;
  font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
}
.stack-card.back { right: 0; top: 0; background: var(--brand-secondary); color: var(--brand-text); }
.stack-card.middle { right: 7.5%; top: 48px; background: var(--brand-surface); color: var(--brand-text); }
.stack-card.front { left: 0; top: 96px; background: var(--brand-accent); color: var(--brand-surface); }
.stack-row { display: flex; justify-content: space-between; align-items: end; gap: 8px; }
.stack-title { font: 800 22px/1.1 var(--font-display); letter-spacing: -.03em; text-transform: none; }
.stack-index { font-size: 32px; font-weight: 400; letter-spacing: 0; line-height: 1; }

.page-head { padding: var(--s12) 0 var(--s8); }
.page-head h1 { font-size: clamp(2rem, 4.5vw + .5rem, 3.5rem); }

@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; gap: var(--s6); }
  .stack { max-width: 330px; height: 280px; margin: 0; }
}

/* ---------- Cards / grids ---------- */
.grid { display: grid; gap: var(--s3); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--brand-surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--s4); box-shadow: var(--shadow);
}
.card p:last-child { margin-bottom: 0; }
.card-num {
  font-family: var(--font-display); font-weight: 800; font-size: 2.75rem; line-height: 1;
  color: var(--brand-accent); opacity: .9; margin-bottom: var(--s2);
}
.card-kicker { font-size: .75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--brand-muted); margin-bottom: var(--s1); }

/* ---------- Authority / sources ---------- */
.sources { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2); list-style: none; padding: 0; margin: 0; }
@media (max-width: 900px) { .sources { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .sources { grid-template-columns: 1fr; } }
.sources li {
  border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s3);
  background: var(--brand-surface);
}
.sources strong { display: block; font-family: var(--font-display); font-weight: 800; font-size: 1.0625rem; margin-bottom: 4px; }
.sources span { display: block; color: var(--brand-muted); font-size: .9375rem; line-height: 1.45; margin-bottom: var(--s1); }
.sources a { font-size: .875rem; font-weight: 700; }
.principles { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); margin-top: var(--s6); }
@media (max-width: 760px) { .principles { grid-template-columns: 1fr; } }
.principle { border-top: 3px solid var(--brand-accent); padding-top: var(--s2); }
.principle h3 { font-size: 1.0625rem; margin-bottom: var(--s1); }
.principle p { color: var(--brand-muted); margin: 0; }

/* ---------- Math example table ---------- */
.math { display: grid; grid-template-columns: .85fr 1.15fr; gap: var(--s6); align-items: center; }
.math > *, .hero-grid > *, .optin-grid > * { min-width: 0; }
@media (max-width: 860px) { .math { grid-template-columns: 1fr; } }
.math-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .9375rem; }
.math-table th, .math-table td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); }
.math-table th { font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--brand-muted); }
.math-table td:last-child, .math-table th:last-child { text-align: right; }
.math-table tfoot td { font-weight: 800; font-family: var(--font-display); border-bottom: 0; font-size: 1.0625rem; }
.math-table .neg { color: inherit; }
.table-wrap { overflow-x: auto; }
.fineprint { font-size: .8125rem; color: var(--brand-muted); margin-top: var(--s2); }

/* ---------- Opt-in ---------- */
.optin { padding: var(--s12) 0; }
.optin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s8); align-items: center; }
@media (max-width: 860px) { .optin-grid { grid-template-columns: 1fr; gap: var(--s4); } }
.optin-list { list-style: none; padding: 0; margin: var(--s3) 0 0; display: grid; gap: 12px; }
.optin-list li { padding-left: 30px; position: relative; color: var(--brand-surface); }
.optin-list li::before {
  content: "\2713"; position: absolute; left: 0; top: .2em; width: 20px; height: 20px; border-radius: 4px;
  background: var(--brand-secondary); color: var(--brand-night);
  display: grid; place-items: center; font-weight: 800; font-size: .75rem; line-height: 1;
}

.form-card {
  background: var(--brand-surface); color: var(--brand-text);
  border-radius: var(--radius); padding: var(--s4); box-shadow: none;
}
.form-card h3 { margin-bottom: var(--s1); }
.form-card > p { color: var(--brand-muted); font-size: .9375rem; }
.field { margin-bottom: var(--s2); }
.field label, .field legend { display: block; font-weight: 700; font-size: .875rem; margin-bottom: 6px; }
.field input[type="text"], .field input[type="email"] {
  width: 100%; font: 1rem var(--font-body); color: var(--brand-text);
  background: var(--brand-surface); border: 2px solid var(--border); border-radius: 8px; padding: 14px;
}
.field input:focus { outline: none; border-color: var(--brand-accent); }
.hp { position: absolute !important; left: -9999px !important; }
.form-legal { font-size: .75rem; color: var(--brand-muted); margin: var(--s2) 0 0; }
.form-error { color: var(--brand-text); font-size: .875rem; font-weight: 700; margin: 0 0 var(--s2); }
.form-error:empty { display: none; }

/* ---------- Content index ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: var(--s4); }
.filter {
  font: 700 .8125rem var(--font-body); letter-spacing: .06em; text-transform: uppercase;
  padding: 10px 16px; border-radius: var(--radius); border: 2px solid var(--border);
  background: transparent; color: var(--brand-text); cursor: pointer;
}
.filter[aria-pressed="true"] { background: var(--brand-accent); border-color: var(--brand-accent); color: var(--brand-surface); }

.entry { display: flex; flex-direction: column; background: var(--brand-surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.entry[hidden] { display: none; }
.entry-media { position: relative; aspect-ratio: 16 / 9; background: var(--brand-night); }
.entry-media img, .entry-media iframe { width: 100%; height: 100%; object-fit: cover; border: 0; }
.entry-media a { display: block; height: 100%; }
.yt-play {
  position: absolute; inset: 0; width: 100%; border: 0; padding: 0; background: none; cursor: pointer;
}
.yt-play img { width: 100%; height: 100%; object-fit: cover; }
.yt-play::after {
  content: ""; position: absolute; right: 14px; bottom: 14px; width: 60px; height: 42px;
  border-radius: 12px; background: var(--brand-night)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 5v14l11-7z' fill='%23ADCAFF'/%3E%3C/svg%3E") center/28px no-repeat;
  transition: background-color .15s ease;
}
.yt-play:hover::after { background-color: var(--brand-accent); }
.entry-body { padding: var(--s3); display: flex; flex-direction: column; gap: var(--s1); flex: 1; }
.entry-meta { display: flex; gap: var(--s2); font-size: .75rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--brand-muted); }
.entry-meta .type { color: var(--brand-accent); }
.entry h2 { font-size: 1.25rem; margin: 0; }
.entry h2 a { color: inherit; text-decoration: none; }
.entry h2 a:hover { color: var(--brand-accent); }
.entry p { color: var(--brand-muted); margin: 0; font-size: .9375rem; }
.entry .more { margin-top: auto; padding-top: var(--s1); font-weight: 700; font-size: .9375rem; }

/* ---------- Prose (about / legal) ---------- */
.prose { max-width: 720px; }
.prose h2 { margin-top: var(--s8); font-size: clamp(1.5rem, 2vw + .75rem, 2rem); scroll-margin-top: 90px; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { margin-top: var(--s4); }
.prose ul, .prose ol { padding-left: 1.25em; margin: 0 0 var(--s2); }
.prose li { margin-bottom: 6px; }
.prose blockquote {
  margin: var(--s4) 0; padding: var(--s3) var(--s4); border-left: 4px solid var(--brand-accent);
  background: var(--brand-tint); border-radius: 0 var(--radius) var(--radius) 0;
  font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; line-height: 1.35;
}
.placeholder-note {
  border: 2px dashed var(--brand-accent); border-radius: var(--radius); padding: var(--s2) var(--s3);
  background: var(--brand-tint); font-size: .9375rem; margin-bottom: var(--s4);
}
.toc { list-style: none; padding: 0; margin: 0 0 var(--s6); display: flex; flex-wrap: wrap; gap: 10px; }
.toc a {
  display: inline-block; padding: 8px 14px; border-radius: var(--radius); border: 1px solid var(--border);
  text-decoration: none; font-weight: 700; font-size: .875rem; color: var(--brand-text);
}
.toc a:hover { border-color: var(--brand-accent); color: var(--brand-accent); }
.updated { color: var(--brand-muted); font-size: .9375rem; }

/* ---------- CTA strip ---------- */
.cta-strip { text-align: center; }
.cta-strip .lead { margin: 0 auto var(--s4); }

/* ---------- Thank-you ---------- */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s3); }
.steps li { counter-increment: step; position: relative; padding-left: 64px; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; background: var(--brand-accent); color: var(--brand-surface);
  font-family: var(--font-display); font-weight: 800;
}
.steps h2 { font-size: 1.25rem; margin-bottom: 6px; }
.steps p { color: var(--brand-muted); margin: 0; }
.download-row { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); }

/* ---------- Social icon strip (under the header on the home page) */
.social-strip { border-bottom: 1px solid var(--brand-secondary); }
.social-strip .container { padding-block: var(--s2); }
.social-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: var(--s1); }
.social-list li { margin: 0; }
.social-list a {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px;
  border-radius: var(--radius); color: var(--brand-text); transition: color 160ms, background-color 160ms;
}
.social-list a:hover { color: var(--brand-surface); background: var(--brand-accent); }
.social-list svg { width: 20px; height: 20px; fill: currentColor; }

/* ---------- Footer ---------- */
.site-footer { background: var(--brand-night); color: var(--brand-secondary); padding: var(--s8) 0 var(--s4); font-size: .9375rem; }
.site-footer a { color: var(--brand-secondary); }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: var(--s6); }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr; gap: var(--s4); } }
.site-footer .brand { color: var(--brand-surface); margin-bottom: var(--s2); }
.site-footer .brand svg { color: var(--brand-secondary); }
.site-footer .brand-name span { color: var(--brand-secondary); }
.footer-title { color: var(--brand-surface); font-weight: 700; font-size: .8125rem; letter-spacing: .12em; text-transform: uppercase; margin-bottom: var(--s2); }
.footer-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.footer-links a { text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }
.disclosures { border-top: 1px solid var(--brand-secondary); margin-top: var(--s6); padding-top: var(--s3); font-size: .8125rem; line-height: 1.55; color: var(--brand-secondary); }
.disclosures p { margin-bottom: var(--s1); }
.math-table th small { font-size: .6875rem; letter-spacing: .04em; text-transform: none; font-weight: 400; white-space: nowrap; }
.math-table td, .math-table th { white-space: nowrap; }
.math-table td:first-child { white-space: normal; }
