/* ============================================================
   AI++ — ai-plusplus.com
   Single stylesheet · All colors in :root · Mobile-first
   Breakpoints: <600px (mobile), 600–960px (tablet portrait), 961px+ (desktop)

   Palette derived from the logo mark:
     light logo  #556AAE (indigo) on warm paper
     dark  logo  #eae7df / #9a9690 on warm near-black
   Type: IBM Plex Sans (body) + JetBrains Mono (labels, data, diagnostics)
   ============================================================ */

/* ── Custom properties · light (default) ───────────────────── */
:root {
  --paper:        #f7f6f2;
  --surface:      #fffefb;
  --sunken:       #efede6;
  --ink:          #1b1a17;
  --ink-2:        #3f3d38;
  --muted:        #6b675f;
  --faint:        #96918a;
  --line:         #ddd9cf;
  --line-soft:    #e8e5dc;

  --accent:       #556aae;
  --accent-deep:  #3f5290;
  --accent-wash:  #eceff8;

  --pass:         #2f6d4f;
  --fail:         #a4442e;
  --wait:         #8a6d1f;

  --shadow-sm:    0 1px 2px rgba(27,26,23,.05);
  --shadow:       0 1px 2px rgba(27,26,23,.05), 0 12px 32px -20px rgba(27,26,23,.28);

  --wide:         1080px;
  --read:         42rem;

  --font-body:    'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --logo-light:   block;
  --logo-dark:    none;
}

/* ── Custom properties · dark ──────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --paper:       #151412;
    --surface:     #1d1c19;
    --sunken:      #232120;
    --ink:         #eae7df;
    --ink-2:       #c4bfb4;
    --muted:       #9a9690;
    --faint:       #7c786f;
    --line:        #34312c;
    --line-soft:   #292724;

    --accent:      #8fa2dc;
    --accent-deep: #a9b8e6;
    --accent-wash: #21242f;

    --pass:        #63b083;
    --fail:        #d9836b;
    --wait:        #cbab52;

    --shadow-sm:   0 1px 2px rgba(0,0,0,.4);
    --shadow:      0 1px 2px rgba(0,0,0,.4), 0 12px 32px -20px rgba(0,0,0,.8);

    --logo-light:  none;
    --logo-dark:   block;
  }
}

/* ── Reset & base ──────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink-2);
  background: var(--paper);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

img, svg { max-width: 100%; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

strong { color: var(--ink); font-weight: 600; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: .6rem 1rem;
  font-family: var(--font-mono); font-size: .8rem;
}
.skip-link:focus { left: 0; }

/* ── Layout shells ─────────────────────────────────────────── */
.wide  { width: 100%; max-width: var(--wide); margin: 0 auto; padding: 0 1.25rem; }
.read  { width: 100%; max-width: var(--read);  margin: 0 auto; padding: 0 1.25rem; }

@media (min-width: 600px) { .wide, .read { padding: 0 2rem; } }
@media (min-width: 961px) { .wide, .read { padding: 0 2.5rem; } }

main { flex: 1 0 auto; }

.band { padding: 3rem 0; }
.band + .band { border-top: 1px solid var(--line-soft); }
.band-sunken { background: var(--sunken); }
@media (min-width: 600px) { .band { padding: 4rem 0; } }
@media (min-width: 961px) { .band { padding: 5.5rem 0; } }

