/*
 * ════════════════════════════════════════════════════════════════════════
 * AI-TERMINAL — design system for /ai/* pages. Loaded AFTER /bizops.css.
 * v3 — single white/purple theme (dark mode removed per direction),
 * 3-item nav, fixed mobile-nav-panel default-hidden bug, refined
 * professional type scale inspired by Stripe/Linear-style SaaS UI.
 * body.ai-theme remaps every legacy bizops.css token, so every existing
 * generator (ai_pages_generator.py, build_flagship_pages.py) re-themes
 * automatically without its internal CSS being touched.
 * ════════════════════════════════════════════════════════════════════════
 */

body.ai-theme {
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;
  --ease: cubic-bezier(.2,.8,.2,1);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 2px rgba(20,20,30,.04), 0 8px 24px rgba(20,20,30,.06);

  --bg-void:      #f7f9fc;
  --bg-panel:     #ffffff;
  --bg-panel-alt: #eef2f9;
  --border-hard:  #dde4ef;
  --text-primary: #0f1a2e;
  --text-dim:     #5b6579;
  --accent-verify:#1d5ce0;   /* primary blue — knowledge / research / trust */
  --accent-alert: #d1364f;   /* red — cost increases */
  --accent-gated: #c2760f;   /* orange — pricing changes */
  --accent-save:  #178a52;   /* green — savings */

  /* legacy token remap — re-themes every existing var()-based rule in the
     three generators without editing their internal CSS blocks */
  --paper: #f7f9fc; --white: #ffffff; --ink: #0f1a2e; --slate: #48506a;
  --fog: #5b6579; --mist: #97a1b8; --veil: #eef2f9;
  --gold: #1d5ce0; --gold-strong: #1547b0; --gold-pale: #6f94ea;
  --gold-bg: #eaf0fd; --gold-bd: #c7d8f8; --green: #178a52; --red: #d1364f;
  --line: #dde4ef;
  --alert-bg: #fceef0; --alert-text: #a02040;
  --panel-2: #eef2f9; --panel-3: #e4eaf4; --border-hard2: #dde4ef;
  --serif: 'Instrument Serif', Georgia, serif;
  --mono:  'Geist Mono', 'SF Mono', ui-monospace, monospace;
  --sans:  'Geist', -apple-system, sans-serif;

  background: var(--paper);
  color: var(--ink);
  font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
  font-family: var(--sans);
  line-height: 1.55;
}

