/* Deep-dive — analytical layer atop the editorial system.
   Reuses editorial.css tokens; adds proof boxes, complexity tables,
   syntax-highlighted code, callouts, and a narrow long-read column. */

/* ─── Page hero (analytical variant) ───────────────────────────── */
.dd-hero {
  padding: 52px 0 30px;
  border-bottom: 1px solid var(--hairline);
}
.dd-hero .eyebrow { display: block; margin-bottom: 14px; }
.dd-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(36px, 5vw, 60px);
  letter-spacing: -0.02em;
  line-height: 1.05;
  max-width: 20ch;
}
.dd-hero .standfirst {
  margin-top: 18px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(17px, 1.6vw, 21px);
  line-height: 1.5;
  color: var(--muted);
  max-width: 60ch;
}
.dd-hero .hero-meta {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ─── Long-read single column ──────────────────────────────────── */
.dd-article {
  max-width: 780px;
  margin: 0 auto;
  padding: 8px 0 0;
}
.dd-section {
  padding: 38px 0;
  border-top: 1px solid var(--hairline);
}
.dd-section:first-of-type { border-top: 0; }
.dd-section-title {
  font-family: var(--font-display);
  font-size: clamp(24px, 2.6vw, 32px);
  letter-spacing: -0.01em;
  margin-bottom: 18px;
}
.dd-section-title .num {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--accent);
  display: block;
  margin-bottom: 6px;
  text-transform: uppercase;
}

/* prose */
.prose { max-width: 68ch; }
.prose p { margin: 0 0 16px; font-size: 16px; line-height: 1.62; }
.prose p:last-child { margin-bottom: 0; }
.prose strong { font-weight: 600; }
.prose em { font-style: italic; }
.prose ul, .prose ol { margin: 0 0 16px; padding-left: 22px; }
.prose li { margin: 0 0 7px; line-height: 1.6; }
.prose code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--ink-soft);
  padding: 1px 5px;
  border-radius: 2px;
}
.prose h3 {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: -0.01em;
  margin: 28px 0 10px;
}
.prose .lede {
  font-family: var(--font-display);
  font-size: clamp(18px, 1.8vw, 21px);
  line-height: 1.52;
  color: var(--fg);
  max-width: 62ch;
}

/* ─── Math — inline + display ──────────────────────────────────── */
.math {
  font-family: 'IBM Plex Mono', var(--font-mono);
  font-size: 0.95em;
  font-style: italic;
}
.mathblock {
  font-family: 'IBM Plex Mono', var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
  background: var(--paper);
  border: 1px solid var(--hairline);
  padding: 16px 20px;
  margin: 18px 0;
  overflow-x: auto;
  text-align: center;
  white-space: pre-wrap;
}
.mathblock .label {
  float: right;
  font-style: normal;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* ─── Theorem / Proof / Lemma boxes ────────────────────────────── */
.box {
  margin: 22px 0;
  border: 1px solid var(--border);
  background: var(--surface);
}
.box-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--hairline);
  background: var(--paper);
}
.box-head .tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
}
.box-head .name {
  font-family: var(--font-display);
  font-size: 15px;
  font-style: italic;
  color: var(--muted);
}
.box-body {
  padding: 14px 16px;
  font-size: 14.5px;
  line-height: 1.6;
}
.box-body p { margin: 0 0 10px; }
.box-body p:last-child { margin-bottom: 0; }
.box-body code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--ink-soft);
  padding: 1px 4px;
}

.box.theorem  { border-left: 3px solid var(--accent); }
.box.theorem  .box-head .tag { color: var(--accent); }
.box.proof    { border-left: 3px solid var(--rule); }
.box.proof    .box-head .tag { color: var(--rule); }
.box.lemma    { border-left: 3px solid oklch(45% 0.07 230); }
.box.lemma    .box-head .tag { color: oklch(45% 0.07 230); }
.box.invariant{ border-left: 3px solid oklch(46% 0.09 150); }
.box.invariant .box-head .tag { color: oklch(46% 0.09 150); }

.qed { float: right; font-family: var(--font-mono); color: var(--muted); }
.qed::after { content: "∎"; }

/* ─── Callouts — insight / warning / pitfall ───────────────────── */
.callout {
  margin: 22px 0;
  padding: 14px 16px 14px 18px;
  border-left: 3px solid var(--rule);
  background: var(--paper);
  font-size: 14.5px;
  line-height: 1.6;
}
.callout .c-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 5px;
  font-weight: 600;
}
.callout.insight { border-color: var(--accent); }
.callout.insight .c-label { color: var(--accent); }
.callout.pitfall { border-color: oklch(50% 0.13 35); background: oklch(50% 0.13 35 / 0.05); }
.callout.pitfall .c-label { color: oklch(50% 0.13 35); }
.callout.note    { border-color: var(--rule); }
.callout.note .c-label { color: var(--muted); }

/* ─── Complexity / comparison tables ───────────────────────────── */
.dtable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 18px 0;
  font-variant-numeric: tabular-nums;
}
.dtable caption {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 8px;
}
.dtable th, .dtable td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
}
.dtable thead th {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1.5px solid var(--rule);
}
.dtable tbody th {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
}
.dtable td.mono, .dtable th.mono { font-family: var(--font-mono); }
.dtable tr.best td, .dtable tr.best th { background: var(--accent-soft); }
.dtable tr.best td:first-child::before {
  content: "▸ ";
  color: var(--accent);
}
.dtable .good { color: oklch(46% 0.09 150); }
.dtable .bad  { color: oklch(50% 0.13 35); }

