@charset "UTF-8";

/* Finite Demand — see BRAND.md.
   Phone-first: the base rules are the small-screen rules. The single
   min-width query near the bottom only opens things up. */

/* ---------------------------------------------------------------- Fonts */

/* Newsreader, self-hosted variable (wght 200-800, opsz 6-72), SIL OFL.
   License: fonts/OFL.txt */

@font-face {
    font-family: "Newsreader";
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url("/fonts/newsreader-latin-roman.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
        U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
        U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Newsreader";
    font-style: italic;
    font-weight: 200 800;
    font-display: swap;
    src: url("/fonts/newsreader-latin-italic.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
        U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
        U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Newsreader";
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url("/fonts/newsreader-latinext-roman.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
        U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
        U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
        U+A720-A7FF;
}

@font-face {
    font-family: "Newsreader";
    font-style: italic;
    font-weight: 200 800;
    font-display: swap;
    src: url("/fonts/newsreader-latinext-italic.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
        U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
        U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
        U+A720-A7FF;
}

/* --------------------------------------------------------------- Tokens */

:root {
    /* Palette — hacktera.com ivory/black/red, plus muted and rule. */
    --color-bg: #fffff0;
    --color-text: #101820;
    --color-muted: #5c6470;
    --color-accent: #f93822;
    --color-rule: #d9d5c4;

    /* Faces */
    --font-display: "Newsreader", Georgia, "Times New Roman", serif;
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* Fluid scale, 360px -> 1200px */
    --step--2: clamp(0.75rem, 0.72rem + 0.14vw, 0.8rem);
    --step--1: clamp(0.85rem, 0.82rem + 0.14vw, 0.9rem);
    --step-0: clamp(1.05rem, 1.02rem + 0.21vw, 1.125rem);
    --step-1: clamp(1.2rem, 1.11rem + 0.57vw, 1.4rem);
    --step-2: clamp(1.45rem, 1.28rem + 1.14vw, 1.85rem);
    --step-3: clamp(1.9rem, 1.6rem + 2vw, 2.6rem);
    --step-4: clamp(2.4rem, 1.71rem + 4.57vw, 4rem);

    /* Spacing */
    --space-xs: 0.375rem;
    --space-s: 0.75rem;
    --space-m: 1.25rem;
    --space-l: 2rem;
    --space-xl: clamp(2.5rem, 6vw, 4rem);
    --space-2xl: clamp(3.5rem, 9vw, 6rem);

    /* Layout */
    --measure: 34rem;
    --gutter: clamp(1.25rem, 5vw, 3rem);
    --slack: 0rem;

    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --color-bg: #101820;
        --color-text: #f2ece0;
        --color-muted: #9aa3af;
        --color-rule: #2a3542;
    }
}

:root[data-theme="dark"] {
    --color-bg: #101820;
    --color-text: #f2ece0;
    --color-muted: #9aa3af;
    --color-rule: #2a3542;
}

/* ---------------------------------------------------------------- Reset */

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

body,
h1,
h2,
h3,
p,
ol,
ul,
figure,
blockquote,
dl,
dd {
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: var(--step-0);
    line-height: 1.65;
    font-weight: 400;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

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

:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    border-radius: 1px;
}

/* -------------------------------------------------------------- Masthead */

#header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: var(--space-m);
    padding: var(--space-s) var(--gutter);
    background-color: var(--color-bg);
    border-bottom: 1px solid var(--color-rule);
    font-size: var(--step--1);
}

#logo {
    display: block;
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    margin-right: calc(var(--space-m) * -0.25);
}

#header a {
    color: var(--color-text);
    text-decoration: none;
}

#header a:hover,
#header a:focus-visible {
    color: var(--color-accent);
}

#theme-toggle {
    margin-left: auto;
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid var(--color-rule);
    border-radius: 50%;
    background-color: transparent;
    color: var(--color-text);
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
}

#theme-toggle:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

/* ---------------------------------------------------------------- Grid */

/* The outer columns are `1fr`, not a fixed gutter, so the grid fills the
   viewport and `full` really is edge to edge. Everything vertical is
   `row-gap`, not margins: grid items never collapse margins, so a
   margin-bottom plus the next element's margin-top would always add up. */
article {
    display: grid;
    grid-template-columns:
        [full-start] minmax(var(--gutter), 1fr)
        [wide-start] minmax(0, var(--slack))
        [text-start] min(var(--measure), 100% - (2 * var(--gutter)))
        [text-end] minmax(0, var(--slack))
        [wide-end] minmax(var(--gutter), 1fr)
        [full-end];
    row-gap: var(--space-m);
    padding-block: var(--space-xl) var(--space-2xl);
}

