/* ==========================================================================
   Card Stack Optimizer — site styles
   Brand direction: Precision Blue (from brand kit precision/light + precision/dark tokens.css)
   Light is the default; dark tokens apply automatically via
   prefers-color-scheme. Fonts are system stacks per the brand kit
   (Arial Black / Arial) — nothing to download or self-host.
   ========================================================================== */

/* ---------- 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: 'Arial Black', Arial, sans-serif;
  --font-body: Arial, Helvetica, sans-serif;
  --radius: 12px;
  --space-unit: 8px;

  /* Derived site tokens */
  --on-night: #FFFFFF;
  --border: color-mix(in srgb, var(--brand-text) 12%, transparent);
  --shadow: 0 1px 2px rgba(8, 21, 37, .06), 0 8px 24px rgba(8, 21, 37, .06);
  --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 dark;
}

/* ---------- Dark tokens (kit: precision/dark/tokens.css) ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --brand-accent: #79A6FF;
    --brand-text: #F1F5FD;
    --brand-muted: #A1B0C6;
    --brand-tint: #182E50;
    --brand-surface: #101C2D;
    --border: color-mix(in srgb, var(--brand-text) 14%, transparent);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

/* ---------- 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: 2px; border-radius: 4px; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -.01em;
  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: #fff; 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--tint { background: var(--brand-tint); }
.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 var(--font-body);
  letter-spacing: .06em; text-transform: uppercase;
  padding: 18px 26px; border-radius: 3px; border: 2px solid transparent;
  text-decoration: none; cursor: pointer;
  transition: transform .15s ease, background-color .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn--primary { background: var(--brand-accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn--primary { color: var(--brand-night); } }
.btn--highlight { background: var(--brand-secondary); color: var(--brand-night); }
.btn--ghost { border-color: currentColor; color: inherit; background: transparent; }
.btn--block { width: 100%; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--brand-surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.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: 900; 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: #fff; }
@media (prefers-color-scheme: dark) { .site-nav .btn { color: var(--brand-night); } }

@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::after { /* the soft ring from banner.svg */
  content: ""; position: absolute; right: -220px; top: 50%; width: 640px; height: 640px;
  transform: translateY(-50%); border-radius: 50%;
  border: 70px solid rgba(173, 202, 255, .06); pointer-events: none;
}
.band-night .eyebrow { color: var(--brand-secondary); }
.band-night .lead { color: rgba(255, 255, 255, .78); }
.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: rgba(255, 255, 255, .6); margin-top: var(--s2); }
.hero-art { justify-self: center; width: min(360px, 100%); color: var(--brand-secondary); }
.hero-art svg { width: 100%; height: auto; }
.pillar-tags { list-style: none; padding: 0; margin: var(--s4) 0 0; display: grid; gap: 10px; }
.pillar-tags li { font-size: .9375rem; letter-spacing: .1em; }
.pillar-tags li:nth-child(even) { color: var(--brand-secondary); }

.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); }
  .hero-art { width: 200px; justify-self: start; order: -1; }
  .pillar-tags { display: none; }
}

/* ---------- 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);
}
.section--tint .card { border-color: transparent; }
.card p:last-child { margin-bottom: 0; }
.card-num {
  font-family: var(--font-display); font-weight: 900; 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: 900; 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: 900; font-family: var(--font-display); border-bottom: 0; font-size: 1.0625rem; }
.math-table .neg { color: #C0392B; }
@media (prefers-color-scheme: dark) { .math-table .neg { color: #FF8A80; } }
.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: rgba(255, 255, 255, .85); }
.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: 900; 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: 0 20px 60px rgba(0, 0, 0, .35);
}
.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); }
fieldset.field { border: 0; padding: 0; margin: 0 0 var(--s2); min-width: 0; }
.choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; }
.choice span {
  display: block; text-align: center; padding: 12px 8px; border: 2px solid var(--border); border-radius: 8px;
  font-weight: 700; font-size: .9375rem; cursor: pointer;
}
.choice span small { display: block; font-weight: 400; color: var(--brand-muted); font-size: .75rem; }
.choice input:checked + span { border-color: var(--brand-accent); background: var(--brand-tint); }
.choice input:focus-visible + span { outline: 3px solid var(--brand-accent); outline-offset: 2px; }
.hp { position: absolute !important; left: -9999px !important; }
.form-legal { font-size: .75rem; color: var(--brand-muted); margin: var(--s2) 0 0; }
.form-error { color: #C0392B; 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: 999px; 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: #fff; }
@media (prefers-color-scheme: dark) { .filter[aria-pressed="true"] { color: var(--brand-night); } }

.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: rgba(8, 21, 37, .85)
    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: 900; 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: 999px; 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: #fff;
  font-family: var(--font-display); font-weight: 900;
}
@media (prefers-color-scheme: dark) { .steps li::before { color: var(--brand-night); } }
.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); }

/* ---------- Footer ---------- */
.site-footer { background: var(--brand-night); color: rgba(255, 255, 255, .75); 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: #fff; margin-bottom: var(--s2); }
.site-footer .brand svg { color: var(--brand-secondary); }
.site-footer .brand-name span { color: var(--brand-secondary); }
.footer-title { color: #fff; 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 rgba(255, 255, 255, .12); margin-top: var(--s6); padding-top: var(--s3); font-size: .8125rem; line-height: 1.55; color: rgba(255, 255, 255, .6); }
.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; }
