/* ==========================================================================
   LIBRARY.CSS — /case-studies, /docs, /about page layer · Tier 3
   Loads LAST, after brand.css, and overrides nothing outside these three
   pages' own components. Existing tokens only: no new colours, no new type
   roles, hairlines only, radius ladder 2 / 6 / 10, 8pt spacing.

   These are reference pages an evaluator forwards into a committee.
   Motion stays quiet: the shared data-reveal system, 24px travel.
   ========================================================================== */

/* Quieter reveals than the marketing pages, matching /trust and /legal.
   motion.css already double-gates behind @supports + prefers-reduced-motion
   with a visible base state; nothing new to gate here. */
[data-reveal] { --reveal-distance: 24px; }

/* --------------------------------------------------------------------------
   1. SHARED — page-hero additions, section shell, notes, CTA band.
   Same idioms as trust.css / platform.css, restated because those files
   never load on these pages.
   -------------------------------------------------------------------------- */
.ph-actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-2); }
.ph-note { margin-top: var(--sp-2); }
@media (min-width: 900px) {
  .page-hero__grid .ph-actions { grid-column: 1 / 8; }
  .page-hero__grid .ph-note { grid-column: 1 / 8; }
}

.lsec { padding-block: var(--sp-16); border-top: var(--rule) solid var(--border); }
@media (min-width: 900px) { .lsec { padding-block: var(--sp-20); } }
.lsec--surface { background: var(--surface); }
.lsec .sec-head { margin-bottom: var(--sp-8); }
@media (min-width: 900px) { .lsec .sec-head { margin-bottom: var(--sp-10); } }
.lsec .sec-head .lede { max-width: 52ch; }
.lsec .grid-12 { align-items: start; }

.note { font-size: var(--t-sm); color: var(--muted); max-width: 62ch; }
.note a, .lede a, .doc-body a, .cs a {
  color: var(--fg);
  text-underline-offset: 3px;
  text-decoration-color: var(--border-strong);
  transition: text-decoration-color var(--duration-fast) var(--ease-ui);
}
@media (hover: hover) and (pointer: fine) {
  .note a:hover, .lede a:hover, .doc-body a:hover, .cs a:hover { text-decoration-color: var(--accent); }
}
.note--after-table { margin-top: var(--sp-5); }

.band-cta { border-top: var(--rule) solid var(--border); padding-block: var(--sp-10); }
.band-cta__inner { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-4) var(--sp-6); }
.band-cta__lead { flex: 1 1 16rem; display: grid; gap: var(--sp-2); }
.band-cta__lead strong { font-family: var(--font-display); font-weight: 700; font-size: var(--t-h3); letter-spacing: var(--tr-h3); line-height: var(--lh-h3); }
.band-cta__actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); }

