/* Data128 — minimal, handcrafted. One serif, hairline rules, clear sections. */

:root {
  --ink: #1A1A18;
  --muted: #4A4A45;
  --faint: #6B6B65;
  --rule: #CFCFCA;
  --rule-light: #E4E4DF;
  --accent: #1B3F9E;
  --accent-dark: #122C70;
  --bg: #FCFCFA;
  --tint: #F0F1F4;
  --code-bg: #F3F3EF;
  --surface: #FFFFFF;      /* inputs, cards sitting on --bg */
  --on-accent: #FFFFFF;    /* text on a filled button */
  --button-bg: #1A1A18;
  --button-hover-bg: #000000;
  --mark: #FFF1B8;
  --danger: #8C2F1C;
  --serif: "Source Serif 4", "Source Serif Pro", Charter, "Bitstream Charter", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}

/* ---------- dark mode
 * Automatic via prefers-color-scheme; [data-theme="dark"] is the same palette
 * as an explicit override, so a toggle can be added later without new colours.
 * Only the tokens change — every rule below is written against them.
 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #E9E9E3;
    --muted: #B0B0A8;
    --faint: #8C8C84;
    --rule: #3A3A34;
    --rule-light: #2A2A26;
    --accent: #93B4FF;
    --accent-dark: #BFD2FF;
    --bg: #131312;
    --tint: #1C1C1A;
    --code-bg: #1B1B19;
    --surface: #1A1A18;
    --on-accent: #131312;
    --button-bg: #E9E9E3;
    --button-hover-bg: #FFFFFF;
    --mark: #5C4B10;
    --danger: #F0A08C;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #E9E9E3;
  --muted: #B0B0A8;
  --faint: #8C8C84;
  --rule: #3A3A34;
  --rule-light: #2A2A26;
  --accent: #93B4FF;
  --accent-dark: #BFD2FF;
  --bg: #131312;
  --tint: #1C1C1A;
  --code-bg: #1B1B19;
  --surface: #1A1A18;
  --on-accent: #131312;
  --button-bg: #E9E9E3;
  --button-hover-bg: #FFFFFF;
  --mark: #5C4B10;
  --danger: #F0A08C;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 24px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.6;
  font-variant-numeric: oldstyle-nums;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; height: auto; }
.accent { color: var(--accent); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 16px; background: var(--ink); color: var(--bg); padding: 8px 12px; z-index: 10; }

.wrap { max-width: 960px; margin: 0 auto; padding: 0 32px; }
.wrap.wide { max-width: 1040px; }

/* small caps label — the one secondary text style */
.label {
  margin: 0;
  font-size: 15px;
  font-weight: 400;
  color: var(--faint);
  font-variant-caps: all-small-caps;
  letter-spacing: 0.06em;
}
.label a { color: inherit; }
.more { font-size: 19px; }

/* ---------- header / footer */

.site-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 16px; padding: 28px 0 18px; border-bottom: 1px solid var(--rule);
}
.wordmark { font-size: 30px; color: var(--ink); letter-spacing: -0.01em; line-height: 1; }
.wordmark:hover { text-decoration: none; color: var(--ink); }
.wordmark.small { font-size: 26px; }
.site-nav { display: flex; flex-wrap: wrap; gap: 8px 28px; font-size: 16px; }
.site-nav a { color: var(--ink); }
.site-nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 6px; }

.site-footer {
  border-top: 1px solid var(--rule); margin-top: 72px; padding: 28px 0 40px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px;
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 8px 24px; font-size: 16px; }
.site-footer nav a { color: var(--ink); }
.colophon { flex-basis: 100%; margin: 4px 0 0; font-size: 14px; color: var(--faint); }

/* ---------- section heading: title + hairline rule */

.block { padding-bottom: 30px; }
.section-heading { display: flex; align-items: center; gap: 20px; margin-bottom: 4px; margin-top: 10px; }
.section-heading h2, .section-heading h3 { margin: 0; font-size: 27px; font-weight: 500; line-height: 1.2; }
.section-heading .rule { flex: 1; height: 1px; background: var(--rule); }

/* ---------- lists of writing */

.entry {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline;
  gap: 4px 24px; padding: 18px 0; color: var(--ink);
}
.entry:hover { text-decoration: none; color: var(--ink); }
.entry:hover .entry-title { color: var(--accent-dark); text-decoration: underline; text-underline-offset: 3px; }
.entry-main { flex: 1 1 480px; min-width: 0; }
.entry-title { display: block; font-size: 22px; font-weight: 500; line-height: 1.3; margin-bottom: 4px; color: var(--accent); }
.entry-desc { display: block; font-size: 17px; color: var(--muted); line-height: 1.5; }

