/* Type: Schibsted Grotesk (text) and JetBrains Mono (code), both SIL OFL. See fonts/OFL-*.txt */
@font-face { font-family: "Schibsted Grotesk"; src: url("fonts/schibsted-grotesk.woff") format("woff"); font-weight: 400 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Schibsted Grotesk"; src: url("fonts/schibsted-grotesk-italic.woff") format("woff"); font-weight: 400 900; font-style: italic; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("fonts/jetbrains-mono.woff") format("woff"); font-weight: 100 800; font-style: normal; font-display: swap; }

/*
  Quiet page, one signature: the annotated intro. Dotted phrases unfold the
  detail behind them. Single column; indigo appears only where you interact.
*/
:root {
  --bg: #FAFAFB;
  --raised: #FFFFFF;
  --ink: #0F1115;
  --text: #3A3F48;
  --muted: #7A808B;
  --line: #E4E6EA;
  --dot: #A3A9B3;
  --hover: #F0F1F4;
  --accent: #3352F5;
  --code-bg: #F0F1F4;
  --code-kw: #3352F5;
  --code-str: #23794D;
  --code-num: #B2512B;
  --code-comment: #8C929C;
  --shadow: 0 1px 2px rgba(15, 17, 21, 0.04), 0 12px 32px -8px rgba(15, 17, 21, 0.18);

  --font: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Type scale: seven sizes, each with one line-height on the 4px grid.
       13/20  code, chips
       14/20  labels, dates, meta, captions, the intro's notes
       16/24  the default: names, rows, links, tables, footnotes
       18/28  prose (and the lead on phones)
       20/32  the lead and pulled quotes; 20/28 for h2
       24/28  page titles on phones
       32/36  page titles
     Tracking tightens as size grows. Reach for a size here before adding one. */

  /* Vertical rhythm: a 4px baseline unit. Every line-height and every vertical
     gap is a step from this scale, so text lands on the same grid down the page.
     A 1px rule takes its pixel out of the padding beside it. */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s8: 32px;
  --s10: 40px;
  --s12: 48px;
  --s16: 64px;
  --s24: 96px;
  --s32: 128px;

  /* Horizontal rhythm: one text edge, one surface edge. Text never leaves the
     column. Surfaces (hover plates, code) hang --bleed past it,
     so what is inside them still lines up with the text around them. */
  --page: 620px;
  --pad: var(--s6);     /* page gutter, and the gap between columns */
  --bleed: var(--s4);
  --indent: var(--s6);  /* lists and quotes */
  --top: var(--s16);    /* where the name sits, on every page */
  --section: var(--s16);
  --end: var(--s32);    /* room after the last line, on pages longer than the window */
  --radius: 12px;       /* surfaces */

  /* Motion: one strong ease-out for anything that enters, leaves, or resizes,
     and one ease-in-out for things already on screen that travel. Plain `ease`
     is for color and hover changes only. */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B0C0E;
    --raised: #141619;
    --ink: #F1F2F4;
    --text: #B8BDC6;
    --muted: #7C828D;
    --line: #23262B;
    --dot: #565C65;
    --hover: #17191D;
    --accent: #7D93FF;
    --code-bg: #131518;
    --code-kw: #93A5FF;
    --code-str: #86CFA2;
    --code-num: #EFA57D;
    --code-comment: #6B717C;
    --shadow: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 16px 40px -8px rgba(0, 0, 0, 0.7);
  }
}

*, *::before, *::after { box-sizing: border-box; }
/* touch-action: no double-tap zoom on phones, pinch zoom still works.
   scrollbar-gutter: the column must not shift sideways when a note makes a
   short page scrollable. overflow-x: a margin note on its way in or out must
   never add a sideways scroll. Tap highlight is off because every pressable
   thing has its own :active state. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
  scrollbar-gutter: stable;
  overflow-x: clip;
  -webkit-tap-highlight-color: transparent;
}

body {
  position: relative;
  display: flow-root;
  margin: 0 auto;
  max-width: calc(var(--page) + 2 * var(--pad));
  padding: 0 var(--pad);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 24px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
}

/* End space. A page that fits in the window ends where its content ends, so it
   never scrolls into nothing. A page that runs past the window gets --end to
   finish in. The spacer is absolutely positioned so that 100% is the page's own
   height: the moment that passes the window, the clamp flips from zero to the
   full space. svh, not dvh, so a phone's collapsing toolbar cannot flip it
   mid-scroll. */