/* Data tables — identical voice to the /integrations directory tables */
.dt { width: 100%; min-width: 640px; border-collapse: collapse; }
.dt--narrow { min-width: 480px; }
.dt caption {
  text-align: left;
  padding: var(--sp-4);
  font-family: var(--font-mono);
  font-size: var(--t-tag);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: var(--rule) solid var(--border);
}
.dt th, .dt td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: var(--rule) solid var(--border);
  text-align: left;
  vertical-align: top;
  font-size: var(--t-sm);
}
.dt thead th {
  font-family: var(--font-mono);
  font-size: var(--t-tag);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.dt tbody th { font-weight: 500; color: var(--fg); }
.dt tbody td { color: var(--muted); }
.dt tbody tr:last-child th, .dt tbody tr:last-child td { border-bottom: none; }
.dt .mono { font-size: 0.8125rem; }
.dt a {
  color: var(--fg);
  text-underline-offset: 3px;
  text-decoration-color: var(--border-strong);
  transition: text-decoration-color var(--duration-fast) var(--ease-ui);
}
@media (hover: hover) and (pointer: fine) { .dt a:hover { text-decoration-color: var(--accent); } }

/* Fact ledger — bracket key left, plain answer right (about page) */
.facts { border-top: var(--rule) solid var(--border); }
.facts > div {
  display: grid;
  gap: var(--sp-2);
  padding-block: var(--sp-5);
  border-bottom: var(--rule) solid var(--border);
}
@media (min-width: 720px) {
  .facts > div { grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); column-gap: var(--gutter); }
}
.facts dt { align-self: start; }
.facts dd strong {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.facts dd p { font-size: var(--t-sm); color: var(--muted); max-width: 56ch; margin-top: var(--sp-1); }

/* --------------------------------------------------------------------------
   2. /case-studies · FILTER ROW — real buttons, one row above the results.
   The pressed state grows the signature brackets, so state is never
   colour-only: [food and beverage] is on, food and beverage is off.
   Hidden until filter.js arrives; without JS the library is simply whole.
   -------------------------------------------------------------------------- */
.cs-controls { display: grid; gap: var(--sp-4); margin-bottom: var(--sp-6); }
.cs-controls[hidden] { display: none; }
.fgroup { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.fgroup > .tag { flex: none; margin-right: var(--sp-2); }
.fbtn {
  min-height: 44px;
  padding: 0 var(--sp-4);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  color: var(--muted);
  background: var(--bg);
  border: var(--rule) solid var(--border);
  border-radius: var(--r-sm);
  touch-action: manipulation;
  transition: color var(--duration-fast) var(--ease-ui),
              border-color var(--duration-fast) var(--ease-ui),
              background-color var(--duration-fast) var(--ease-ui);
}
@media (hover: hover) and (pointer: fine) {
  .fbtn:hover { color: var(--fg); border-color: var(--border-strong); }
}
.fbtn[aria-pressed="true"] {
  color: var(--fg);
  font-weight: 500;
  border-color: var(--border-strong);
  background: var(--accent-wash);
}
.fbtn::before { content: "\00a0"; font-weight: 500; color: var(--accent-text); }
.fbtn::after  { content: "\00a0"; font-weight: 500; color: var(--accent-text); }
.fbtn[aria-pressed="true"]::before { content: "["; }
.fbtn[aria-pressed="true"]::after  { content: "]"; }

.cs-count { margin-bottom: var(--sp-6); }

/* --------------------------------------------------------------------------
   3. /case-studies · THE LIBRARY — a 12-column grid with deliberately
   uneven spans and weights: 8/4, 5/7, 5/7. Filtered entries leave via
   `hidden`; nothing animates layout height, so the reflow is one clean
   user-initiated step.
   -------------------------------------------------------------------------- */
.cs-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--sp-4) var(--gutter); }
@media (min-width: 900px) { .cs-grid { row-gap: var(--sp-6); } }
.cs { grid-column: 1 / -1; }
@media (min-width: 900px) {
  .cs--8 { grid-column: span 8; }
  .cs--7 { grid-column: span 7; }
  .cs--5 { grid-column: span 5; }
  .cs--4 { grid-column: span 4; }
}
.cs[hidden] { display: none; }

.cs {
  display: grid;
  align-content: start;
  gap: var(--sp-4);
  border: var(--rule) solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
  padding: var(--sp-6);
}
.cs-grid .cs--lead { border-color: var(--border-strong); }
.cs__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); }
.cs__head .tag { display: inline-flex; }
.cs h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--t-h3);
  line-height: 1.1;
  letter-spacing: -0.02em;
  max-width: 24ch;
}
.cs--lead h3 { font-size: clamp(1.5rem, 1.2rem + 1.6vw, 2.25rem); max-width: 22ch; }
.cs__body { font-size: var(--t-sm); color: var(--muted); max-width: 52ch; }
.cs .big { margin-block: var(--sp-2) 0; }

/* The results ledger inside an entry — label + tabular numeral per row */
.cs__stats { border-top: var(--rule) solid var(--border); }
.cs__stats > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: var(--sp-4);
  align-items: baseline;
  padding-block: var(--sp-3);
  border-bottom: var(--rule) solid var(--border);
}
.cs__stats > div:last-child { border-bottom: none; }
.cs__stats dt { font-size: var(--t-sm); color: var(--muted); }
.cs__stats dt .tag { display: inline; }
.cs__stats dd {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums lining-nums;
  font-weight: 500;
  font-size: 1.0625rem;
  letter-spacing: -0.02em;
  color: var(--fg);
  white-space: nowrap;
}
.cs__stats dd small { font-family: var(--font-mono); font-size: 0.75rem; font-weight: 400; color: var(--muted); }
.cs__foot { margin-top: auto; }

