/* ==========================================================================
   Quantile Labs
   Derived from docs/design-plan.md. One hue, six steps. Emphasis is spent on
   limitations, not on claims.
   ========================================================================== */

@font-face{font-family:'Instrument Sans';font-style:normal;font-weight:500 600;font-display:swap;src:url(/assets/fonts/instrument-sans.woff2) format('woff2')}
@font-face{font-family:'Source Serif 4';font-style:normal;font-weight:400 600;font-display:swap;src:url(/assets/fonts/source-serif.woff2) format('woff2')}
@font-face{font-family:'IBM Plex Mono';font-style:normal;font-weight:400;font-display:swap;src:url(/assets/fonts/plex-mono-400.woff2) format('woff2')}
@font-face{font-family:'IBM Plex Mono';font-style:normal;font-weight:500;font-display:swap;src:url(/assets/fonts/plex-mono-500.woff2) format('woff2')}

:root {
  /* Palette: a single violet hue in six steps. See design-plan.md §1. */
  --paper:  #F2F1F5;
  --vellum: #E4E2EA;
  --rule:   #C9C5D4;
  --slate:  #605A6E;
  --ink:    #201E28;
  --tail:   #56287A;
  --tail-lift: #B79BD6; /* the only tint permitted on ink surfaces */

  --display: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif;
  --body: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --measure: 34rem;   /* ~66ch of Source Serif at body size */
  --shell: 1180px;
  --rail: 200px;
  --gap: clamp(32px, 5vw, 72px);

  /* Spacing scale */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px; --s5: 24px;
  --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px; --s10: 128px;
}

/* --- reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  line-height: 1.62;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }
img { height: auto; }

::selection { background: var(--tail); color: var(--paper); }

:focus-visible {
  outline: 2px solid var(--tail);
  outline-offset: 3px;
  border-radius: 1px;
}

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

/* --- typography ----------------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: -0.018em;
  line-height: 1.12;
  text-wrap: balance;
}

h1 { font-size: clamp(2rem, 1.5rem + 2.4vw, 2.875rem); letter-spacing: -0.026em; }
h2 { font-size: clamp(1.375rem, 1.2rem + 0.85vw, 1.6875rem); }
h3 { font-size: clamp(1.0625rem, 1rem + 0.35vw, 1.1875rem); letter-spacing: -0.008em; }

p { text-wrap: pretty; }
p + p { margin-top: 1.1em; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-color: var(--tail); text-decoration-thickness: 2px; }

strong { font-weight: 600; }

/* Mono is reserved for measurements, metadata, and labels. */
.label {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--slate);
}

.num {
  font-family: var(--mono);
  font-size: 0.94em;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.lede {
  font-size: clamp(1.125rem, 1.05rem + 0.4vw, 1.3125rem);
  line-height: 1.5;
  color: var(--ink);
  max-width: var(--measure);
}

/* --- layout --------------------------------------------------------------- */
.shell {
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: clamp(20px, 5vw, 56px);
}

.skip {
  position: absolute; left: -9999px;
  background: var(--ink); color: var(--paper);
  padding: var(--s3) var(--s5);
  font-family: var(--display); font-size: 0.875rem;
  z-index: 10;
}
.skip:focus { left: var(--s5); top: var(--s5); }

/* The document grid: a metadata rail and a measured column, left-aligned so the
   page keeps a wide right margin and reads as a document, not a landing page. */
.doc {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}

/* Running text is held to the measure. Tables and figures are data, not prose,
   and may use the whole column. */
.prose > *, .section > * { max-width: var(--measure); }
.prose > .section,
.prose > .table-wrap, .section > .table-wrap,
.prose > .fig, .section > .fig,
.prose > .rows, .section > .rows { max-width: none; }

.rail {
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.55;
  color: var(--slate);
}
.rail dl { display: grid; gap: var(--s4); }
.rail dt {
  font-size: 0.6875rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--slate);
}
.rail dd { color: var(--ink); }

