/*
  Editorial system. System fonts only (no downloads): New York on Apple devices via ui-serif,
  Charter or Georgia elsewhere. One accent (oxblood). Every colour pair is contrast-tested
  in tests/site.spec.ts at 7:1 or more, light and dark.
*/
:root {
  --bg: #faf8f3;
  --ink: #1a1714;
  --muted: #4d4740;
  --rule: #d8d1c4;
  --accent: #8c2318;
  --accent-ink: #fff;
  --serif: ui-serif, "New York", charter, "Bitstream Charter", "Sitka Text", cambria, georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", roboto, "Helvetica Neue", arial, sans-serif;
  --measure: 38rem;
  --rail: 11rem;
  --gutter: 3rem;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161412;
    --ink: #eee8de;
    --muted: #c2b9ac;
    --rule: #3b3631;
    --accent: #e9a585;
    --accent-ink: #161412;
  }
}

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

html {
  /* iOS Safari still needs the prefix to stop landscape text inflation. */
  /* stylelint-disable-next-line property-no-vendor-prefix */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  hanging-punctuation: first;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1.125rem/1.6 var(--serif);
  font-kerning: normal;
  font-variant-numeric: lining-nums proportional-nums;
  overflow-wrap: break-word;
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

.wrap {
  max-width: calc(var(--measure) + 2.5rem);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  line-height: 1.15;
  text-wrap: balance;
}

p,
dd,
li {
  text-wrap: pretty;
}

/* Links read as text with an accent rule beneath; only the primary actions are set in the accent. */
a {
  color: var(--ink);
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

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

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

.skip {
  position: absolute;
  left: 1rem;
  top: -10rem;
  z-index: 1;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--sans);
}

.skip:focus {
  top: 1rem;
}

.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.nw {
  white-space: nowrap;
}

/* Small sans for dates and metadata: a second voice, never the reading voice. */
.when,
.where,
dt,
.note {
  font-family: var(--sans);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Masthead */
.masthead {
  padding-block: 3rem 1.25rem;
}

h1 {
  font-size: clamp(3.25rem, 2rem + 6vw, 6rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 0.95;
}

.lede {
  max-width: 20ch;
  margin: 1.25rem 0 0;
  font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.125rem);
  font-style: italic;
  line-height: 1.25;
}

.where {
  margin: 1.25rem 0 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.5rem;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
  font-family: var(--sans);
  font-size: 1rem;
}

.actions a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
}

.actions .primary {
  color: var(--accent);
  font-weight: 600;
}

/* Sections: a heavy rule, then the heading. On wide screens the heading moves to a left rail. */
section {
  padding-block: 1.25rem 2rem;
}

section:focus {
  outline: none;
}

section > h2 {
  margin-bottom: 0.5rem;
  padding-top: 0.75rem;
  border-top: 2px solid var(--ink);
  font-size: 1.0625rem;
  font-style: italic;
  font-weight: 500;
}

/* Work */
.cards {
  margin: 0;
  padding: 0;
  list-style: none;
}

.cards > li + li {
  border-top: 1px solid var(--rule);
}

.card {
  padding-block: 1.5rem 1.75rem;
}

.card .when {
  margin: 0;
}

.card h3 {
  margin: 0.25rem 0 1rem;
  font-size: clamp(1.5rem, 1.3rem + 0.8vw, 1.875rem);
  letter-spacing: -0.01em;
}

dl {
  margin: 0;
}

dt {
  margin-top: 0.875rem;
  font-weight: 600;
  color: var(--ink);
}

dt:first-child {
  margin-top: 0;
}

dd {
  margin: 0.125rem 0 0;
}

.note {
  margin: 1rem 0 0;
}

.go {
  margin: 0.5rem 0 0;
  font-family: var(--sans);
  font-size: 1rem;
}

.go a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--accent);
  font-weight: 600;
}

/* The result row carries the evidence: its figures are set semibold so a skim lands on them. */
.card dd:last-of-type .nw {
  font-weight: 600;
}

/* Background and credentials */
.list,
.creds {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Different list from .cards; the order cannot conflict. */
/* stylelint-disable-next-line no-descending-specificity */
.list > li {
  padding-block: 1rem;
}

.list > li + li {
  border-top: 1px solid var(--rule);
}

.list h3 {
  font-size: 1.1875rem;
}

.list .when {
  margin: 0.125rem 0 0.375rem;
}

.list p:last-child {
  margin: 0;
}

/* Different elements from .cards items; the specificity order cannot conflict. */
/* stylelint-disable-next-line no-descending-specificity */
.creds li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0 1rem;
  padding-block: 0.25rem;
  border-bottom: 1px solid var(--rule);
}

.creds li:last-child {
  border-bottom: 0;
}

.creds a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.creds li > span:first-child {
  padding-block: 0.6rem;
}

/* Footer */
.foot {
  padding-block: 0 4rem;
}

/* The rule sits inside the padding so it lines up with the text column, like the section rules. */
.foot::before {
  content: "";
  display: block;
  margin-bottom: 0.5rem;
  border-top: 2px solid var(--ink);
}

.foot .actions {
  margin-top: 0;
}

.foot .when {
  margin: 0.5rem 0 0;
}

/* Tablet and up: problem / what I did / result as a two-column grid. */
@media (width >= 40rem) {
  .card dl {
    display: grid;
    grid-template-columns: 7.5rem 1fr;
    gap: 0.75rem 1.5rem;
  }

  .card dt {
    margin: 0;
    padding-top: 0.2rem;
  }

  .card dd {
    margin: 0;
  }
}

/* Desktop: a left rail for section names, the reading column on the right. */
@media (width >= 64rem) {
  .wrap {
    max-width: calc(var(--rail) + var(--gutter) + var(--measure) + 2.5rem);
  }

  .masthead {
    padding-block: 6rem 3.5rem;
  }

  section {
    display: grid;
    grid-template-columns: var(--rail) 1fr;
    column-gap: var(--gutter);
    max-width: calc(var(--rail) + var(--gutter) + var(--measure));
    padding: 0 0 2.5rem;
    border-top: 2px solid var(--ink);
  }

  /* One unbroken rule per section (on the section itself), not one per column. */
  section > h2 {
    margin: 0;
    padding-top: 1.5rem;
    border-top: 0;
  }

  .cards > li:first-child .card,
  .list > li:first-child {
    padding-top: 1.5rem;
  }

  .creds li:first-child {
    padding-top: 0.75rem;
  }

  .foot .actions,
  .foot .when {
    margin-left: calc(var(--rail) + var(--gutter));
  }
}

@media print {
  .skip {
    display: none;
  }

  a {
    color: inherit;
  }

  .go a::after,
  .creds a::after {
    content: " (" attr(href) ")";
    font-weight: 400;
  }
}
