/* ==========================================================================
   Site stylesheet
   Editorial / journal aesthetic: warm off-white ground, high-contrast serif
   display type, letter-spaced small labels, hairline rules, ink-black accents.
   Everything is driven by the tokens in :root — change those to re-theme.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --bg: #f7f6f2;
  --bg-2: #efede7;          /* cards, code, subtle panels */
  --ink: #161615;
  --ink-2: #4a4a46;         /* body text on long reads */
  --muted: #7a7a74;         /* labels, captions, metadata */
  --rule: #d8d6ce;          /* hairlines */
  --rule-strong: #b9b7ae;
  --accent: var(--ink);     /* buttons, active states */
  --accent-fg: var(--bg);

  --font-display: "Playfair Display", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-body: "EB Garamond", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --max: 1240px;
  --gutter: clamp(16px, 4vw, 48px);
  --space: clamp(48px, 7vw, 96px);   /* vertical rhythm between sections */

  --radius: 2px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131312;
    --bg-2: #1c1c1a;
    --ink: #ecebe6;
    --ink-2: #c9c8c1;
    --muted: #8f8f88;
    --rule: #2c2c29;
    --rule-strong: #45453f;
  }
}
:root[data-theme="dark"] {
  --bg: #131312;
  --bg-2: #1c1c1a;
  --ink: #ecebe6;
  --ink-2: #c9c8c1;
  --muted: #8f8f88;
  --rule: #2c2c29;
  --rule-strong: #45453f;
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.55;
  font-feature-settings: "kern", "liga", "onum";
  -webkit-font-smoothing: antialiased;
}
img, svg, video, canvas { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: .18em; text-decoration-thickness: 1px; }
hr { border: 0; border-top: 1px solid var(--rule); margin: var(--space) 0; }
button { font: inherit; color: inherit; }
::selection { background: var(--ink); color: var(--bg); }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.skip-link {
  position: absolute; left: -999px; top: 8px; padding: .5rem 1rem;
  background: var(--ink); color: var(--bg); z-index: 100;
}
.skip-link:focus { left: 8px; }

/* ---------- Type ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0 0 .5em;
}
h1 { font-size: clamp(2.6rem, 6.5vw, 5rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.8rem, 3.2vw, 2.4rem); }
h3 { font-size: clamp(1.25rem, 2vw, 1.5rem); }
h4 { font-size: 1.1rem; }
p { margin: 0 0 1em; }

.lede {
  font-size: clamp(1.25rem, 2vw, 1.55rem);
  line-height: 1.4;
  color: var(--ink-2);
  max-width: 34ch;
}

/* Small letter-spaced label — the signature of the design */
.eyebrow {
  font-family: var(--font-body);
  font-size: .72rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
  display: inline-block;
  margin: 0 0 1rem;
}
.eyebrow--ink { color: var(--ink); }
.numeral { font-variant-numeric: lining-nums; font-style: normal; }

.muted { color: var(--muted); }
.small { font-size: .95rem; }
.serif-italic { font-style: italic; }

/* ---------- Layout ---------- */
.wrap {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.section { padding-block: var(--space); border-top: 1px solid var(--rule); }
.section--flush { border-top: 0; }

.section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1.5rem;
  margin-bottom: 2.25rem;
}
.section-head .eyebrow { margin: 0; }
.section-head .eyebrow .numeral { color: var(--ink); margin-right: 1.5rem; }
.section-title { margin-top: .75rem; }