.rail--sticky { position: sticky; top: var(--s7); }

.rail__index { list-style: none; padding: 0; display: grid; gap: var(--s2); }
.rail__index a {
  display: grid;
  grid-template-columns: 1.9em 1fr;
  gap: var(--s2);
  text-decoration: none;
  color: var(--slate);
  padding-block: 2px;
}
.rail__index a:hover { color: var(--tail); }
.rail__index span { font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .doc { grid-template-columns: minmax(0, 1fr); gap: var(--s6); }
  .rail--sticky { position: static; }
  .rail { padding-bottom: var(--s5); border-bottom: 1px solid var(--rule); }
  .rail dl { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .rail__index { display: none; }
}

/* --- masthead ------------------------------------------------------------- */
.masthead {
  border-bottom: 1px solid var(--rule);
  padding-block: var(--s5);
}
.masthead__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s4) var(--s7);
}

.wordmark {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.0625rem;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}
.wordmark:hover { color: var(--tail); }

.masthead nav ul {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-wrap: wrap;
  gap: var(--s3) var(--s5);
}
.masthead nav a {
  font-family: var(--display);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--slate);
  text-decoration: none;
  padding-block: 2px;
}
.masthead nav a:hover { color: var(--ink); }
.masthead nav a[aria-current='page'] {
  color: var(--ink);
  box-shadow: inset 0 -1px 0 var(--tail);
}

/* --- page header ---------------------------------------------------------- */
.page-head { padding-block: clamp(var(--s7), 8vw, var(--s9)) var(--s7); }
.page-head h1 { max-width: 20ch; }
.page-head .lede { margin-top: var(--s5); }
.page-head .label { display: block; margin-bottom: var(--s4); }

main { padding-bottom: var(--s10); }

/* --- prose ---------------------------------------------------------------- */
.prose > * + * { margin-top: var(--s5); }
.prose h2 { margin-top: var(--s8); }
.prose h3 { margin-top: var(--s7); }
.prose > h2:first-child, .prose > h3:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.15em; display: grid; gap: var(--s3); }
.prose li::marker { color: var(--slate); }
.prose a { text-decoration-color: var(--rule); }

.section {
  padding-top: var(--s7);
  margin-top: var(--s8);
  border-top: 1px solid var(--rule);
}
.section:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.section > * + * { margin-top: var(--s5); }
/* the numbered label already carries its own gap to the heading */
.section > .section__num + h2 { margin-top: 0; }
.section > * + .limits { margin-top: var(--s6); }
.section > * + .table-wrap { margin-top: var(--s6); }
.section__num {
  font-family: var(--mono); font-size: 0.6875rem; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--tail);
  display: block; margin-bottom: var(--s3);
}

.rule { border: 0; border-top: 1px solid var(--rule); margin-block: var(--s8); }

/* --- the hatch: "this is the part that matters" --------------------------- */
/* Used in exactly three places: the tail of Fig. 1, the limits block, and the
   "cannot claim" cells of the access table. Nowhere else. */
.hatch-swatch {
  display: inline-block;
  width: 1.4em; height: 0.72em;
  vertical-align: -0.02em;
  border: 1px solid var(--tail);
  background-image: repeating-linear-gradient(45deg, var(--tail) 0 1px, transparent 1px 6px);
}

.limits {
  margin-top: var(--s6);
  padding: var(--s5) var(--s6);
  background: var(--vellum);
  border-left: 2px solid var(--tail);
  background-image: repeating-linear-gradient(45deg, rgba(86, 40, 122, 0.09) 0 1px, transparent 1px 7px);
}
.limits__label {
  font-family: var(--mono); font-size: 0.6875rem; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--tail);
  display: block; margin-bottom: var(--s3);
}
/* The caveat is the heaviest text in the section it qualifies. */
.limits p {
  font-weight: 600;
  font-size: 1.02em;
  line-height: 1.5;
  color: var(--ink);
  max-width: var(--measure);
}
.limits p + p { margin-top: var(--s3); }

