/* Meridian Foundry Group. Tokens and scale defined in docs/plan.md "Design Spec". */

@font-face { font-family: "Space Grotesk"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/space-grotesk-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-weight: 500; font-style: normal; font-display: swap; src: url("/fonts/space-grotesk-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-weight: 700; font-style: normal; font-display: swap; src: url("/fonts/space-grotesk-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-style: normal; font-display: swap; src: url("/fonts/jetbrains-mono-latin-500-normal.woff2") format("woff2"); }

:root {
  --bg: #0F1115;
  --surface: #181B20;
  --line: #2A2F37;
  --text: #F3F4F6;
  --muted: #94A3B8;
  --accent: #D97706;
  --accent-text: #F59E0B;
  --on-accent: #111111;
  --visited: #C4B5FD;
  --grid: rgba(255, 255, 255, 0.04);

  --s1: 4px; --s2: 8px; --s3: 16px; --s4: 24px; --s5: 40px; --s6: 64px; --s7: 96px;
  --max: 1120px;
  --gutter: 24px;
  --r-control: 6px;
  --r-panel: 10px;
  --font: "Space Grotesk", ui-sans-serif, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #F8F9FA;
    --surface: #FFFFFF;
    --line: #E2E8F0;
    --text: #0F172A;
    --muted: #475569;
    --accent: #D97706;
    --accent-text: #B45309;
    --on-accent: #111111;
    --visited: #6D28D9;
    --grid: rgba(15, 23, 42, 0.06);
  }
}

