/* ==========================================================================
   Handover documents (brand book, theme playbook) — playbook §14.3.
   Loaded from the document sections only, never from layout/theme.html, so
   these pages cost the storefront nothing.

   Chapters are blocks inside ONE section: the platform wraps every section in
   <div id="shopline-section-…>, and a sticky element cannot escape its own
   wrapper (§11.1), so the contents rail only follows the reader if the whole
   document lives in a single section.

   Chapter and contents numbering is done with CSS counters, never written in,
   so reordering or hiding a chapter in the editor renumbers everything.
   ========================================================================== */

.doc {
  --doc-rail: 250px;
  counter-reset: doc-chapter;
  background: var(--white);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--fs-body);
  line-height: var(--lh-normal);
}

/* ---------- cover ---------- */
.doc__cover {
  border-bottom: 1px solid var(--ink);
  padding-block: clamp(3rem, 8vw, 6rem) clamp(2rem, 4vw, 3rem);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.doc__kicker { font-family: var(--font-mono); font-size: var(--fs-eyebrow); letter-spacing: var(--ls-eyebrow); text-transform: uppercase; color: var(--accent-text); }
.doc__title { font-family: var(--font-display); font-weight: 200; font-size: var(--fs-display-md); line-height: var(--lh-tight); letter-spacing: var(--ls-display); margin: 0; }
.doc__standfirst { font-size: var(--fs-lead); line-height: var(--lh-relaxed); color: var(--body); max-width: 62ch; margin: 0; }

/* the colophon states the page is unpublished — otherwise the next person
   assumes a page nobody linked is a page nobody can reach */
.doc__colophon {
  display: flex; flex-wrap: wrap; gap: 8px 22px;
  font-family: var(--font-mono); font-size: var(--fs-2xs);
  letter-spacing: 0.06em; color: var(--mute);
  border-top: 1px solid var(--line); padding-top: 16px; margin-top: 8px;
}

/* ---------- body: rail + chapters ---------- */
.doc__body { display: grid; grid-template-columns: var(--doc-rail) minmax(0, 1fr); gap: var(--gap-split); align-items: start; padding-block: clamp(2rem, 5vw, 3.5rem); }
.doc__rail { position: sticky; top: var(--sticky-top); display: flex; flex-direction: column; gap: 10px; }
.doc__rail-title { font-family: var(--font-mono); font-size: var(--fs-eyebrow-sm); letter-spacing: var(--ls-eyebrow); text-transform: uppercase; color: var(--mute); margin-bottom: 4px; }
.doc__rail ol { counter-reset: doc-index; display: flex; flex-direction: column; gap: 2px; }
.doc__rail li { counter-increment: doc-index; }
.doc__rail a {
  display: grid; grid-template-columns: 2.1em 1fr; gap: 4px;
  padding: 7px 0; font-size: var(--fs-xs); line-height: var(--lh-snug);
  color: var(--body); text-decoration: none; border-bottom: 1px solid var(--line-soft);
}
/* counter carriers must be spans: the base sheet hides empty h*, p, a, ol, ul, dl */
.doc__rail a::before { content: counter(doc-index, decimal-leading-zero); font-family: var(--font-mono); font-size: var(--fs-eyebrow-sm); color: var(--mute); letter-spacing: .08em; }
.doc__rail a:hover { color: var(--ink); border-bottom-color: var(--sand); }
.doc__rail a[aria-current="true"] { color: var(--ink); font-weight: 600; }

.doc__chapters { display: flex; flex-direction: column; gap: clamp(2.5rem, 6vw, 4.5rem); }

.doc__chapter { counter-increment: doc-chapter; scroll-margin-top: calc(var(--sticky-top) + 10px); }
.doc__chapter-head { display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--ink); padding-top: 18px; margin-bottom: 24px; }
.doc__chapter-num { font-family: var(--font-mono); font-size: var(--fs-eyebrow-sm); letter-spacing: var(--ls-eyebrow); text-transform: uppercase; color: var(--accent-text); }
.doc__chapter-num::before { content: "Chapter " counter(doc-chapter, decimal-leading-zero); }
.doc__chapter-title { font-family: var(--font-display); font-weight: 300; font-size: var(--fs-h2-sm); line-height: var(--lh-snug); margin: 0; }
.doc__chapter-intro { font-size: var(--fs-body-lg); line-height: var(--lh-relaxed); color: var(--body); max-width: 68ch; margin: 0; }

.doc__section { display: flex; flex-direction: column; gap: 14px; margin-top: 30px; }
.doc__section-title { font-family: var(--font-mono); font-size: var(--fs-eyebrow-sm); letter-spacing: var(--ls-eyebrow); text-transform: uppercase; color: var(--mute); }
.doc p { font-size: var(--fs-body-sm); line-height: var(--lh-relaxed); color: var(--body); max-width: 68ch; margin: 0; }
.doc strong { color: var(--ink); font-weight: 600; }
.doc code { font-family: var(--font-mono); font-size: 0.9em; background: var(--bone); padding: 2px 5px; color: var(--ink-soft); }