/* --- figure --------------------------------------------------------------- */
.fig { margin-block: var(--s8); }
.fig__head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s3) var(--s4);
  padding-bottom: var(--s3);
  border-bottom: 1px solid var(--rule);
}
.fig__title { font-family: var(--display); font-size: 0.9375rem; font-weight: 500; }
.fig__plot { margin-top: var(--s5); max-width: 940px; }

.plot { width: 100%; height: auto; }
.plot__grid line { stroke: var(--rule); stroke-width: 1; stroke-dasharray: 2 4; }
.plot__axis { stroke: var(--slate); stroke-width: 1; }
.plot__hatch { stroke: var(--tail); stroke-width: 1; opacity: 0.55; }
.plot__tail-edge { stroke: var(--tail); stroke-width: 1; stroke-dasharray: 3 3; }
.plot__ecdf { fill: none; stroke: var(--slate); stroke-width: 1.5; }
.plot__ecdf--tail { stroke: var(--tail); stroke-width: 2.5; }
.plot__mean { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 5 4; }
.plot__tick, .plot__axis-title, .plot__note {
  font-family: var(--mono); font-size: 11px; fill: var(--slate);
}
.plot__axis-title { font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; }
.plot__note { font-size: 11.5px; fill: var(--ink); }
.plot__note--tail {
  font-family: var(--mono); font-size: 11.5px; font-weight: 500; fill: var(--tail);
}

.fig__caption { margin-top: var(--s5); max-width: var(--measure); }
.fig__key { font-weight: 600; }
.fig__swatch {
  display: inline-block; width: 1.4em; height: 0.72em;
  margin-right: 0.45em; vertical-align: -0.02em;
  border: 1px solid var(--tail);
  background-image: repeating-linear-gradient(45deg, var(--tail) 0 1px, transparent 1px 6px);
}
.fig__source {
  margin-top: var(--s3);
  font-family: var(--mono); font-size: 0.75rem; color: var(--slate);
}
.fig__data { margin-top: var(--s5); }
.fig__data summary {
  font-family: var(--mono); font-size: 0.75rem; color: var(--slate);
  cursor: pointer; width: fit-content;
}
.fig__data summary:hover { color: var(--tail); }
.fig__data .table { margin-top: var(--s4); }

/* --- tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin-top: var(--s5); }
.table {
  width: 100%; border-collapse: collapse;
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}
.table caption {
  font-family: var(--mono); font-size: 0.75rem; color: var(--slate);
  text-align: left; padding-bottom: var(--s3);
}
.table th, .table td {
  text-align: left; vertical-align: top;
  padding: var(--s3) var(--s4) var(--s3) 0;
  border-bottom: 1px solid var(--rule);
}
.table thead th {
  font-family: var(--display); font-size: 0.8125rem; font-weight: 600;
  letter-spacing: 0.01em;
  border-bottom: 1px solid var(--slate);
  white-space: nowrap;
}
.table tbody th { font-family: var(--display); font-size: 0.875rem; font-weight: 500; }

/* Access-level table: the "cannot claim" row carries the hatch. */
.table--access td { min-width: 15ch; }
.table--access .cannot {
  background-image: repeating-linear-gradient(45deg, rgba(86, 40, 122, 0.1) 0 1px, transparent 1px 7px);
  padding-left: var(--s3);
  font-weight: 600;
}
.table--access tbody th { white-space: nowrap; }

/* --- findings ledger ------------------------------------------------------ */
/* A ruled ledger rather than a card grid: it looks deliberate at one entry and
   still scans at fifty. */
