/* Thoughts — shared foundation.
   Every essay layers its own style.css over this file by overriding the
   custom properties below and adding art direction scoped to html.theme-<name>. */

:root {
  --bg: #ffffff;
  --fg: #1d1a16;
  --muted: #6d655a;
  --accent: #b4441c;
  --rule: #e7e2d9;
  --surface: #f7f5f1;
  --selection: #f4c9a8;

  --font-body: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --font-display: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --font-ui: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --measure: 40rem;
  --wide: 62rem;
  --gutter: 1rem;
  --text: clamp(1.13rem, 1.02rem + 0.35vw, 1.3rem);
  --leading: 1.62;

  color-scheme: light;
}

/* Pages stay white in every colour scheme so images look the way they were made. */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 4.5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--text);
  line-height: var(--leading);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--selection); }

a { color: inherit; text-decoration-color: color-mix(in srgb, var(--accent) 70%, transparent); text-decoration-thickness: 0.07em; text-underline-offset: 0.18em; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

img, svg, video { max-width: 100%; height: auto; display: block; }

/* Visually hidden, still read by screen readers */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 50;
  background: var(--fg); color: var(--bg); padding: 0.5rem 0.9rem;
  font: 600 0.85rem var(--font-ui); text-decoration: none; border-radius: 4px;
}
.skip:focus { top: 1rem; }

/* ---------------------------------------------------------------- chrome */

.site-bar {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  padding: 1.1rem max(var(--gutter), calc((100% - var(--wide)) / 2));
  font: 500 0.88rem/1.2 var(--font-ui);
  letter-spacing: 0.01em;
  position: relative; z-index: 5;
}
.site-bar a { text-decoration: none; }
.wordmark { font-weight: 650; }
.wordmark span { font-weight: 450; color: var(--muted); }
.all { color: var(--muted); }
.all::before { content: '← '; }
.home .all::before { content: none; }
.home .all::after { content: ' ↗'; }
@media (max-width: 30rem) { .wordmark span { display: none; } }

.progress {
  position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 40; pointer-events: none;
}
.progress span {
  display: block; height: 100%; background: var(--accent);
  transform-origin: 0 50%; transform: scaleX(var(--read, 0));
}

/* ---------------------------------------------------------------- hero */

.hero {
  max-width: var(--wide);
  margin: clamp(2.5rem, 7vw, 6rem) auto clamp(2rem, 5vw, 3.5rem);
  padding: 0 var(--gutter);
}
.hero-meta {
  margin: 0 0 1.25rem;
  font: 500 0.82rem/1.4 var(--font-ui);
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.hero-title {
  margin: 0;
  max-width: 18em;
  font-family: var(--font-display);
  font-weight: 560;
  font-size: clamp(2.3rem, 1.4rem + 4vw, 4.6rem);
  line-height: 1.04;
  letter-spacing: -0.022em;
  text-wrap: balance;
}
.hero-dek {
  margin: 1.5rem 0 0; max-width: 34em;
  font-size: 1.25em; line-height: 1.45; color: var(--muted); font-style: italic;
  text-wrap: pretty;
}
.hero-dek:empty { display: none; }

/* ---------------------------------------------------------------- prose
   A named-line grid so any child can opt into content, wide or full width. */

.prose {
  display: grid;
  grid-template-columns:
    [full-start] minmax(var(--gutter), 1fr)
    [wide-start] minmax(0, calc((var(--wide) - var(--measure)) / 2))
    [content-start] min(var(--measure), 100% - 2 * var(--gutter)) [content-end]
    minmax(0, calc((var(--wide) - var(--measure)) / 2)) [wide-end]
    minmax(var(--gutter), 1fr) [full-end];
}
.prose > * { grid-column: content; margin: 0 0 1.15em; }
.prose > figure,
.prose > .wide,
.prose > .table-scroll,
.prose > figure.table { grid-column: wide; }
.prose > .full { grid-column: full; }

.prose p { text-wrap: pretty; hyphens: auto; }
.prose > p:first-child { font-size: 1.2em; line-height: 1.5; }
.prose strong { font-weight: 650; }

.prose h2, .prose h3, .prose h4 {
  font-family: var(--font-display);
  line-height: 1.15; letter-spacing: -0.012em; text-wrap: balance;
}
.prose h2 { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.25rem); font-weight: 600; margin: 2.4em 0 0.7em; }
.prose h3 { font-size: 1.35em; font-weight: 600; margin: 2em 0 0.6em; }
.prose h4 { font-size: 1.1em; font-weight: 650; margin: 1.8em 0 0.5em; }