body.ai-theme header {
  background: rgba(251,250,255,.92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-hard);
}
body.ai-theme .logo { color: var(--text-primary); letter-spacing: .04em; font-weight: 700; }
body.ai-theme .logo em { color: var(--accent-verify); }
body.ai-theme .live-indicator { display: none; } /* redundant badge next to the logo */
body.ai-theme .header-inner {
  flex-direction: row !important; justify-content: space-between; align-items: center;
  padding: 0 !important; height: 64px; flex-wrap: nowrap;
}
body.ai-theme nav { width: auto; border-top: none; padding: 0; }
body.ai-theme nav a.link { color: var(--text-dim); font-weight: 500; transition: color .12s var(--ease); }
body.ai-theme nav a.link:hover, body.ai-theme nav a.link.active { color: var(--accent-verify); }
body.ai-theme .nav-cta-link {
  background: var(--accent-verify); color: #fff !important; padding: 8px 16px;
  border-radius: 999px; font-weight: 600; transition: opacity .12s var(--ease);
}
body.ai-theme .nav-cta-link:hover { opacity: .88; color: #fff !important; }

.nav-burger {
  display: none; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 1px solid var(--border-hard); border-radius: var(--radius-sm);
  background: var(--bg-panel); color: var(--text-primary); cursor: pointer; flex-shrink: 0;
}
.nav-burger svg { width: 18px; height: 18px; pointer-events: none; }

body.ai-theme footer { background: var(--bg-panel-alt); border-top: 1px solid var(--border-hard); }
body.ai-theme .footer-title { color: var(--text-primary); font-weight: 700; letter-spacing: .04em; }
body.ai-theme footer a, body.ai-theme footer span { color: var(--text-dim); }
body.ai-theme footer a:hover { color: var(--accent-verify); }

body.ai-theme h1, body.ai-theme h2.sec, body.ai-theme .verdict {
  font-family: var(--serif); color: var(--text-primary); letter-spacing: -.01em;
}
body.ai-theme .kicker, body.ai-theme .eyebrow { color: var(--accent-verify); letter-spacing: .1em; font-weight: 700; }

body.ai-theme .metric-matrix, body.ai-theme .price-cell,
body.ai-theme .hash-value, body.ai-theme .tbl td.num {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}

body.ai-theme .panel {
  background: var(--bg-panel); border: 1px solid var(--border-hard);
  border-radius: var(--radius); box-shadow: var(--shadow-card); padding: var(--space-5);
}
body.ai-theme .btn, body.ai-theme .card, body.ai-theme .tbl,
body.ai-theme .note, body.ai-theme input, body.ai-theme select {
  border-radius: var(--radius-sm);
}
body.ai-theme .card {
  box-shadow: var(--shadow-card); transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}
body.ai-theme .card:hover {
  transform: translateY(-2px); box-shadow: 0 4px 8px rgba(20,20,30,.06), 0 16px 32px rgba(20,20,30,.09);
}
body.ai-theme .btn, body.ai-theme .cta, body.ai-theme .copy-btn { color: #fff !important; }
body.ai-theme .btn.ghost { color: var(--ink) !important; background: var(--white) !important; }

/* ── horizontal-scroll containment: wide tables/matrices scroll within
   their own box instead of overflowing the page on mobile ── */
.scroll-x { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); }
.scroll-x::-webkit-scrollbar { height: 6px; }
body.ai-theme .scroll-x::-webkit-scrollbar-thumb { background: var(--mist); border-radius: 3px; }
.scroll-x > table, .scroll-x > .metric-matrix { margin: 0; }

body.ai-theme .metric-matrix {
  display: grid; grid-template-columns: 1fr repeat(var(--vendor-cols, 1), minmax(120px, 1fr));
  border: 1px solid var(--border-hard); border-radius: var(--radius); background: var(--bg-panel);
  min-width: 420px;
}
body.ai-theme .mm-row { display: contents; }
body.ai-theme .mm-row > div { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-hard); font-size: 13px; }
body.ai-theme .mm-theme {
  grid-column: 1 / -1; background: var(--bg-panel-alt); color: var(--text-dim);
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  padding: var(--space-2) var(--space-4);
}
body.ai-theme .mm-label { color: var(--text-dim); }
body.ai-theme .mm-value { text-align: right; font-weight: 600; }

body.ai-theme .gated-card {
  border: 1px solid var(--accent-gated); background: var(--bg-panel); border-radius: var(--radius); padding: var(--space-5);
}
body.ai-theme .gated-card .gated-tag {
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent-gated); border: 1px solid var(--accent-gated); border-radius: var(--radius-sm);
  padding: 3px 8px; display: inline-block; margin-bottom: var(--space-3);
}
body.ai-theme .gated-card ul { list-style: none; margin: var(--space-3) 0; padding: 0; }
body.ai-theme .gated-card li { padding: var(--space-1) 0; font-size: 13px; color: var(--text-primary); border-bottom: 1px solid var(--border-hard); }
body.ai-theme .gated-card .cta {
  display: inline-block; margin-top: var(--space-3); font-family: var(--mono); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; background: var(--accent-gated); color: #fff;
  border: 1px solid var(--accent-gated); border-radius: var(--radius-sm); padding: 10px 16px;
}
body.ai-theme .pending-card {
  border: 1px dashed var(--border-hard); background: var(--bg-panel); border-radius: var(--radius); padding: var(--space-5); color: var(--text-dim);
}
body.ai-theme .pending-card .pending-tag {
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-dim); border: 1px dashed var(--border-hard); border-radius: var(--radius-sm);
  padding: 3px 8px; display: inline-block; margin-bottom: var(--space-3);
}