/* index rows: title, description, then a metadata line */
.entry.index-entry { display: block; padding: 11px 0 15px; }
.index-entry .entry-title { font-size: 20px; font-weight: 500; line-height: 1.3; margin-bottom: 3px; }
.index-entry .entry-desc { font-size: 16px; line-height: 1.45; margin-bottom: 4px; }
.index-entry .entry-meta { display: block; white-space: normal; }
.index-entry .entry-meta time { font-variant-caps: inherit; }

/* one-line variant: title + meta on a single row, for dense index lists */
.entry.compact { padding: 7px 0; gap: 2px 16px; }
.entry.compact .entry-title { font-size: 19px; font-weight: 500; line-height: 1.35; margin-bottom: 0; }
.entry.compact .label { white-space: nowrap; }

.series { margin: 0; padding: 0; list-style: none; }
.series li { display: flex; gap: 24px; padding: 12px 0; }
.series .num { width: 28px; flex: none; font-size: 18px; color: var(--faint); padding-top: 2px; }
.series a { flex: 1; color: var(--ink); }
.series a:hover { text-decoration: none; }
.series a:hover .entry-title { color: var(--accent-dark); text-decoration: underline; text-underline-offset: 3px; }
.series .entry-title { font-size: 20px; }

ul.plain { margin: 0; padding: 0; list-style: none; }

/* ---------- home */

/* compact hero: the wordmark already sits in the header, so this is a short
   statement of intent rather than a full title screen */
.hero { padding: 26px 0 24px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 20px; }
.hero-tagline { margin: 0; flex: 1 1 420px; font-size: clamp(23px, 2.6vw, 29px); font-weight: 500; line-height: 1.25; letter-spacing: -0.01em; text-wrap: balance; }
.hero-intro { margin: 0; flex: 1 1 320px; max-width: 560px; font-size: 16px; line-height: 1.5; color: var(--muted); }
.hero .more { flex-basis: 100%; margin-top: 2px; font-size: 16px; }

/* ---------- full index: section -> group -> items */

.index-group { margin-top: 18px; }
.index-group:first-of-type { margin-top: 6px; }
.index-group > .label { margin-bottom: 2px; padding-bottom: 4px; border-bottom: 1px solid var(--rule-light); }
.index-tools .entry-title { font-size: 19px; }
.tagcloud { display: flex; flex-wrap: wrap; gap: 6px 14px; padding-top: 10px; }
.tagcloud a { font-size: 16px; color: var(--accent); }
.tagcloud a:hover { color: var(--accent-dark); text-decoration: underline; text-underline-offset: 3px; }
.tagcloud .n { color: var(--faint); font-size: 14px; }
.series.compact li { padding: 7px 0; gap: 16px; }
.series.compact .entry-title { font-size: 19px; font-weight: 400; }
.series.compact .num { width: 20px; font-size: 16px; padding-top: 1px; }

.explore { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 32px; padding-top: 16px; }
.explore h3 { margin-bottom: 8px; }
.explore li { font-size: 18px; line-height: 1.8; }
.explore li a { color: var(--accent); }

.about { display: flex; flex-wrap: wrap; gap: 48px; padding: 56px 0 72px; border-top: 1px solid var(--rule); }
.about-text { flex: 3 1 400px; min-width: 0; }
.about-text h2 { margin: 0 0 16px; font-size: 34px; font-weight: 500; }
.highlights { flex: 2 1 280px; min-width: 0; margin: 0; padding: 0 0 0 40px; list-style: none;
  border-left: 1px solid var(--rule); display: flex; flex-direction: column; gap: 28px; }
.highlights li { display: flex; gap: 18px; align-items: flex-start; }
.highlights .icon { flex: none; color: var(--accent); }
.highlights strong { display: block; font-weight: 400; font-size: 19px; }
.highlights span span { font-size: 16px; color: var(--muted); }

.band {
  background: var(--tint); border-radius: 6px; padding: 32px 36px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 24px;
}
.band h2 { margin: 0 0 6px; font-size: 28px; font-weight: 500; }
.band p { margin: 0; font-size: 17px; color: var(--muted); }
.signup { flex: 1 1 340px; display: flex; gap: 10px; }
.signup input { flex: 1; min-width: 0; padding: 12px 14px; border: 1px solid var(--rule); border-radius: 4px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; }
.button, .signup button {
  display: inline-block; padding: 12px 20px; border: 0; border-radius: 4px;
  background: var(--button-bg); color: var(--on-accent); font: inherit; font-size: 16px; cursor: pointer;
}
.button:hover { color: var(--on-accent); text-decoration: none; background: var(--button-hover-bg); }

/* ---------- page heads */