body::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  width: 1px;
  height: var(--end);
  height: clamp(0px, (100% - 100svh) * 999, var(--end));
  pointer-events: none;
}

::selection { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--ink); }

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--line);
  transition: text-decoration-color 150ms ease;
}
/* Hover only where there is a pointer that hovers; touch gets :active instead */
@media (hover: hover) and (pointer: fine) {
  a:hover { text-decoration-color: var(--accent); }
}
a:active { text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

p { margin: 0; }
.quiet { color: var(--muted); }

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--raised);
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1;
}

/* Masthead */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding-top: var(--top);
  margin-bottom: var(--s16);
}
.name { color: var(--ink); font-weight: 600; letter-spacing: -0.01em; text-decoration: none; }

/* Lead: the annotated intro. The name opens it on the homepage, in the same
   spot the masthead puts it on every other page, so it holds still between them. */
.intro-name {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.intro-role { margin: 0 0 var(--s6); color: var(--muted); font-size: 14px; line-height: 20px; }
.lead { position: relative; padding-top: var(--top); }
/* One flowing intro: every paragraph the same voice, no section labels */
.lead > p:not(.intro-role) {
  color: var(--ink);
  font-size: 20px;
  font-weight: 450;
  line-height: 32px;
  letter-spacing: -0.012em;
  text-wrap: pretty;
}
.lead > p:not(.intro-role) + p { margin-top: var(--s4); }
.term {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 5px;
  text-decoration-color: var(--dot);
  transition: color 150ms ease, text-decoration-color 150ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .term:hover { text-decoration-color: var(--accent); }
}
/* Press answers on the way down, before the click opens anything */
.term:active { text-decoration-color: var(--accent); transition-duration: 0s; }
.term[aria-expanded="true"] { color: var(--accent); text-decoration-color: var(--accent); }

/* Notes. Every dotted phrase carries one, and it opens as close to the phrase
   as the window allows (static/js/terms.js decides which):
     - Wide window: in the right margin, on the phrase's own line. Nothing in the
       intro moves and nothing is covered.
     - Not quite wide enough: the column steps aside to make that margin, then
       steps back.
     - No room at all (phones): the paragraph parts under the phrase's line and
       the note sits between the lines.
   Both forms are the same quiet text, unboxed. */
.note-label { display: block; color: var(--muted); }
.note-text { display: block; margin-top: var(--s1); }

/* In the margin. --s10 away from the column, joined to it by a short dotted
   leader that picks up where the phrase's underline leaves off. Arriving, the
   note slides out from the text; between phrases it glides to the next line. */
main { transition: transform 280ms var(--ease-in-out); }
.note {
  position: absolute;
  top: 0;
  left: calc(100% + var(--s10));
  z-index: 1;
  color: var(--text);
  font-size: 14px;
  line-height: 20px;
  pointer-events: none;
  transition: transform 260ms var(--ease-out);
}
.note.is-open { pointer-events: auto; }
.note-body { opacity: 0; transform: translateX(-8px); transition: opacity 120ms var(--ease-out), transform 120ms var(--ease-out); }
.note.is-open .note-body { opacity: 1; transform: none; transition-duration: 200ms; }
.note-body::before {
  content: "";
  position: absolute;
  top: 9px;
  left: calc(-1 * var(--s8));
  width: var(--s6);
  border-top: 1.5px dotted var(--dot);
  clip-path: inset(0 100% 0 0);
  transition: clip-path 120ms var(--ease-out);
}
.note.is-open .note-body::before { clip-path: inset(0 0 0 0); transition-duration: 300ms; }

/* Between the lines. A full-width float lands below the line it is anchored
   in, so the sentence above keeps its shape and the rest moves down as one.
   JS measures the content and sets the height; leaving is quicker than arriving. */
.note-inline {
  display: block;
  float: left;
  width: 100%;
  height: 0;
  overflow: hidden;
  opacity: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  letter-spacing: 0;
  transition: height 180ms var(--ease-out), opacity 180ms var(--ease-out);
}
.note-inline.is-open { opacity: 1; transition-duration: 240ms; }
.note-inner { display: block; padding: var(--s2) 0 var(--s3); }

@media (prefers-reduced-motion: reduce) {
  main, .note, .note-inline, .note-body::before { transition: none; }
  .note-body, .note.is-open .note-body { transform: none; transition: opacity 150ms ease; }
}

/* Sections */
.block { margin-top: var(--section); }
.year + .year { margin-top: var(--s12); }
.label {
  margin: 0 0 var(--s4);
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
}
.label a { color: inherit; text-decoration: none; transition: color 150ms ease; }
@media (hover: hover) and (pointer: fine) {
  .label a:hover { color: var(--ink); }
}
.label a:active { color: var(--ink); }

/* Rows: soft hover plate that bleeds past the text edge. The plate's padding
   hangs outside the rhythm on all four sides (negative margins), so the gaps
   around a list are measured from its text, the same as everywhere else. */
.rows { list-style: none; margin: calc(-1 * var(--s3)) 0; padding: 0; }
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: var(--pad);
  margin: 0 calc(-1 * var(--bleed));
  padding: var(--s3) var(--bleed);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  transition: background-color 150ms ease;
}
/* The plate arrives at once and fades on the way out, so running the pointer
   down the list never lags behind it */
