/* moonast — the site's only stylesheet.

   One idea: the library's subject is the annotation, so the site is struck like
   a specimen sheet from a press. Every surface is a plate of steel, every rule
   is a hairline of gold leaf, every corner is cut rather than rounded. Colour
   comes from metal, not from paint: brass, gold leaf, silver, gunmetal.

   Every colour is a token, and every token is light-dark(), so the page flips
   from `color-scheme` alone. Plates stay dark in both themes, the way a struck
   die stays metal on paper or under a lamp. */

/* ---------------------------------------------------------------- tokens */

:root {
  color-scheme: light;

  --ground:      light-dark(#efece4, #0a0a0b);
  --ground-2:    light-dark(#e8e4d9, #0f0f11);
  --surface:     light-dark(#f8f6f0, #121215);

  --ink:         light-dark(#15130f, #f5f1e6);
  --ink-soft:    light-dark(#453f34, #d2c9b7);
  --ink-faint:   light-dark(#6e6656, #928975);

  --line:        color-mix(in oklab, var(--ink) 20%, transparent);
  --line-soft:   color-mix(in oklab, var(--ink) 9%, transparent);

  /* Gold leaf, from the shadowed edge to the burnish. */
  --gold-0: #5d4210;
  --gold-1: #8a6520;
  --gold-2: #b8912f;
  --gold-3: #d8b154;
  --gold-4: #f3dfa0;
  --gold-5: #fdf6d8;

  /* Silver, used for the layer that reads annotations. */
  --silver-1: #8d97a3;
  --silver-2: #c3ccd6;
  --silver-3: #eef3f8;

  --gilt: linear-gradient(
    104deg,
    var(--gold-1) 0%,
    var(--gold-3) 16%,
    var(--gold-5) 30%,
    var(--gold-2) 46%,
    var(--gold-0) 58%,
    var(--gold-4) 74%,
    var(--gold-3) 86%,
    var(--gold-1) 100%
  );
  --gilt-edge: linear-gradient(
    135deg,
    var(--gold-3) 0%,
    var(--gold-1) 22%,
    var(--gold-2) 44%,
    var(--gold-0) 62%,
    var(--gold-3) 84%,
    var(--gold-2) 100%
  );
  --argent: linear-gradient(
    104deg,
    var(--silver-1) 0%,
    var(--silver-3) 34%,
    #a9b3be 55%,
    var(--silver-3) 78%,
    var(--silver-1) 100%
  );

  /* The same leaf used as a surface rather than as type. A gradient designed
     for letterforms carries shadowed bands; under dark ink they swallow it. */
  --gilt-surface: linear-gradient(
    100deg,
    var(--gold-2) 0%,
    var(--gold-4) 22%,
    var(--gold-5) 48%,
    var(--gold-3) 72%,
    var(--gold-2) 100%
  );

  /* Temper: the colour steel takes when it is drawn from the fire — a plum
     indigo with a rose edge. It marks what is selected, never what is
     important, so gold keeps that job to itself. */
  --temper-0: #2c2238;
  --temper-1: #4c3654;
  --rose: #d59a7d;
  --on-temper: #f8f1e5;

  /* Gold that may be used as text on the page ground. */
  --gold-text:  light-dark(#7c5c15, #e9cd85);
  --gold-wash:  light-dark(#f2e8c9, #2b2415);

  /* A struck steel plate: dark in either theme. */
  --steel:          light-dark(#15151a, #131318);
  --steel-2:        light-dark(#1d1d24, #1c1c23);
  --steel-line:     #33323a;
  --on-steel:       #eee9dd;
  --on-steel-dim:   #a49c8c;
  --on-steel-faint: #7c7566;

  --font-display: "Bodoni Moda", "Didot", "Times New Roman", serif;
  --font-body: "Inter Tight", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* Two corners cut, two left square: a plate sheared off the die. */
  --cut: polygon(
    0 0,
    calc(100% - 16px) 0,
    100% 16px,
    100% 100%,
    16px 100%,
    0 calc(100% - 16px)
  );
  --cut-sm: polygon(
    0 0,
    calc(100% - 6px) 0,
    100% 6px,
    100% 100%,
    6px 100%,
    0 calc(100% - 6px)
  );

  --maxw: 1200px;
  --hair: 1px;
}

/* An explicit choice beats the OS; without one, follow it. */
:root:not([data-theme]) { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* --------------------------------------------------------------- ground */

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

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-gutter: stable;
  /* Code is shown as characters, not as glyphs to be admired: `>=` stays two
     characters. Form controls do not inherit. */
  font-variant-ligatures: no-contextual;
}

html,
body { margin: 0; }

body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16.5px;
  line-height: 1.62;
  font-feature-settings: "kern" 1, "calt" 1;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Carded paper: a faint graduation of light across the page, so the ground is
   never a flat fill. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 70% at 50% -20%, color-mix(in oklab, var(--gold-4) 18%, transparent), transparent 62%),
    radial-gradient(80% 50% at 100% 100%, color-mix(in oklab, var(--ink) 6%, transparent), transparent 70%);
  opacity: light-dark(1, 0.5);
}

body > * { position: relative; z-index: 1; }

button,
input,
textarea,
select {
  font: inherit;
  font-variant-ligatures: no-contextual;
  color: inherit;
}

img,
svg { max-width: 100%; }

a {
  color: var(--gold-text);
  text-decoration-color: color-mix(in oklab, var(--gold-text) 45%, transparent);
  text-underline-offset: 3px;
}

a:hover { text-decoration-color: var(--gold-text); }

::selection {
  background: color-mix(in oklab, var(--gold-3) 45%, transparent);
  color: var(--ink);
}

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

/* Chrome ignores ::-webkit-scrollbar once scrollbar-color is set, so the
   standard property is kept out of its way. */
@supports not selector(::-webkit-scrollbar) {
  * {
    scrollbar-color: color-mix(in oklab, var(--gold-1) 60%, var(--ink)) transparent;
    scrollbar-width: thin;
  }
}

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: color-mix(in oklab, var(--ink) 5%, transparent); }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--gold-2), var(--gold-0));
  border: 2px solid var(--ground);
  border-radius: 0;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--gold-4), var(--gold-1));
}
::-webkit-scrollbar-corner { background: transparent; }
pre::-webkit-scrollbar-thumb { border-color: var(--steel); }

/* ------------------------------------------------------------ typography */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.015em;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0 0 1em; }

.display {
  font-size: clamp(2.6rem, 6.6vw, 5.2rem);
  line-height: 0.94;
  letter-spacing: -0.035em;
  font-weight: 500;
}

h2 {
  font-size: clamp(1.65rem, 3vw, 2.5rem);
  line-height: 1.06;
}

h3 {
  font-size: 1.22rem;
  line-height: 1.2;
  letter-spacing: -0.005em;
}

h4 { font-size: 1rem; }

/* A word set in gold leaf: the gradient is the foil, the shadow is the strike.
   A clipped gradient is painted inside the element's own box, and display type
   at a tight leading reaches past it — so the span carries its own padding. */
.gilt {
  display: inline-block;
  background-image: var(--gilt);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding: 0.18em 0.06em;
  margin: -0.18em -0.06em;
  filter: drop-shadow(0 1px 0 color-mix(in oklab, var(--gold-0) 45%, transparent));
}

/* Struck the other way: silver foil. */
.argent {
  background-image: var(--argent);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 1px 0 color-mix(in oklab, #000 30%, transparent));
}

/* The engraved counter-stroke, for a hairline rule of type. */
.eyebrow,
.label {
  font-family: var(--font-body);
  font-size: 0.688rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.label.gold { color: var(--gold-text); }
.label.block { display: block; margin-bottom: 8px; }

.num-index {
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.24em;
  font-variant-numeric: lining-nums;
  color: var(--gold-text);
}

code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.895em;
}

p code,
li code,
td code,
.note code,
blockquote code {
  background: color-mix(in oklab, var(--gold-3) 14%, transparent);
  border: var(--hair) solid color-mix(in oklab, var(--gold-1) 26%, transparent);
  padding: 0.1em 0.32em;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- layout */

.wrap {
  width: min(100% - 44px, var(--maxw));
  margin-inline: auto;
}

@media (width <= 860px) {
  .wrap { width: min(100% - 26px, var(--maxw)); }
}

.band { padding: 74px 0; }
.band + .band { border-top: var(--hair) solid var(--line-soft); }
.band-head { max-width: 62ch; margin-bottom: 34px; }
.band-head h2 { margin: 10px 0 12px; }
.band-head p { color: var(--ink-soft); margin: 0; }

.grid { display: grid; gap: 22px; }
.grid > * { min-width: 0; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (width <= 1000px) {
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (width <= 860px) {
  .band { padding: 52px 0; }
  .grid.two,
  .grid.three,
  .grid.four { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------------------------------------- ornaments */

/* A hairline of gold leaf, tapering at both ends, with a struck lozenge. */
.rule {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0;
  color: var(--gold-2);
}
.rule::before,
.rule::after {
  content: "";
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, transparent, currentColor 18%, currentColor 82%, transparent);
  opacity: 0.8;
}
.rule i {
  width: 7px;
  height: 7px;
  background: var(--gilt-edge);
  rotate: 45deg;
  flex: none;
}

/* Engine-turned ground: interlaced rings, the way a banknote is ruled. */
.guilloche {
  height: 18px;
  box-shadow:
    inset 0 1px 0 color-mix(in oklab, var(--gold-1) 35%, transparent),
    inset 0 -1px 0 color-mix(in oklab, var(--gold-1) 35%, transparent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 22 22'%3E%3Cg fill='none' stroke='%238a6520' stroke-opacity='0.75' stroke-width='0.6'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Ccircle cx='0' cy='0' r='7'/%3E%3Ccircle cx='22' cy='0' r='7'/%3E%3Ccircle cx='0' cy='22' r='7'/%3E%3Ccircle cx='22' cy='22' r='7'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 22px 22px;
  mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
  opacity: 0.6;
}

/* A struck oval around a numeral, as on a coin. */
.coin {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: #2a1f08;
  background: radial-gradient(circle at 34% 26%, var(--gold-5), var(--gold-3) 56%, var(--gold-2));
  border-radius: 50%;
  box-shadow:
    inset 0 1px 0 color-mix(in oklab, #fff 55%, transparent),
    inset 0 -1px 1px color-mix(in oklab, #000 40%, transparent),
    0 1px 0 color-mix(in oklab, #000 22%, transparent);
  text-shadow: 0 1px 0 color-mix(in oklab, #fff 30%, transparent);
}

/* ---------------------------------------------------------------- header */

.top {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in oklab, var(--ground) 88%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: var(--hair) solid var(--line-soft);
}

.top::after {
  content: "";
  position: absolute;
  inset: auto 0 -1px 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--gold-2) 60%, transparent) 30%, color-mix(in oklab, var(--gold-4) 85%, transparent) 50%, color-mix(in oklab, var(--gold-2) 60%, transparent) 70%, transparent);
  opacity: 0.85;
}

.top .wrap {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 62px;
}

.mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.24rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.mark .glyph {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  font-weight: 700;
  color: #241a05;
  background: var(--gilt-surface);
  clip-path: var(--cut-sm);
  box-shadow: inset 0 1px 0 color-mix(in oklab, #fff 60%, transparent);
}

.mark b { font-weight: 500; }

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.nav a {
  position: relative;
  padding: 7px 11px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-decoration: none;
  white-space: nowrap;
}

.nav a::after {
  content: "";
  position: absolute;
  left: 11px;
  right: 11px;
  bottom: 2px;
  height: 1px;
  background: var(--gilt);
  scale: 0 1;
  transform-origin: left;
  transition: scale 0.28s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.nav a:hover { color: var(--ink); }
.nav a:hover::after { scale: 1 1; }

.nav a[aria-current="page"] { color: var(--ink); }
.nav a[aria-current="page"]::after { scale: 1 1; }

/* Icon buttons keep their own padding, so the glyph is not squeezed. */
.nav a.icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--ink-faint);
}
.nav a.icon::after { display: none; }
.nav a.icon svg { width: 15px; height: 15px; display: block; }
.nav a.icon:hover { color: var(--gold-text); }

/* Narrow screens: the links tighten rather than disappear, and the header
   takes a second line before it would push anything off the page. */
@media (width <= 860px) {
  .top .wrap { height: 56px; gap: 10px; }
  .mark { font-size: 1.08rem; }
  .mark .glyph { width: 23px; height: 23px; }
  .nav { gap: 0; }
  .nav a { padding: 6px 7px; letter-spacing: 0.1em; font-size: 0.64rem; }
  .nav a::after { left: 7px; right: 7px; }
  .nav a.icon { width: 28px; height: 28px; }
  .nav a.icon svg { width: 14px; height: 14px; }
}

@media (width <= 620px) {
  .top .wrap {
    height: auto;
    flex-wrap: wrap;
    padding: 7px 0 8px;
    row-gap: 2px;
  }
  .mark { font-size: 1rem; }
  .nav {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }
  .nav a { padding: 5px 4px; font-size: 0.6rem; letter-spacing: 0.06em; }
  .nav a::after { left: 4px; right: 4px; }
}

/* ----------------------------------------------------------------- plate */

/* A plate is a piece of struck steel with a cut edge and a hairline of gold
   in the cut. `::before` is the surface, so the ring shows through. */
.plate {
  position: relative;
  isolation: isolate;
  background: var(--gilt-edge);
  padding: 1px;
  clip-path: var(--cut);
  /* A plate carries its own ink: light text on steel, in either theme. */
  color: var(--on-steel);
}

.plate h1,
.plate h2,
.plate h3,
.plate h4 { color: var(--on-steel); }

.plate p { color: var(--on-steel-dim); }
.plate a { color: var(--gold-3); }
.plate code { color: var(--gold-4); }

.plate::before {
  content: "";
  position: absolute;
  inset: 1px;
  z-index: -1;
  clip-path: var(--cut);
  background-color: var(--steel);
  background-image:
    repeating-linear-gradient(90deg, color-mix(in oklab, #fff 3%, transparent) 0 1px, transparent 1px 3px),
    radial-gradient(140% 120% at 12% -20%, color-mix(in oklab, #fff 7%, transparent), transparent 60%),
    linear-gradient(180deg, var(--steel-2), var(--steel));
}

.plate.rivets::before {
  background-image:
    radial-gradient(circle at 13px 13px, color-mix(in oklab, var(--gold-3) 70%, transparent) 0 1.6px, transparent 2px),
    radial-gradient(circle at calc(100% - 19px) 13px, color-mix(in oklab, var(--gold-3) 70%, transparent) 0 1.6px, transparent 2px),
    radial-gradient(circle at 13px calc(100% - 13px), color-mix(in oklab, var(--gold-3) 70%, transparent) 0 1.6px, transparent 2px),
    radial-gradient(circle at calc(100% - 19px) calc(100% - 13px), color-mix(in oklab, var(--gold-3) 70%, transparent) 0 1.6px, transparent 2px),
    repeating-linear-gradient(90deg, color-mix(in oklab, #fff 3%, transparent) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, var(--steel-2), var(--steel));
}

/* Foil that follows the pointer across a plate. */
.plate.lit { --mx: 50%; --my: 0%; }
.plate.lit::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(
    260px circle at var(--mx) var(--my),
    color-mix(in oklab, var(--gold-4) 16%, transparent),
    transparent 68%
  );
  mix-blend-mode: screen;
}

.plate > * { position: relative; z-index: 1; }

/* The home plate is a stack of three panes inside one frame, so its spacing
   is its own. */
#hero-card .stack { padding: 12px; }

#hero-card textarea {
  min-height: 132px;
  padding: 10px 0;
  border-bottom: var(--hair) solid var(--steel-line);
}

#hero-card pre {
  padding: 10px 0;
  font-size: 0.76rem;
}

/* Bare code and editors inside a plate sit on steel, so they take its ink
   rather than the page's. */
.plate pre,
.plate textarea {
  margin: 0;
  color: var(--on-steel);
  background: none;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.8rem;
  line-height: 1.72;
  white-space: pre;
  tab-size: 2;
  border: 0;
  overflow-x: auto;
}

.plate textarea {
  display: block;
  width: 100%;
  padding: 2px 0;
  resize: none;
  field-sizing: content;
  min-height: 4.6em;
  max-height: 42vh;
  caret-color: var(--gold-3);
}

.plate textarea:focus { outline: none; }

.plate pre code {
  font: inherit;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  white-space: inherit;
}

.card { padding: 22px 24px; }
.card h3 { margin-bottom: 8px; }
.card p { margin: 0; color: var(--ink-soft); font-size: 0.95rem; }

/* ------------------------------------------------------------- code plate */

.code-block {
  position: relative;
  isolation: isolate;
  background: var(--gilt-edge);
  padding: 1px;
  clip-path: var(--cut);
  margin: 18px 0;
}

.code-block::before {
  content: "";
  position: absolute;
  inset: 1px;
  z-index: -1;
  clip-path: var(--cut);
  background-color: var(--steel);
  background-image:
    repeating-linear-gradient(90deg, color-mix(in oklab, #fff 2.5%, transparent) 0 1px, transparent 1px 4px),
    linear-gradient(180deg, var(--steel-2), var(--steel));
}

.code-block > * { position: relative; }

.code-block pre,
pre.code {
  margin: 0;
  padding: 15px 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  /* A regular weight in a mono face reads thin against steel; the medium cut
     keeps plain identifiers level with the bold keywords beside them. */
  font-weight: 500;
  font-size: 0.8125rem;
  line-height: 1.72;
  color: var(--on-steel);
  tab-size: 2;
  white-space: pre;
  background: none;
}

.code-block pre + pre { border-top: var(--hair) solid var(--steel-line); }

.code-block pre code,
pre.code code {
  font-size: 1em;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  white-space: inherit;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 15px;
  border-bottom: var(--hair) solid var(--steel-line);
  font-family: var(--font-mono);
  font-size: 0.688rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--on-steel-dim);
  background: linear-gradient(180deg, color-mix(in oklab, #fff 5%, transparent), transparent);
}

.card-head .name { color: var(--on-steel); letter-spacing: 0.05em; }
.card-head .spacer { margin-left: auto; }

.status {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 15px;
  border-top: var(--hair) solid var(--steel-line);
  font-family: var(--font-mono);
  font-size: 0.688rem;
  letter-spacing: 0.06em;
  color: var(--on-steel-faint);
  background: color-mix(in oklab, #000 16%, transparent);
}
.status .spacer { margin-left: auto; }

/* Stamped marks, one per layer: silver, gold, bronze. */
.dot {
  width: 6px;
  height: 6px;
  flex: none;
  rotate: 45deg;
  background: var(--gold-3);
}
.dot.attr { background: var(--silver-2); }
.dot.hole { background: var(--gold-4); }
.dot.gen  { background: #c98a4b; }
.status.ready .dot { background: #9fd08a; }
.status.bad .dot { background: #e08d7a; }

/* ------------------------------------------------------------- syntax ink */

.tk-com  { color: var(--on-steel-faint); }
.tk-str  { color: #dcc091; }
.tk-key  { color: #f3ead6; font-weight: 700; }
.tk-ty   { color: #bcc7d4; }
.tk-num  { color: #e2a45f; }
.tk-punct{ color: #8b8577; }

/* A hole is the thing the library is about: it is always gold. */
.tk-hole {
  color: #241a05;
  font-weight: 700;
  background: var(--gilt-surface);
  padding: 0 2px;
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--gold-0) 60%, transparent);
}

.tk-attr {
  color: #f6e7bb;
  background: color-mix(in oklab, var(--gold-2) 16%, transparent);
  box-shadow: inset 0 -1px 0 color-mix(in oklab, var(--gold-3) 55%, transparent);
  padding: 0 2px;
}

/* Non-ASCII graphemes occupy whole character cells, so padding a trailing
   comment with spaces lands where it should. */
.w2 { display: inline-block; width: 2ch; }
.w1 { display: inline-block; width: 1ch; }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 11px 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  background: transparent;
  border: var(--hair) solid color-mix(in oklab, var(--gold-1) 55%, transparent);
  clip-path: var(--cut-sm);
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.btn:hover {
  border-color: var(--gold-2);
  background: color-mix(in oklab, var(--gold-3) 16%, transparent);
}

.btn.primary {
  color: #1d1505;
  font-weight: 700;
  background: var(--gilt-surface);
  background-size: 200% 100%;
  text-shadow: 0 1px 0 color-mix(in oklab, #fff 45%, transparent);
  border-color: transparent;
  box-shadow:
    inset 0 1px 0 color-mix(in oklab, #fff 55%, transparent),
    inset 0 -1px 0 color-mix(in oklab, #000 22%, transparent);
}

.btn.primary:hover { background-position: 100% 0; }

.btn svg { width: 14px; height: 14px; }

.cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.prose .cta,
.band .cta { margin-top: 26px; }

/* A closing line under a demo, and a limit on how wide prose may run. */
.tail { margin-top: 26px; }
.measure { max-width: 70ch; }

/* A stack of steel set flush under the plate above it, and its counterpart. */
.band.short { padding-bottom: 34px; }
.band.tight { padding-top: 0; }

/* Two columns with room for a table beside prose. */
.grid.wide { gap: 40px; }

/* A code plate followed by a remark reads as one thought. */
.code-block + blockquote { margin-top: 6px; }

/* ------------------------------------------------------------------ hero */

.hero {
  position: relative;
  padding: 68px 0 66px;
  overflow: clip;
}

/* The specimen plate is printed on a ruled bed. */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(90deg, color-mix(in oklab, var(--ink) 5%, transparent) 1px, transparent 1px),
    linear-gradient(180deg, color-mix(in oklab, var(--ink) 5%, transparent) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(120% 90% at 50% 0%, #000, transparent 78%);
  opacity: 0.55;
  pointer-events: none;
}

:root[data-theme="dark"] .hero::before { opacity: 0.3; }

.hero .wrap { position: relative; }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 1fr);
  gap: 46px;
  align-items: start;
}

@media (width <= 1000px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 34px; }
}

.hero .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.hero .eyebrow::before {
  content: "";
  width: 26px;
  height: 1px;
  background: var(--gilt);
}

.hero .display { margin-bottom: 20px; }
.hero .lede {
  max-width: 46ch;
  font-size: 1.02rem;
  color: var(--ink-soft);
  margin-bottom: 26px;
}

.hero .cta { margin-bottom: 26px; }

/* Metal hallmark under the hero: the four packages, struck. */
.hallmarks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  padding-top: 18px;
  border-top: var(--hair) solid var(--line-soft);
}
.hallmarks span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
}
.hallmarks span::before {
  content: "";
  width: 5px;
  height: 5px;
  rotate: 45deg;
  background: var(--gilt-edge);
}

/* ------------------------------------------------------------- the stack */

.stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.stack > * { min-width: 0; }

.pane-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border-bottom: var(--hair) solid var(--steel-line);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--on-steel-dim);
}

.tag {
  padding: 1px 6px;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #1d1505;
  background: linear-gradient(100deg, var(--gold-3), var(--gold-4));
}
.tag.h { background: linear-gradient(100deg, var(--gold-4), var(--gold-5)); }
.tag.g { background: linear-gradient(100deg, #d9a468, #e9c69c); }

.link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 4px 2px 14px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-faint);
}

.plate .link { color: var(--on-steel-faint); }
.link::before {
  content: "";
  width: 1px;
  height: 22px;
  background: linear-gradient(180deg, transparent, var(--gold-2), transparent);
  margin-right: 4px;
}
.link .call { color: var(--gold-text); }
.plate .link .call { color: var(--gold-3); }
.link .via { opacity: 0.7; }

/* ------------------------------------------------------------- stat strip */

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: var(--hair) solid var(--line-soft);
  border-bottom: var(--hair) solid var(--line-soft);
}

.stats > div {
  padding: 22px 18px 20px;
  border-left: var(--hair) solid var(--line-soft);
}
.stats > div:first-child { border-left: 0; padding-left: 0; }

.stats .n {
  display: block;
  font-family: var(--font-display);
  font-size: 3.4rem;
  font-weight: 600;
  line-height: 1;
  margin-bottom: 0.12em;
  font-variant-numeric: lining-nums;
  /* Foil, struck: a gold face with a light edge above and a shadow below. Fake
     gradients on text clip; this does not. */
  color: light-dark(#6f4f10, #edcf8b);
  text-shadow:
    0 1px 0 color-mix(in oklab, #fff 55%, transparent),
    0 -1px 0 color-mix(in oklab, var(--gold-0) 22%, transparent);
}

.stats .l {
  display: block;
  margin-top: 8px;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--ink-faint);
}

@media (width <= 700px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats > div:nth-child(3) { border-left: 0; padding-left: 0; }
  .stats > div:nth-child(n + 3) { border-top: var(--hair) solid var(--line-soft); }
}

/* ----------------------------------------------------------- layer cards */

.layer {
  padding: 20px 0 0;
  border-top: var(--hair) solid var(--line);
}
.layer .n {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--gold-text);
}
.layer h3 { margin: 8px 0 8px; }
.layer p { color: var(--ink-soft); font-size: 0.94rem; margin: 0; }

/* Steps of the chain, numbered on a coin. */
.pipe { display: grid; }

.pipe-step {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 16px;
  padding: 16px 0;
  border-top: var(--hair) solid var(--line-soft);
}
.pipe-step:first-child { border-top: 0; }
.pipe-step h4 {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.pipe-step p { margin: 0; font-size: 0.9rem; color: var(--ink-soft); }

/* ---------------------------------------------------------------- tables */

.tscroll {
  overflow-x: auto;
  margin: 18px 0;
}

table.plain {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

table.plain th {
  text-align: left;
  padding: 9px 14px 9px 0;
  font-family: var(--font-body);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-text);
  border-bottom: var(--hair) solid color-mix(in oklab, var(--gold-1) 45%, transparent);
  white-space: nowrap;
}

table.plain td {
  padding: 11px 14px 11px 0;
  vertical-align: top;
  border-bottom: var(--hair) solid var(--line-soft);
  color: var(--ink-soft);
}

table.plain tr:last-child td { border-bottom: 0; }
table.plain td:first-child { color: var(--ink); }
table.plain code { font-size: 0.82em; }

/* ---------------------------------------------------- prose, notes, quote */

.prose { min-width: 0; }
.prose h2 { margin-bottom: 14px; }
.prose h3 { margin: 30px 0 10px; }
.prose > section + section {
  margin-top: 56px;
  padding-top: 34px;
  border-top: var(--hair) solid var(--line-soft);
}
.prose p { color: var(--ink-soft); }
.prose ul,
.prose ol { color: var(--ink-soft); padding-left: 1.2em; margin: 0 0 1em; }
.prose li { margin-bottom: 0.35em; }

.step-n {
  display: block;
  font-family: var(--font-body);
  font-size: 0.688rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-text);
  margin-bottom: 8px;
}

/* A straight gold bar on the left: no radius on that side, or it bows. */
blockquote {
  margin: 22px 0;
  padding: 14px 20px;
  border-left: 2px solid var(--gold-2);
  border-radius: 0 4px 4px 0;
  background: color-mix(in oklab, var(--gold-3) 9%, transparent);
  font-family: var(--font-display);
  font-size: 1.06rem;
  line-height: 1.45;
  color: var(--ink);
}
blockquote p { margin: 0; color: inherit; }

.note {
  margin: 22px 0;
  padding: 14px 18px 14px 20px;
  border-left: 2px solid var(--gold-2);
  border-radius: 0 4px 4px 0;
  background: color-mix(in oklab, var(--gold-3) 8%, transparent);
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.note strong { color: var(--ink); }

/* --------------------------------------------------------------- sidebar */

.doc,
.page {
  padding: 44px 0 70px;
}

.doc {
  display: grid;
  grid-template-columns: 214px minmax(0, 1fr);
  gap: 46px;
  align-items: start;
}

@media (width <= 900px) {
  .doc { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 26px; }
}

.side {
  position: sticky;
  top: 86px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  border-left: var(--hair) solid var(--line-soft);
  padding-left: 18px;
}

@media (width <= 900px) {
  .side {
    position: static;
    max-height: none;
    margin-bottom: 24px;
    padding: 14px 0 14px 14px;
    border-left: 0;
    border-top: var(--hair) solid var(--line-soft);
    border-bottom: var(--hair) solid var(--line-soft);
    display: flex;
    flex-wrap: wrap;
    gap: 4px 6px;
  }
  .side .group { display: contents; }
  .side .group h4 { width: 100%; }
}

.side .group { margin-bottom: 20px; }

.side h4 {
  font-family: var(--font-body);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold-text);
  margin-bottom: 8px;
}

.side a {
  display: block;
  margin-left: -19px;
  padding: 4px 0 4px 10px;
  font-size: 0.83rem;
  color: var(--ink-faint);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.side a:hover { color: var(--ink); }
.side a.on { color: var(--ink); border-left-color: var(--gold-2); }

/* The group holding the entry in view takes the mark as well, so a long index
   says where you are without a second observer. */
.side .group:has(a.on) h4 { color: var(--ink); }

@media (width <= 900px) {
  .side a {
    display: inline-block;
    margin-left: 0;
    padding: 2px 7px;
    border: var(--hair) solid var(--line-soft);
    font-size: 0.72rem;
  }
  .side a.on { border-color: var(--gold-2); }
  .side .group { margin-bottom: 10px; }
  .side h4 { margin-bottom: 5px; }
}

.side a.pkg-link {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.02em;
  padding-top: 2px;
  padding-bottom: 6px;
}

.side a.sub {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding-top: 2px;
  padding-bottom: 2px;
}

/* ------------------------------------------------------------ api entries */

.intro { margin-bottom: 44px; }
.pkg { margin-bottom: 56px; }
.pkg h2 {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: var(--hair) solid color-mix(in oklab, var(--gold-1) 40%, transparent);
}
.pkg h2 .path {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
}
.pkg .about { color: var(--ink-soft); max-width: 62ch; margin-top: 12px; }

.prose h3.group-head {
  margin: 34px 0 4px;
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold-text);
}

.entry {
  padding: 14px 0 16px;
  border-bottom: var(--hair) solid var(--line-soft);
}

.entry.nested { border-top: 0; padding-top: 8px; }

.entry .sig {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.6;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.entry .anchor {
  opacity: 0;
  margin-left: 6px;
  color: var(--gold-text);
  text-decoration: none;
}
.entry:hover .anchor,
.entry .anchor:focus-visible { opacity: 1; }

.entry .desc { margin-top: 6px; color: var(--ink-soft); font-size: 0.9rem; }
.entry .desc p { margin: 0 0 0.6em; color: inherit; }
.entry .desc pre {
  margin: 10px 0;
  padding: 12px 14px;
  overflow-x: auto;
  background: var(--steel);
  color: var(--on-steel);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.78rem;
  line-height: 1.7;
  border-left: 2px solid var(--gold-2);
}
.entry .desc pre code {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  white-space: pre;
}

.entry .params {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  font-size: 0.82rem;
  color: var(--ink-faint);
}
.entry .params li { display: flex; gap: 8px; padding: 2px 0; }
.entry .params .pname {
  font-family: var(--font-mono);
  color: var(--ink);
  min-width: 0;
}

.entry.kind-error .sig { color: light-dark(#8a3520, #e6a08c); }

/* ------------------------------------------------------------ playground */

.play {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  /* Two plates of one height, so the pair reads as a single instrument. */
  align-items: stretch;
}

@media (width <= 940px) {
  .play { grid-template-columns: minmax(0, 1fr); }
}

.pane-box {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  background: var(--gilt-edge);
  padding: 1px;
  clip-path: var(--cut);
  min-width: 0;
  /* Editors and output are steel, whatever the page's ink is. */
  color: var(--on-steel);
}

.pane-box pre {
  margin: 0;
  padding: 15px 18px;
  overflow-x: auto;
  color: var(--on-steel);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.8125rem;
  line-height: 1.72;
  white-space: pre;
  tab-size: 2;
}

.pane-box pre code {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  white-space: inherit;
}

.pane-box::before {
  content: "";
  position: absolute;
  inset: 1px;
  z-index: -1;
  clip-path: var(--cut);
  background: var(--steel);
  background-image: linear-gradient(180deg, var(--steel-2), var(--steel));
}

.pane-box > * { position: relative; }

.pane-box textarea {
  display: block;
  width: 100%;
  min-height: 300px;
  padding: 15px 18px;
  border: 0;
  background: transparent;
  color: var(--on-steel);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.72;
  resize: none;
  flex: 1 1 auto;
  white-space: pre;
  overflow-x: auto;
  tab-size: 2;
}

.pane-box textarea:focus { outline: none; }
.pane-box:focus-within { box-shadow: 0 0 0 1px var(--gold-3); }

.pane-box .out-pre {
  min-height: 300px;
  max-height: 460px;
  overflow: auto;
  flex: 1 1 auto;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.chip {
  padding: 7px 13px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  background: transparent;
  border: var(--hair) solid var(--line);
  clip-path: var(--cut-sm);
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  color: var(--on-temper);
  font-weight: 600;
  background: linear-gradient(158deg, var(--temper-1), var(--temper-0));
  border-color: color-mix(in oklab, var(--rose) 85%, transparent);
  box-shadow:
    inset 0 1px 0 color-mix(in oklab, var(--rose) 55%, transparent),
    inset 0 -1px 0 color-mix(in oklab, #000 30%, transparent),
    0 1px 0 color-mix(in oklab, #000 18%, transparent);
}

.chip[aria-pressed="true"]:hover {
  background: linear-gradient(158deg, var(--temper-1), var(--temper-0));
  border-color: var(--rose);
}

.fills {
  border-top: var(--hair) solid var(--steel-line);
  padding: 10px 14px;
  display: grid;
  gap: 7px;
  background: color-mix(in oklab, #000 18%, transparent);
}

.fill-row {
  display: grid;
  grid-template-columns: minmax(0, 84px) 84px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.fill-row .hn {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--gold-3);
  overflow: hidden;
  text-overflow: ellipsis;
}

.fill-row select,
.fill-row input {
  width: 100%;
  min-width: 0;
  padding: 4px 6px;
  color: var(--on-steel);
  background: color-mix(in oklab, #fff 7%, transparent);
  border: var(--hair) solid var(--steel-line);
  font-family: var(--font-mono);
  font-size: 0.74rem;
}

.fill-row select option { color: #15151a; }

/* ----------------------------------------------------------------- chain */

.chain-svg { display: block; width: 100%; height: auto; }

.chain-stage { cursor: pointer; }
.chain-stage rect.hit { fill: transparent; }
.chain-stage:focus-visible { outline: 2px solid var(--gold-text); outline-offset: 2px; }
.chain-stage:hover rect.hit,
.chain-stage[aria-current="true"] rect.hit {
  fill: color-mix(in oklab, var(--gold-3) 12%, transparent);
}

.chain-figure { margin: 0; }
.chain-figure figcaption {
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--ink-faint);
  text-align: center;
}

/* ----------------------------------------------------------------- footer */

footer.site {
  border-top: var(--hair) solid var(--line-soft);
  padding: 30px 0 40px;
  margin-top: 20px;
}
footer.site .wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
footer.site p {
  margin: 0;
  font-size: 0.76rem;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}
footer.site .r {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}
footer.site .r a {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-decoration: none;
}
footer.site .r a:hover { color: var(--gold-text); }
footer.site .r a.icon { display: grid; place-items: center; width: 26px; height: 26px; }
footer.site .r a.icon svg { width: 14px; height: 14px; display: block; }

/* --------------------------------------------------------------- utility */

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 10px 14px;
  background: var(--gold-3);
  color: #201705;
  z-index: 99;
}
.skip:focus { left: 8px; top: 8px; }

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

.small { font-size: 0.84rem; color: var(--ink-faint); }
.center { text-align: center; }

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

/* The page scroll bar shows while the page moves or under the pointer and
   hides a moment after; it keeps its place, so nothing shifts. */
@supports selector(::-webkit-scrollbar) {
  html:not(.scrolling)::-webkit-scrollbar-thumb { background: transparent; border-color: transparent; box-shadow: none; }
}
@supports not selector(::-webkit-scrollbar) {
  html:not(.scrolling) { scrollbar-color: transparent transparent; }
}

/* Long identifiers in running text break rather than widen the page. */
:where(p, li, td, dd, h1, h2, h3, h4) code { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Grid items give way to their scrolling code and tables instead of widening the page. */
.doc > * { min-width: 0; }
