/* AI, plainly — shared design system
   Paper editorial: Newsreader serif body, Archivo sans labels, red accent. */

:root {
  --paper:  #faf7f0;
  --ink:    #1c1a15;
  --body:   #403c34;
  --muted:  #8d8676;
  --rule:   #e4ded0;
  --rule-2: #efe9db;
  --accent: #9a2e22;
  --accent-t:#f1e4e0;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans:  "Archivo", system-ui, -apple-system, sans-serif;
  --maxw: 660px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
html.anim [data-reveal] { opacity: 0; transform: translateY(12px); }

body {
  margin: 0; background: var(--paper); color: var(--body);
  font-family: var(--serif); font-size: 19px; line-height: 1.62;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
  font-optical-sizing: auto;
}
.wrap {
  max-width: var(--maxw); margin: 0 auto;
  padding-left: max(26px, env(safe-area-inset-left));
  padding-right: max(26px, env(safe-area-inset-right));
}

h1, h2 { margin: 0; color: var(--ink); font-family: var(--serif); font-weight: 500; letter-spacing: -0.012em; line-height: 1.08; }
a { color: var(--accent); }
em { font-style: italic; }

.meta { font-family: var(--sans); text-transform: uppercase; letter-spacing: .14em; font-weight: 600; }

/* ---------- Masthead ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(130%) blur(8px);
  border-bottom: 1px solid var(--rule);
}
.nav-inner {
  max-width: var(--maxw); margin: 0 auto; display: flex; align-items: center; gap: 14px;
  padding-top: 12px; padding-bottom: 12px;
  padding-left: max(26px, env(safe-area-inset-left));
  padding-right: max(26px, env(safe-area-inset-right));
}
.brand { font-family: var(--serif); font-style: italic; font-weight: 500; font-size: 18px; color: var(--ink); white-space: nowrap; text-decoration: none; }
.brand:hover { color: var(--accent); }
.nav-links { margin-left: auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px 8px; }
.nav-links a {
  font-family: var(--sans); font-weight: 600; font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase;
  text-decoration: none; color: var(--muted); padding: 5px 4px; border-radius: 5px; white-space: nowrap;
  transition: color .15s; -webkit-tap-highlight-color: transparent;
}
.nav-links a:hover, .nav-links a.active { color: var(--accent); }
@media (max-width: 560px){
  .nav-links a { font-size: 10.5px; letter-spacing: .05em; padding: 5px 3px; }
  .nav-inner { gap: 8px; }
}

section { scroll-margin-top: 66px; }

/* ---------- Opener ---------- */
.hero { padding-top: clamp(56px, 13vw, 96px); padding-bottom: clamp(20px, 5vw, 30px); }
.hero h1 { font-size: clamp(38px, 9.5vw, 68px); font-weight: 500; }
.hero .standfirst {
  font-style: italic; font-weight: 400; color: var(--body);
  font-size: clamp(20px, 3.6vw, 26px); line-height: 1.42; max-width: 24em;
  margin: clamp(20px, 4vw, 28px) 0 0;
}
.hero .standfirst .lead-in { font-style: normal; color: var(--ink); }

/* ---------- Hub lesson list ---------- */
.lessons { padding-top: clamp(10px, 3vw, 18px); }
.lesson {
  display: block; text-decoration: none; border-top: 1px solid var(--rule);
  padding: clamp(22px, 5.5vw, 30px) 0; color: inherit; -webkit-tap-highlight-color: transparent;
}
.lesson:hover .l-title { color: var(--accent); }
.lesson .kick { display: flex; align-items: baseline; gap: 10px; color: var(--accent); }
.lesson .kick .num { font-family: var(--sans); font-weight: 700; font-size: 13px; letter-spacing: .1em; }
.lesson .kick .ln { flex: 1; height: 1px; background: var(--rule); align-self: center; }
.lesson .kick .kind { font-family: var(--sans); font-weight: 600; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.lesson h2 { font-size: clamp(28px, 6.5vw, 42px); font-weight: 500; margin: 10px 0 0; transition: color .15s; }
.lesson .promise { font-style: italic; color: var(--body); font-size: clamp(16.5px, 3vw, 18.5px); margin: 8px 0 0; max-width: 32em; }
.lesson .go { font-family: var(--sans); font-weight: 600; font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-top: 12px; display: inline-block; }

/* ---------- Article sections (five layers) ---------- */
.layers { padding-top: clamp(10px, 3vw, 18px); }
.layer { padding: clamp(34px, 8vw, 52px) 0; border-top: 1px solid var(--rule); }
.layer .kick { display: flex; align-items: baseline; gap: 10px; color: var(--accent); }
.layer .kick .num { font-family: var(--sans); font-weight: 700; font-size: 13px; letter-spacing: .1em; }
.layer .kick .ln { flex: 1; height: 1px; background: var(--rule); align-self: center; }
.layer h2 { font-size: clamp(31px, 7.5vw, 46px); font-weight: 500; margin: 12px 0 0; }
.layer .tag { font-style: italic; color: var(--muted); font-size: clamp(18px, 3.4vw, 21px); margin: 6px 0 0; }
.layer .def { color: var(--ink); font-size: clamp(18px, 3.2vw, 20px); margin: clamp(16px, 4vw, 22px) 0 0; line-height: 1.58; max-width: 34em; }
.layer .analogy { color: var(--body); font-size: clamp(16.5px, 3vw, 18px); margin: 14px 0 0; max-width: 34em; }
.layer .analogy b { font-style: italic; font-weight: 500; color: var(--accent); }

/* first layer drop cap */
#prompt .def::first-letter {
  float: left; font-family: var(--serif); font-weight: 500; color: var(--accent);
  font-size: 3.1em; line-height: .82; padding: 6px 10px 0 0;
}

.ba { margin-top: clamp(20px, 5vw, 26px); display: grid; grid-template-columns: 1fr 1fr; gap: 0; border-top: 1px solid var(--rule); }
@media (max-width: 520px){ .ba { grid-template-columns: 1fr; } }
.ba .c { padding: 16px 20px 6px 0; }
.ba .c + .c { padding-left: clamp(18px, 5vw, 28px); border-left: 1px solid var(--rule); }
@media (max-width: 520px){ .ba .c + .c { border-left: 0; border-top: 1px solid var(--rule); padding-left: 0; padding-top: 16px; } }
.ba .cap { font-family: var(--sans); font-weight: 600; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 8px; display: block; }
.ba .a .cap { color: var(--muted); }
.ba .b .cap { color: var(--accent); }
.ba .t { font-style: italic; font-size: 16.5px; line-height: 1.5; }
.ba .a .t { color: var(--muted); }
.ba .b .t { color: var(--ink); }

/* ---------- Lesson prose ---------- */
.prose { padding-top: clamp(10px, 3vw, 18px); }
.prose p { margin: clamp(16px, 4vw, 22px) 0 0; max-width: 34em; }
.prose p.lede { color: var(--ink); font-size: clamp(18px, 3.2vw, 20px); line-height: 1.58; }
.prose h2 { font-size: clamp(28px, 6.5vw, 40px); margin-top: clamp(34px, 8vw, 52px); }
.prose h2 .num { color: var(--accent); font-family: var(--sans); font-weight: 700; font-size: 13px; letter-spacing: .1em; display: block; margin-bottom: 8px; }
.prose .aside {
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  padding: 18px 0; margin: clamp(20px, 5vw, 28px) 0; font-style: italic; color: var(--body); max-width: 34em;
}
.prose .aside b { color: var(--accent); font-weight: 500; }
.prose code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .82em;
  background: var(--rule-2); border-radius: 3px; padding: 2px 6px; color: var(--ink);
}

