/* The one stylesheet, shared by every page. Design rules: docs/design. */

:root {
    --font-display: "Source Serif 4", Georgia, "Times New Roman", serif;
    --font-body: "Source Sans 3", "Segoe UI", Helvetica, Arial, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

    --ink-900: #16171a;
    --ink-700: #43464d;
    --ink-600: #5a5d65;
    --ink-500: #7b7e86;
    --ink-300: #c8cacd;
    --ink-200: #dedfe1;
    --paper: #fbfbfa;
    --paper-raised: #ffffff;
    --accent-700: #3a2e4f;
    --accent-600: #4a3b63;
    --accent-500: #5c4a7a;
    --accent-100: #e4dfec;
    --alert-600: #8f2727;

    --fs-display: 3.25rem;
    --fs-h1: 2.5rem;
    --fs-subhead: 1.5rem;
    --fs-h3: 1.4375rem;
    --fs-h4: 1.1875rem;
    --fs-body-lg: 1.1875rem;
    --fs-body: 1.0625rem;
    --fs-sm: 0.9375rem;
    --fs-xs: 0.8125rem;
    --fs-micro: 0.75rem;

    --space-2: 4px;
    --space-3: 8px;
    --space-4: 12px;
    --space-5: 16px;
    --space-6: 20px;
    --space-7: 24px;
    --space-8: 32px;
    --space-9: 40px;
    --space-10: 56px;
    --space-11: 72px;

    --page-max: 1280px;
    --page-narrow: 720px;
    --measure-article: 34rem;
    --measure-form: 22rem;

    --rule-hairline: 1px solid var(--ink-200);
    --rule-medium: 2px solid var(--ink-900);
    --rule-heavy: 3px solid var(--ink-900);
    --rule-dotted: 1px dotted var(--ink-300);
    --ease: 90ms cubic-bezier(0.2, 0, 0.1, 1);
}

/* Base */

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

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    color: var(--ink-900);
    font-family: var(--font-body);
    font-size: var(--fs-body);
    line-height: 1.62;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: -0.012em;
    text-wrap: balance;
}

h1 {
    font-size: var(--fs-h1);
}

p { margin: 0; text-wrap: pretty; }

a {
    color: var(--accent-600);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: color var(--ease);
}

a:hover { color: var(--accent-700); text-decoration-thickness: 2px; }

/* Headline links are undecorated until hovered. */
.wordmark, h1 a, h2 a, h3 a { color: inherit; text-decoration: none; }

.wordmark:hover, h1 a:hover, h2 a:hover, h3 a:hover {
    color: inherit;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

:focus-visible { outline: 2px solid var(--accent-500); outline-offset: 2px; }

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

/* Facts are set in serif or sans; what is *about* a fact (when, who, which
   section) is set in uppercase mono. */
.meta, .kicker, .tag, label, .details dt, .masthead nav a, .sections a {
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.meta, label, .details dt { color: var(--ink-500); }
.kicker { color: var(--accent-600); font-weight: 500; }

/* Page frame */

.wrap {
    width: 100%;
    max-width: var(--page-max);
    margin: 0 auto;
    padding-inline: var(--space-6);
}

.masthead { border-bottom: var(--rule-heavy); }

.masthead .wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-6);
    padding-block: var(--space-6);
}

.brand { display: grid; gap: var(--space-2); }

.wordmark {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 2.25rem;
    line-height: 1;
    letter-spacing: -0.02em;
}

.masthead nav { display: flex; flex-wrap: wrap; gap: var(--space-6); }

.masthead nav a, .sections a { text-decoration: none; }

.sections {
    position: sticky;
    top: 0;
    z-index: 4;
    background: var(--paper);
    border-bottom: var(--rule-hairline);
}

.sections .wrap { display: flex; gap: var(--space-7); }
.sections a { display: block; padding: var(--space-4) 0; color: var(--ink-600); }

main { flex: 1; padding-block: var(--space-9) var(--space-11); }

.foot { border-top: var(--rule-heavy); }
.foot .wrap { padding-block: var(--space-8) var(--space-10); }

/* Front page: a lead story beside a rail of the rest, then a band for each beat */

.front {
    display: grid;
    grid-template-columns: minmax(0, 2.15fr) minmax(0, 1fr);
    gap: var(--space-9);
}

.lead h1 { font-size: var(--fs-display); line-height: 1.04; }
.lead .meta { display: block; margin-top: var(--space-4); }

/* The lead is a column so its picture can take the height the rail leaves spare:
   the row is as tall as the taller of the two, and the picture fills the rest of
   the lead's side. It is 21:9 at the least, and cropped, so a tall photo never
   pushes the rail and everything below it down the page. Stacked, under 1040px,
   there is no spare height and it stays 21:9. */
.lead { display: flex; flex-direction: column; }

.lead-image {
    position: relative;
    flex: 1 0 auto;
    aspect-ratio: 21 / 9;
    margin-top: var(--space-6);
}

/* Out of the flow, so the picture's own size never sets the row's height. */
.lead-image img { position: absolute; inset: 0; height: 100%; }

.lead-image img, .card-image img {
    display: block;
    width: 100%;
    object-fit: cover;
    background: var(--ink-200);
}

.rail {
    display: grid;
    gap: var(--space-6);
    align-content: start;
    border-left: var(--rule-hairline);
    padding-left: var(--space-7);
}

.rail article {
    display: grid;
    gap: var(--space-4);
    padding-bottom: var(--space-5);
    border-bottom: var(--rule-hairline);
}

.rail .beats { margin-bottom: 0; }
.rail h2 { font-size: var(--fs-h4); }

/* Below the fold, each beat has a band: its name and the one rule that runs out
   from it, then up to four articles in a row. Nothing else separates the bands or
   the articles in one: the next band's rule is the break. */