.grid { display: grid; gap: 2rem; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid--split { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(2rem, 6vw, 6rem); }
.grid--split-even { grid-template-columns: 1fr 1fr; gap: clamp(2rem, 6vw, 6rem); }

@media (max-width: 1024px) {
  .grid--5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .grid--2, .grid--3, .grid--4, .grid--5, .grid--split, .grid--split-even { grid-template-columns: 1fr; }
  .section-head { flex-direction: column; align-items: flex-start; gap: .75rem; }
}

/* ---------- Header / nav ---------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 2rem;
  padding-block: 1.4rem;
}
.brand { display: flex; align-items: center; gap: 1rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand__mark {
  font-family: var(--font-display); font-size: 1.6rem; line-height: 1;
  display: inline-flex; align-items: center; gap: .35rem;
}
.brand__mark small { font-size: .9rem; color: var(--muted); }
.brand__name { font-size: .72rem; letter-spacing: .2em; text-transform: uppercase; }

.nav { display: flex; align-items: center; gap: 2.2rem; }
.nav a { font-size: 1rem; }
.nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: .3em; text-decoration-thickness: 1px; }
.nav--secondary { gap: 1.6rem; }
.nav--secondary a { font-size: .95rem; color: var(--ink-2); }

.nav-toggle {
  display: none; background: none; border: 1px solid var(--rule-strong);
  padding: .4rem .7rem; font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; cursor: pointer;
}
@media (max-width: 860px) {
  .site-header { flex-wrap: wrap; }
  .nav-toggle { display: inline-block; }
  .site-header__navs {
    display: none; width: 100%; flex-direction: column; align-items: flex-start; gap: .5rem;
    padding-top: 1rem; border-top: 1px solid var(--rule);
  }
  .site-header__navs.is-open { display: flex; }
  .nav, .nav--secondary { flex-direction: column; align-items: flex-start; gap: .6rem; }
}
@media (min-width: 861px) {
  .site-header__navs { display: contents; }
}

/* ---------- Hero ---------- */
.hero { padding-block: clamp(2rem, 5vw, 4.5rem) var(--space); }
.hero__grid {
  display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 6fr); gap: clamp(2rem, 5vw, 5rem); align-items: center;
}
.hero__art { position: relative; }
.hero__art img { width: 100%; }
.hero__aside {
  position: absolute; right: 0; top: 0; text-align: right;
  font-size: .68rem; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); line-height: 1.9;
}
.hero__aside::after { content: ""; display: block; width: 40px; height: 1px; background: var(--rule-strong); margin: .8rem 0 0 auto; }
.hero__quote {
  position: absolute; right: 0; bottom: 0; text-align: right; max-width: 22ch;
  font-style: italic; font-size: 1.05rem; line-height: 1.4; color: var(--ink-2);
}
.hero__quote cite {
  display: block; font-style: normal; font-size: .66rem; letter-spacing: .2em; text-transform: uppercase;
  color: var(--muted); margin-top: .5rem;
}
.hero__actions { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 2.25rem; }
@media (max-width: 860px) {
  .hero__grid { grid-template-columns: 1fr; }
  .hero__aside, .hero__quote { position: static; text-align: left; margin-top: 1rem; }
  .hero__aside::after { margin-left: 0; }
}

/* ---------- Buttons & links ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .6rem;
  padding: .85rem 1.6rem; border: 1px solid var(--ink); border-radius: var(--radius);
  font-size: 1rem; line-height: 1; transition: background .2s var(--ease), color .2s var(--ease);
}
.btn:hover { text-decoration: none; background: var(--bg-2); }
.btn--primary { background: var(--accent); color: var(--accent-fg); }
.btn--primary:hover { background: var(--ink-2); color: var(--accent-fg); }
.btn--small { padding: .55rem 1rem; font-size: .9rem; }

.arrow-link {
  font-size: .72rem; letter-spacing: .2em; text-transform: uppercase;
  border-bottom: 1px solid var(--ink); padding-bottom: .15rem; white-space: nowrap;
}
.arrow-link:hover { text-decoration: none; color: var(--muted); border-color: var(--muted); }
.arrow-link::after, .btn--arrow::after { content: "\2192"; margin-left: .5rem; }

/* ---------- Cards (image + text; used by posts / books / toys) ---------- */
.cards { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card {
  display: grid; grid-template-columns: 96px 1fr; border: 1px solid var(--rule);
  background: var(--bg); transition: border-color .2s var(--ease);
}
.card:hover { border-color: var(--rule-strong); text-decoration: none; }
.card__img { background: var(--bg-2); border-right: 1px solid var(--rule); }
.card__img img { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 1 / 1; }
.card__body { padding: 1.1rem 1rem 1.2rem; display: flex; flex-direction: column; }
.card__num { font-size: .68rem; letter-spacing: .2em; color: var(--muted); margin-bottom: .4rem; }
.card__title { font-family: var(--font-display); font-size: 1.25rem; margin: 0 0 .45rem; line-height: 1.15; }
.card__desc { font-size: .95rem; color: var(--ink-2); margin: 0; line-height: 1.4; }
.card__meta { margin-top: auto; padding-top: .8rem; font-size: .68rem; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); }

/* stacked variant: image on top (books, toys) */
.card--stack { grid-template-columns: 1fr; }
.card--stack .card__img { border-right: 0; border-bottom: 1px solid var(--rule); }
.card--stack .card__img img { aspect-ratio: 16 / 10; }
.card--cover .card__img img { aspect-ratio: 5 / 7; object-fit: cover; }