/* The testimonial slot — the exact treatment a real review would get,
   holding an explicit placeholder instead of an invented person. */
.cs__quote {
  margin: 0;
  padding-left: var(--sp-4);
  border-left: 2px solid var(--accent);
}
.cs__quote p {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.25rem, 1.1rem + 0.8vw, 1.625rem);
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: var(--fg);
  max-width: 30ch;
}
.cs__attr { margin-top: var(--sp-3); }

/* Empty state — full width, dashed hairline, the system's assumption voice */
.cs-empty {
  grid-column: 1 / -1;
  border: var(--rule) dashed var(--border-strong);
  border-radius: var(--r-sm);
  padding: var(--sp-6);
  display: grid;
  gap: var(--sp-2);
  justify-items: start;
}
.cs-empty p:not(.tag) { font-size: var(--t-sm); color: var(--muted); max-width: 52ch; }
.cs-empty[hidden] { display: none; }

/* --------------------------------------------------------------------------
   4. /docs · DOCUMENT LAYOUT — the legal.css approach, restated: sticky
   15rem ToC rail at 900px+, 66ch measure, hairline-separated clauses,
   mono bracket clause numbering.
   -------------------------------------------------------------------------- */
.doc { padding-block: 0 var(--sp-20); }
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-10); align-items: start; }
@media (min-width: 900px) {
  .doc-layout { grid-template-columns: minmax(0, 15rem) minmax(0, 1fr); gap: var(--sp-16); }
  .doc-toc {
    position: sticky;
    top: calc(var(--header-h) + var(--sp-6));
    max-height: calc(100svh - var(--header-h) - var(--sp-12));
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}
.doc-toc { border-top: var(--rule) solid var(--border); padding-top: var(--sp-5); }
.doc-toc .tag { margin-bottom: var(--sp-2); }
.toc-list a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 44px;
  padding-block: var(--sp-1);
  font-size: var(--t-sm);
  line-height: 1.35;
  color: var(--muted);
  text-decoration: none;
  border-bottom: var(--rule) solid var(--border);
  transition: color var(--duration-fast) var(--ease-ui);
}
.toc-list .cno { flex: none; min-width: 3.2ch; }
@media (hover: hover) and (pointer: fine) { .toc-list a:hover { color: var(--fg); } }
.toc-rel { margin-top: var(--sp-8); }