/* ---------- Interactive demo frame ---------- */
.demo {
  margin: clamp(22px, 5vw, 30px) 0; border: 1px solid var(--rule); border-radius: 6px;
  background: #fffdf8; overflow: hidden;
}
.demo-head {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--paper) 60%, transparent);
}
.demo-head .dlabel {
  font-family: var(--sans); font-weight: 600; font-size: 10.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted); margin-right: 6px;
}
.tab {
  font-family: var(--sans); font-weight: 600; font-size: 11px; letter-spacing: .06em;
  color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 4px;
  padding: 5px 10px; cursor: pointer; transition: color .15s, background .15s;
}
.tab:hover { color: var(--accent); }
.tab.on { color: var(--accent); background: var(--accent-t); }
.demo-stage { padding: clamp(14px, 4vw, 22px); position: relative; }
.demo-note {
  font-family: var(--sans); font-size: 11.5px; letter-spacing: .06em; color: var(--muted);
  padding: 10px 14px; border-top: 1px solid var(--rule);
}

/* token chips (tokenizer demo + attention text) */
.chip {
  display: inline-block; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13.5px; line-height: 1.5; padding: 2px 4px; border-radius: 3px;
  background: var(--rule-2); color: var(--ink); margin: 0 1px 4px 0; white-space: pre-wrap;
}
.chip.alt  { background: var(--accent-t); color: var(--accent); }

