/* ==========================================================================
   Base: reset, elements, typography, layout primitives.
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Anchors must not land underneath the fixed header. */
  scroll-padding-top: calc(var(--header-h) + 1.5rem);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink-2);
  font-family: var(--font-ui);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* `clip` (not `hidden`) so position:sticky keeps working inside. */
  overflow-x: clip;
}

img, picture, video, svg { display: block; max-width: 100%; }
img { height: auto; background: var(--stone); }

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 400; color: var(--text-strong); }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
figure { margin: 0; }

a { color: inherit; text-decoration: none; }

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }

::selection { background: var(--ink); color: var(--paper); }
.chapter--dark ::selection { background: var(--d-bronze); color: var(--d-ground); }

/* --- Focus ---------------------------------------------------------------
   Visible, high-contrast, and never removed. */
:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 3px;
  border-radius: 1px;
}
.chapter--dark :focus-visible { outline-color: var(--d-bronze); }

.skip-link {
  position: absolute;
  left: 1rem; top: 0;
  transform: translateY(-140%);
  z-index: 200;
  background: var(--ink);
  color: var(--paper);
  padding: 0.75rem 1.25rem;
  font-size: var(--fs-small);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: transform var(--t-fast) var(--ease);
}
.skip-link:focus-visible { transform: translateY(0.75rem); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* [hidden] must beat any later display rule. */
[hidden] { display: none !important; }

/* ==========================================================================
   Typography
   ========================================================================== */

.display,
.h1, .h2, .h3 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: var(--track-tight);
  color: var(--text-strong);
}

.display { font-size: var(--fs-display); line-height: var(--lh-display); }
.h1 { font-size: var(--fs-h1); line-height: var(--lh-head); }
.h2 { font-size: var(--fs-h2); line-height: var(--lh-head); }
.h3 { font-size: var(--fs-h3); line-height: 1.16; }

.h4 {
  font-family: var(--font-ui);
  font-size: var(--fs-h4);
  font-weight: 600;
  line-height: 1.34;
  letter-spacing: -0.005em;
  color: var(--text-strong);
}

/* Small tracked caps — the metadata voice used throughout the site. */
.meta {
  font-family: var(--font-ui);
  font-size: var(--fs-meta);
  font-weight: 600;
  letter-spacing: var(--track-meta);
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1.4;
}
.meta--accent { color: var(--accent-text); }
.meta--strong { color: var(--text-strong); }

.lead {
  font-size: var(--fs-lead);
  line-height: 1.5;
  color: var(--text);
  max-width: 46ch;
}

.prose { max-width: var(--maxw-text); }
.prose > * + * { margin-top: 1.15em; }
.prose p { color: var(--text); }
.prose a {
  color: var(--accent-text);
  text-decoration: underline;
  text-underline-offset: 0.22em;
  text-decoration-thickness: 1px;
}
.prose a:hover { text-decoration-thickness: 2px; }

.num {
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

/* Italic display, used sparingly for emphasis inside serif headlines. */
.em { font-style: italic; }
.accent { color: var(--accent-text); }

/* ==========================================================================
   Layout primitives
   ========================================================================== */

.shell {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--pad-x);
}

.shell--narrow { max-width: 1100px; }
.shell--wide { max-width: 1860px; }

.section { padding-block: var(--section); }
.section--sm { padding-block: var(--section-sm); }
.section--flush-top { padding-top: 0; }
.section--flush-bottom { padding-bottom: 0; }

.chapter--dark .section { position: relative; }

/* The section marker: an index, a title and a rule that runs to the edge. */
.marker {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding-bottom: 1.1rem;
  margin-bottom: clamp(2rem, 4vw, 3.5rem);
  border-bottom: 1px solid var(--rule);
}
.marker__index {
  font-family: var(--font-ui);
  font-size: var(--fs-meta);
  font-weight: 700;
  letter-spacing: var(--track-meta);
  color: var(--accent-text);
  flex: none;
}
.marker__title {
  font-family: var(--font-ui);
  font-size: var(--fs-meta);
  font-weight: 600;
  letter-spacing: var(--track-meta);
  text-transform: uppercase;
  color: var(--text-muted);
}
.marker__aside { margin-left: auto; }

.rule { height: 1px; background: var(--rule); border: 0; margin: 0; }

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

/* Split layouts — asymmetric by default, because symmetry reads as a template. */
.split {
  display: grid;
  gap: clamp(2rem, 5vw, 5rem);
  align-items: start;
}
.split--text-image { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
.split--image-text { grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); }
.split--wide-narrow { grid-template-columns: minmax(0, 7fr) minmax(0, 4fr); }
.split--narrow-wide { grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); }
.split--even { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.stack > * + * { margin-top: var(--flow, 1.25rem); }
.stack--tight { --flow: 0.6rem; }
.stack--loose { --flow: 2rem; }

/* ==========================================================================
   Media frames
   ========================================================================== */

.frame {
  position: relative;
  overflow: hidden;
  background: var(--stone);
}
.frame > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.frame--ar    { aspect-ratio: var(--ar, 4 / 3); }
.frame--tall  { aspect-ratio: 3 / 4; }
.frame--taller{ aspect-ratio: 2 / 3; }
.frame--wide  { aspect-ratio: 16 / 10; }
.frame--panoramic { aspect-ratio: 21 / 9; }
.frame--square { aspect-ratio: 1; }

/* The arcade device. */
.frame--arch { border-radius: var(--arch); }

figcaption,
.caption {
  margin-top: 0.75rem;
  font-size: var(--fs-meta);
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
}
.caption__plate { color: var(--accent-text); font-weight: 700; flex: none; }

/* Utilities used sparingly. */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.full-bleed {
  width: 100vw;
  margin-inline: calc(50% - 50vw);
  max-width: 100vw;
}
