/*
 * The style guide's own layout. Not part of either shipped surface.
 *
 * It is on the **app** spacing scale rather than the public one, because it is
 * a reference document read densely by whoever is building screens, not a page
 * that has to breathe. Nothing here is a pattern to copy; the patterns are the
 * specimens.
 */

.guide {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-5) var(--gutter-app) var(--space-8);
  font-size: var(--step-body);
}

.guide h2 {
  font-size: var(--step-display-2);
  letter-spacing: var(--track-26);
}

.guide section {
  padding-top: var(--rhythm-app-lg);
  margin-top: var(--rhythm-app-lg);
  border-top: 1px solid var(--hairline);
}

.guide section > * + * {
  margin-top: var(--space-4);
}

.lede {
  color: var(--text-help);
  font-size: var(--step-body);
}

/* The sticky bar. `position: sticky` on the header so the theme control is
   reachable from anywhere in a very long document — the guide is read by
   flipping themes on one specimen, and scrolling back to the top to do it
   would make the comparison useless. */
.guide-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--gutter-app);
  background: var(--paper);
  border-bottom: 1px solid var(--hairline);
}

.seg {
  display: inline-flex;
  border: 1px solid var(--hairline);
}

.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-help);
  font-family: var(--font-mono);
  font-size: var(--step-mono-4);
  font-weight: 500;
  letter-spacing: var(--track-mono-wide);
  text-transform: uppercase;
  padding: 9px 12px;
  min-height: 36px;
  cursor: pointer;
}

.seg button + button {
  border-left: 1px solid var(--hairline);
}

/* **Never colour alone**: the active segment is also the only one whose text
   is at full ink weight, and it carries aria-pressed for anything that is not
   reading colour at all. */
.seg button[aria-pressed="true"] {
  background: var(--accent-ui);
  color: var(--surface);
}

/* ---- Swatches --------------------------------------------------------- */

.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--space-3);
}

.swatch {
  border: 1px solid var(--hairline);
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.swatch .chip {
  height: 52px;
  border: 1px solid var(--hairline);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 4px 6px;
}

.swatch code {
  font-family: var(--font-mono);
  font-size: var(--step-mono-2);
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}

.swatch .note {
  font-family: var(--font-mono);
  font-size: var(--step-mono-4);
  letter-spacing: var(--track-mono);
  text-transform: uppercase;
  color: var(--text-help);
}

/* A measurement the page took of itself, in the theme you are looking at.
   `.pass` and `.fail` carry a glyph as well as a colour — the guide would be
   a poor advertisement for §11 if its own verdicts were hue-only. */
.verdict { font-family: var(--font-mono); font-size: var(--step-mono-4); letter-spacing: var(--track-mono); }
.verdict.pass { color: var(--valence-good); }
.verdict.fail { color: var(--valence-bad); }

.ramp {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--hairline);
}

.ramp div {
  padding: var(--space-2) 4px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: var(--step-mono-4);
  letter-spacing: var(--track-mono);
}

/* ---- Specimens -------------------------------------------------------- */

.specimen {
  border: 1px solid var(--hairline);
  padding: var(--space-3);
}

.specimen + .specimen { margin-top: var(--space-3); }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-3);
}

.type-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--hairline);
}

.type-row:last-child { border-bottom: 0; }

.type-row .meta {
  flex: none;
  width: 190px;
  font-family: var(--font-mono);
  font-size: var(--step-mono-4);
  letter-spacing: var(--track-mono);
  text-transform: uppercase;
  color: var(--text-help);
}

/* ---- The data table (§7) ---------------------------------------------- *
 *
 * Mono headers at 10px / .12em / uppercase / --text-help. Rows 32px dense.
 * **Hairline between rows, none within. No zebra striping** — it is noise at
 * this density and the hairline already does the work. Numerals tabular and
 * right-aligned, text left, which is the one alignment rule that makes a
 * column of numbers scannable.
 */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step-body-dense);
  white-space: nowrap;
}