@media (hover: hover) and (pointer: fine) {
  a.row:hover { background: var(--hover); transition-duration: 0s; }
}
a.row:active { background: var(--hover); transition-duration: 0s; }
.row-main { display: block; min-width: 0; }
.row-title { display: block; font-weight: 500; letter-spacing: -0.005em; }
.row-desc { display: block; color: var(--muted); }
.row-desc a { color: var(--muted); transition: color 150ms ease, text-decoration-color 150ms ease; }
@media (hover: hover) and (pointer: fine) {
  .row-desc a:hover { color: var(--ink); }
}
.row-desc a:active { color: var(--ink); }
.row-end { color: var(--muted); font-size: 14px; line-height: 20px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.draft { margin-left: var(--s2); padding: 1px 6px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); font-size: 13px; font-weight: 400; vertical-align: 1px; }
.after { margin-top: var(--s4); }

.inline-links { display: flex; flex-wrap: wrap; gap: var(--s1) var(--pad); margin: 0; padding: 0; list-style: none; }
/* A 24px line of text is a small target: widen what a finger can hit to 44px */
.inline-links a { position: relative; }
.inline-links a::after { content: ""; position: absolute; inset: -10px -8px; }

/* Page and article headers */
.page-head { margin-bottom: var(--s10); }
.title {
  margin: 0;
  color: var(--ink);
  font-size: 32px;
  font-weight: 600;
  line-height: 36px;
  letter-spacing: -0.022em;
  text-wrap: balance;
}
.sub { margin-top: var(--s2); }
.meta { font-size: 14px; line-height: 20px; }
.draft-note { margin-bottom: var(--s6); padding: 7px var(--s3); border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: 14px; line-height: 20px; }
article + .block { margin-top: var(--s24); }

/* Prose */
.prose { font-size: 18px; line-height: 28px; }
.prose > * { margin-bottom: 0; }
.prose > * + * { margin-top: var(--s5); }
.prose p { text-wrap: pretty; }
.prose h2, .prose h3, .prose h4 { margin-bottom: 0; color: var(--ink); font-weight: 600; letter-spacing: -0.012em; text-wrap: balance; scroll-margin-top: var(--s6); }
.prose h2 { margin-top: var(--s12); font-size: 20px; line-height: 28px; }
/* h3 and h4 are the body size in semibold; weight, ink, and the space above carry them */
.prose h3 { margin-top: var(--s10); font-size: inherit; line-height: inherit; }
.prose h4 { margin-top: var(--s8); font-size: inherit; line-height: inherit; }
.prose h2 + * { margin-top: var(--s3); }
.prose h3 + *, .prose h4 + * { margin-top: var(--s2); }
.prose > :first-child { margin-top: 0; }
.prose .anchor { margin-left: var(--s2); color: var(--muted); font-weight: 400; text-decoration: none; opacity: 0; transition: opacity 150ms ease; }
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose .anchor:focus-visible { opacity: 1; }
.prose strong { color: var(--ink); font-weight: 600; }
.prose ul, .prose ol { padding-left: var(--indent); }
.prose li + li, .prose li > ul, .prose li > ol { margin-top: var(--s2); }
.prose li > ul, .prose li > ol { margin-bottom: 0; }
/* Browsers set list numbers in tabular figures, and in this face that widens
   the full stop to a digit's width ("1 ."). Proportional figures keep it tight. */