[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--text); font: 400 16px/1.55 var(--font); }
img { display: block; }
a { color: inherit; }
a:visited { text-decoration-color: var(--visited); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
ul, ol { list-style: none; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; vertical-align: top; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: var(--s3); top: -60px; z-index: 20; background: var(--accent); color: var(--on-accent); padding: var(--s2) var(--s3); border-radius: var(--r-control); font-weight: 700; }
.skip:focus { top: var(--s3); }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
section { padding: var(--s7) 0; border-top: 1px solid var(--line); }
section.hero { border-top: 0; }

h1 { font-size: 56px; line-height: 1.05; letter-spacing: -0.02em; font-weight: 700; max-width: 14ch; }
h2 { font-size: 36px; line-height: 1.15; letter-spacing: -0.01em; font-weight: 700; max-width: 22ch; margin-bottom: var(--s5); }
h3 { font-size: 20px; line-height: 1.3; font-weight: 700; }
p { max-width: 60ch; }
.lead { font-size: 19px; line-height: 1.5; color: var(--muted); margin: var(--s4) 0 var(--s5); }
.eyebrow, .tier-name, .sev, .platform-strip, .tier-flag, legend, .compare th[scope="row"], .mismatch th { font-family: var(--mono); font-weight: 500; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.eyebrow { color: var(--muted); margin-bottom: var(--s3); }
.optional { color: var(--muted); text-transform: none; letter-spacing: 0; font-family: var(--font); font-size: 13px; }

/* Buttons and links */
.btn { white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 48px; padding: 12px 22px; border-radius: var(--r-control); background: var(--accent); color: var(--on-accent); font: 700 16px/1.2 var(--font); text-decoration: none; border: 1px solid var(--accent); cursor: pointer; }
.btn:visited { color: var(--on-accent); }
.btn:hover { filter: brightness(1.08); }
.btn-sm { min-height: 44px; padding: 8px 16px; font-size: 14px; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:visited { color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-block { display: flex; width: 100%; }
.btn[disabled] { opacity: 0.7; cursor: progress; }
.text-link { color: var(--text); text-underline-offset: 4px; display: inline-flex; align-items: center; min-height: 44px; }

/* Header */
.site-header { position: relative; z-index: 2; }
.nav { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding-top: var(--s3); padding-bottom: var(--s3); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: 0.06em; text-decoration: none; font-size: 15px; }
.brand-short { display: none; }
.nav-links { display: flex; gap: var(--s4); }
.nav-links a { color: var(--muted); text-decoration: none; font-size: 15px; display: inline-flex; min-height: 44px; align-items: center; }
.nav-links a:hover { color: var(--text); }

/* Hero */
.hero { position: relative; padding: var(--s6) 0 var(--s5); overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent);
  mask-image: linear-gradient(to bottom, #000 55%, transparent);
}
.hero-grid { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: var(--s6); align-items: center; }
.cta-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s4); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: var(--s4); }

.listing-check .panel-eyebrow { display: inline-grid; }
.listing-check .panel-eyebrow > span, .swap > span { grid-area: 1 / 1; }
.swap { display: inline-grid; }
.mismatch { font-size: 14px; }
.mismatch th, .mismatch td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.mismatch tbody tr:last-child > * { border-bottom: 0; }
.mismatch thead th { color: var(--muted); }
.mismatch tbody th { color: var(--muted); white-space: nowrap; }
.nowrap { white-space: nowrap; }
.panel-caption { margin-top: var(--s3); font-size: 13px; color: var(--muted); display: none; }

/* Fix animation: amber "was" values and corrected "now" values trade places on a
   9s loop (~3.5s broken, ~4.3s fixed). Hover pauses it so either state can be read. */
.fix .was { color: var(--accent-text); font-weight: 700; animation: was-loop 9s ease-in-out infinite; }
.fix .now, .panel-eyebrow .now { opacity: 0; animation: now-loop 9s ease-in-out infinite; }
.fix .now { font-weight: 500; }
.panel-eyebrow .was { animation: was-loop 9s ease-in-out infinite; }
tr:nth-child(3) .fix .was, tr:nth-child(3) .fix .now { animation-delay: 0.15s; }
.listing-check:hover .was, .listing-check:hover .now { animation-play-state: paused; }
@keyframes was-loop {
  0%, 38% { opacity: 1; transform: none; }
  44%, 92% { opacity: 0; transform: translateY(-4px); }
  98%, 100% { opacity: 1; transform: none; }
}
@keyframes now-loop {
  0%, 38% { opacity: 0; transform: translateY(4px); }
  44%, 92% { opacity: 1; transform: none; }
  98%, 100% { opacity: 0; transform: translateY(4px); }
}

.platform-strip { display: flex; gap: var(--s5); padding: var(--s4) 0 0; margin-top: var(--s6); border-top: 1px solid var(--line); color: var(--muted); }

/* Problem */
.compare { font-size: 16px; }
.compare th, .compare td { padding: 16px 12px 16px 0; border-bottom: 1px solid var(--line); }
.compare thead th { color: var(--muted); font-weight: 500; }
.compare th[scope="row"] { color: var(--muted); width: 18%; }
.compare td:nth-child(2) { color: var(--muted); }

/* Method */
.method { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s6); align-items: start; }
.steps li { display: grid; grid-template-columns: 48px 1fr; gap: var(--s3); padding: var(--s4) 0; border-bottom: 1px solid var(--line); }
.steps p { color: var(--muted); margin-top: var(--s1); }
.num { font: 700 20px/1.3 var(--mono); color: var(--accent-text); }
.audit-doc h3 { margin-bottom: var(--s3); }
.findings li { display: flex; gap: var(--s3); align-items: baseline; padding: 12px 0; border-bottom: 1px dashed var(--line); font-size: 15px; }
.findings li:last-child { border-bottom: 0; }
.sev { flex: none; min-width: 46px; text-align: center; padding: 2px 6px; border-radius: 3px; border: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.sev-high { border-color: var(--accent); color: var(--accent-text); }
.sev-med { border-color: var(--muted); color: var(--text); }

/* Pricing */
.tiers { display: grid; grid-template-columns: repeat(3, minmax(220px, 1fr)); gap: var(--s4); }
.tier { display: flex; flex-direction: column; gap: var(--s3); border: 1px solid var(--line); border-radius: var(--r-panel); padding: var(--s4); background: var(--surface); }
.tier-featured { border-color: var(--accent); }
.tier-flag { color: var(--accent-text); }
.tier-name { color: var(--muted); }
.tier-featured .tier-flag + .tier-name { margin-top: calc(var(--s3) * -0.5); }
.price { font-size: 32px; font-weight: 700; line-height: 1.1; }
.price span { font-size: 14px; color: var(--muted); font-weight: 400; white-space: nowrap; }
.tier ul { flex: 1; display: grid; gap: 6px; color: var(--muted); font-size: 15px; align-content: start; }
.tier-note { font-size: 13px; color: var(--muted); }

/* Rules */
.rules { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s5); }
.rules > div { border-top: 2px solid var(--accent); padding-top: var(--s3); }
.rules p { color: var(--muted); margin-top: var(--s2); }

/* Intake */
.intake { display: grid; grid-template-columns: 0.8fr 1.2fr; gap: var(--s6); align-items: start; }
.next { list-style: decimal; padding-left: 20px; color: var(--muted); display: grid; gap: var(--s3); margin-bottom: var(--s4); }
.cap-line, #intake-left-tier { color: var(--muted); font-size: 14px; }
#switch-to-free { margin-top: var(--s3); }
.form-card { padding: var(--s5); }
.group { border: 0; margin-bottom: var(--s4); }
.group > legend { color: var(--muted); margin-bottom: var(--s3); }
.field { display: grid; gap: 6px; margin-bottom: var(--s3); border: 0; min-width: 0; }
.field label, .field > legend { font-size: 14px; font-weight: 500; font-family: var(--font); text-transform: none; letter-spacing: 0; color: var(--text); }
.field input, .field select { width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--bg); color: var(--text); font: 400 16px/1.3 var(--font); }
.field input:focus-visible, .field select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field [aria-invalid="true"] { border-color: var(--accent); }
.checks { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); }
.check { display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.hint { font-size: 13px; color: var(--muted); }
.field-error { font-size: 13px; color: var(--accent-text); font-weight: 500; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s3); align-items: start; }
.ts-slot { min-height: 65px; margin: var(--s2) 0 var(--s3); border: 1px dashed var(--line); border-radius: var(--r-control); }
.ts-slot.ready { border: 0; }
.banner { border: 1px solid var(--accent); border-radius: var(--r-control); padding: var(--s3); margin-bottom: var(--s3); display: grid; gap: var(--s2); justify-items: start; }
.banner p { font-size: 15px; }
.ref { font: 500 12px var(--mono); color: var(--muted); }
.reviewer { margin-top: var(--s3); font-size: 13px; color: var(--muted); }
.spinner { display: none; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
.is-sending .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.success { display: grid; gap: var(--s3); justify-items: start; }
.success:focus { outline: none; }
.success h3:focus-visible { outline: 2px solid var(--accent); }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding: var(--s6) 0 var(--s7); color: var(--muted); font-size: 14px; }
.footer-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: var(--s5); }
.footer-grid p + p { margin-top: var(--s2); }
.site-footer .brand { color: var(--text); font-size: 13px; }
.site-footer a { text-underline-offset: 3px; }

