/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Tokens ── */
:root {
  --bg:            #ffffff;
  --text:          #161616;
  --text-secondary:#525252;
  --border:        #e0e0e0;
  --accent:        #97630e;   /* readable gold — accent text, links, numbers (AA on white) */
  --accent-bright: #eeb462;   /* brand gold — decorative: bullets, on-dark accents */
  --accent-inv:    #eeb462;   /* gold on dark backgrounds (hover states) */
  --focus:         #97630e;

  --font-sans:  'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
  --font-serif: 'IBM Plex Serif', Georgia, 'Times New Roman', serif;
  --font-mono:  'IBM Plex Mono', 'Menlo', monospace;

  /* Carbon spacing scale */
  --sp-02: 0.25rem;   /*  4 */
  --sp-03: 0.5rem;    /*  8 */
  --sp-05: 1rem;      /* 16 */
  --sp-06: 1.5rem;    /* 24 */
  --sp-07: 2rem;      /* 32 */
  --sp-08: 2.5rem;    /* 40 */
  --sp-09: 3rem;      /* 48 */
  --sp-10: 4rem;      /* 64 */

  --max-w: 42rem;
}

/* ── Base ── */
html { font-size: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--sp-05);
}

/* ── Focus ── */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ── Skip link (WCAG 2.4.1) ── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--text);
  color: var(--bg);
  padding: var(--sp-03) var(--sp-05);
  text-decoration: none;
}
.skip-link:focus { left: 0; }

/* ── Header ── */
header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-05);
  padding: var(--sp-06) 0;
  border-bottom: 1px solid var(--text);
}

.site-name {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-03);
  font-weight: 400;
  font-size: 0.875rem;
  text-decoration: none;
  color: var(--text);
}
.logo {
  display: block;
  height: 1.5rem;
  width: auto;
}

nav { display: flex; gap: var(--sp-05); }