/* ---------- Numbered list (posts / papers index, "essays" block) ---------- */
.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.row {
  display: grid; grid-template-columns: 2.5rem minmax(0, 1fr) auto; align-items: baseline; gap: 1rem;
  padding: .95rem 0; border-bottom: 1px solid var(--rule);
}
.row a.row__link { display: contents; }
.row__num { font-size: .72rem; letter-spacing: .15em; color: var(--muted); }
.row__title { font-family: var(--font-display); font-size: 1.15rem; }
.row__dek { color: var(--ink-2); font-size: .95rem; }
.row__title + .row__dek::before { content: ""; display: inline-block; width: 1.25rem; }
.row__meta { font-size: .72rem; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.row__arrow { color: var(--muted); }
.row:hover .row__arrow { color: var(--ink); }
.row--wrap .row__main { display: flex; flex-wrap: wrap; gap: 0 .5rem; align-items: baseline; }
@media (max-width: 720px) {
  .row { grid-template-columns: 2.5rem 1fr; }
  .row__meta { grid-column: 2; }
  .row__arrow { display: none; }
}

/* ---------- Entries (papers, repos: text-first records) ---------- */
.entries { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.entry {
  display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: 1.5rem;
  padding: 1.6rem 0; border-bottom: 1px solid var(--rule);
}
.entry__side { font-size: .72rem; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); line-height: 1.8; }
.entry__title { font-family: var(--font-display); font-size: 1.35rem; margin: 0 0 .3rem; }
.entry__authors { font-style: italic; color: var(--ink-2); margin-bottom: .4rem; }
.entry__venue { font-size: .95rem; color: var(--muted); margin-bottom: .6rem; }
.entry__desc { color: var(--ink-2); margin: 0 0 .75rem; max-width: 70ch; }
.entry__links { display: flex; flex-wrap: wrap; gap: 1.2rem; }
.entry__links a { font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; border-bottom: 1px solid var(--rule-strong); padding-bottom: .1rem; }
.entry__links a:hover { text-decoration: none; border-color: var(--ink); }
.entry--with-figure { grid-template-columns: 7rem minmax(0, 1fr) 140px; }
.entry__figure img { border: 1px solid var(--rule); }
@media (max-width: 720px) {
  .entry, .entry--with-figure { grid-template-columns: 1fr; gap: .6rem; }
  .entry__figure { max-width: 200px; }
}

/* Repo record — deliberately no image; metadata pills instead */
.repo__name { font-family: var(--font-mono); font-size: 1.05rem; font-weight: 500; }
.repo__name .owner { color: var(--muted); }
.pills { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 .8rem; }
.pill {
  font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2);
  border: 1px solid var(--rule-strong); padding: .25rem .55rem; border-radius: 999px;
}
.pill--dot::before { content: ""; display: inline-block; width: .5em; height: .5em; border-radius: 50%; background: var(--ink); margin-right: .45em; vertical-align: 1px; }

/* ---------- Pull quote / manifesto columns ---------- */
.manifesto { display: grid; grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr); gap: clamp(2rem, 5vw, 5rem); }
.manifesto__rule { background: var(--rule); }
.pull-quote {
  align-self: center; text-align: center; font-family: var(--font-display); font-style: italic;
  font-size: clamp(1.3rem, 2.2vw, 1.7rem); line-height: 1.4; margin: 0; padding-inline: 1rem;
}
.pull-quote::after { content: ""; display: block; width: 32px; height: 1px; background: var(--rule-strong); margin: 1.6rem auto 1.2rem; }
.pull-quote cite { display: block; font-style: normal; font-family: var(--font-body); font-size: .68rem; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
@media (max-width: 720px) {
  .manifesto { grid-template-columns: 1fr; }
  .manifesto__rule { height: 1px; }
}

/* ---------- Article / long-form prose (post, paper, book pages) ---------- */
.article-head { padding-block: clamp(2rem, 5vw, 4rem) 2.5rem; max-width: 60rem; }
.article-head h1 { font-size: clamp(2.2rem, 5vw, 3.8rem); }
.article-meta { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); margin-top: 1.5rem; }
.article-hero { margin-bottom: 3rem; }
.article-hero img { width: 100%; border: 1px solid var(--rule); }
.article-hero figcaption { font-size: .9rem; color: var(--muted); margin-top: .6rem; font-style: italic; }