.ledger { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--ink); }
.entry { border-bottom: 1px solid var(--rule); padding-block: var(--s6); }
.entry__meta {
  display: flex; flex-wrap: wrap; gap: var(--s3) var(--s5);
  font-family: var(--mono); font-size: 0.75rem; color: var(--slate);
  letter-spacing: 0.04em;
}
.entry__access { text-transform: uppercase; color: var(--tail); font-weight: 500; }
.entry__title { margin-top: var(--s3); font-size: clamp(1.125rem, 1rem + 0.5vw, 1.3125rem); }
.entry__title a { text-decoration: none; }
.entry__title a:hover { color: var(--tail); text-decoration: underline; }
.entry__system { margin-top: var(--s2); color: var(--slate); font-size: 0.9375rem; }
.entry__finding { margin-top: var(--s4); max-width: var(--measure); }
.entry__links {
  margin-top: var(--s4); padding: 0; list-style: none;
  display: flex; flex-wrap: wrap; gap: var(--s3) var(--s5);
  font-family: var(--mono); font-size: 0.75rem;
}
.entry__links a { color: var(--tail); }

.empty {
  border: 1px solid var(--rule);
  border-left: 2px solid var(--tail);
  background: var(--vellum);
  padding: var(--s6);
  max-width: var(--measure);
}
.empty h2 { font-size: 1.0625rem; }
.empty p { margin-top: var(--s3); color: var(--ink); }
.empty .label { display: block; margin-bottom: var(--s3); color: var(--tail); }

/* --- definition rows (sectors, careers, contact routes) ------------------- */
.rows { display: grid; }
.row {
  padding-block: var(--s6);
  border-top: 1px solid var(--rule);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s3);
}
.row:last-child { border-bottom: 1px solid var(--rule); }
.row h3 { font-size: 1.1875rem; }
.row__what {
  font-family: var(--mono); font-size: 0.6875rem; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--tail);
}
.row p { max-width: var(--measure); }

/* --- form ----------------------------------------------------------------- */
.form { display: grid; gap: var(--s5); max-width: 34rem; margin-top: var(--s6); }
.field { display: grid; gap: var(--s2); }
.field > span {
  font-family: var(--display); font-size: 0.8125rem; font-weight: 500;
  letter-spacing: 0.01em;
}
.field input, .field select, .field textarea {
  font: inherit;
  font-size: 0.9375rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 0;
  padding: var(--s3) var(--s4);
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--tail);
}
.field textarea { resize: vertical; min-height: 6em; }
.field__hint { font-family: var(--mono); font-size: 0.75rem; color: var(--slate); }

.button {
  font-family: var(--display); font-size: 0.875rem; font-weight: 600;
  background: var(--ink); color: var(--paper);
  border: 1px solid var(--ink); border-radius: 0;
  padding: var(--s3) var(--s6);
  cursor: pointer;
  justify-self: start;
}
.button:hover { background: var(--tail); border-color: var(--tail); }

/* --- footer --------------------------------------------------------------- */
.foot {
  border-top: 1px solid var(--rule);
  padding-block: var(--s8) var(--s7);
}
.foot__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr));
  gap: var(--s7) var(--gap);
}
.foot h2 {
  font-family: var(--mono); font-size: 0.6875rem; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--slate);
}
.foot ul { list-style: none; padding: 0; margin-top: var(--s4); display: grid; gap: var(--s3); }
.foot a { font-family: var(--display); font-size: 0.875rem; text-decoration: none; color: var(--ink); }
.foot a:hover { color: var(--tail); text-decoration: underline; }
.foot__about { max-width: 30ch; font-size: 0.9375rem; color: var(--slate); margin-top: var(--s4); }
.foot__bottom {
  margin-top: var(--s8); padding-top: var(--s5);
  border-top: 1px solid var(--rule);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s3) var(--s5);
  font-family: var(--mono); font-size: 0.75rem; color: var(--slate);
}

/* --- small screens -------------------------------------------------------- */
/* No hamburger. Seven links fit if the header is banded rather than left to
   wrap raggedly: wordmark on its own line, nav below a hairline. */
