/*
 * Alluv design system. Derived from Alluv Identity
 * (sourced-console/internal/identityui); DESIGN.md has the rationale.
 * Dark only: one palette, ink on night, hairline rules, no card fills.
 */

/* 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;

  /* Colour: identical to Alluv Identity. */
  --paper: #1b2030;
  --ink: #eeedf4;
  --muted: #afb7cd;
  --accent: #c6b6d8;
  --line: #59607366;      /* decorative only, never an essential boundary */
  --field-line: #7c849b;  /* essential control boundaries, 3:1 on paper */
  --error: #f0b7ab;
  --glow: #4b3e6924;

  /* 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, 3vw, 32px);
  --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: 64ch;
  --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) radial-gradient(ellipse at 27% 30%, var(--glow), transparent 57%) no-repeat;
  -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: var(--accent); 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, centred 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: 12px; letter-spacing: .13em; text-transform: uppercase; }
.lede { color: var(--muted); font-size: var(--text-lg); 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; }

.prose { max-width: var(--measure); }
.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); }

/* 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: atmosphere and words side by side; artwork drops above on mobile. */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  align-items: center;
  gap: clamp(36px, 6vw, 100px);
  padding-bottom: var(--space-8);
}
.hero-text { display: grid; gap: var(--space-5); }
.hero-compact .art { min-height: 260px; }

/* About-style page: heading in a narrow left column, content to its right. */
.about-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: var(--space-4) var(--space-7); align-items: start; }
.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:first-child { border-top: 1px solid var(--line); padding-top: var(--space-8); }
.principles h2::before {
  content: counter(principle, decimal-leading-zero);
  display: block; margin-bottom: var(--space-2);
  color: var(--muted); font: 400 12px/1 var(--mono); letter-spacing: .1em;
}

/* 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); }
.index-item { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; align-items: baseline; gap: var(--space-2) var(--space-5); padding: var(--space-5) 0; border-bottom: 1px solid var(--line); }
.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-item { position: relative; }
.index-item:hover .index-name a { color: var(--accent); }
.index-item:focus-within { outline: 2px solid var(--accent); outline-offset: 4px; }
.index-name a:focus-visible { outline: 0; }
.index-desc { color: var(--muted); }
.index-meta { color: var(--muted); font-size: var(--text-sm); font-family: var(--mono); }

/* 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; }

/* 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; }

/* 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); }
  .hero { grid-template-columns: 1fr; gap: var(--space-5); }
  /* Nothing sits beside the artwork here, so it runs edge to edge. */
  .hero .art { order: -1; min-height: 300px; margin-inline: calc(-1 * var(--gutter)); }
  .index-item, .about-row { grid-template-columns: 1fr; }
  .hero-compact .art { min-height: 220px; }
  .section, .principles > li:first-child { padding-block: var(--space-7); }
  .specimen { grid-template-columns: 1fr; }
}

@media (forced-colors: active) {
  .art { 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, .nav, .skip { display: none; }
}
