/* The shell every page shares: page ground, top bar, footer, and the two
 * texture rules that carry meaning.
 *
 * Texture encodes attribution, not severity — BRAND.md §6.2. Solid = covered,
 * hatch = accounted for (the signature blob, or a later signature), stipple =
 * nothing signs these bytes. One hue, one tone. Ink density descends with
 * presence, so an uncovered region is the quietest part of a bar rather than
 * the loudest, and that survives inversion. */

* { box-sizing: border-box; }

body {
  margin: 0;
  /* The footer belongs at the bottom of the viewport when a page is shorter
     than one, and after the content when it is longer. */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  background-image: radial-gradient(1100px 560px at 84% -16%, var(--glow), transparent 62%);
  background-attachment: fixed;
  color: var(--body);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.wrap, .shell, .page { flex: 1 0 auto; }

/* --- Reading progress --------------------------------------------------- */

/* A hairline of `--signal` across the top edge, filling as the page scrolls. It began on
   the whitepaper and belongs on every route: it is the only thing on these pages that says
   how much is left, and a long document without it reads as unbounded.
 *
 * **Dark only, deliberately.** On the light ground the same hairline reads as a stray rule
 * under the browser chrome rather than as an instrument — there is not enough contrast
 * between `--paper` and the edge of the viewport for a 2px line to belong to the page.
 *
 * **Which theme is showing comes from the reader's clock, not from their OS.** `theme.js`
 * stamps `data-theme` before first paint — light between 08:00 and 20:00 local, dark
 * otherwise — so the `[data-theme="light"]` rule below is the one that actually fires. The
 * `prefers-color-scheme` rule beside it is reached only when scripting is off and nothing
 * was stamped, which every route here has to survive. Both are declared for the same reason
 * `tokens.css` declares every value three times, and in the same direction: dark is the
 * default, so this shows by default and is switched *off* for light.
 *
 * Width is the only thing that animates, and it needs no layout: `position: fixed` takes it
 * out of flow entirely, so a scroll handler that runs on every frame cannot cost a reflow. */
.progress {
  position: fixed; top: 0; left: 0; height: 2px; width: 0;
  background: var(--signal); z-index: 20; transition: width 0.08s linear;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .progress { display: none; }
}
:root[data-theme="light"] .progress { display: none; }

/* --- Top bar ----------------------------------------------------------- */

.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; padding: 30px 0 0;
}

.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 16px; font-weight: 600; letter-spacing: -0.02em;
  color: var(--fg); user-select: none; text-decoration: none;
  border-radius: 3px;
}
.brand svg { display: block; width: 19px; height: 19px; flex: none; }
.brand:focus-visible { outline: 2px solid var(--signal); outline-offset: 4px; }

/* The mark is the gaps between the runs, so it stays monochrome and takes its
   colours from the theme rather than carrying its own. */
.mark-ground { fill: var(--fg); }
.mark-run { fill: var(--paper); }

/* --- Footer ------------------------------------------------------------ */

.foot {
  flex: none;
  width: 100%;
  max-width: 760px;
  margin-inline: auto;
  padding-inline: 24px;
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 16px; flex-wrap: wrap;
  margin-top: 56px; padding: 18px 0 26px;
  border-top: 1px solid var(--line);
  font-size: 13px; color: var(--faint);
}
.foot nav { display: flex; gap: 18px; flex-wrap: wrap; }
/* Links rest at body weight and spend the accent on interaction. Resting them
   blue would put all the colour in the quietest corner of the page. */
.foot a { color: var(--body); text-decoration: none; border-radius: 3px; }
.foot a:hover { color: var(--signal); }
.foot a:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; }
.foot .provenance {
  font-family: var(--mono); font-size: 11.5px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* --- Texture ----------------------------------------------------------- */

.seg { position: absolute; top: 0; bottom: 0; }
.seg.covered { background: var(--bar-ink); }
.seg.attributed {
  background-image: repeating-linear-gradient(
    45deg, var(--bar-ink) 0 1.6px, transparent 1.6px 4.6px);
}
.seg.unattributed {
  background-image: radial-gradient(
    circle at center, var(--bar-ink) 0.85px, transparent 1px);
  background-size: 4px 4px;
}

.legend {
  display: flex; flex-wrap: wrap; gap: 18px;
  font-size: 11.5px; color: var(--faint);
}
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 14px; height: 9px; border-radius: 1px; flex: none; }
.legend .k-covered { background: var(--bar-ink); }
.legend .k-attributed {
  background-image: repeating-linear-gradient(
    45deg, var(--bar-ink) 0 1.2px, transparent 1.2px 3.4px);
}
.legend .k-tick { background: var(--line-strong); width: 2px; }
.legend .k-unattributed {
  background-image: radial-gradient(
    circle at center, var(--bar-ink) 0.8px, transparent 1px);
  background-size: 3.4px 3.4px;
}

/* Values an integrator copies. Click selects, and the accent confirms that
   something happened — interaction again, never content. */
.pick { border-radius: 3px; cursor: pointer; transition: color 0.13s ease; }
.pick:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.pick.picked { color: var(--signal); }

.sr {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media print {
  .top, .foot { display: none !important; }
}