.prose { max-width: 42rem; font-size: 1.2rem; line-height: 1.6; color: var(--ink); }
.prose > * + * { margin-top: 1.2em; }
.prose h2 { font-size: 1.9rem; margin-top: 2.2em; }
.prose h3 { font-size: 1.4rem; margin-top: 1.8em; }
.prose p:first-of-type::first-letter { /* optional drop cap; remove if unwanted */
  font-family: var(--font-display); font-size: 3.4em; float: left; line-height: .8; padding: .08em .12em 0 0;
}
.prose blockquote { margin: 1.5em 0; padding-left: 1.25em; border-left: 1px solid var(--rule-strong); font-style: italic; color: var(--ink-2); }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: .35em; }
.prose figure { margin: 2em 0; }
.prose figure img { border: 1px solid var(--rule); }
.prose figcaption { font-size: .9rem; color: var(--muted); margin-top: .6rem; font-style: italic; }
.prose a { text-decoration: underline; text-underline-offset: .18em; text-decoration-thickness: 1px; }
.prose code { font-family: var(--font-mono); font-size: .85em; background: var(--bg-2); padding: .1em .35em; border-radius: var(--radius); }
.prose pre { background: var(--bg-2); border: 1px solid var(--rule); padding: 1rem 1.2rem; overflow-x: auto; font-size: .85rem; line-height: 1.5; }
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose .footnotes { font-size: .95rem; color: var(--ink-2); border-top: 1px solid var(--rule); padding-top: 1.5rem; margin-top: 3rem; }
.prose table { width: 100%; border-collapse: collapse; font-size: 1rem; }
.prose th, .prose td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.prose th { font-size: .72rem; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); font-weight: 400; }
.prose .no-dropcap::first-letter { all: unset; }

/* Sidebar layout for record pages (paper, book, repo) */
.record { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: clamp(2rem, 6vw, 6rem); align-items: start; }
.record__aside { position: sticky; top: 2rem; }
.facts { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.facts li { padding: .7rem 0; border-bottom: 1px solid var(--rule); display: flex; justify-content: space-between; gap: 1rem; font-size: .95rem; }
.facts dt, .facts .k { font-size: .68rem; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.facts .v { text-align: right; }
.aside-actions { display: flex; flex-direction: column; gap: .6rem; margin-top: 1.25rem; }
.aside-actions .btn { justify-content: center; }
.cover { border: 1px solid var(--rule); margin-bottom: 1.5rem; }
@media (max-width: 860px) {
  .record { grid-template-columns: 1fr; }
  .record__aside { position: static; }
}

/* Code block (repo install snippet, BibTeX) */
.codeblock {
  background: var(--bg-2); border: 1px solid var(--rule); padding: 1rem 1.2rem; overflow-x: auto;
  font-family: var(--font-mono); font-size: .85rem; line-height: 1.5; margin: 0 0 1.5rem;
}

/* Prev / next */
.pager { display: flex; justify-content: space-between; gap: 2rem; border-top: 1px solid var(--rule); margin-top: var(--space); padding-top: 1.5rem; }
.pager a { max-width: 45%; }
.pager .eyebrow { display: block; margin-bottom: .3rem; }
.pager__title { font-family: var(--font-display); font-size: 1.15rem; }
.pager .next { text-align: right; margin-left: auto; }

/* ---------- Toys ---------- */
.toy-frame { border: 1px solid var(--rule); background: var(--bg-2); padding: clamp(1rem, 3vw, 2rem); }
.toy-toolbar { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; margin-bottom: 1rem; }
.toy-toolbar label { font-size: .72rem; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); display: inline-flex; align-items: center; gap: .5rem; }
.toy-toolbar input[type="range"] { accent-color: var(--ink); }

/* ---------- Contact ---------- */
.contact-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.contact-list li { display: grid; grid-template-columns: 8rem 1fr; gap: 1rem; padding: .85rem 0; border-bottom: 1px solid var(--rule); }
.contact-list .k { font-size: .68rem; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); align-self: center; }
@media (max-width: 480px) { .contact-list li { grid-template-columns: 1fr; gap: .2rem; } }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--rule); margin-top: var(--space); padding-block: 1.5rem 2rem;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 2rem;
  font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
}
.site-footer .nav { gap: 1.6rem; }
.site-footer .nav a { font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; }
.site-footer .brand__mark { color: var(--ink); }

/* ---------- Utilities ---------- */
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0 !important; }
.tr { text-align: right; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media print {
  .site-header, .site-footer, .pager, .nav-toggle, .hero__art { display: none !important; }
  body { background: #fff; color: #000; }
}

/* Email rendered as glyph outlines (contact page) so it cannot be scraped as text */
.mail { display: inline-flex; align-items: center; line-height: 1; }
.mail-img { display: block; height: 1.3em; width: auto; }
.mail-copy { margin-left: .9rem; font: inherit; font-size: .68rem; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); background: none; border: 0; border-bottom: 1px solid var(--rule-strong); padding: 0 0 .1rem; cursor: pointer; }
.mail-copy:hover { color: var(--ink); border-color: var(--ink); }