nav a {
  font-size: 0.875rem;
  color: var(--text);
  text-decoration: none;
  padding: var(--sp-02) var(--sp-03);
  transition: color 0.1s, background-color 0.1s;
}
nav a:hover,
nav a:focus-visible {
  color: var(--bg);
  background: var(--text);
  outline: none;
}
nav a[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Accent text ── */
.accent { color: var(--accent); }

/* ── Lead ── */
.lead { padding: var(--sp-10) 0 0; }
.lead p {
  font-size: 1.5rem;
  line-height: 1.4;
  font-weight: 300;
  max-width: 38rem;
}

/* ── Sections ── */
section {
  padding-top: var(--sp-10);
  padding-bottom: var(--sp-09);
}
section + section { border-top: 1px solid var(--border); }
.lead + section { border-top: none; }

section h2 {
  font-family: var(--font-serif);
  font-size: 2.25rem;
  font-weight: 300;
  line-height: 1.2;
  margin-bottom: var(--sp-06);
}

/* ── Entry list ── */
.entries {
  list-style: none;
  padding-left: var(--sp-07);
}

.entries a {
  display: block;
  padding: var(--sp-06) var(--sp-05);
  margin: 0 calc(-1 * var(--sp-05));
  text-decoration: none;
  color: var(--text);
  transition: color 0.1s, background-color 0.1s;
}
.entries a:hover {
  background: var(--text);
  color: var(--bg);
}

.entries h3 {
  font-size: 1rem;
  font-weight: 400;
  margin-bottom: var(--sp-02);
  color: var(--accent);
}

.entries p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.entries a:hover p { color: #c6c6c6; }

.entries a:hover h3 { color: var(--bg); }

.see-all {
  display: inline-block;
  margin-top: var(--sp-06);
  margin-left: var(--sp-07);
  font-size: 0.875rem;
  color: var(--text);
  text-decoration: none;
  padding: var(--sp-02) var(--sp-03);
  border: 1px solid var(--text);
  transition: color 0.1s, background-color 0.1s;
}
.see-all:hover {
  color: var(--bg);
  background: var(--text);
}

/* "All cases"-style buttons reused inside entry cards / prose (Contact page) */
.entries li .see-all {
  display: inline-block;
  margin: var(--sp-05) 0 0;
  padding: var(--sp-02) var(--sp-03);
  border: 1px solid var(--text);
  background: none;
  color: var(--text);
  text-decoration: none;
}
.entries li .see-all:hover { color: var(--bg); background: var(--text); }
.prose a.see-all { margin-left: 0; color: var(--text); text-decoration: none; }
.prose a.see-all:hover { color: var(--bg); background: var(--text); }
/* space each call entry away from the next section, and keep its button close to its own text */
.calls li { margin-bottom: var(--sp-08); }

/* ── Partners (warm tinted block) ── */
.partners {
  background:
    radial-gradient(circle at 15% 80%, rgba(186,78,0,0.04) 0%, transparent 50%),
    radial-gradient(circle at 85% 20%, rgba(186,78,0,0.03) 0%, transparent 40%),
    #f9f7f4;
  color: var(--text);
  padding: var(--sp-09) var(--sp-05) var(--sp-09) calc(var(--sp-05) + var(--sp-07));
  margin: 0 calc(-1 * var(--sp-05));
  border-top: none;
}
.partners + section { border-top: none; }
.partners p {
  font-size: 1rem;
  line-height: 1.6;
  max-width: 36rem;
}
.partners a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.partners a:hover { text-decoration-thickness: 2px; }

/* ── Anno Machinae (framed block with image) ── */
.anno {
  display: flex;
  align-items: stretch;
  gap: var(--sp-07);
  background: var(--bg);
  border: 1px solid var(--text);
  padding: var(--sp-07);
  margin: 0 calc(-1 * var(--sp-05));
}
.anno + section { border-top: none; }
.anno-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.anno-title {
  font-family: var(--font-serif);
  font-size: 3rem;
  font-weight: 300;
  line-height: 1.1;
  margin-bottom: var(--sp-06);
  color: var(--accent);
}
.anno p {
  font-size: 1rem;
  line-height: 1.6;
}
.anno p + p { margin-top: var(--sp-05); }
.anno a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.anno a:hover { text-decoration-thickness: 2px; }
.anno-img {
  display: block;
  width: 22rem;
  height: auto;
  flex-shrink: 0;
  object-fit: contain;
}
@media (max-width: 32rem) {
  .anno { flex-direction: column; }
  .anno-img { width: 14rem; align-self: center; order: -1; }
}

/* ── Prose blocks ── */
.prose { padding-left: var(--sp-07); }
.prose p {
  font-size: 1rem;
  line-height: 1.6;
  max-width: 36rem;
}
.prose p + p { margin-top: var(--sp-05); }
.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.prose a:hover { text-decoration-thickness: 2px; }

/* ── Listings (details/summary, join page) ── */
.listings { padding-left: var(--sp-07); }

.listing {
  border-top: 1px solid var(--border);
}
.listing:last-child { border-bottom: 1px solid var(--border); }

.listing summary {
  display: block;
  padding: var(--sp-06) var(--sp-05);
  margin: 0 calc(-1 * var(--sp-05));
  cursor: pointer;
  list-style: none;
  transition: color 0.1s, background-color 0.1s;
}
.listing summary::-webkit-details-marker { display: none; }
.listing summary::marker { display: none; content: ""; }

.listing summary:hover {
  background: var(--text);
  color: var(--bg);
}

.listing summary h3 {
  font-size: 1rem;
  font-weight: 400;
  margin-bottom: var(--sp-02);
  color: var(--accent);
}
.listing summary p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.listing summary:hover h3 { color: var(--bg); }
.listing summary:hover p { color: #c6c6c6; }

.listing-body {
  padding: 0 var(--sp-05) var(--sp-06);
  font-size: 0.875rem;
  line-height: 1.6;
}
.listing-body p + p { margin-top: var(--sp-05); }
.listing-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.listing-body a:hover { text-decoration-thickness: 2px; }

/* ── Single case / article (grid layout) ── */
.case { counter-reset: case-section; padding-top: var(--sp-07); }

/* masthead — the site <header> brands the page, so no running header here */
.case-head { padding-bottom: var(--sp-07); }
.case h1 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 3rem;
  line-height: 1.05;
  letter-spacing: -0.025em;
  max-width: 18ch;
  margin-bottom: var(--sp-06);
}
.case .deck {
  font-weight: 300;
  font-size: 1.5rem;
  line-height: 1.32;
  color: var(--text-secondary);
  max-width: 34ch;
}

/* sections: numbered rail + body */
.case section {
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  gap: 0 var(--sp-06);
  padding: var(--sp-08) 0;
  border-top: 1px solid var(--border);
  counter-increment: case-section;
}
.case section > * { grid-column: 2; min-width: 0; max-width: 38rem; }
.case section::before {
  content: counter(case-section, decimal-leading-zero);
  grid-column: 1;
  grid-row: 1;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--accent);
  padding-top: 0.3rem;
}

.case h2 {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 1.35rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: var(--sp-05);
}

.case p { font-size: 1rem; line-height: 1.6; }
.case p + p { margin-top: var(--sp-05); }
.case b { font-weight: 600; }
.case a { color: var(--accent); text-decoration: none; border-bottom: 1px solid #e3cda0; }
.case a:hover { border-bottom-color: var(--accent); }

.case ul { list-style: none; margin: var(--sp-05) 0; }
.case li {
  position: relative;
  padding-left: var(--sp-06);
  margin-bottom: var(--sp-03);
  font-size: 0.9375rem;
  line-height: 1.55;
}
.case li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.58em;
  width: 7px;
  height: 7px;
  background: var(--accent-bright);
}

.case code {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  background: #f4f4f4;
  padding: 0.05rem 0.3rem;
}

/* video figures */
.case figure { margin: var(--sp-06) 0 var(--sp-02); }
.case figure video,
.case figure:not(.photo) > img {
  display: block;
  width: 100%;
  height: auto;
  background: #000;
  border: 1px solid var(--border);
}
.case figure .fallback { display: block; padding: var(--sp-06); font-size: 0.875rem; }
.case figcaption {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-06);
  margin-top: var(--sp-05);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text-secondary);
}
.case .figlabel {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
  padding-top: 0.2em;
}
.case figcaption b { color: var(--text); font-weight: 600; }