/* ─── Code blocks + lightweight syntax highlight ───────────────── */
.codeblock {
  margin: 20px 0;
  border: 1px solid var(--hairline);
  background: oklch(22% 0.012 70);
  overflow: hidden;
}
.codeblock .code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid oklch(32% 0.012 70);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: oklch(70% 0.01 90);
}
.codeblock .code-head .file { color: oklch(78% 0.05 60); }
.codeblock .code-head .role { color: oklch(60% 0.01 90); }
.codeblock pre {
  margin: 0;
  padding: 14px 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.62;
  color: oklch(88% 0.01 90);
  counter-reset: ln;
}
.codeblock .ln {
  display: block;
  padding: 0 16px 0 0;
  white-space: pre;
}
.codeblock .ln::before {
  counter-increment: ln;
  content: counter(ln);
  display: inline-block;
  width: 40px;
  padding-right: 14px;
  margin-right: 14px;
  text-align: right;
  color: oklch(42% 0.012 70);
  border-right: 1px solid oklch(32% 0.012 70);
  user-select: none;
}
.codeblock .ln.hl { background: oklch(52% 0.10 28 / 0.16); }
.codeblock .ln.cmt-only::before { color: oklch(38% 0.012 70); }

/* token colors — applied via spans by the build */
.tok-kw  { color: oklch(72% 0.13 25); }   /* keywords */
.tok-ty  { color: oklch(78% 0.10 200); }  /* types */
.tok-fn  { color: oklch(82% 0.12 90); }   /* function names */
.tok-num { color: oklch(78% 0.10 150); }  /* numbers */
.tok-str { color: oklch(75% 0.11 140); }  /* strings */
.tok-cmt { color: oklch(55% 0.03 140); font-style: italic; } /* comments */
.tok-pp  { color: oklch(68% 0.09 320); }  /* preprocessor */
.tok-op  { color: oklch(70% 0.02 90); }   /* operators (subtle) */

/* inline "design proposal" tag — for pages without verified solution code */
.design-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: oklch(50% 0.13 35);
  border: 1px solid oklch(50% 0.13 35);
  background: oklch(50% 0.13 35 / 0.06);
  padding: 1px 6px;
  border-radius: 2px;
  vertical-align: middle;
  margin-left: 4px;
}

/* annotation gutter under code */
.code-note {
  margin: -12px 0 22px;
  padding: 12px 16px;
  border: 1px solid var(--hairline);
  border-top: 0;
  background: var(--paper);
  font-size: 13px;
  line-height: 1.58;
}
.code-note .cn-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-right: 8px;
}

/* ─── Step / derivation list ───────────────────────────────────── */
.derive {
  margin: 18px 0;
  counter-reset: dstep;
  padding: 0;
  list-style: none;
}
.derive li {
  position: relative;
  padding: 0 0 14px 38px;
  margin: 0;
  border-left: 1px solid var(--hairline);
}
.derive li:last-child { border-left-color: transparent; padding-bottom: 0; }
.derive li::before {
  counter-increment: dstep;
  content: counter(dstep);
  position: absolute;
  left: -13px;
  top: -2px;
  width: 25px; height: 25px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--bg);
  background: var(--rule);
  border-radius: 50%;
}
.derive li .d-head {
  font-weight: 600;
  font-size: 14.5px;
  display: block;
  margin-bottom: 3px;
}
.derive li .d-body { font-size: 14px; line-height: 1.58; color: var(--muted); }

/* ─── Key-value stat ribbon (score evidence) ───────────────────── */
.evidence {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border: 1px solid var(--hairline);
  background: var(--surface);
  margin: 20px 0;
}
.evidence .cell {
  padding: 13px 16px;
  border-right: 1px solid var(--hairline);
}
.evidence .cell:last-child { border-right: 0; }
.evidence .cell .k {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.evidence .cell .v {
  font-family: var(--font-display);
  font-size: 21px;
  letter-spacing: -0.01em;
  margin-top: 4px;
  display: block;
  font-variant-numeric: tabular-nums;
}
.evidence .cell .v.pass { color: var(--accent); }

/* ─── Cross-reference chips ─────────────────────────────────────── */
.xref {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}
.xref a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  padding: 6px 11px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  transition: border-color 100ms ease;
}
.xref a:hover { border-color: var(--fg); }
.xref a .x-kind {
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ─── Page nav (prev / next / up) ──────────────────────────────── */
.dd-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--hairline);
  flex-wrap: wrap;
}
.dd-nav a {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.dd-nav a:hover { color: var(--accent); }

/* ─── Mini table of contents (sticky on wide) ──────────────────── */
.dd-toc {
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.9;
}
.dd-toc a { color: var(--muted); display: block; }
.dd-toc a:hover { color: var(--accent); }
.dd-toc a.active { color: var(--fg); }

/* related-problems block reused name */
.dd-related {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.dd-related a {
  display: block;
  border: 1px solid var(--hairline);
  background: var(--surface);
  padding: 12px 14px;
  transition: border-color 100ms ease;
}
.dd-related a:hover { border-color: var(--fg); }
.dd-related .r-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}
.dd-related .r-title {
  display: block;
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: -0.01em;
  margin-top: 4px;
}

/* link into deep-dive from a problem page */
.deepdive-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 8px 0 0;
  padding: 16px 18px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  flex-wrap: wrap;
}
.deepdive-banner .db-text { max-width: 52ch; }
.deepdive-banner .db-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.deepdive-banner .db-title {
  font-family: var(--font-display);
  font-size: 18px;
  margin-top: 3px;
}
.deepdive-banner .db-desc { font-size: 13.5px; color: var(--muted); margin-top: 3px; }

@media (max-width: 720px) {
  .codeblock pre { font-size: 11.5px; }
  .codeblock .ln::before { width: 28px; padding-right: 8px; margin-right: 8px; }
}