.page-head { padding: 80px 0 48px; }
.page-head h1, .article-head h1, .book-head h1 {
  margin: 0 0 16px; font-size: clamp(40px, 5.4vw, 64px); font-weight: 500; line-height: 1.06;
  letter-spacing: -0.02em; text-wrap: balance;
}
.lede { margin: 0 0 24px; max-width: 620px; font-size: 20px; line-height: 1.55; color: var(--muted); }
.jump { display: flex; flex-wrap: wrap; gap: 8px 24px; font-size: 17px; }
.jump a { color: var(--accent); }
.jump a:hover { color: var(--accent-dark); text-decoration: underline; text-underline-offset: 3px; }
.kicker { margin-bottom: 18px; font-size: 16px; }

/* ---------- article */

.article-head { padding: 72px 0 40px; max-width: 760px; }
.article-head h1 { font-size: clamp(38px, 5vw, 56px); line-height: 1.08; }
.dek { margin: 0 0 24px; font-size: 22px; line-height: 1.5; color: var(--muted); font-style: italic; }
.meta { margin: 0; font-size: 16px; color: var(--faint); }

.article-layout { display: flex; flex-wrap: wrap; gap: 56px; padding-top: 48px; border-top: 1px solid var(--rule); }
.article-layout > .prose { flex: 999 1 560px; min-width: 0; max-width: 680px; }
.margin { flex: 1 1 200px; max-width: 260px; display: flex; flex-direction: column; gap: 32px;
  font-size: 16px; line-height: 1.55; color: var(--muted); }
.margin > div + div { border-top: 1px solid var(--rule-light); padding-top: 16px; }
.margin .label { margin-bottom: 8px; color: var(--ink); font-weight: 600; letter-spacing: 0.08em; }
.margin p { margin: 0 0 8px; }
.margin li { margin-bottom: 6px; }
.toc { margin: 0; padding-left: 20px; }
.toc li::marker { color: var(--faint); }
.toc a { color: var(--accent); }
.toc a:hover { color: var(--accent-dark); text-decoration: underline; text-underline-offset: 3px; }
@media (min-width: 1000px) {
  .margin { position: sticky; top: 24px; align-self: flex-start; max-height: calc(100vh - 48px); overflow-y: auto; }
}

.summary { background: var(--tint); border-radius: 6px; padding: 24px 28px; margin-bottom: 48px; }
.summary .label { margin: 0 0 10px; font-size: 16px; font-weight: 600; letter-spacing: 0.08em; color: var(--accent); }
.prose .summary p, .summary p { margin: 0; font-size: 19px; }

.prev-next { margin-top: 56px; padding-top: 20px; border-top: 1px solid var(--rule);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; font-size: 18px; }

/* ---------- microbook */

.book-head { padding: 72px 0 64px; display: flex; flex-wrap: wrap; gap: 56px; align-items: center; }
.book-head > div:last-child { flex: 1 1 360px; min-width: 0; }
.cover {
  flex: 0 0 240px; aspect-ratio: 2 / 3; background: var(--code-bg); border: 1px solid var(--rule);
  padding: 26px; display: flex; flex-direction: column; justify-content: space-between;
}
.cover-title { font-size: 30px; line-height: 1.1; font-weight: 500; }
.cover-author { font-size: 15px; color: var(--faint); }
.facts { margin: 0 0 28px; display: grid; gap: 6px; font-size: 17px; }
.facts div { display: flex; gap: 16px; }
.facts dt { width: 96px; flex: none; color: var(--faint); font-variant-caps: all-small-caps; letter-spacing: 0.06em; }
.facts dd { margin: 0; }
.book-about .prose { max-width: 720px; padding-top: 16px; font-size: 19px; }
.summary-line { font-size: 21px; }
.chapters li { align-items: baseline; }
.chapters .label { flex: none; }
.book-layout { margin-top: 16px; }
.back { margin-top: 48px; font-size: 16px; }

/* ---------- prose (rendered markdown) */

.prose { font-size: 20px; line-height: 1.7; }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose table, .prose pre, .prose figure { margin: 0 0 24px; }
.prose h2 { margin: 56px 0 14px; font-size: 30px; font-weight: 500; line-height: 1.25; }
.prose h3 { margin: 40px 0 10px; font-size: 23px; font-weight: 600; line-height: 1.3; }
.prose h4 { margin: 32px 0 8px; font-size: 20px; font-weight: 600; }
.prose h5, .prose h6 { margin: 24px 0 8px; font-size: 18px; font-weight: 600; color: var(--muted); }
.prose li { margin-bottom: 6px; }
.prose li > ul, .prose li > ol { margin: 6px 0 0; }
.prose strong { font-weight: 600; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 48px 0; }
.prose mark { background: var(--mark); color: var(--ink); padding: 0 2px; }
.prose img { display: block; margin: 8px auto; border-radius: 3px; }
.prose blockquote { margin-left: 0; padding: 2px 0 2px 22px; border-left: 2px solid var(--rule); color: var(--muted); }
.prose blockquote p:last-child { margin-bottom: 0; }

