/* Off-white and near-black on a strict grid, with one vermilion accent.
   Sans-serif for headlines and interface, serif only for long reading.
   Layout is written mobile first; wider layouts live in the media queries. */

@font-face { font-family: "Schibsted Grotesk"; src: url("/assets/fonts/schibsted-grotesk.woff2") format("woff2"); font-weight: 400 900; font-display: swap; }
@font-face { font-family: "Newsreader"; src: url("/assets/fonts/newsreader.woff2") format("woff2"); font-weight: 200 800; font-style: normal; font-display: swap; }
@font-face { font-family: "Newsreader"; src: url("/assets/fonts/newsreader-italic.woff2") format("woff2"); font-weight: 200 800; font-style: italic; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/assets/fonts/jetbrains-mono.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }

:root {
  color-scheme: light;
  --paper: #faf8f3;
  --tint: #f1eee6;
  --ink: #1a1a18;
  --ink-soft: #5f5e57;
  --rule: #e2dfd6;
  --accent: #c8341b;
  --on-accent: #fff9f5;
  --contour: #d3cfc2;
  --contour-strong: #a8a497;
  --sans: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --width: 72rem;
  --gap: 1.5rem;
  --measure: 40rem;
  --code-foreground: #26251f;
  --code-background: transparent;
  --code-token-constant: #8a5a10;
  --code-token-string: #3f6b3a;
  --code-token-comment: #76746a;
  --code-token-keyword: #c8341b;
  --code-token-parameter: #26251f;
  --code-token-function: #1f5a85;
  --code-token-string-expression: #3f6b3a;
  --code-token-punctuation: #5f5e57;
  --code-token-link: #1f5a85;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #131311;
  --tint: #1d1c19;
  --ink: #edebe4;
  --ink-soft: #a3a196;
  --rule: #2e2d28;
  --accent: #ff7a5c;
  --on-accent: #1a0c07;
  --contour: #3a3933;
  --contour-strong: #5f5d54;
  --code-foreground: #e6e4dc;
  --code-token-constant: #dcb06a;
  --code-token-string: #a9bd83;
  --code-token-comment: #8e8c81;
  --code-token-keyword: #ff7a5c;
  --code-token-parameter: #e6e4dc;
  --code-token-function: #8fbbd6;
  --code-token-string-expression: #a9bd83;
  --code-token-punctuation: #a3a196;
  --code-token-link: #8fbbd6;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 4.5rem; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 1rem/1.5 var(--sans); overflow-wrap: break-word; -webkit-font-smoothing: antialiased; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

a { color: inherit; text-decoration-color: var(--accent); text-decoration-thickness: 1px; 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 { max-width: 100%; }
img { height: auto; }

.label { font: 500 0.75rem/1.4 var(--sans); letter-spacing: 0.02em; color: var(--ink-soft); margin: 0; }
.label a { color: inherit; }

.skip-link { position: absolute; left: -999rem; top: 0.5rem; background: var(--ink); color: var(--paper); padding: 0.5rem 0.9rem; z-index: 20; }
.skip-link:focus { left: 0.5rem; }

/* Header */
.masthead { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule); }
.masthead-inner { display: flex; align-items: center; gap: 0.75rem clamp(0.75rem, 3vw, 1.75rem); max-width: var(--width); margin: 0 auto; padding: 0.6rem var(--gutter); }
.masthead-name { font: 700 1.0625rem/1.2 var(--sans); letter-spacing: -0.01em; text-decoration: none; margin-right: auto; white-space: nowrap; }
.masthead ul { display: flex; gap: clamp(0.75rem, 3vw, 1.5rem); list-style: none; margin: 0; padding: 0; }
.masthead nav a { font-size: 0.875rem; font-weight: 500; text-decoration: none; display: inline-block; padding: 0.4rem 0; border-bottom: 2px solid transparent; }
.masthead nav a[aria-current] { border-bottom-color: var(--accent); }
.theme-toggle { display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; padding: 0; background: var(--tint); color: var(--ink); border: 1px solid var(--rule); border-radius: 50%; cursor: pointer; transition: border-color 0.15s; flex: none; }
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle[hidden] { display: none; }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

main { max-width: var(--width); margin: 0 auto; padding: 0 var(--gutter); }

/* Buttons */
.button { display: inline-flex; align-items: center; min-height: 2.5rem; padding: 0.35rem 1.05rem; border: 1px solid var(--ink); border-radius: 2px; font-size: 0.875rem; font-weight: 600; text-decoration: none; transition: background 0.15s, color 0.15s, border-color 0.15s; }
.button:hover { background: var(--ink); color: var(--paper); }
.button-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.button-primary:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* Homepage hero */
.hero { display: grid; gap: var(--gap); padding: clamp(1.75rem, 4vw, 3rem) 0 clamp(1.5rem, 3vw, 2.5rem); }
.hero-title { font: 600 clamp(2rem, 4.4vw, 3.25rem)/1.08 var(--sans); letter-spacing: -0.025em; margin: 0.6rem 0 0.7rem; text-wrap: balance; }
.hero-intro { font-size: 1.0625rem; color: var(--ink-soft); margin: 0 0 1.15rem; max-width: 30em; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.feature { display: flex; flex-direction: column; background: var(--accent); color: var(--on-accent); text-decoration: none; overflow: hidden; border-radius: 2px; min-height: 17rem; transition: transform 0.2s; }
.feature:hover { color: var(--on-accent); }
.feature:hover .feature-title { text-decoration: underline; text-decoration-thickness: 2px; text-decoration-color: currentColor; }
.feature-plate { flex: 1; min-height: 8rem; position: relative; }
.feature-plate .plate { position: absolute; inset: 0; width: 100%; height: 100%; }
.feature .plate .contours { stroke: currentColor; stroke-opacity: 0.32; }
.feature .plate .contours .index { stroke: currentColor; stroke-opacity: 0.6; }
.feature .plate .summit { fill: currentColor; }
.feature-body { padding: 0 1.25rem 1.15rem; position: relative; }
.feature .label { color: inherit; opacity: 0.9; }
.feature-title { font: 600 clamp(1.25rem, 2.2vw, 1.6rem)/1.18 var(--sans); letter-spacing: -0.015em; margin: 0.3rem 0 0; text-wrap: balance; }

/* Contour plates */
.plate { display: block; width: 100%; height: 100%; }
.plate .contours { fill: none; stroke: var(--contour); stroke-width: 1px; stroke-linejoin: round; }
.plate .contours path { vector-effect: non-scaling-stroke; }
.plate .contours .index { stroke: var(--contour-strong); }
.plate .summit { fill: var(--accent); }

/* Sections */
.section { padding: clamp(1.5rem, 3vw, 2.5rem) 0 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; border-top: 2px solid var(--ink); padding: 0.55rem 0 1rem; }
.section-title { font: 600 1.25rem/1.2 var(--sans); letter-spacing: -0.01em; margin: 0; }
.section-link { font-size: 0.875rem; font-weight: 600; color: var(--accent); text-decoration: none; white-space: nowrap; }
.section-link:hover { text-decoration: underline; }

/* Article tiles */
.tiles { display: grid; gap: 1.75rem var(--gap); }
.tile-plate { display: block; aspect-ratio: 16 / 5; background: var(--tint); border-radius: 2px; overflow: hidden; margin-bottom: 0.7rem; }
.tile:hover .plate .contours { stroke: var(--contour-strong); }
.tile-title { font: 600 1.125rem/1.25 var(--sans); letter-spacing: -0.01em; margin: 0.25rem 0 0.35rem; text-wrap: pretty; }
.tile-title a { text-decoration: none; }
.tile-title a:hover { text-decoration: underline; }
.tile-excerpt { margin: 0; font-size: 0.9375rem; line-height: 1.45; color: var(--ink-soft); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }

/* Series band */
.series-band { margin-top: clamp(2rem, 4vw, 3rem); padding: 1.25rem clamp(1rem, 2.5vw, 1.75rem) 1.35rem; background: var(--tint); border-radius: 2px; }
.series-head { margin-bottom: 0.9rem; }
.series-head .section-title { margin-top: 0.15rem; }
.series-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.series-grid a { display: flex; gap: 0.7rem; align-items: baseline; padding: 0.55rem 0; border-top: 1px solid var(--rule); text-decoration: none; font-size: 0.9375rem; font-weight: 500; line-height: 1.3; height: 100%; }
.series-grid a:hover .series-part { text-decoration: underline; }
.series-num { font: 500 0.75rem var(--mono); color: var(--accent); }

/* Article list */
.ledger-year { display: grid; gap: 0.1rem; padding: 0.45rem 0 0.7rem; border-top: 1px solid var(--rule); }
.section-head + .ledger-year { border-top: 0; padding-top: 0; }
.ledger-year-label { font: 600 0.875rem/1.5 var(--sans); color: var(--accent); margin: 0; }
.ledger-list { list-style: none; margin: 0; padding: 0; }
.ledger-list li { display: flex; justify-content: space-between; align-items: baseline; gap: 1.25rem; padding: 0.28rem 0; }
.ledger-list a { font-weight: 500; line-height: 1.3; text-decoration: none; }
.ledger-list a:hover { text-decoration: underline; }
.ledger-meta { font-size: 0.8125rem; color: var(--ink-soft); white-space: nowrap; }

/* Topics */
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; margin: 0; padding: 0; }
.chips a { display: inline-block; padding: 0.3rem 0.7rem; border: 1px solid var(--rule); border-radius: 999px; font-size: 0.875rem; font-weight: 500; text-decoration: none; transition: border-color 0.15s, color 0.15s; }
.chips a:hover { border-color: var(--accent); color: var(--accent); }
.chips span { color: var(--ink-soft); font-weight: 400; margin-left: 0.15rem; }

/* Author */
.author-strip { display: flex; gap: 1.1rem; align-items: flex-start; margin: clamp(2rem, 4vw, 3rem) 0 clamp(1.5rem, 3vw, 2.5rem); padding-top: 1.25rem; border-top: 2px solid var(--ink); }
.author-strip img { width: 4.5rem; height: 4.5rem; border-radius: 50%; object-fit: cover; flex: none; }
.author-name { font: 600 1.125rem/1.2 var(--sans); margin: 0 0 0.25rem; }
.author-strip p { margin: 0 0 0.45rem; max-width: 42em; color: var(--ink-soft); font-size: 0.9375rem; }

/* Footer */
.colophon { margin-top: 2.5rem; background: var(--tint); }
.colophon-inner { max-width: var(--width); margin: 0 auto; padding: 1.5rem var(--gutter) 1.25rem; display: grid; gap: 1rem; }
.colophon-name { font-weight: 700; margin: 0; }
.colophon-motto { margin: 0; color: var(--ink-soft); font-size: 0.875rem; }
.colophon-links { display: flex; flex-wrap: wrap; gap: 0.25rem 1.1rem; list-style: none; margin: 0; padding: 0; font-size: 0.875rem; }
.colophon-links a { text-decoration: none; }
.colophon-links a:hover { text-decoration: underline; }
.colophon-copy { margin: 0; font-size: 0.8125rem; color: var(--ink-soft); }

/* Index-style pages */
.page-head { padding: clamp(1.5rem, 4vw, 2.75rem) 0 clamp(1rem, 2vw, 1.5rem); }
.page-title { font: 600 clamp(1.9rem, 4vw, 2.75rem)/1.1 var(--sans); letter-spacing: -0.02em; margin: 0.35rem 0 0; text-wrap: balance; }
.page-deck { font-size: 1.0625rem; margin: 0.6rem 0 0; color: var(--ink-soft); max-width: 34em; }
.ledger-page { border-top: 2px solid var(--ink); }
.ledger-page .ledger-year:first-child { border-top: 0; }
.page-prose { margin-bottom: 2.5rem; }
.topic-list { list-style: none; padding: 0; margin: 0 0 2.5rem; border-top: 2px solid var(--ink); }
.topic-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: 0.55rem 0; border-bottom: 1px solid var(--rule); }
.topic-list a { font: 600 1.125rem/1.25 var(--sans); text-decoration: none; }
.topic-list a:hover { text-decoration: underline; }