/* ── Header / nav ──────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line-soft);
}
.header-inner {
  max-width: var(--wide); margin: 0 auto; padding: .7rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
@media (min-width: 600px) { .header-inner { padding: .8rem 2rem; } }
@media (min-width: 961px) { .header-inner { padding: .9rem 2.5rem; } }

.site-logo { display: block; line-height: 0; }
.site-logo img { height: 26px; width: auto; }
.logo-light { display: var(--logo-light); }
.logo-dark  { display: var(--logo-dark); }
@media (min-width: 600px) { .site-logo img { height: 30px; } }


.main-nav { display: none; gap: 1.6rem; align-items: center; }
@media (min-width: 961px) { .main-nav { display: flex; } }
.nav-link {
  font-family: var(--font-mono); font-size: .78rem; letter-spacing: .02em;
  color: var(--muted); text-decoration: none; padding: .3rem 0;
  border-bottom: 1px solid transparent;
}
.nav-link:hover { color: var(--ink); text-decoration: none; border-bottom-color: var(--line); }
.nav-link.active { color: var(--accent); border-bottom-color: var(--accent); }
.nav-cta {
  font-family: var(--font-mono); font-size: .78rem;
  background: var(--accent); color: #fff; padding: .45rem .9rem;
  border-radius: 3px; text-decoration: none;
}
.nav-cta:hover { background: var(--accent-deep); color: #fff; text-decoration: none; }

.hamburger {
  display: flex; flex-direction: column; gap: 4px; background: none;
  border: 0; cursor: pointer; padding: .4rem;
}
@media (min-width: 961px) { .hamburger { display: none; } }
.hamburger span { display: block; width: 20px; height: 2px; background: var(--ink); }

.mobile-nav {
  position: fixed; inset: 0; z-index: 60; background: var(--paper);
  display: none; flex-direction: column; align-items: flex-start;
  justify-content: center; gap: .4rem; padding: 2rem;
}
.mobile-nav.open { display: flex; }
.mobile-nav a {
  font-family: var(--font-mono); font-size: 1.05rem; color: var(--ink);
  padding: .6rem 0; text-decoration: none;
}
.mobile-nav a.active { color: var(--accent); }
.mobile-nav-close {
  position: absolute; top: 1.2rem; right: 1.4rem; background: none; border: 0;
  font-size: 2rem; line-height: 1; color: var(--muted); cursor: pointer;
}

/* ── Type scale ────────────────────────────────────────────── */
.eyebrow {
  font-family: var(--font-mono); font-size: .7rem; letter-spacing: .16em;
  text-transform: uppercase; color: var(--accent); font-weight: 600;
  margin-bottom: .9rem;
}
.eyebrow-muted { color: var(--muted); }

h1 {
  font-size: clamp(1.9rem, 6.2vw, 3.1rem); line-height: 1.08; letter-spacing: -.025em;
  color: var(--ink); font-weight: 700; text-wrap: balance; margin-bottom: 1rem;
}
h2 {
  font-size: clamp(1.35rem, 4.2vw, 1.95rem); line-height: 1.18; letter-spacing: -.018em;
  color: var(--ink); font-weight: 700; text-wrap: balance; margin-bottom: .85rem;
}
h3 {
  font-size: clamp(1.02rem, 2.6vw, 1.18rem); line-height: 1.3; letter-spacing: -.008em;
  color: var(--ink); font-weight: 600; margin-bottom: .45rem;
}
h4 {
  font-family: var(--font-mono); font-size: .74rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: .5rem;
}

p { margin-bottom: 1rem; }
p:last-child { margin-bottom: 0; }

.lead { font-size: clamp(1.02rem, 2.8vw, 1.18rem); color: var(--ink-2); }
.small { font-size: .87rem; }
.tiny  { font-size: .78rem; color: var(--muted); }
.tabular { font-variant-numeric: tabular-nums; }

ul.plain, ol.plain { list-style: none; }
ul.bul { padding-left: 1.15rem; margin-bottom: 1rem; }
ul.bul li { margin-bottom: .4rem; }
ul.bul li::marker { color: var(--faint); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-block; font-family: var(--font-mono); font-size: .82rem;
  padding: .7rem 1.25rem; border-radius: 3px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; transition: background .15s, color .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-deep); color: #fff; }
.btn-ghost { background: transparent; color: var(--accent); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--accent); background: var(--accent-wash); }
.btn-row { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1.4rem; }

/* ── Hero ──────────────────────────────────────────────────── */
.hero { padding: 2.5rem 0 3rem; }
@media (min-width: 600px) { .hero { padding: 3.5rem 0 4rem; } }
@media (min-width: 961px) { .hero { padding: 4.5rem 0 5rem; } }

.hero-claim { max-width: 34rem; }
.hero-sub { font-size: clamp(1rem, 2.8vw, 1.16rem); color: var(--ink-2); margin-top: .2rem; }

