/*
 * Alluv design system, direction "Estuary"; DESIGN.md has the rationale.
 * Dark only: one palette, river water at depth, hairline rules, no card fills.
 * Running text is set in the serif; the sans is for controls and metadata.
 * Pages are documents, not landing pages: one column, figures with captions,
 * plain numbering, and no ornament that a template would have supplied.
 */

/* Type ------------------------------------------------------------------ */
@font-face {
  font-family: Manrope; font-style: normal; font-weight: 400;
  font-display: swap; src: url("fonts/manrope-400.ttf") format("truetype");
}
@font-face {
  font-family: Manrope; font-style: normal; font-weight: 600;
  font-display: swap; src: url("fonts/manrope-600.ttf") format("truetype");
}
@font-face {
  font-family: Newsreader; font-style: normal; font-weight: 400;
  font-display: swap; src: url("fonts/newsreader.ttf") format("truetype");
}

/* Tokens ---------------------------------------------------------------- */
:root {
  color-scheme: dark;

  /* Color: cool, deep water with a verdigris accent. */
  --paper: #0e1518;
  --ink: #e4ebe8;
  --muted: #9aaba8;
  --accent: #a8c4ba;
  --line: #4a5e5c66;      /* decorative only, never an essential boundary */
  --field-line: #5f7672;  /* essential control boundaries, 3:1 on paper */
  --error: #f0b7ab;

  /* Artwork ink, read by alluv.js: one color, as r,g,b. */
  --art-line: 206,222,216;

  /* Families. */
  --serif: Newsreader, Georgia, serif;
  --sans: Manrope, system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Type scale: display steps are fluid, text steps are fixed. */
  --text-xs: 11px;
  --text-sm: 13px;
  --text-md: 16px;
  --text-lg: 19px;
  --display-sm: clamp(26px, 2.8vw, 34px);
  --display-md: clamp(34px, 4.4vw, 44px);
  --display-lg: clamp(44px, 6vw, 56px);
  --display-xl: clamp(52px, 8vw, 84px);

  /* Space: a 4px base, named by step. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;

  --gutter: clamp(16px, 5.5vw, 80px);
  --measure: 60ch;
  --shell: 1360px;
  --radius: 4px;
  --target: 52px;

  background: var(--paper);
  color: var(--ink);
  font: 400 var(--text-md)/1.6 var(--sans);
}

/* Base ------------------------------------------------------------------ */
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
img, svg, canvas { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
::selection { background: var(--accent); color: var(--paper); }

h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0; text-wrap: balance; }
h1 { font-size: var(--display-lg); line-height: 1.08; letter-spacing: -.035em; }
h2 { font-size: var(--display-sm); line-height: 1.2; letter-spacing: -.02em; }
h3 { font-size: var(--text-lg); line-height: 1.3; letter-spacing: -.01em; }
p { margin: 0; }

a { color: var(--ink); text-decoration: underline; text-decoration-color: currentColor; text-decoration-thickness: 1px; text-underline-offset: .22em; }
a:hover { color: var(--accent); }

code, kbd, samp { font-family: var(--mono); font-size: .88em; }
code { color: var(--accent); }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--space-7) 0; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.skip {
  position: absolute; left: var(--space-4); top: -100px;
  padding: var(--space-2) var(--space-3);
  background: var(--accent); color: var(--paper);
}
.skip:focus { top: var(--space-4); }

/* Shell ----------------------------------------------------------------- */
.shell {
  /* Full-bleed box, centered content: artwork can run to the viewport edge
     and is clipped there, so the page itself never scrolls sideways. */
  min-height: 100svh;
  padding: 0 max(var(--gutter), (100% - var(--shell)) / 2 + var(--gutter));
  overflow-x: clip;
  display: flex;
  flex-direction: column;
}
.masthead, .footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-5);
  color: var(--muted);
}
.masthead { min-height: 100px; border-bottom: 1px solid var(--line); }
.footer { min-height: 76px; border-top: 1px solid var(--line); font-size: var(--text-xs); padding: var(--space-4) 0; }
.footer a { color: var(--muted); }
.main { flex: 1; padding: var(--space-8) 0 var(--space-9); }