.prose code { font-family: var(--mono); font-size: 0.8em; background: var(--code-bg); padding: 2px 5px; border-radius: 3px; font-variant-numeric: normal; }
.prose pre, .prose .codehilite pre {
  font-family: var(--mono); font-size: 14px; line-height: 1.65; background: var(--code-bg);
  padding: 18px 22px; border-radius: 4px; overflow-x: auto; font-variant-numeric: normal;
}
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose .codehilite { margin: 0 0 24px; background: none; }
.prose .codehilite pre { margin: 0; }

.prose table { display: block; overflow-x: auto; border-collapse: collapse; font-size: 16px; line-height: 1.45; font-variant-numeric: lining-nums tabular-nums; }
.prose th, .prose td { padding: 9px 16px 9px 0; border-bottom: 1px solid var(--rule-light); text-align: left; vertical-align: top; }
.prose th { font-weight: 600; border-bottom-color: var(--ink); }

.prose .admonition { background: var(--tint); border-radius: 6px; padding: 18px 22px; margin: 0 0 24px; font-size: 18px; }
.prose .admonition-title { margin: 0 0 6px; font-weight: 600; font-variant-caps: all-small-caps; letter-spacing: 0.06em; color: var(--accent); }
.prose .admonition p:last-child { margin-bottom: 0; }
.prose .admonition.warning .admonition-title, .prose .admonition.danger .admonition-title,
.prose .admonition.caution .admonition-title { color: var(--danger); }

.prose .footnote { margin-top: 56px; padding-top: 16px; border-top: 1px solid var(--rule); font-size: 16px; color: var(--muted); }
.prose .footnote hr { display: none; }
.prose sup { line-height: 0; }
.prose .footnote-ref { font-size: 13px; }

/* standalone pages (advisory, about): their sections get the same rule heading */
.page-body { max-width: 760px; }
.page-body h2 { display: flex; align-items: center; gap: 24px; font-size: 32px; margin-top: 64px; }
.page-body h2::after { content: ""; flex: 1; height: 1px; background: var(--rule); }

/* ---------- small screens */

@media (max-width: 640px) {
  body { font-size: 18px; }
  .wrap { padding: 0 20px; }
  .hero { padding: 64px 0 56px; }
  .prose { font-size: 18px; }
  .highlights { padding-left: 0; border-left: 0; }
  .section-heading h2 { font-size: 26px; }
  .cover { flex-basis: 180px; }
  .article-layout { gap: 40px; }
  .margin { max-width: none; }
}

/* microbook chapters: a small "Chapter N" label above each chapter title */
.book { counter-reset: chapter; }
.book > h2 { counter-increment: chapter; padding-top: 32px; border-top: 1px solid var(--rule); }
.book > h2::before {
  content: "Chapter " counter(chapter); display: block; margin-bottom: 8px;
  font-size: 15px; color: var(--faint); font-variant-caps: all-small-caps; letter-spacing: 0.08em;
}
.book > h2:first-child { border-top: 0; padding-top: 0; }

/* ---------- image lightbox
 * The dialog is a native modal, so Escape, focus trapping and page inertness
 * are the browser's job; this only styles it.
 */
.zoomable { cursor: zoom-in; }
.zoomable:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.lightbox {
  width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh;
  margin: 0; padding: 0; border: 0; background: transparent; overflow: hidden;
  color: #F2F2EE;
}
.lightbox::backdrop { background: rgba(10, 10, 9, 0.92); }
.lightbox[open] { display: flex; align-items: center; justify-content: center; }

.lightbox-figure {
  margin: 0; padding: 24px; max-width: 100%; max-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
}
.lightbox-img {
  max-width: min(96vw, 1600px); max-height: 86dvh;
  width: auto; height: auto; object-fit: contain;
  background: #fff; border-radius: 2px; cursor: zoom-out;
}
.lightbox-caption {
  margin: 0; max-width: 760px; text-align: center;
  font-family: var(--serif); font-size: 15px; line-height: 1.5; color: #C9C9C2;
}

.lightbox-close {
  position: fixed; top: 14px; right: 16px; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; padding: 0;
  border: 1px solid rgba(242, 242, 238, 0.28); border-radius: 50%;
  background: rgba(20, 20, 18, 0.6); color: #F2F2EE; cursor: pointer;
}
.lightbox-close:hover { background: rgba(242, 242, 238, 0.16); border-color: rgba(242, 242, 238, 0.5); }
.lightbox-close:focus-visible { outline: 2px solid #F2F2EE; outline-offset: 2px; }

@media (max-width: 640px) {
  .lightbox-figure { padding: 12px; }
  .lightbox-img { max-width: 96vw; max-height: 80dvh; }
}