body.ai-theme .notary-badge {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer; border: 1px solid var(--border-hard);
  border-radius: var(--radius-sm); padding: var(--space-1) var(--space-2); background: var(--bg-panel);
  color: var(--accent-verify); font-family: var(--mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  transition: border-color .12s var(--ease);
}
body.ai-theme .notary-badge:hover { border-color: var(--accent-verify); }
body.ai-theme .notary-badge svg { width: 12px; height: 12px; flex-shrink: 0; }
body.ai-theme .notary-drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(420px, 100%); background: var(--bg-panel);
  border-left: 1px solid var(--border-hard); transform: translateX(100%); transition: transform .25s var(--ease);
  z-index: 200; overflow-y: auto; padding: var(--space-5); box-shadow: var(--shadow-card);
}
body.ai-theme .notary-drawer.open { transform: translateX(0); }
body.ai-theme .notary-drawer .drawer-title {
  font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-dim); margin-bottom: var(--space-4);
}
body.ai-theme .notary-drawer .hash-row { margin-bottom: var(--space-4); }
body.ai-theme .notary-drawer .hash-row label {
  display: block; font-family: var(--mono); font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px;
}
body.ai-theme .notary-drawer .hash-value { font-size: 12px; word-break: break-all; color: var(--text-primary); }
body.ai-theme .notary-drawer .chain-link { color: var(--accent-verify); font-family: var(--mono); font-size: 11px; margin: 4px 0; }
body.ai-theme .notary-drawer a.source-link { color: var(--accent-verify); font-size: 13px; text-decoration: underline; }
body.ai-theme .notary-drawer .method-tag {
  font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim);
  border: 1px solid var(--border-hard); border-radius: var(--radius-sm); padding: 2px 6px; display: inline-block; margin-left: 6px;
}
body.ai-theme .notary-drawer .copy-btn {
  margin-top: var(--space-4); width: 100%; font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; background: var(--accent-verify); color: #fff; border: none; border-radius: var(--radius-sm); padding: 10px; cursor: pointer;
}
body.ai-theme .notary-drawer .close-btn {
  position: absolute; top: 14px; right: 16px; background: none; border: none; color: var(--text-dim); font-size: 18px; cursor: pointer;
}
body.ai-theme .notary-scrim {
  position: fixed; inset: 0; background: rgba(28,26,39,.4); z-index: 190; opacity: 0; pointer-events: none; transition: opacity .25s var(--ease);
}
body.ai-theme .notary-scrim.open { opacity: 1; pointer-events: auto; }

body.ai-theme .io-bar-row { display: grid; grid-template-columns: 1fr 2fr 1fr; align-items: center; gap: var(--space-3); margin: var(--space-2) 0; font-family: var(--mono); font-size: 12px; }
body.ai-theme .io-bar-track { position: relative; height: 18px; background: var(--bg-panel-alt); border: 1px solid var(--border-hard); border-radius: 999px; overflow: hidden; }
body.ai-theme .io-bar-fill-in { position: absolute; right: 50%; top: 0; height: 100%; background: var(--accent-verify); }
body.ai-theme .io-bar-fill-out { position: absolute; left: 50%; top: 0; height: 100%; background: var(--accent-alert); }
body.ai-theme .io-bar-mid { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--text-dim); }

/* ── mobile nav panel: hidden by default AT ALL WIDTHS. This must NOT be
   scoped inside the media query below — that was the exact bug that made
   it render as a plain inline div on desktop. ── */
.mobile-nav-panel {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-void); z-index: 300; padding: var(--space-6) var(--space-5);
  flex-direction: column; gap: var(--space-2);
}
.mobile-nav-panel.open { display: flex; }
.mobile-nav-panel a {
  font-family: var(--sans); font-size: 17px; font-weight: 600;
  color: var(--text-primary); padding: var(--space-3) 0; border-bottom: 1px solid var(--border-hard);
}
.mobile-nav-panel .mnp-close {
  align-self: flex-end; width: 40px; height: 40px; border: 1px solid var(--border-hard); border-radius: var(--radius-sm);
  background: none; color: var(--text-primary); font-size: 20px; cursor: pointer; margin-bottom: var(--space-4);
}

/* ── premium-card override: neutralise the old thick-border / hard-offset
   "6px 6px 0 var(--ink)" brutalist shadow used across every legacy template
   (.card,.panel,.tbl,.btn,.tier,.term,.stack,.callout,.keybox,.formula,
   .pledge) in favour of soft, subtle elevation — Stripe/Linear/Vercel
   register instead of a dev-tool/hacker register. Scoped to body.ai-theme
   so nothing outside /ai/ changes. ── */
body.ai-theme .card, body.ai-theme .panel, body.ai-theme .tbl,
body.ai-theme .tier, body.ai-theme .term, body.ai-theme .stack,
body.ai-theme .callout, body.ai-theme .keybox, body.ai-theme .formula,
body.ai-theme .pledge {
  border-width: 1px !important;
  border-color: var(--border-hard) !important;
  box-shadow: var(--shadow-card) !important;
  border-radius: var(--radius);
}
body.ai-theme .tier.featured { box-shadow: 0 2px 4px rgba(29,92,224,.08), 0 12px 28px rgba(29,92,224,.14) !important; border-color: var(--accent-verify) !important; }
body.ai-theme .card:hover, body.ai-theme .tier:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 8px rgba(20,20,30,.06), 0 16px 32px rgba(20,20,30,.09) !important;
}
body.ai-theme .term, body.ai-theme .callout, body.ai-theme .keybox, body.ai-theme .formula {
  background: var(--text-primary) !important; /* keep dark "terminal output" cards intentional, not accidental */
}
body.ai-theme .btn {
  border: none !important; box-shadow: none !important; border-radius: var(--radius-sm);
  background: var(--accent-verify) !important; color: #fff !important;
  transition: opacity .12s var(--ease);
}
body.ai-theme .btn:hover { opacity: .88; }