/* Wordmark: typographic only, never an image. */
.wordmark { color: var(--ink); font: 400 42px/1 var(--serif); letter-spacing: -2px; text-decoration: none; }
.wordmark:hover { color: var(--ink); }

.nav { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-5); margin: 0; padding: 0; list-style: none; }
.nav a { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); font-size: var(--text-sm); text-decoration: none; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); }
.nav a[aria-current="page"] { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: .4em; }

/* Text ------------------------------------------------------------------ */
.label { color: var(--muted); font-size: var(--text-sm); }
.lede { color: var(--ink); font: 400 22px/1.45 var(--serif); max-width: 52ch; }
.small { color: var(--muted); font-size: var(--text-sm); }
.display { font-size: var(--display-xl); line-height: 1.02; letter-spacing: -.04em; }

/* Running text reads as an essay: the serif, larger, at the measure. */
.prose { max-width: var(--measure); font: 400 19px/1.55 var(--serif); }
.prose > * + * { margin-top: var(--space-4); }
.prose > h2 { margin-top: var(--space-7); }
.prose > h3 { margin-top: var(--space-6); }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose li + li { margin-top: var(--space-2); }
.prose blockquote { margin-left: 0; border-left: 2px solid var(--accent); padding-left: var(--space-4); color: var(--muted); }

/* Code samples and contents: ruled, never boxed. */
.code { margin: var(--space-5) 0; max-width: 100%; overflow-x: auto; padding: var(--space-4) 0; border-block: 1px solid var(--line); font: 400 14px/1.6 var(--mono); }
.code code { font-size: inherit; color: var(--ink); }
.contents { margin: 0; padding-left: 1.4em; font-size: var(--text-md); display: grid; gap: var(--space-2); }

/* Layout ---------------------------------------------------------------- */
.stack > * + * { margin-top: var(--space-5); }
.section { padding: var(--space-8) 0; border-top: 1px solid var(--line); }
.section:first-child { border-top: 0; padding-top: 0; }
.section-head { display: grid; gap: var(--space-3); margin-bottom: var(--space-6); }

/* Hero: the words, then the artwork below as a captioned figure. */
.hero { padding-bottom: var(--space-8); }
.hero-text { display: grid; gap: var(--space-5); max-width: var(--measure); }
.hero .art { margin: var(--space-7) 0 var(--space-6); min-height: 240px; }
.hero-compact .art { min-height: 190px; }
.caption { position: absolute; left: 0; top: 100%; margin-top: var(--space-2); color: var(--muted); font-size: var(--text-sm); }

/* About-style page: one column, heading above its text, like an essay. */
.about-row { display: grid; gap: var(--space-4); }
.about-row > * { max-width: var(--measure); }
.about-row .details { border: 0; padding: 0; }
.principles { margin: 0; padding: 0; list-style: none; counter-reset: principle; }
.principles > li { counter-increment: principle; }
.principles > li { border-top: 0; padding-block: var(--space-6); }
.principles > li:first-child { border-top: 1px solid var(--line); padding-top: var(--space-8); }
.principles h2::before { content: counter(principle) ". "; color: var(--muted); }

/* Index: a ruled list of entries, the umbrella's primary component. */
.index { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); padding-top: var(--space-3); }
.index-item { display: grid; gap: var(--space-4); padding: var(--space-5) 0; }
.index-text { max-width: var(--measure); }
.index-name { font: 400 var(--display-sm)/1.2 var(--serif); letter-spacing: -.02em; }
.index-name a { text-decoration: none; }
.index-name a::after { content: ""; position: absolute; inset: 0; }
.index-text { position: relative; display: grid; gap: var(--space-1); }
.index-text:hover .index-name a { color: var(--accent); }
.index-text:focus-within { outline: 2px solid var(--accent); outline-offset: 4px; }
.index-name a:focus-visible { outline: 0; }
.index-desc { color: var(--muted); font: 400 18px/1.5 var(--serif); }
.index-meta { color: var(--muted); font-size: var(--text-sm); }

/* Definition list: label over value, ruled top and bottom. */
.details { margin: 0; border-block: 1px solid var(--line); padding: var(--space-5) 0; display: grid; gap: var(--space-4); }
.details dt { color: var(--muted); font-size: 12px; margin-bottom: var(--space-1); }
.details dd { margin: 0; overflow-wrap: anywhere; }