/* Article header */
.progress { position: fixed; inset: 0 0 auto; height: 3px; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); z-index: 15; }
@supports (animation-timeline: scroll()) {
  .progress { animation: progress linear both; animation-timeline: scroll(root); }
  @keyframes progress { to { transform: scaleX(1); } }
}
@supports not (animation-timeline: scroll()) { .progress { display: none; } }

.entry-head { display: grid; gap: 1rem var(--gap); padding: clamp(1.5rem, 4vw, 2.75rem) 0 clamp(1rem, 2vw, 1.5rem); border-bottom: 1px solid var(--rule); }
.entry-title { font: 600 clamp(1.8rem, 4vw, 2.75rem)/1.12 var(--sans); letter-spacing: -0.022em; margin: 0.45rem 0 0; text-wrap: balance; }
.entry-deck { font-size: 1.0625rem; line-height: 1.4; margin: 0.65rem 0 0; max-width: 34em; color: var(--ink-soft); }
.entry-plate { aspect-ratio: 16 / 5; background: var(--tint); border-radius: 2px; overflow: hidden; }
.entry-cover { margin: 0; }
.entry-cover img { display: block; width: 100%; max-height: 22rem; object-fit: cover; border-radius: 2px; }
.entry-cover figcaption { font-size: 0.8125rem; color: var(--ink-soft); margin-top: 0.35rem; }