/* Sticky mobile CTA (shown by app.js only on small screens, after the hero, while the form is off screen) */
.sticky-cta { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
.sticky-cta[hidden] { display: none; }

/* Legal pages */
.legal { padding: var(--s6) 0 var(--s7); }
.legal h1 { font-size: 40px; max-width: none; margin-bottom: var(--s3); }
.legal h2 { font-size: 22px; margin: var(--s5) 0 var(--s3); max-width: none; }
.legal p, .legal li { color: var(--muted); max-width: 70ch; }
.legal ul { list-style: disc; padding-left: 20px; display: grid; gap: var(--s2); }
.legal p + p { margin-top: var(--s3); }

/* 768 to 1023 */
@media (max-width: 1023px) {
  .hero-grid, .method, .intake { grid-template-columns: 1fr; gap: var(--s5); }
  .tiers { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

/* Under 768 */
@media (max-width: 767px) {
  h1 { font-size: 38px; }
  h2 { font-size: 28px; margin-bottom: var(--s4); }
  section { padding: var(--s6) 0; }
  .nav-links { display: none; }
  .brand-full { display: none; }
  .brand-short { display: inline; }
  .tiers, .rules, .footer-grid { grid-template-columns: 1fr; }
  .two { grid-template-columns: 1fr; }
  .form-card { padding: var(--s4); }
  .platform-strip { flex-direction: column; gap: var(--s2); margin-top: var(--s5); }
  body.has-sticky { padding-bottom: 80px; }

  /* Hero table restacks: one block per platform, values never wrap mid-number. */
  .mismatch thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .mismatch tbody, .mismatch tr, .mismatch th, .mismatch td { display: block; }
  .mismatch tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .mismatch tbody tr:last-child { border-bottom: 0; }
  .mismatch th, .mismatch td { border: 0; padding: 2px 0; }
  .mismatch tbody th { color: var(--text); margin-bottom: 4px; }
  .mismatch td { display: grid; grid-template-columns: 90px 1fr; }
  .mismatch td::before { content: attr(data-label); font: 500 12px/1.8 var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

  /* Comparison table restacks into labelled pairs. */
  .compare thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .compare tbody, .compare tr, .compare th, .compare td { display: block; width: auto; }
  .compare tr { padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
  .compare th, .compare td { border: 0; padding: 2px 0; }
  .compare td::before { content: attr(data-label) ": "; font-weight: 700; color: var(--text); }
}

/* Under 400 */
@media (max-width: 399px) {
  :root { --gutter: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .fix .was, .panel-eyebrow .was { animation: none; }
  .fix .now, .panel-eyebrow .now { animation: none; opacity: 0; }
  .panel-caption { display: block; }
  .spinner { animation-duration: 2s; }
}