/* attention generated text */
.att-text {
  font-family: var(--serif); font-size: clamp(16.5px, 3vw, 18.5px); line-height: 1.75; color: var(--ink);
}
.att-text .tok {
  cursor: pointer; border-radius: 3px; padding: 0 1px; -webkit-tap-highlight-color: transparent;
  transition: background .12s; border-bottom: 1px solid transparent;
}
.att-text .tok:hover, .att-text .tok.on { border-bottom-color: var(--accent); }
.att-text .tok.src { background: var(--accent-t); }
.att-text .prompt-part { color: var(--muted); }
.att-text .prompt-part.vis { color: var(--ink); background: var(--accent-t); }
.att-svg { position: absolute; inset: 0; pointer-events: none; }
.att-svg line { stroke: var(--accent); stroke-width: 1.25; }

/* embedding map */
.emb-map { display: block; width: 100%; height: auto; }
.emb-map text { font-family: var(--sans); font-size: 11px; fill: var(--body); cursor: pointer; }
.emb-map circle { fill: var(--accent); opacity: .55; transition: opacity .15s, r .15s; }
.emb-map .hot circle, .emb-map .hot text { opacity: 1; }
.emb-map .hot text { fill: var(--accent); font-weight: 600; }
.emb-map line { stroke: var(--accent); stroke-width: 1; opacity: .55; }

/* before/after toggle */
.toggle { display: inline-flex; border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; }
.toggle button {
  font-family: var(--sans); font-weight: 600; font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); background: transparent; border: 0; padding: 7px 14px; cursor: pointer; transition: all .15s;
}
.toggle button.on { color: var(--paper); background: var(--accent); }
.ft-answer { font-style: italic; font-size: 16.5px; line-height: 1.6; min-height: 3em; }
.ft-answer.mine { color: var(--ink); }

/* ---------- Pager ---------- */
.pager {
  display: flex; justify-content: space-between; gap: 14px; border-top: 1px solid var(--rule);
  margin-top: clamp(30px, 7vw, 44px); padding: 18px 0 0;
}
.pager a {
  font-family: var(--sans); font-weight: 600; font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase;
  text-decoration: none; color: var(--muted);
}
.pager a:hover, .pager a.next { color: var(--accent); }
.pager a.prev { margin-right: auto; }