/* Article body and margin */
.entry-grid { display: grid; gap: 1.1rem; padding-top: 1.25rem; }
.entry-meta { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 0.1rem 0.8rem; align-items: baseline; font-size: 0.875rem; }
.entry-meta dt { font-size: 0.75rem; font-weight: 500; color: var(--ink-soft); }
.entry-meta dd { margin: 0; }
.toc { margin-top: 0.75rem; border-top: 1px solid var(--rule); padding-top: 0.55rem; }
.toc summary { font-size: 0.75rem; font-weight: 600; color: var(--ink-soft); cursor: pointer; padding: 0.2rem 0; }
.toc ol { list-style: none; margin: 0.35rem 0 0; padding: 0; }
.toc li { padding: 0.17rem 0; line-height: 1.25; font-size: 0.8125rem; }
.toc .toc-3 { padding-left: 0.7rem; color: var(--ink-soft); }
.toc a { text-decoration: none; }
.toc a:hover { text-decoration: underline; }

.prose { max-width: var(--measure); font: 400 clamp(1.0625rem, 0.3vw + 1rem, 1.1875rem)/1.6 var(--serif); min-width: 0; }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 0.95em; }
.prose h1, .prose h2 { font: 600 1.4em/1.2 var(--sans); letter-spacing: -0.015em; margin: 1.6em 0 0.45em; text-wrap: balance; }
.prose h3 { font: 600 1.12em/1.3 var(--sans); letter-spacing: -0.005em; margin: 1.35em 0 0.35em; }
.prose h4, .prose h5, .prose h6 { font: 600 0.875em/1.4 var(--sans); margin: 1.3em 0 0.35em; color: var(--ink-soft); }
.prose ul, .prose ol { padding-left: 1.25em; margin: 0 0 0.95em; }
.prose li { margin-bottom: 0.25em; }
.prose li::marker { color: var(--accent); }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 1.8em 0; }
.prose blockquote { margin: 1.2em 0; padding: 0.1em 0 0.1em 1em; border-left: 3px solid var(--accent); font-style: italic; color: var(--ink); }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose :not(pre) > code { font: 0.82em var(--mono); background: var(--tint); padding: 0.1em 0.3em; border-radius: 2px; }
.prose img { display: block; margin: 1.2em 0; border-radius: 2px; }
.prose .figure { margin: 1.4em 0; }
.prose .figure img { margin: 0; }
.prose figcaption { font: 400 0.8125rem/1.35 var(--sans); color: var(--ink-soft); margin-top: 0.4em; }
.table-wrap { overflow-x: auto; margin: 1.2em 0; }
.prose table { border-collapse: collapse; width: 100%; font: 400 0.875rem/1.35 var(--sans); }
.prose th { font-weight: 600; text-align: left; border-bottom: 2px solid var(--ink); padding: 0.4em 0.8em 0.4em 0; white-space: nowrap; }
.prose td { padding: 0.4em 0.8em 0.4em 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.custom_text_color_blue { color: var(--code-token-function); }

/* Code */
.codeblock { position: relative; margin: 1.2em 0; background: var(--tint); border-radius: 2px; }
.codeblock[data-lang]::before { content: attr(data-lang); display: block; font: 500 0.6875rem/1 var(--sans); color: var(--ink-soft); padding: 0.6rem 0.9rem 0; }
.codeblock pre { margin: 0; padding: 0.55rem 0.9rem 0.8rem; overflow-x: auto; font: 400 0.8125rem/1.55 var(--mono); tab-size: 4; background: transparent !important; color: var(--code-foreground); }
.codeblock code { font: inherit; }

/* Article footer */
.entry-foot { max-width: var(--measure); padding-top: 1.25rem; }
.series-note { background: var(--tint); padding: 0.8rem 1rem; margin-bottom: 1.1rem; border-radius: 2px; font-size: 0.9375rem; }
.series-note .label { font-weight: 600; }
.series-note ol { margin: 0.4rem 0 0; padding-left: 1.3em; }
.series-note li { padding: 0.08rem 0; }
.series-note li[aria-current] { color: var(--ink-soft); }
.share { display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; align-items: baseline; padding: 0.7rem 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); font-size: 0.875rem; }
.share a, .copy-link { font: inherit; }
.copy-link { background: none; border: 0; padding: 0; color: inherit; cursor: pointer; text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
.signature { display: flex; gap: 0.85rem; align-items: center; padding: 1rem 0; font-size: 0.9375rem; }
.signature img { width: 3rem; height: 3rem; border-radius: 50%; object-fit: cover; flex: none; }
.signature p { margin: 0; line-height: 1.4; color: var(--ink-soft); }
.signature strong { color: var(--ink); }
.turns { display: grid; gap: 0.8rem; padding: 0.9rem 0; border-top: 1px solid var(--rule); }
.turn { display: grid; gap: 0.15rem; text-decoration: none; }
.turn-title { font-weight: 600; line-height: 1.25; }
.turn:hover .turn-title { text-decoration: underline; }
.related { padding: 0.9rem 0 0.5rem; border-top: 1px solid var(--rule); }
.related h2 { font-weight: 600; color: var(--ink); font-size: 0.875rem; }
.related ul { list-style: none; padding: 0; margin: 0.35rem 0 0; }
.related li { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; padding: 0.2rem 0; }
.related a { text-decoration: none; font-weight: 500; line-height: 1.3; font-size: 0.9375rem; }
.related a:hover { text-decoration: underline; }
.related .label { white-space: nowrap; }

/* Tablet and up */
@media (min-width: 40rem) {
  .turns { grid-template-columns: 1fr 1fr; gap: var(--gap); }
  .turn-next { text-align: right; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tile-plate { aspect-ratio: 16 / 7; }
  .series-grid { grid-template-columns: repeat(2, 1fr); column-gap: var(--gap); }
  .ledger-year { grid-template-columns: 4.5rem 1fr; }
  .colophon-inner { grid-template-columns: auto 1fr; align-items: start; column-gap: 2.5rem; }
  .colophon-links { justify-content: flex-end; }
  .colophon-copy { grid-column: 1 / -1; }
}

/* Desktop */
@media (min-width: 62rem) {
  .hero { grid-template-columns: 7fr 5fr; align-items: stretch; column-gap: 2.5rem; }
  .hero-text { align-self: center; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .series-band { display: grid; grid-template-columns: 3fr 9fr; column-gap: var(--gap); align-items: start; }
  .series-head { margin-bottom: 0; }
  .series-grid { grid-template-columns: repeat(2, 1fr); }
  .entry-head { grid-template-columns: 8fr 4fr; align-items: center; }
  .entry-plate { aspect-ratio: 16 / 9; }
  .entry-grid { grid-template-columns: 13rem minmax(0, 1fr); column-gap: 2.75rem; padding-top: 1.75rem; }
  .entry-margin { position: sticky; top: 4.5rem; align-self: start; max-height: calc(100vh - 5.5rem); overflow-y: auto; scrollbar-width: thin; }
  .entry-meta { display: block; }
  .entry-meta dd { margin-bottom: 0.5rem; }
  .entry-foot { margin-left: calc(13rem + 2.75rem); }
  .toc summary { pointer-events: none; list-style: none; }
  .toc summary::-webkit-details-marker { display: none; }
  .codeblock { max-width: 46rem; width: 46rem; }
}
@media (min-width: 62rem) and (max-width: 74rem) { .codeblock { width: auto; max-width: 100%; } }

@media print {
  .masthead, .colophon, .share, .turns, .related, .entry-plate, .progress, .toc, .theme-toggle { display: none; }
  body { background: #fff; color: #000; }
}