.clause { max-width: 66ch; }
.clause + .clause { border-top: var(--rule) solid var(--border); padding-top: var(--sp-8); margin-top: var(--sp-8); }
.clause > * + * { margin-block-start: var(--sp-4); }
.clause h2 {
  font-size: clamp(1.375rem, 1.15rem + 1vw, 1.75rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.clause h3 {
  font-size: 1.0625rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin-block-start: var(--sp-8);
}
.clause p { line-height: 1.6; }
.clause .tag { display: inline; }
.clause--wide { max-width: 56rem; }
.clause--wide > p, .clause--wide > ul { max-width: 66ch; }

.cno {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums lining-nums;
  font-weight: 500;
  font-size: 0.78em;
  letter-spacing: 0.02em;
  color: var(--accent-text);
  margin-right: 0.4em;
}

.doc-list li {
  position: relative;
  padding-left: 1.5em;
  margin-block-start: var(--sp-3);
  line-height: 1.6;
}
.doc-list li::before {
  content: "\00b7";
  position: absolute;
  left: 0.25em;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--accent-text);
}
.doc-list b { color: var(--fg); }
.doc-note { font-size: var(--t-sm); color: var(--muted); }
.doc-table { margin-block-start: var(--sp-6); }

/* Lifecycle ledger — the four states as a keyed list */
.lifecycle { border-top: var(--rule) solid var(--border); }
.lifecycle > div {
  display: grid;
  gap: var(--sp-1);
  padding-block: var(--sp-4);
  border-bottom: var(--rule) solid var(--border);
}
@media (min-width: 640px) {
  .lifecycle > div { grid-template-columns: minmax(0, 10rem) minmax(0, 1fr); column-gap: var(--gutter); }
}
.lifecycle dt { font-family: var(--font-mono); font-size: 0.8125rem; font-weight: 500; color: var(--fg); }
.lifecycle dd { font-size: var(--t-sm); color: var(--muted); }

/* --------------------------------------------------------------------------
   5. /docs · CODE — real <pre><code>, a labelled bar, a real copy button.
   The block scrolls inside itself; the page never scrolls sideways.
   Copy buttons are hidden until filter.js arrives, since a dead control
   is worse than none.
   -------------------------------------------------------------------------- */
.code {
  margin: var(--sp-6) 0 0;
  border: var(--rule) solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}
.code__bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 48px;
  padding: var(--sp-1) var(--sp-2) var(--sp-1) var(--sp-4);
  border-bottom: var(--rule) solid var(--border);
  background: var(--bg);
}
.code__bar > .tag { margin-right: auto; }
.code__status { font-family: var(--font-mono); font-size: var(--t-tag); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-text); }
.copy-btn {
  min-height: 44px;
  padding: 0 var(--sp-4);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg);
  border: var(--rule) solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--bg);
  touch-action: manipulation;
  transition: background-color var(--duration-fast) var(--ease-ui), border-color var(--duration-fast) var(--ease-ui);
}
@media (hover: hover) and (pointer: fine) { .copy-btn:hover { background: var(--surface-2); border-color: var(--fg); } }
.copy-btn[hidden] { display: none; }
.code pre {
  margin: 0;
  padding: var(--sp-4) var(--sp-5);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.65;
  color: var(--fg);
  tab-size: 2;
}
.code code { font-family: inherit; }

/* --------------------------------------------------------------------------
   6. /about · PRINCIPLES, ROLES, HIRING — ledgers, not cards.
   -------------------------------------------------------------------------- */
.roles { border-top: var(--rule) solid var(--border); }
.roles > li {
  display: grid;
  gap: var(--sp-2);
  padding-block: var(--sp-5);
  border-bottom: var(--rule) solid var(--border);
}
@media (min-width: 900px) {
  .roles > li {
    grid-template-columns: minmax(0, 6fr) minmax(0, 3fr) minmax(0, 3fr);
    column-gap: var(--gutter);
    align-items: baseline;
  }
}
.roles strong {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1875rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.roles .role__meta { font-size: var(--t-sm); color: var(--muted); }
.roles .role__band {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums lining-nums;
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--fg);
  white-space: nowrap;
}
.roles .role__band .tag { display: inline; }
@media (min-width: 900px) { .roles .role__band { justify-self: end; text-align: right; } }
.roles .role__note { grid-column: 1 / -1; font-size: var(--t-sm); color: var(--muted); max-width: 62ch; }

.hire-steps { border-top: var(--rule) solid var(--border); }
.hire-steps li {
  display: grid;
  gap: var(--sp-2);
  padding-block: var(--sp-5);
  border-bottom: var(--rule) solid var(--border);
}
.hire-steps strong {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.hire-steps p:not(.tag) { font-size: var(--t-sm); color: var(--muted); max-width: 56ch; }

/* The one large numeral on /about, adjacent to the thesis it proves */
.ab-lede { margin-top: var(--sp-6); max-width: 34ch; }
.ab-num .huge { margin-block: var(--sp-4); }

/* --------------------------------------------------------------------------
   7. CLOSING — same decelerating ending as the rest of the site.
   -------------------------------------------------------------------------- */
.lib-closing { padding-block: var(--sp-16) var(--sp-24); background: var(--surface); border-top: var(--rule) solid var(--border); }
.lib-closing .grid-12 { align-items: end; }
.lib-closing__actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); }

/* --------------------------------------------------------------------------
   8. REDUCED MOTION — nothing here animates on its own; transitions are
   colour-only and base.css collapses them. Restated for the one border
   transition on .fbtn so state changes stay instant.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .fbtn, .copy-btn { transition-duration: 0.01ms; }
}