/* photo figures (historical / editorial images) */
/* Photos break out of the text column and align with the section-number rail
   (01, 02, 03…): tall ones hug the left edge, wide ones span the full grid. */
.case figure.photo { margin: var(--sp-07) 0; }
.case section > figure.photo { grid-column: 1 / -1; max-width: none; }
/* tall photos sit at the rail with their caption set to the right, aligned to the base */
.case figure.photo.tall { display: flex; align-items: flex-end; gap: var(--sp-06); }
.case figure.photo.tall img { width: 18rem; flex: none; }
.case figure.photo.tall figcaption { max-width: 20rem; margin-top: 0; padding-bottom: var(--sp-02); }
.case figure.photo:not(.tall) figcaption { max-width: 38rem; }
.case figure.photo img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  background: #f4f4f4;
}
.case figure.photo figcaption {
  display: block;
  margin-top: var(--sp-03);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-secondary);
}
.case figure.photo figcaption .credit { display: block; margin-top: var(--sp-02); }
.case figure.photo figcaption a { color: var(--text-secondary); border-bottom: 1px solid var(--border); }
.case figure.photo figcaption a:hover { border-bottom-color: var(--accent); }

/* math */
.case .math {
  background: #f4f4f4;
  padding: var(--sp-06);
  margin: var(--sp-06) 0;
  overflow-x: auto;
}
.case .math math { display: block; font-size: 1.0625rem; text-align: left; margin: 0.6em 0; }
.case .math math:first-of-type { margin-top: 0; }
.case .math math:last-of-type { margin-bottom: 0; }
.case .math math.cont { margin-top: 0.25em; margin-left: 2.8em; }
.case .math .lbl { color: var(--accent); }
.case .math .note { color: var(--text-secondary); font-size: 0.82em; }
/* optimization-problem tables: left-align rows, give columns real gaps */
.case .math mtd { text-align: left; padding-block: 0.14em; }
.case .math mtd:nth-child(1) { padding-right: 0.8em; }
.case .math mtd:nth-child(2) { padding-right: 1.8em; }