.artifact-grid { display: grid; gap: 1rem; margin-top: 2.2rem; }
@media (min-width: 961px) { .artifact-grid { grid-template-columns: 1.35fr 1fr; align-items: start; } }

.artifact {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 6px; overflow: hidden; box-shadow: var(--shadow);
}
.artifact-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: .75rem;
  padding: .6rem .9rem; border-bottom: 1px solid var(--line-soft);
  background: var(--sunken);
}
.artifact-title {
  font-family: var(--font-mono); font-size: .72rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); font-weight: 600;
}
.artifact-meta { font-family: var(--font-mono); font-size: .68rem; color: var(--faint); }
.artifact-body { padding: .9rem; }
.artifact-body.tight { padding: .5rem; }

/* ── Plan diagram ──────────────────────────────────────────── */
.plan-svg { width: 100%; height: auto; display: block; }

.plan-svg .pn-box     { fill: var(--surface); stroke: var(--line); stroke-width: 1; }
.plan-svg .pn-box-hl  { fill: var(--accent-wash); stroke: var(--accent); stroke-width: 1; }
.plan-svg .pn-rule    { stroke: var(--line-soft); stroke-width: 1; }
.plan-svg .pn-flow    { stroke: var(--line); stroke-width: 1.5; fill: none; }

.plan-svg .pn-kind    { font-family: var(--font-mono); font-size: 10px; fill: var(--accent); letter-spacing: 1px; }
.plan-svg .pn-desc    { font-family: var(--font-body); font-size: 13px; fill: var(--ink); }
.plan-svg .pn-case    { font-family: var(--font-body); font-size: 12.5px; fill: var(--ink); }
.plan-svg .pn-anchor  { font-family: var(--font-mono); font-size: 10px; fill: var(--muted); }
.plan-svg .pn-sub     { font-family: var(--font-mono); font-size: 9.5px; fill: var(--faint); }
.plan-svg .pn-foot    { font-family: var(--font-mono); font-size: 10.5px; fill: var(--pass); }
.plan-svg .pn-foot2   { font-family: var(--font-mono); font-size: 9.5px; fill: var(--faint); }
.plan-svg .node-check { font-family: var(--font-mono); font-size: 11px; fill: var(--pass); }

.plan-node .node-check { opacity: 0; }
.plan-node.verified .node-check { opacity: 1; transition: opacity .3s ease; }

/* ── Record excerpt ────────────────────────────────────────── */
.record {
  font-family: var(--font-mono); font-size: .72rem; line-height: 1.62;
  color: var(--ink-2); overflow-x: auto; white-space: pre; margin: 0;
}
.record .k   { color: var(--accent); }
.record .s   { color: var(--pass); }
.record .n   { color: var(--wait); }
.record .c   { color: var(--faint); }

.record-lines { display: grid; gap: .55rem; }
.rec-line { display: grid; grid-template-columns: auto 1fr; gap: .6rem; align-items: baseline; font-size: .78rem; }
.rec-tag {
  font-family: var(--font-mono); font-size: .62rem; letter-spacing: .07em;
  padding: .12rem .38rem; border-radius: 2px; border: 1px solid currentColor;
  white-space: nowrap;
}
.rec-tag.pass { color: var(--pass); }
.rec-tag.wait { color: var(--wait); }
.rec-tag.act  { color: var(--accent); }
.rec-body { color: var(--ink-2); }
.rec-body em { color: var(--muted); font-style: italic; }

/* ── Cost line ─────────────────────────────────────────────── */
.cost {
  display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap;
  font-family: var(--font-mono);
}
.cost-value { font-size: clamp(1.6rem, 5vw, 2.2rem); color: var(--ink); font-weight: 600; letter-spacing: -.02em; }
.cost-label { font-size: .74rem; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }

/* ── Break-it demo ─────────────────────────────────────────── */
.breaker { display: grid; gap: 1rem; }
@media (min-width: 961px) { .breaker { grid-template-columns: 1fr 1.25fr; align-items: start; } }