.data-table th {
  font-family: var(--font-mono);
  font-size: var(--step-mono-4);
  font-weight: 500;
  letter-spacing: var(--track-mono);
  text-transform: uppercase;
  color: var(--text-help);
  text-align: left;
  padding: var(--space-1) var(--space-2);
  border-bottom: 1px solid var(--hairline);
}

.data-table td {
  height: 32px;
  padding: 0 var(--space-2);
  border-bottom: 1px solid var(--hairline);
  color: var(--ink-body);
}

.data-table .num { text-align: right; font-variant-numeric: var(--numeric); }
.data-table tr:last-child td { border-bottom: 0; }

/* A sortable header says so — the caret is the affordance, and it is present
   in the un-sorted state at reduced weight rather than appearing on hover,
   because an affordance that only exists on hover does not exist on a phone. */
.data-table th.sortable::after { content: " ↕"; opacity: 0.45; }
.data-table th[aria-sort="descending"]::after { content: " ↓"; opacity: 1; }

/* ---- The provisional vocabulary (§7) ---------------------------------- *
 *
 * Four words, no exceptions. **A projected number never renders at the same
 * weight as a confirmed one** — that is the whole rule, and it is why
 * `.projected` is a colour change and not only a `~`.
 */
.confirmed { color: var(--ink); }
.provisional {
  color: var(--text-help);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.projected { color: var(--text-help); font-weight: 400; }
.not-obtainable { color: var(--text-help); }

/* ---- State (§3.4) ------------------------------------------------------ */

.state-cell {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 4px 8px;
  min-height: 28px;
  border: 1px solid var(--hairline);
  font-family: var(--font-mono);
  font-size: var(--step-mono-4);
  letter-spacing: var(--track-mono);
  text-transform: uppercase;
  color: var(--text-help);
}

/* **The hatch is a swatch beside the word, never a fill behind it.** Behind
   10px mono at .12em it makes the label unreadable — which would be this
   page demonstrating a state that carries its meaning in pattern alone, on
   the same page that forbids it. The swatch is 22px square, which is enough
   for three repeats of a 4px pitch and therefore enough to tell 135deg from
   90deg from 45deg. */
.state-cell .patch {
  width: 22px;
  height: 22px;
  flex: none;
  border: 1px solid var(--hairline);
  background-color: var(--surface);
}

.state-cell .patch--missing { background-image: var(--state-missing); }
.state-cell .patch--unreadable { background-image: var(--state-unreadable); }
.state-cell .patch--elite { background-image: var(--who-elite); }

.state-blocked {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid var(--state-blocked);
  background: color-mix(in srgb, var(--state-blocked) 8%, transparent);
  color: var(--ink);
  font-size: var(--step-body-dense);
}

/* ---- Space specimens --------------------------------------------------- */

.space-row { display: flex; align-items: center; gap: var(--space-3); }
.space-row .bar { height: 14px; background: var(--who-me); }

/* ---- Responsive (§9) ---------------------------------------------------
 *
 * Breakpoints are 560 and 900. At <=560 the gutter drops to 16, the app
 * display ceiling drops to 26px, and two-column grids stack — which the
 * `auto-fit` minimums above already do, so only the type and the gutter need
 * saying.
 */
@media (max-width: 560px) {
  .guide { padding-left: var(--gutter-app-narrow); padding-right: var(--gutter-app-narrow); }
  .guide-bar { padding-left: var(--gutter-app-narrow); padding-right: var(--gutter-app-narrow); }
  .guide h2 { font-size: var(--step-display-3); letter-spacing: var(--track-20); }
  .type-row .meta { width: 100%; }
  .ramp { grid-template-columns: repeat(4, 1fr); }
  /* 36px is a reasonable segment on a desktop and a miss under a thumb. The
     44px floor is scoped to <=560px in §9, so it is applied here rather than
     inflating a dense control at every width. */
  .seg button { min-height: var(--touch-min); }
}