body.ai-theme .brand-badge{display:inline-flex;align-items:center;gap:5px;font-family:var(--mono);font-size:10.5px;
  font-weight:700;letter-spacing:.04em;padding:3px 9px;border-radius:999px;border:1px solid var(--gold-bd);
  background:var(--gold-bg);color:var(--gold-strong);white-space:nowrap}
body.ai-theme .next-action-row{display:flex;flex-wrap:wrap;gap:12px;margin:28px 0 8px;padding-top:20px;border-top:1px solid var(--border-hard)}
body.ai-theme .research-panel{background:var(--text-primary);color:#eef2f9;border-radius:var(--radius);padding:32px;margin:28px 0}
body.ai-theme .research-panel h3{font-family:var(--serif);font-size:24px;color:#fff;margin-bottom:10px}
body.ai-theme .research-panel p{color:#c7d0e0;font-size:14px;max-width:70ch}
body.ai-theme .research-panel .brand-badge{background:rgba(255,255,255,.1);border-color:rgba(255,255,255,.22);color:#a9c4ff}
body.ai-theme .verified-ts{font-family:var(--mono);font-size:11px;color:var(--text-dim);display:inline-flex;align-items:center;gap:5px}

/* ═══════════════════════ MOBILE (≤640px) ═══════════════════════════════ */
@media (max-width: 640px) {
  /* tighten vertical rhythm between sections — the desktop spacing felt
     too airy once stacked single-column on a phone */
  body.ai-theme .ai-hero { padding: 24px 0 16px !important; }
  body.ai-theme h2.sec { margin: 18px 0 6px !important; font-size: 21px !important; }
  body.ai-theme section.pad { padding: 14px 0 !important; }
  body.ai-theme .panel { padding: var(--space-4) !important; margin: 14px 0 !important; }

  /* swipeable horizontal card carousels: cards.problem-cards, .trust-cards,
     and the plain .cards grid all become one scroll-snapping row instead of
     a tall vertical stack, so a right-to-left swipe moves between cards */
  body.ai-theme .cards {
    display: flex !important;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: var(--space-3) !important;
    margin: 14px calc(-1 * var(--space-4)) !important;
    padding: 4px var(--space-4) 10px !important;
    scrollbar-width: none;
  }
  body.ai-theme .cards::-webkit-scrollbar { display: none; }
  body.ai-theme .cards > * {
    flex: 0 0 82%;
    scroll-snap-align: start;
  }
  body.ai-theme .trust-cards > * { flex-basis: 68%; }

  body.ai-theme nav { display: none; }
  .nav-burger { display: inline-flex; }

  html, body { overflow-x: hidden; max-width: 100vw; }
  .wrap { padding: 0 var(--space-4); }
  body.ai-theme .metric-matrix { display: block; border: none; min-width: 0; }
  body.ai-theme .mm-theme { border: 1px solid var(--border-hard); border-bottom: none; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
  body.ai-theme .bento-card {
    border: 1px solid var(--border-hard); background: var(--bg-panel); border-radius: var(--radius); padding: var(--space-4); margin-bottom: var(--space-3);
  }
  body.ai-theme .bento-card .bento-name {
    font-family: var(--serif); font-size: 20px; margin-bottom: var(--space-2); display: flex; align-items: center; gap: var(--space-2);
  }
  body.ai-theme .bento-row { display: flex; justify-content: space-between; padding: var(--space-2) 0; border-bottom: 1px solid var(--border-hard); font-size: 13px; }
  body.ai-theme .bento-row .bento-label { color: var(--text-dim); }
  body.ai-theme .bento-row .bento-value { font-family: var(--mono); font-variant-numeric: tabular-nums; }
  body.ai-theme .notary-drawer {
    width: 100%; height: auto; max-height: 80vh; top: auto; bottom: 0; right: 0; transform: translateY(100%);
    border-left: none; border-top: 1px solid var(--border-hard); border-radius: var(--radius) var(--radius) 0 0;
  }
  body.ai-theme .notary-drawer.open { transform: translateY(0); }
  .tbl { min-width: 480px; }
}