.band {
    display: grid;
    gap: var(--space-7);
    margin-top: var(--space-9);
}

/* The fold: the one heavy rule, between the front and the first band. It belongs
   to the band, so a page with no bands has no rule to end on. */
.front + .band {
    padding-top: var(--space-9);
    border-top: var(--rule-medium);
}

/* The name runs into a hairline that fills the rest of the row. */
.band .kicker { display: flex; align-items: center; gap: var(--space-4); }
.band .kicker::after { content: ""; flex: 1; border-top: var(--rule-hairline); }

.band-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-8);
}

.band-grid article {
    display: grid;
    gap: var(--space-4);
    align-content: start;
}

.card-image img { aspect-ratio: 3 / 2; }
.band-grid h3 { font-size: var(--fs-h3); }

/* A beat label: the article's subject, set in mono with a 2px accent underline.
   Wayfinding, not decoration, so it is a plain span until there is a beat page
   for it to link to. An article's beats sit in a row above its headline. */
.tag {
    display: inline-block;
    padding-bottom: 2px;
    border-bottom: 2px solid var(--accent-500);
    color: var(--accent-600);
    font-size: var(--fs-xs);
    font-weight: 500;
}

.beats {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3) var(--space-5);
    margin: 0 0 var(--space-5);
    padding: 0;
    list-style: none;
}

/* Article and form pages share a narrow column. */

.narrow { max-width: var(--page-narrow); margin: 0 auto; }
.narrow h1 { margin-bottom: var(--space-5); }

.article time { display: block; margin-bottom: var(--space-8); }
.article p { max-width: var(--measure-article); font-size: var(--fs-body-lg); }
.article p + p { margin-top: var(--space-6); }

/* A subheader is set in the page headline's face and width, only a little
   larger than the text around it. The space above is what marks the break. */
.article h2 {
    max-width: var(--measure-article);
    margin: var(--space-8) 0 var(--space-4);
    font-size: var(--fs-subhead);
    line-height: 1.2;
}

/* Images sit between paragraphs at the column's width; the credit is metadata,
   so it is set in mono under the caption. */
.article figure { margin: var(--space-8) 0; }
.article img { display: block; max-width: 100%; height: auto; }
.article figcaption {
    max-width: var(--measure-article);
    margin-top: var(--space-3);
    color: var(--ink-700);
    font-size: var(--fs-sm);
}
.article figcaption .meta { display: block; margin-top: var(--space-2); }

/* A citation is a superscript number linking to its entry under the body. */
.cite { margin-left: 1px; font-size: var(--fs-micro); line-height: 0; }
/* Two citations in a row would read as one number, so a comma goes between. */
.cite + .cite::before { content: ","; }

.sources {
    max-width: var(--measure-article);
    margin-top: var(--space-9);
    padding-top: var(--space-6);
    border-top: var(--rule-hairline);
}
/* .article p sets the body size, which would otherwise win over .kicker. */
.sources .kicker { font-size: var(--fs-micro); }
.sources ol { margin: var(--space-4) 0 0; padding-left: var(--space-7); font-size: var(--fs-sm); }
.sources li + li { margin-top: var(--space-3); }
/* Leave room for the sticky section bar when a citation jumps here. */
.sources li { scroll-margin-top: var(--space-11); }
.sources li:target { background: var(--accent-100); }
/* The quotes a source is cited for, each marked with the number a citation shows. */
.sources .quotes { margin: var(--space-2) 0 0; padding-left: 0; list-style: none; color: var(--ink-700); }
.sources .quotes li + li { margin-top: var(--space-2); }
.sources .quote-mark { margin-right: var(--space-2); font-size: var(--fs-micro); }

/* Forms and account details */

form { display: grid; gap: var(--space-2); max-width: var(--measure-form); }
form, .details { margin: var(--space-7) 0; }
label + input { margin-bottom: var(--space-5); }
form .button { justify-self: start; }

input {
    padding: 10px 12px;
    border: 1px solid var(--ink-900);
    border-radius: 0;
    background: var(--paper-raised);
    color: var(--ink-900);
    font: inherit;
    font-size: var(--fs-sm);
}

.button {
    display: inline-block;
    padding: 10px 18px;
    border: 1px solid var(--ink-900);
    border-radius: 0;
    background: var(--ink-900);
    color: var(--paper);
    font: inherit;
    font-size: var(--fs-sm);
    font-weight: 600;
    letter-spacing: 0.02em;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--ease), border-color var(--ease), color var(--ease);
}

.button:hover { background: var(--ink-700); border-color: var(--ink-700); color: var(--paper); }

.error {
    padding: var(--space-3) var(--space-4);
    border-left: 3px solid var(--alert-600);
    color: var(--alert-600);
}

.details {
    display: grid;
    grid-template-columns: 9rem 1fr;
    gap: 0 var(--space-6);
}

.details dt, .details dd {
    margin: 0;
    padding: var(--space-3) 0;
    border-bottom: var(--rule-dotted);
}

/* Match the value's line height so label and value sit on one line. */
.details dt { line-height: calc(var(--fs-body) * 1.62); }

/* The rail drops under the lead at 1040px, and a band's row becomes two columns.
   The lead headline shrinks at 760px, and a band's row becomes one. */

@media (max-width: 1040px) {
    .front { grid-template-columns: minmax(0, 1fr); gap: var(--space-8); }
    .band-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .rail {
        border-left: 0;
        padding-left: 0;
        border-top: var(--rule-medium);
        padding-top: var(--space-6);
    }
}

@media (max-width: 760px) {
    .lead h1 { font-size: var(--fs-h1); }
    .band-grid { grid-template-columns: minmax(0, 1fr); }
}