/* commission / context line in the case head */
.case .meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.55;
  letter-spacing: 0.01em;
  color: var(--text-secondary);
  margin-top: var(--sp-05);
  max-width: 38rem;
}
.case .meta b { color: var(--text); font-weight: 600; }

/* related-cases cross-link block */
.case .related {
  background:
    radial-gradient(circle at 10% 80%, rgba(151,99,14,0.05) 0%, transparent 55%),
    radial-gradient(circle at 90% 15%, rgba(151,99,14,0.03) 0%, transparent 45%),
    #f9f7f3;
  border-left: 3px solid var(--accent-bright);
  padding: var(--sp-06) var(--sp-07);
  margin: var(--sp-07) 0;
}
.case .related p {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0;
}
.case .related a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  border-bottom: none;
}
.case .related a:hover { text-decoration-thickness: 2px; }

/* "read first" disclaimer block (sensitive/speculative cases) */
.case .disclaimer {
  border: 1px solid #d8b9bd;
  background: #fbf4f3;
  padding: var(--sp-06) var(--sp-06) var(--sp-03);
  margin: var(--sp-07) 0;
}
.case .disclaimer h2 {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #8a2b34;
  margin: 0 0 var(--sp-05);
}
.case .disclaimer ul { list-style: none; margin: 0; }
.case .disclaimer li {
  position: relative;
  padding-left: var(--sp-06);
  margin-bottom: var(--sp-05);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: #3a2a26;
}
.case .disclaimer li::before {
  content: "\2014";
  position: absolute;
  left: 0;
  top: 0;
  width: auto;
  height: auto;
  background: none;
  color: #8a2b34;
}
.case .disclaimer b { color: #8a2b34; font-weight: 600; }

/* unnumbered sections — lead (intro hero) and coda (closing / credits) */
.case section.lead,
.case section.coda { counter-increment: none; }
.case section.lead::before,
.case section.coda::before { content: none; }

/* portrait avatars (historical figures, people) — square, in the left rail */
.case p,
.case blockquote { position: relative; }
.case .portrait {
  position: absolute;
  top: 0.3rem;
  left: calc(-3.5rem - var(--sp-06));
  width: 2.5rem;
  height: 2.5rem;
  overflow: hidden;
  background: #f4f4f4;
  border: 1px solid var(--border);
}
.case .portrait img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* pull quote */
.case blockquote {
  margin: var(--sp-06) 0;
  padding-left: var(--sp-05);
  border-left: 3px solid var(--accent-bright);
  font-size: 1.2rem;
  line-height: 1.45;
  font-weight: 300;
}
.case blockquote cite {
  display: block;
  margin-top: var(--sp-03);
  font-style: normal;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* small-print notes and credits */
.case .note { color: var(--text-secondary); }
.case .credits { font-size: 0.8125rem; line-height: 1.7; color: var(--text-secondary); }
.case .credits a { border-bottom-color: var(--border); }

/* data tables */
.case table.stats {
  width: 100%;
  border-collapse: collapse;
  margin: var(--sp-06) 0;
  font-size: 0.875rem;
}
.case table.stats caption {
  caption-side: top;
  text-align: left;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: var(--sp-03);
}
.case table.stats th,
.case table.stats td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.case table.stats thead th {
  font-weight: 600;
  color: var(--text);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.case table.stats td { font-family: var(--font-mono); }
.case table.stats td.num,
.case table.stats th.num { text-align: right; }
.case table.stats td.num { white-space: nowrap; }
.case table.stats tr.highlight td { color: var(--accent); font-weight: 600; }

/* keyboard mockup: two ortholinear hand-blocks, no stagger, table-as-keys */
.case figure.keyboard { grid-column: 1 / -1; max-width: none; margin: var(--sp-07) 0; }
.case figure.keyboard figcaption {
  display: block;
  max-width: 38rem;
  margin: var(--sp-05) auto 0;
  padding: 0;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--text-secondary);
}
.keyboard-halves {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: clamp(1.5rem, 6vw, 4rem);
  padding: var(--sp-05) 0;
}
.hand { border-collapse: separate; border-spacing: 0.4rem; margin: 0 auto; }
.hand caption {
  caption-side: bottom;
  padding-top: var(--sp-03);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.hand td {
  width: 2.75rem;
  height: 2.75rem;
  text-align: center;
  vertical-align: middle;
  font-family: var(--font-mono);
  font-size: 1.0625rem;
  text-transform: uppercase;
  color: var(--text);
  background: #fbfbfb;
  border: 1px solid var(--border);
  border-radius: 0.3rem;
}
.hand td.home {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
  background: #fdf6ea;
}
.hand td.empty { border-style: dashed; background: transparent; }

@media (max-width: 32rem) {
  .case h1 { font-size: 2.25rem; }
  .case section { grid-template-columns: 1fr; gap: 0; }
  .case section > * { grid-column: 1; }
  .case section::before { grid-row: auto; padding-top: 0; margin-bottom: var(--sp-03); }
  /* tall photos stack their caption below the image on narrow screens */
  .case figure.photo.tall { flex-direction: column; align-items: stretch; gap: var(--sp-03); }
  .case figure.photo.tall img { width: 100%; }
  .case figure.photo.tall figcaption { max-width: none; padding-bottom: 0; }
  /* no rail on narrow screens — portraits become small inline squares */
  .case .portrait {
    position: static;
    display: inline-block;
    vertical-align: text-bottom;
    width: 1.9rem;
    height: 1.9rem;
    margin: 0 0.4rem -0.3rem 0;
  }
  .case table.stats { font-size: 0.8125rem; }
  .case table.stats th, .case table.stats td { padding: 0.4rem 0.5rem; }
  .hand { border-spacing: 0.25rem; }
  .hand td { width: 2.1rem; height: 2.1rem; font-size: 0.875rem; }
  .keyboard-halves { gap: var(--sp-06); }
}

/* "Also via" block — Gemini / Gopher / WCAG, propagated to every page */
.via {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: var(--sp-07) 0 var(--sp-05);
}
.via a { color: var(--text-secondary); text-decoration: underline; text-underline-offset: 2px; }
.via a:hover { color: var(--text); }
.via + section { padding-top: var(--sp-07); }

/* ── Footer ── */
footer {
  border-top: 1px solid var(--text);
  padding: var(--sp-06) 0 var(--sp-09);
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-06);
  flex-wrap: wrap;
}
footer p { margin: 0.15rem 0; }
footer a {
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 2px;
}
footer a:hover { color: var(--text); }
.links-badge { text-decoration: none; flex: none; }
.links-badge img { image-rendering: pixelated; }

/* ── Print ── */
@media print {
  body { max-width: none; }
  nav a { padding: 0; }
  nav a:hover { color: var(--text); background: none; }
  .entries a:hover { background: none; color: var(--text); }
  .partners { background: none; }
  .anno { border: 1px solid var(--border); }
  .anno-img { display: none; }
  .case figure { break-inside: avoid; }
}