.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: 0.4em 0; padding-left: 0.2em; }
.prose li::marker { color: var(--accent); font-family: var(--font-ui); font-weight: 600; }

.prose blockquote {
  margin-inline: 0;
  padding: 0.2em 0 0.2em 1.3em;
  border-left: 3px solid var(--accent);
}
.prose blockquote p { margin: 0 0 0.7em; }
.prose blockquote p:last-child { margin-bottom: 0; }

.prose hr { border: 0; height: 1.5em; margin: 2.5em 0; text-align: center; }
.prose hr::before { content: '⁂'; color: var(--muted); letter-spacing: 0.5em; }

.prose code { font-family: var(--font-mono); font-size: 0.86em; }

.prose aside.note {
  font: 0.92rem/1.55 var(--font-ui);
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.9rem 1.1rem;
  margin-block: 1.5em;
}

.prose figure { margin: 2.2em 0; }
.prose figure img {
  margin: 0 auto; border-radius: 4px;
  cursor: zoom-in;
}
/* Portrait images (phone screenshots) are capped by height so they never fill several screens. */
.prose figure img.tall { max-width: min(100%, calc(80vh * var(--ratio))); }
.prose figcaption {
  max-width: var(--measure); margin: 0.85em auto 0;
  font: 0.84rem/1.5 var(--font-ui); color: var(--muted); text-align: center; text-wrap: balance;
}
.prose figcaption a { color: inherit; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-block: 2em; }
.prose figure.table { margin-block: 2em; }
.prose figure.table .table-scroll { margin: 0; }
.prose table {
  width: 100%; border-collapse: collapse;
  font: 0.92rem/1.45 var(--font-ui); font-variant-numeric: tabular-nums;
}
.prose th, .prose td { text-align: left; vertical-align: top; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--rule); }
.prose thead th, .prose tr:first-child td strong { font-weight: 650; }
.prose thead th { border-bottom: 2px solid var(--fg); }

/* <rant> asides, as the author marks them in several essays */
.prose aside.rant {
  position: relative; margin-block: 2em;
  padding: 1.7rem 1.4rem 1.4rem; background: var(--surface);
  font: 0.98rem/1.6 var(--font-ui);
}
.prose aside.rant p { margin: 0 0 0.8em; }
.prose aside.rant p:last-child { margin: 0; }
.prose aside.rant::before,
.prose aside.rant::after { position: absolute; font: 600 0.75rem var(--font-mono); color: var(--accent); }
.prose aside.rant::before { content: '<rant>'; top: 0.55rem; left: 1.4rem; }
.prose aside.rant::after { content: '</rant>'; bottom: 0.35rem; right: 1rem; }

/* ---------------------------------------------------------------- table of contents */