.break-options { display: grid; gap: .5rem; }
.break-btn {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px;
  padding: .7rem .85rem; font-family: var(--font-body); font-size: .87rem;
  color: var(--ink-2); transition: border-color .15s, background .15s;
}
.break-btn:hover { border-color: var(--accent); }
.break-btn.active { border-color: var(--accent); background: var(--accent-wash); color: var(--ink); }
.break-btn .bk-label {
  display: block; font-family: var(--font-mono); font-size: .66rem;
  letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin-bottom: .18rem;
}
.break-btn.active .bk-label { color: var(--accent); }

.diagnostics {
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  padding: .9rem; min-height: 11rem; box-shadow: var(--shadow-sm);
}
.diag-empty { color: var(--faint); font-family: var(--font-mono); font-size: .78rem; }
.diag {
  font-family: var(--font-mono); font-size: .74rem; line-height: 1.6;
  border-left: 2px solid var(--fail); padding-left: .7rem; margin-bottom: .85rem;
}
.diag:last-child { margin-bottom: 0; }
.diag-code { color: var(--fail); font-weight: 600; }
.diag-msg { color: var(--ink-2); display: block; margin-top: .2rem; }
.diag-fix { color: var(--muted); display: block; margin-top: .3rem; }
.diag-fix::before { content: "→ "; color: var(--faint); }
.diag-ok { border-left-color: var(--pass); }
.diag-ok .diag-code { color: var(--pass); }

/* ── Cards / grids ─────────────────────────────────────────── */
.grid-3 { display: grid; gap: 1.1rem; }
@media (min-width: 600px) { .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 961px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

.grid-2 { display: grid; gap: 1.1rem; }
@media (min-width: 600px) { .grid-2 { grid-template-columns: repeat(2, 1fr); } }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  padding: 1.25rem; box-shadow: var(--shadow-sm);
}
.card-num {
  font-family: var(--font-mono); font-size: .7rem; color: var(--accent);
  letter-spacing: .1em; margin-bottom: .55rem;
}

/* ── Stat strip ────────────────────────────────────────────── */
.stats { display: grid; gap: 1.4rem; }
@media (min-width: 600px) { .stats { grid-template-columns: repeat(3, 1fr); } }
.stat-value {
  font-family: var(--font-mono); font-size: clamp(1.7rem, 5.5vw, 2.4rem);
  color: var(--ink); font-weight: 600; letter-spacing: -.02em; line-height: 1;
}
.stat-label { font-size: .87rem; color: var(--muted); margin-top: .45rem; }
.stat-src { font-family: var(--font-mono); font-size: .64rem; color: var(--faint); margin-top: .3rem; }

/* ── Doors ─────────────────────────────────────────────────── */
.door {
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  padding: 1.4rem; display: flex; flex-direction: column;
}
.door-kicker {
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent); margin-bottom: .6rem;
}
.door h3 { margin-bottom: .5rem; }
.door p { font-size: .92rem; }
.door-who {
  font-family: var(--font-mono); font-size: .7rem; color: var(--muted);
  margin-top: auto; padding-top: .9rem; border-top: 1px solid var(--line-soft);
}

/* ── Method / notes cards ──────────────────────────────────── */
.note-card { padding: 1.6rem 0; border-bottom: 1px solid var(--line-soft); }
.note-card:last-child { border-bottom: 0; }
.note-date {
  display: inline-block; font-family: var(--font-mono); font-size: .68rem;
  letter-spacing: .08em; color: var(--muted); background: var(--sunken);
  padding: .2rem .55rem; border-radius: 3px; margin-bottom: .7rem;
}
.note-title { font-size: clamp(1.05rem, 3vw, 1.28rem); line-height: 1.28; margin-bottom: .55rem; }
.note-title a.out {
  display: inline-block; font-family: var(--font-mono); font-size: .72rem;
  color: var(--accent); font-weight: 500; margin-top: .3rem;
}
.note-summary { font-size: .93rem; color: var(--ink-2); margin-bottom: .8rem; }
.note-topics { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem; }
.note-topics li {
  font-family: var(--font-mono); font-size: .68rem; color: var(--muted);
  background: var(--sunken); border: 1px solid var(--line-soft);
  padding: .18rem .5rem; border-radius: 3px;
}