.prose li::marker { color: var(--muted); font-variant-numeric: normal; }
.prose blockquote { margin: var(--s8) 0; padding: 0 var(--indent); color: var(--ink); font-size: 20px; line-height: 32px; letter-spacing: -0.012em; }
.prose blockquote > * + * { margin-top: var(--s3); }
.prose hr { border: 0; height: 1px; background: var(--line); margin: var(--s12) 0 calc(var(--s12) - 1px); }
.prose img, .prose video, .prose picture { display: block; max-width: 100%; height: auto; border-radius: var(--radius); }
.prose figure { margin-left: 0; margin-right: 0; }
.prose figcaption { margin-top: var(--s2); color: var(--muted); font-size: 14px; line-height: 20px; }

/* Code */
code, samp { font-family: var(--mono); font-size: 0.84em; font-variant-ligatures: none; }
/* line-height: 1 keeps the mono face's taller box from pushing its line off the grid */
:not(pre) > code { padding: 0.12em 0.36em; background: var(--code-bg); border-radius: 5px; color: var(--ink); line-height: 1; }
pre {
  margin: 0 calc(-1 * var(--bleed));
  padding: var(--s4) var(--bleed);
  background: var(--code-bg);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 13px;
  line-height: 20px;
  tab-size: 4;
}
pre code { font-size: inherit; background: none; padding: 0; color: inherit; }
pre.z-code { color: var(--ink); background: var(--code-bg); }
.z-comment { color: var(--code-comment); font-style: italic; }
.z-keyword, .z-storage, .z-keyword.z-operator.z-word { color: var(--code-kw); }
.z-keyword.z-operator, .z-punctuation { color: var(--muted); }
.z-string { color: var(--code-str); }
.z-constant.z-numeric, .z-constant.z-language, .z-constant.z-character { color: var(--code-num); }

/* Tables. No tabular figures here: this face's tabular set also widens the
   decimal point, which turns 1.00 into "1 . 00". */
.prose table { width: 100%; border-collapse: collapse; font-size: 16px; line-height: 24px; display: block; overflow-x: auto; }
.prose th, .prose td { padding: var(--s2) var(--pad) 7px 0; text-align: left; border-bottom: 1px solid var(--line); }
.prose th { color: var(--muted); font-weight: 500; }

/* Footnotes */
.prose sup { line-height: 0; }
.prose .footnote-reference a { padding: 0 1px; color: var(--accent); text-decoration: none; font-weight: 600; }
.prose .footnote-definition, .prose .footnotes { color: var(--muted); font-size: 16px; line-height: 24px; }
.prose .footnotes { margin-top: var(--s12); padding-top: calc(var(--s6) - 1px); border-top: 1px solid var(--line); }
.prose .footnotes ol { margin: 0; padding-left: var(--indent); }

@media (max-width: 600px) {
  :root { --top: var(--s12); --section: var(--s12); --end: var(--s24); }
  .masthead { margin-bottom: var(--s12); }
  .lead > p:not(.intro-role) { font-size: 18px; line-height: 28px; }
  .page-head { margin-bottom: var(--s8); }
  .title { font-size: 24px; line-height: 28px; }
  .prose { font-size: 16px; line-height: 24px; }
  .prose > * + * { margin-top: var(--s4); }
  .prose blockquote { font-size: 18px; line-height: 28px; }
  .row { grid-template-columns: minmax(0, 1fr); row-gap: var(--s1); }
  .inline-links { column-gap: var(--s4); }
  /* Code runs edge to edge, and still starts on the text edge */
  pre { margin-left: calc(-1 * var(--pad)); margin-right: calc(-1 * var(--pad)); padding-left: var(--pad); padding-right: var(--pad); border-radius: 0; }
}