/* ---------- Nesting figure (five layers) ---------- */
.figure { margin: clamp(30px, 7vw, 46px) 0 0; }
.nest {
  position: relative; border: 1px solid var(--rule); border-radius: 4px; cursor: pointer;
  padding: clamp(36px, 8vw, 44px) clamp(12px, 3.5vw, 18px) clamp(12px, 3.5vw, 18px);
  transition: background .16s ease; -webkit-tap-highlight-color: transparent; background: transparent;
}
.nest:hover { background: color-mix(in srgb, var(--accent) 3%, transparent); }
.nest:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nest .lbl {
  position: absolute; top: clamp(11px, 3vw, 14px); left: clamp(13px, 4vw, 17px);
  font-family: var(--sans); font-weight: 600; font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.nest .lbl .n { color: var(--accent); margin-right: 7px; }
.nest.core {
  border: 1px solid var(--accent-t); background: var(--accent-t); text-align: center;
  padding: clamp(16px, 4.5vw, 22px); cursor: pointer;
}
.nest.core:hover { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.nest.core .lbl { position: static; color: var(--accent); display: block; margin-bottom: 4px; }
.nest.core .word { font-family: var(--serif); font-style: italic; font-weight: 500; font-size: clamp(20px, 5.5vw, 25px); color: var(--ink); }
figcaption { font-family: var(--sans); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); text-align: center; margin-top: 14px; }

/* ---------- Coda ---------- */
.coda { border-top: 3px double var(--rule); margin-top: clamp(10px, 3vw, 16px); padding: clamp(36px, 8vw, 54px) 0 clamp(20px, 5vw, 30px); text-align: center; }
.coda .meta { color: var(--accent); font-size: 12px; }
.coda h2 { font-size: clamp(28px, 6.5vw, 40px); font-weight: 500; margin-top: 12px; }
.coda p { font-style: italic; color: var(--body); max-width: 32em; margin: 18px auto 0; font-size: clamp(17px, 3.2vw, 20px); line-height: 1.55; }
.coda .seq { font-family: var(--sans); font-weight: 600; font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink); margin-top: 26px; }
.coda .seq .dot { color: var(--accent); margin: 0 8px; }

/* ---------- Contact ---------- */
.contact { border-top: 1px solid var(--rule); padding: clamp(36px, 8vw, 54px) 0 clamp(30px, 7vw, 44px); }
.contact .meta { color: var(--accent); font-size: 12px; }
.contact h2 { font-size: clamp(26px, 6vw, 36px); font-weight: 500; margin-top: 12px; }
.contact .lede { font-style: italic; color: var(--body); max-width: 30em; margin: 14px 0 0; font-size: clamp(16.5px, 3vw, 18.5px); line-height: 1.55; }
.contact form { margin-top: clamp(22px, 5vw, 30px); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px){ .row { grid-template-columns: 1fr; } }
.fld {
  width: 100%; font-family: var(--serif); font-size: 17px; color: var(--ink);
  background: transparent; border: 1px solid var(--rule); border-radius: 4px;
  padding: 11px 13px; transition: border-color .15s;
}
.fld::placeholder { color: var(--muted); font-style: italic; }
.fld:focus { outline: none; border-color: var(--accent); }
textarea.fld { resize: vertical; min-height: 92px; line-height: 1.5; }
.send-row { margin-top: 12px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.btn-send {
  font-family: var(--sans); font-weight: 600; font-size: 12px; letter-spacing: .11em; text-transform: uppercase;
  color: var(--paper); background: var(--accent); border: 1px solid var(--accent); border-radius: 4px;
  padding: 11px 22px; cursor: pointer; transition: opacity .15s;
}
.btn-send:hover { opacity: .88; }
.btn-send[disabled] { opacity: .5; cursor: default; }
.form-note { font-family: var(--sans); font-size: 12px; letter-spacing: .04em; color: var(--muted); }
.form-note.bad { color: var(--accent); }
.honey { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.sent { font-style: italic; color: var(--ink); font-size: clamp(17px, 3vw, 19px); margin: clamp(22px, 5vw, 30px) 0 0; }

/* ---------- Footer ---------- */
footer { padding: 0 0 calc(env(safe-area-inset-bottom) + 60px); }
footer .fr {
  max-width: var(--maxw); margin: 0 auto; border-top: 1px solid var(--rule); text-align: center;
  padding-top: 22px;
  padding-left: max(26px, env(safe-area-inset-left));
  padding-right: max(26px, env(safe-area-inset-right));
}
footer .fr .t { font-style: italic; color: var(--body); font-size: 16px; }
footer .fr .u { font-family: var(--sans); font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; margin-top: 8px; }
footer .fr a { text-decoration: none; color: var(--accent); }

/* ---------- Reveal ---------- */
html.anim [data-reveal] { transition: opacity .6s cubic-bezier(.2,.7,.2,1), transform .6s cubic-bezier(.2,.7,.2,1); }
html.anim [data-reveal].in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html.anim [data-reveal] { opacity: 1 !important; transform: none !important; }
  html { scroll-behavior: auto; }
}