/* ── Book ──────────────────────────────────────────────────── */
.book { display: grid; gap: 1.3rem; }
@media (min-width: 600px) { .book { grid-template-columns: 150px 1fr; align-items: start; } }
.book-cover {
  border: 1px solid var(--line); border-radius: 4px; box-shadow: var(--shadow);
  background: var(--sunken); aspect-ratio: 2/3; display: flex; align-items: center;
  justify-content: center; text-align: center; padding: 1rem;
  font-family: var(--font-mono); font-size: .68rem; color: var(--faint);
}
.book-badge {
  display: inline-block; font-family: var(--font-mono); font-size: .66rem;
  letter-spacing: .08em; text-transform: uppercase; color: var(--pass);
  border: 1px solid currentColor; padding: .2rem .5rem; border-radius: 3px;
  margin-bottom: .7rem;
}

/* ── Steps (how-it-works) ──────────────────────────────────── */
.steps { display: grid; gap: 0; counter-reset: step; }
.step {
  display: grid; gap: .3rem .9rem; padding: 1.5rem 0;
  border-bottom: 1px solid var(--line-soft); counter-increment: step;
}
.step:last-child { border-bottom: 0; }
@media (min-width: 600px) { .step { grid-template-columns: 3.2rem 1fr; } }
.step-n {
  font-family: var(--font-mono); font-size: .8rem; color: var(--accent);
  font-weight: 600; padding-top: .15rem;
}
.step-n::before { content: counter(step, decimal-leading-zero); }

/* ── Definition rows ───────────────────────────────────────── */
.rows { border-top: 1px solid var(--line); margin: 1.2rem 0; }
.row { display: grid; gap: .3rem .9rem; padding: 1rem 0; border-bottom: 1px solid var(--line-soft); }
@media (min-width: 600px) { .row { grid-template-columns: 12rem 1fr; } }
.row .k { color: var(--ink); font-weight: 600; font-size: .95rem; }
.row .k .sub { display: block; font-weight: 400; color: var(--faint); font-size: .78rem; margin-top: .1rem; }
.row .v { font-size: .93rem; }

/* ── Callout ───────────────────────────────────────────────── */
.callout {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: 0 5px 5px 0;
  padding: 1.1rem 1.2rem; margin: 1.4rem 0; box-shadow: var(--shadow-sm);
}
.callout h4 { color: var(--accent); }

/* ── Reveal animation (FOUC-safe) ──────────────────────────── */
.reveal-init { opacity: 0; transform: translateY(10px); }
.reveal-on {
  opacity: 1; transform: none;
  transition: opacity .55s ease, transform .55s ease;
}

/* ── Footer ────────────────────────────────────────────────── */
.site-footer {
  flex-shrink: 0; border-top: 1px solid var(--line);
  padding: 2.2rem 0 2.6rem; margin-top: 1rem;
}
.footer-inner {
  max-width: var(--wide); margin: 0 auto; padding: 0 1.25rem;
  display: grid; gap: 1.4rem;
}
@media (min-width: 600px) {
  .footer-inner { padding: 0 2rem; grid-template-columns: 1fr auto; align-items: end; }
}
@media (min-width: 961px) { .footer-inner { padding: 0 2.5rem; } }
.footer-links { display: flex; flex-wrap: wrap; gap: 1.1rem; }
.footer-links a { font-family: var(--font-mono); font-size: .76rem; color: var(--muted); }
.footer-links a:hover { color: var(--accent); }
.footer-note { font-family: var(--font-mono); font-size: .7rem; color: var(--faint); }

/* ── 404 ───────────────────────────────────────────────────── */
.e404 { text-align: center; padding: 5rem 0; }
.e404-code {
  font-family: var(--font-mono); font-size: clamp(3rem, 14vw, 5.5rem);
  color: var(--accent); font-weight: 600; line-height: 1; letter-spacing: -.03em;
}

/* ── Print ─────────────────────────────────────────────────── */
@media print {
  .site-header, .mobile-nav, .hamburger, .btn-row, .breaker { display: none; }
  body { background: #fff; color: #000; }
}