.toc { display: none; }
/* Sits in the margin outside the wide column, so it only appears when there is room. */
@media (min-width: 92rem) {
  .toc {
    display: block; position: fixed; z-index: 4;
    top: 6rem; left: calc(50% - var(--wide) / 2 - 14.5rem);
    width: 12rem; max-height: calc(100vh - 8rem); overflow: auto;
    font: 0.8rem/1.4 var(--font-ui);
    opacity: 0; transition: opacity 0.3s;
  }
  .toc.is-visible { opacity: 1; }
  .toc p { margin: 0 0 0.8rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
  .toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
  .toc a { display: block; padding: 0.35rem 0 0.35rem 0.9rem; margin-left: -1px; border-left: 2px solid transparent; color: var(--muted); text-decoration: none; }
  .toc a.is-current { color: var(--fg); border-left-color: var(--accent); }
}

/* ---------------------------------------------------------------- lightbox */

.lightbox {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 2vmin;
  background: color-mix(in srgb, #0b0a08 92%, transparent);
  cursor: zoom-out; opacity: 0; transition: opacity 0.2s;
}
.lightbox.is-open { opacity: 1; }
.lightbox img { max-width: 100%; max-height: 100%; width: auto; height: auto; border-radius: 3px; }
.lightbox button {
  position: absolute; top: 1rem; right: 1rem;
  font: 600 0.85rem var(--font-ui); color: #fff; background: rgb(255 255 255 / 0.12);
  border: 0; border-radius: 99px; padding: 0.5rem 0.9rem; cursor: pointer;
}

/* ---------------------------------------------------------------- end matter */

.sign-off {
  max-width: var(--measure);
  margin: 4rem auto 0;
  padding: 2rem var(--gutter) 0;
  border-top: 1px solid var(--rule);
  font: 0.95rem/1.55 var(--font-ui);
  color: var(--muted);
  box-sizing: content-box;
}
.sign-off p { margin: 0 0 0.6rem; }
.sign-off-name { color: var(--fg); font-weight: 600; }
.sign-off-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 1.2rem !important; }
.tag {
  font-size: 0.78rem; text-decoration: none; padding: 0.2rem 0.6rem;
  border: 1px solid var(--rule); border-radius: 99px; color: var(--muted);
}
.tag:hover { border-color: var(--accent); }

/* Titles of other essays are set the way those essays set them (vars from build.py card_style). */
.in-face {
  font-family: var(--card-font, var(--font-display));
  font-weight: var(--card-weight, 560);
  font-style: var(--card-style, normal);
  font-stretch: var(--card-stretch, 100%);
  text-transform: var(--card-case, none);
  letter-spacing: var(--card-tracking, -0.01em);
}

.pager {
  display: grid; grid-template-columns: 1fr 1fr;
  max-width: var(--wide); margin: 4rem auto 0; padding: 0 var(--gutter);
}
.pager-link {
  display: flex; flex-direction: column; gap: 0.7rem;
  padding: 1.6rem 1.5rem 1.8rem 0; text-decoration: none; color: var(--card-fg, var(--fg));
  border-top: 1px solid var(--fg);
}
.pager-link + .pager-link, .pager > span + .pager-link { padding: 1.6rem 0 1.8rem 1.5rem; text-align: right; border-left: 1px solid var(--rule); }
.pager-link:hover { color: var(--card-fg, var(--fg)); }
.pager-label { font: 500 0.75rem var(--font-mono); color: var(--muted); }
.pager-link:hover .pager-label { color: var(--card-accent, var(--accent)); }
.pager-title { font-size: calc(1.45rem * var(--card-scale, 1)); line-height: 1.1; text-wrap: balance; transition: translate 0.3s ease; }
.pager-link:first-child:hover .pager-title { translate: -0.25rem 0; }
.pager-link:last-child:hover .pager-title { translate: 0.25rem 0; }
@media (max-width: 40rem) {
  .pager { grid-template-columns: 1fr; }
  .pager-link + .pager-link, .pager > span + .pager-link { padding-left: 0; text-align: left; border-left: 0; }
}

.site-foot {
  max-width: var(--wide); margin: 5rem auto 0; padding: 0 var(--gutter) 3rem;
  font-family: var(--font-ui);
}
.more h2 { font: 650 0.78rem var(--font-ui); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 1rem; }
.more ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1px; background: var(--rule); border-block: 1px solid var(--rule); }
.more li { background: var(--bg); }
.more a { display: flex; flex-direction: column; gap: 0.35rem; padding: 1.1rem 1rem 1.2rem 0; text-decoration: none; height: 100%; }
.more li + li a { padding-left: 1rem; }
.more-date { font-size: 0.75rem; color: var(--muted); }
.more-title { font-size: calc(1.08rem * var(--card-scale, 1)); line-height: 1.25; }
@media (max-width: 40rem) { .more li + li a { padding-left: 0; } }
.colophon { margin: 2.5rem 0 0; font-size: 0.8rem; color: var(--muted); }
.colophon a { color: inherit; }

/* ---------------------------------------------------------------- 404 */

.lost-main { max-width: var(--measure); margin: 18vh auto 0; padding: 0 var(--gutter); }
.lost-code { font: 600 1rem var(--font-mono); color: var(--accent); margin: 0; }
.lost-main h1 { font: 560 clamp(2.2rem, 6vw, 3.6rem)/1.05 var(--font-display); letter-spacing: -0.02em; margin: 0.8rem 0 1rem; }

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

@media print {
  .site-bar, .progress, .pager, .site-foot, .toc, .skip { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .prose > figure { break-inside: avoid; }
  .prose a::after { content: ' (' attr(href) ')'; font-size: 0.8em; color: #555; word-break: break-all; }
}