/* Hanging-marker list. NOT a grid: "<strong>Lead.</strong> then a sentence"
   is three grid items (marker, inline element, anonymous trailing text), and
   the third wraps to a new row, sizes the auto track to the paragraph and
   collapses the 1fr beside it — which pushes the page sideways on a phone. */
.doc__list { display: flex; flex-direction: column; gap: 11px; }
.doc__list li { position: relative; padding-left: 20px; font-size: var(--fs-body-sm); line-height: var(--lh-relaxed); color: var(--body); }
.doc__list li::before { content: "—"; position: absolute; left: 0; top: 0; color: var(--sand-deep); }

/* ---------- measured specimens ---------- */
.doc__swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.doc__swatch { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--line); overflow: hidden; }
.doc__swatch-chip { height: 68px; }
.doc__swatch-meta { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--white); }
.doc__swatch-name { font-family: var(--font-mono); font-size: var(--fs-2xs); color: var(--ink); }
.doc__swatch-val { font-family: var(--font-mono); font-size: var(--fs-eyebrow-sm); color: var(--mute); letter-spacing: .04em; }
.doc__swatch-role { font-size: var(--fs-eyebrow-sm); color: var(--body-soft); line-height: 1.5; }

.doc__ladder { display: flex; flex-direction: column; gap: 4px; }
.doc__rung { display: grid; grid-template-columns: minmax(0, 1fr) 7.5em 5em; gap: 14px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.doc__rung-sample { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.doc__rung-token { font-family: var(--font-mono); font-size: var(--fs-eyebrow-sm); color: var(--mute); letter-spacing: .04em; }
.doc__rung-value { font-family: var(--font-mono); font-size: var(--fs-eyebrow-sm); color: var(--ink-soft); text-align: right; }

.doc__bars { display: flex; flex-direction: column; gap: 8px; }
.doc__bar { display: grid; grid-template-columns: 9em minmax(0, 1fr) 5em; gap: 12px; align-items: center; }
.doc__bar-fill { height: 12px; background: var(--accent-pale); border-left: 2px solid var(--accent); min-width: 2px; }
.doc__bar-token { font-family: var(--font-mono); font-size: var(--fs-eyebrow-sm); color: var(--mute); letter-spacing: .04em; }
.doc__bar-value { font-family: var(--font-mono); font-size: var(--fs-eyebrow-sm); color: var(--ink-soft); text-align: right; }

.doc__contrast { display: flex; flex-direction: column; gap: 6px; }
.doc__pair { display: grid; grid-template-columns: minmax(0, 1fr) 4.5em 3.5em; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.doc__pair-demo { padding: 8px 12px; font-size: var(--fs-xs); }
.doc__pair-ratio { font-family: var(--font-mono); font-size: var(--fs-eyebrow-sm); text-align: right; color: var(--ink-soft); }
.doc__pair-verdict { font-family: var(--font-mono); font-size: var(--fs-eyebrow-sm); text-align: right; }
.doc__pair-verdict[data-pass="true"] { color: var(--accent-text); }
.doc__pair-verdict[data-pass="false"] { color: var(--alert); font-weight: 600; }

/* ---------- reference tables ---------- */
.doc__table-wrap { overflow-x: auto; }
.doc table { border-collapse: collapse; width: 100%; min-width: 460px; }
.doc th, .doc td { text-align: left; vertical-align: top; padding: 10px 14px 10px 0; border-bottom: 1px solid var(--line-soft); font-size: var(--fs-xs); line-height: var(--lh-normal); }
.doc th { font-family: var(--font-mono); font-size: var(--fs-eyebrow-sm); letter-spacing: var(--ls-eyebrow); text-transform: uppercase; color: var(--mute); font-weight: 400; border-bottom-color: var(--sand); }
.doc td { color: var(--body); }
.doc td:first-child { color: var(--ink); white-space: nowrap; }

.doc__note { display: flex; gap: 10px; background: var(--bone); border-left: 2px solid var(--sand); padding: 14px 18px; font-size: var(--fs-xs); line-height: var(--lh-normal); color: var(--body-soft); }
.doc__note strong { color: var(--ink-soft); }

.doc__specimen { border: 1px solid var(--line); padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.doc__mark-grounds { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.doc__ground { display: flex; align-items: center; justify-content: center; padding: 26px 18px; border: 1px solid var(--line); min-height: 104px; }
.doc__ground img { max-width: 100%; height: auto; width: 116px; }
.doc__ground-label { font-family: var(--font-mono); font-size: var(--fs-eyebrow-sm); color: var(--mute); text-align: center; margin-top: 6px; display: block; }

@media (max-width: 900px) {
  .doc__body { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .doc__rail { position: static; border-bottom: 1px solid var(--line); padding-bottom: 18px; }
  .doc__rung { grid-template-columns: minmax(0, 1fr) 6.5em; }
  .doc__rung-value { display: none; }
  .doc__bar { grid-template-columns: 7em minmax(0, 1fr) 4.5em; }
  .doc__pair { grid-template-columns: minmax(0, 1fr) 4em 3.5em; }
}