/* Controls -------------------------------------------------------------- */
.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--target); padding: var(--space-3) 18px;
  border: 1px solid var(--accent); border-radius: var(--radius);
  background: var(--accent); color: var(--paper);
  font: 600 14px/1.5 var(--sans); text-decoration: none; cursor: pointer;
}
.button:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.button-quiet { background: transparent; color: var(--ink); border-color: var(--field-line); }
.button-quiet:hover { background: transparent; color: var(--ink); border-color: var(--accent); }

.field { display: grid; gap: 9px; }
.field label { font-size: var(--text-sm); }
.field input, .field textarea, .field select {
  width: 100%; min-width: 0; min-height: var(--target);
  padding: var(--space-3) 14px;
  border: 1px solid var(--field-line); border-radius: var(--radius);
  background: var(--paper); color: var(--ink);
  font: inherit;
}
.field input:hover, .field textarea:hover, .field select:hover { border-color: var(--accent); }

.message { border-left: 2px solid var(--accent); padding-left: var(--space-4); overflow-wrap: anywhere; font-size: 14px; }
.message-error { border-color: var(--error); color: var(--error); }

/* Tables: rules, not stripes. */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { color: var(--muted); font-weight: 400; font-size: 12px; text-align: left; }
.table th, .table td { padding: var(--space-3) var(--space-4) var(--space-3) 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap { overflow-x: auto; }
.table-wrap + .prose { margin-top: var(--space-5); }

/* Artwork --------------------------------------------------------------- */
/* Decorative and static. Always aria-hidden, never in a hit area. */
.art { position: relative; min-height: 420px; pointer-events: none; }
/* Runs from the column to the viewport's right edge; .shell clips it there. */
.cloud { position: absolute; top: 0; left: 0; width: calc(100% + max(var(--gutter), (100vw - var(--shell)) / 2 + var(--gutter))); height: 100%; max-width: none; }

/* Margin sketches: a small still drawing beside a section or an entry, with
   its caption, like a figure in a field notebook. Stacked below the text on
   narrower screens. */
.margin { position: relative; margin: 0; max-width: 320px; pointer-events: none; }
.margin .caption { position: static; margin-top: var(--space-2); }
.sketch { display: block; width: 100%; height: 170px; }
@media (min-width: 1180px) {
  .about-row, .index-item { grid-template-columns: minmax(0, 640px) 320px; column-gap: var(--space-9); align-items: start; }
  .about-row { grid-template-rows: auto 1fr; }  /* a tall sketch grows the text row, not the heading's */
  .about-row > :not(.margin) { grid-column: 1; }
  .about-row > .margin { grid-column: 2; grid-row: 1 / span 2; }
}

/* Design-system reference page only. */
.swatch-chip { display: block; width: 48px; height: 28px; border: 1px solid var(--line); border-radius: var(--radius); }
.specimen { display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: var(--space-2) var(--space-5); align-items: baseline; padding: var(--space-4) 0; border-bottom: 1px solid var(--line); }
.specimen > :first-child { color: var(--muted); font-size: 12px; font-family: var(--mono); }
.space-bar { height: 12px; background: var(--accent); border-radius: 2px; }

/* Responsive ------------------------------------------------------------ */
@media (max-width: 760px) {
  .masthead { min-height: 80px; padding: var(--space-4) 0; }
  .main { padding: var(--space-6) 0 var(--space-8); }
  /* The figure runs edge to edge; its caption keeps to the gutter. */
  .hero .art { min-height: 240px; margin-inline: calc(-1 * var(--gutter)); }
  .hero .caption { left: var(--gutter); }
  .hero-compact .art { min-height: 200px; }
  .section, .principles > li:first-child { padding-block: var(--space-7); }
  .specimen { grid-template-columns: 1fr; }
}

@media (forced-colors: active) {
  .art, .margin { display: none; }
  .button { border-color: ButtonText; }
  .index-item:focus-within { outline-color: Highlight; }
}

@media print {
  :root { --paper: #fff; --ink: #000; --muted: #444; --accent: #000; --line: #ccc; color-scheme: light; }
  body { background: #fff; }
  .art, .margin, .nav, .skip { display: none; }
}