article > *,
section > * {
    grid-column: text;
}

/* Sections carry no box of their own — their children join the article
   grid directly. Never style `section` itself; see BRAND.md. */
section {
    display: contents;
}

.wide,
section > .wide {
    grid-column: wide;
}

.fullwidth,
section > .fullwidth {
    grid-column: full;
}

/* ----------------------------------------------------------------- Type */

h1,
h2,
h3,
.dek,
.epigraph blockquote p,
.wordmark {
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-weight: 400;
    line-height: 1.15;
    text-wrap: balance;
}

h1 {
    font-size: var(--step-3);
    letter-spacing: -0.015em;
}

/* Headings add to the row-gap above them and nothing below, so a heading
   binds to the text it introduces rather than the section it follows. */
h2 {
    font-size: var(--step-2);
    margin-top: var(--space-l);
}

h3 {
    font-size: var(--step-1);
    margin-top: var(--space-s);
}

/* Pull back against the row-gap: a dek belongs to its title, not to the
   rhythm of the page. */
p.dek {
    font-size: var(--step-1);
    font-style: italic;
    color: var(--color-muted);
    margin-top: calc(var(--space-xs) - var(--space-m));
}

p {
    text-align: left;
    hyphens: none;
}

ol,
ul {
    padding-left: 1.35em;
}

li + li {
    margin-top: var(--space-xs);
}

li > ol,
li > ul {
    margin-top: var(--space-xs);
}

strong {
    font-weight: 600;
}

a:link,
a:visited {
    color: var(--color-text);
    text-decoration: underline;
    text-decoration-color: var(--color-muted);
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.15em;
}

a:hover,
a:focus-visible {
    text-decoration-color: var(--color-accent);
    text-decoration-thickness: 0.12em;
}

code {
    font-family: var(--font-mono);
    font-size: 0.9em;
}

pre {
    padding: var(--space-m);
    overflow-x: auto;
    border-left: 2px solid var(--color-rule);
}

pre > code {
    font-size: var(--step--1);
    line-height: 1.5;
}

/* ------------------------------------------------------------- Epigraph */

div.epigraph {
    margin-block: var(--space-l) var(--space-s);
    padding-inline: var(--space-m);
}

div.epigraph::before {
    content: "";
    display: block;
    width: 4rem;
    height: 2px;
    background-color: var(--color-accent);
    margin-bottom: var(--space-m);
}

div.epigraph blockquote p {
    font-size: var(--step-1);
    font-style: italic;
    line-height: 1.4;
    margin: 0;
}

div.epigraph blockquote p + p {
    margin-top: var(--space-s);
}

div.epigraph blockquote footer {
    margin-top: var(--space-s);
    font-family: var(--font-body);
    font-size: var(--step--1);
    font-style: normal;
    font-variant-caps: all-small-caps;
    letter-spacing: 0.06em;
    color: var(--color-muted);
}

/* ------------------------------------------------------ Blockquotes */

blockquote {
    padding-left: var(--space-m);
    border-left: 2px solid var(--color-rule);
}

/* The epigraph's blockquote is a bare container — its rule is the red
   bar drawn by div.epigraph::before, not a left border. */
div.epigraph blockquote {
    margin-top: 0;
    padding-left: 0;
    border-left: 0;
}

blockquote footer {
    margin-top: var(--space-xs);
    font-size: var(--step--1);
    color: var(--color-muted);
}

/* ----------------------------------------------------- Notes (asides) */

/* Notes live in the reading column, after the paragraph that referenced
   them. Nothing is hidden and nothing floats — see BRAND.md. */

aside.note {
    padding-left: var(--space-m);
    border-left: 2px solid var(--color-rule);
    font-size: var(--step--1);
    line-height: 1.5;
    color: var(--color-muted);
}

aside.note > p {
    margin: 0;
}

aside.note > p + p {
    margin-top: var(--space-s);
}

aside.note.numbered {
    position: relative;
}

aside.note.numbered > .note-num {
    display: block;
    font-size: var(--step--2);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--color-accent);
    margin-bottom: var(--space-xs);
}

sup.note-ref {
    font-size: 0.7em;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--color-accent);
    line-height: 0;
    vertical-align: super;
    margin-left: 0.1em;
}

/* -------------------------------------------------------- Brand marks */

/* `hr` is a reduction of pattern.svg's geometry to three squares. */
hr {
    border: 0;
    height: auto;
    margin-block: var(--space-l);
    text-align: center;
    line-height: 0;
}