@media (max-width: 760px) {
  .masthead { padding-block: var(--s4) 0; }
  .masthead__inner { display: block; }
  .wordmark { font-size: 1rem; }
  .masthead nav {
    margin-top: var(--s3);
    border-top: 1px solid var(--rule);
    padding-block: var(--s3);
  }
  .masthead nav ul { gap: var(--s2) var(--s4); }
  .masthead nav a { font-size: 0.8125rem; }

  .page-head { padding-block: var(--s7) var(--s6); }

  /* Stacking three groups of stacked links made the footer a very long scroll.
     Keep the grouping, but set each group's links inline under its heading:
     three short bands instead of eleven rows, and no orphaned column. */
  .foot { padding-block: var(--s7) var(--s6); }
  .foot__grid { grid-template-columns: minmax(0, 1fr); gap: var(--s5); }
  .foot__about { max-width: none; margin-top: var(--s3); }
  .foot ul {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s2) var(--s5);
    margin-top: var(--s3);
  }
  .foot__bottom { margin-top: var(--s6); }
}

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

/* reference lines and annotation leaders in plots */
.plot__threshold { stroke: var(--tail); stroke-width: 1; stroke-dasharray: 4 4; opacity: 0.75; }
.plot__ref { font-family: var(--mono); font-size: 11px; fill: var(--slate); }
.plot__ref--tail { fill: var(--tail); font-weight: 500; }
.plot__leader { fill: none; stroke: var(--tail); stroke-width: 1; opacity: 0.6; }
.plot__cliff { stroke: var(--tail); stroke-width: 2.5; }

/* The ledger is a list of records, not prose: undo the prose list treatment. */
.prose .ledger { display: block; padding-left: 0; gap: 0; }
.prose .entry__links {
  display: flex; flex-wrap: wrap; gap: var(--s3) var(--s5); padding-left: 0;
}

/* A horizontally scrolling table must be reachable by keyboard, so the wrapper
   is focusable. Suppress the focus ring when the pointer put focus there. */
.table-wrap:focus { outline: none; }
.table-wrap:focus-visible { outline: 2px solid var(--tail); outline-offset: 2px; }

/* --- Quantile Report block ------------------------------------------------ */
/* Every evaluation reports the same five figures plus the Gap Ratio. The home
   figure prints them so the page demonstrates the specification. */
.qr { margin-top: var(--s6); max-width: 40rem; }
.qr__head {
  display: flex; align-items: baseline; gap: var(--s3);
  padding-bottom: var(--s2); border-bottom: 1px solid var(--ink);
}
.qr__spec { font-family: var(--mono); font-size: 0.6875rem; color: var(--slate); }
.qr__table { margin-top: 0; font-size: 0.875rem; }
.qr__table tbody th {
  font-family: var(--mono); font-weight: 500; font-size: 0.8125rem;
  white-space: nowrap; width: 5rem;
}
.qr__table td:first-of-type { width: 6rem; text-align: right; padding-right: var(--s5); }
.qr__table td:last-child { color: var(--slate); }
.qr__gap th, .qr__gap td { border-bottom: 0; padding-top: var(--s4); font-weight: 600; }
.qr__gap th { color: var(--tail); }
.qr__gap td:last-child { color: var(--ink); }
.qr__gap { border-top: 1px solid var(--rule); }

.plot__mark { fill: var(--tail); }

/* Markdown-authored tables and inline code in findings, notes, and methods. */
.prose table {
  width: 100%; border-collapse: collapse;
  font-size: 0.9375rem; font-variant-numeric: tabular-nums;
  margin-top: var(--s5);
}
.prose table th, .prose table td {
  text-align: left; vertical-align: top;
  padding: var(--s3) var(--s4) var(--s3) 0;
  border-bottom: 1px solid var(--rule);
}
.prose table thead th {
  font-family: var(--display); font-size: 0.8125rem; font-weight: 600;
  border-bottom: 1px solid var(--slate); white-space: nowrap;
}
code {
  font-family: var(--mono); font-size: 0.9em;
  background: var(--vellum); padding: 0.1em 0.3em;
}
.limits code { background: transparent; padding: 0; }
/* A status-only empty state carries no body copy, so drop the label's gap. */
.empty .label:last-child { margin-bottom: 0; }