hr::before {
    content: "";
    display: inline-block;
    width: 0.4rem;
    height: 0.4rem;
    background-color: var(--color-accent);
    box-shadow:
        1rem 0 0 var(--color-accent),
        -1rem 0 0 var(--color-accent);
}

.qed {
    display: inline-block;
    width: 0.55em;
    height: 0.55em;
    margin-left: 0.3em;
    background-color: var(--color-accent);
    vertical-align: baseline;
}

/* The one place pattern.svg appears at size: the index cover band. */
.pattern-band {
    height: clamp(5rem, 14vw, 9rem);
    margin-block: var(--space-s) var(--space-l);
    background-image: url("/pattern.svg");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-block: 1px solid var(--color-rule);
}

/* -------------------------------------------------------- Figures/media */

figure {
    margin-top: var(--space-s);
}

figcaption,
.img-caption {
    margin-top: var(--space-xs);
    font-size: var(--step--1);
    color: var(--color-muted);
}

figure img {
    display: block;
    width: 100%;
    height: auto;
}

/* `.diagram` marks line art on a transparent ground -- figures rasterized
   from the original PDF reports. Their ink is near-black, so on the dark
   background they would all but vanish. Inverting flips the ink to light
   without touching the palette (a filter is not a color, so the token rules
   still hold); the hue-rotate puts the few tinted fills back where they
   started. Opt-in by class: a photograph must never be inverted. Both dark
   blocks below, same as every token, so the manual toggle wins either way. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .diagram img {
        filter: invert(1) hue-rotate(180deg);
    }
}

:root[data-theme="dark"] .diagram img {
    filter: invert(1) hue-rotate(180deg);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--step--1);
}

th,
td {
    text-align: left;
    padding: var(--space-xs) var(--space-s) var(--space-xs) 0;
    border-bottom: 1px solid var(--color-rule);
}

.table-wrapper {
    overflow-x: auto;
}

/* ------------------------------------------------------------ Index */

.wordmark {
    font-size: var(--step-4);
    letter-spacing: -0.02em;
    margin-top: var(--space-l);
}

.byline {
    margin-top: calc(var(--space-xs) - var(--space-m));
    font-size: var(--step--1);
    color: var(--color-muted);
    letter-spacing: 0.02em;
}

ol.essay-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

ol.essay-list > li {
    margin: 0;
    padding-block: var(--space-m);
    border-top: 1px solid var(--color-rule);
}

ol.essay-list > li:last-child {
    border-bottom: 1px solid var(--color-rule);
}

.essay-title {
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-size: var(--step-1);
    font-weight: 400;
    line-height: 1.2;
    margin: 0;
    text-wrap: balance;
}

.essay-title a {
    text-decoration: none;
}

.essay-title a:hover,
.essay-title a:focus-visible {
    text-decoration: underline;
    text-decoration-color: var(--color-accent);
    text-decoration-thickness: 0.06em;
    text-underline-offset: 0.15em;
}

.essay-dek {
    margin-top: var(--space-xs);
    font-size: var(--step--1);
    color: var(--color-muted);
}

.essay-year {
    margin-top: var(--space-xs);
    font-size: var(--step--1);
    font-variant-numeric: tabular-nums;
    color: var(--color-muted);
}

/* -------------------------------------------------------- Essay foot */

footer.essay-foot {
    margin-top: var(--space-xl);
    padding-top: var(--space-m);
    border-top: 1px solid var(--color-rule);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-s) var(--space-m);
    align-items: baseline;
    justify-content: space-between;
    font-size: var(--step--1);
    color: var(--color-muted);
}

footer.essay-foot a {
    color: var(--color-muted);
    text-decoration: none;
}

footer.essay-foot a:hover,
footer.essay-foot a:focus-visible {
    color: var(--color-accent);
}

/* ------------------------------------------------------- Wide screens */

@media (min-width: 48em) {
    :root {
        /* Open the slack columns so .wide has somewhere to go. */
        --slack: 8rem;
    }

    #header {
        gap: var(--space-l);
        padding-inline: var(--space-xl);
    }

    div.epigraph {
        padding-inline: var(--space-l);
    }

    ol.essay-list > li {
        display: grid;
        grid-template-columns: 1fr auto;
        column-gap: var(--space-l);
    }

    .essay-title {
        grid-column: 1;
    }

    .essay-dek {
        grid-column: 1;
    }

    .essay-year {
        grid-column: 2;
        grid-row: 1;
        margin-top: 0.35em;
        text-align: right;
    }
}

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