/* doc-shell — the document idiom: ruled clauses, a marginal gutter for labels
   and numbers, one accent per sheet. Shared by check-your-file, data and the
   generated coverage table. */

:root {
  --bg: #131310;
  --bg-2: #1E1E1A;
  --bg-3: #282823;
  --ink: #ECEAE0;
  --ink-2: #B8B6AC;
  --ink-3: #76746C;
  --ink-base: #131310;
  --rule: #2E2D27;
  --rule-strong: #3E3D36;
  --accent: #C9E343;
  --accent-deep: #9BB02E;

  --sans: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --gutter: 176px;
  --gap: 34px;
  --head-h: 47px;
}

* { box-sizing: border-box; }

html {
  scroll-padding-top: calc(var(--head-h) + 16px);
}

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }
::selection { background: var(--accent); color: var(--ink-base); }

.sheet {
  max-width: 1104px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 48px);
}

.mono {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

p.mono { margin: 0; }

.measure { max-width: 64ch; }

/* ===== Running header ===== */

.doc-head {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(19, 19, 16, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rule-strong);
}

.doc-head-in {
  display: flex;
  align-items: center;
  gap: 10px 22px;
  min-width: 0;
  min-height: var(--head-h);
  padding-top: 7px;
  padding-bottom: 7px;
  flex-wrap: wrap;
}

.doc-mark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
  flex: 0 0 auto;
}

.doc-mark svg { width: 11px; height: 20px; display: block; color: var(--ink); }

.doc-mark b {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.025em;
  display: inline-flex;
  align-items: center;
}

.doc-mark i {
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
  margin-left: 3px;
  transform: translateY(-3px);
}

.doc-slug {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
  padding-left: 22px;
  border-left: 1px solid var(--rule-strong);
}

.doc-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  min-width: 0;
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.doc-nav a {
  color: var(--ink-3);
  text-decoration: none;
  white-space: nowrap;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
}

.doc-nav a:hover { color: var(--ink); border-bottom-color: var(--rule-strong); }

.doc-open {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--rule-strong);
  padding: 6px 11px;
  white-space: nowrap;
  flex: 0 0 auto;
}

.doc-open:hover { border-color: var(--accent); color: var(--accent); }

/* ===== Masthead ===== */

.masthead { padding: clamp(40px, 7vw, 84px) 0 clamp(16px, 2.5vw, 26px); }

.doc-kicker {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 22px;
}

.doc-kicker a { color: var(--ink-3); text-decoration: none; }
.doc-kicker a:hover { color: var(--accent); }
.doc-kicker b { color: var(--ink-2); font-weight: 400; }

h1.doc-title {
  font-weight: 500;
  font-size: clamp(33px, 5.2vw, 60px);
  line-height: 0.99;
  letter-spacing: -0.038em;
  color: var(--ink);
  margin: 0 0 clamp(28px, 4vw, 44px);
  max-width: 21ch;
  text-wrap: balance;
}

.masthead-foot {
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, 1fr);
  gap: var(--gap);
  border-top: 1px solid var(--rule-strong);
  padding-top: 20px;
}

.masthead-foot .abstract {
  font-size: clamp(16px, 1.5vw, 18.5px);
  line-height: 1.5;
  letter-spacing: -0.006em;
  color: var(--ink-2);
  margin: 0;
  max-width: 52ch;
}

.masthead-foot .abstract b { color: var(--ink); font-weight: 500; }

/* ===== Clauses ===== */

.clause {
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, 1fr);
  gap: var(--gap);
  border-top: 1px solid var(--rule-strong);
  margin-top: clamp(38px, 5vw, 58px);
  padding-top: 24px;
}

.clause-mark {
  font-family: var(--mono);
  font-size: 34px;
  font-weight: 500;
  line-height: 0.9;
  letter-spacing: -0.03em;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.clause-mark small {
  display: block;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--ink-3);
  margin-top: 10px;
  text-transform: uppercase;
  font-weight: 400;
}

.clause-body > :first-child { margin-top: 0; }

.clause-body h2 {
  font-weight: 500;
  font-size: clamp(21px, 2.3vw, 27px);
  line-height: 1.16;
  letter-spacing: -0.024em;
  color: var(--ink);
  margin: 0 0 14px;
  max-width: 30ch;
  text-wrap: balance;
}

.clause-body h3 {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 34px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}

.clause-body p {
  color: var(--ink-2);
  margin: 0 0 16px;
  max-width: 64ch;
}

.clause-body p:last-child { margin-bottom: 0; }
.clause-body p b, .clause-body p strong { color: var(--ink); font-weight: 600; }

.clause-body a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--rule-strong);
}

.clause-body a:hover { border-color: var(--accent); color: var(--accent); }

.clause-body code {
  font-family: var(--mono);
  font-size: 0.88em;
  letter-spacing: 0.01em;
  color: var(--ink);
}

/* Annex clause: the heading itself sits in the gutter, the answer beside it. */
.clause-annex { padding-top: 22px; }

.clause-annex > h2 {
  grid-column: 1;
  font-size: 15.5px;
  font-weight: 500;
  line-height: 1.32;
  letter-spacing: -0.012em;
  color: var(--ink);
  margin: 0;
}

.clause-annex .clause-body p { font-size: 14.5px; }

/* A lead statement: the sentence the sheet is built on. */
.lead-statement {
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, 1fr);
  gap: var(--gap);
  margin-top: clamp(34px, 4.5vw, 52px);
}

.lead-statement .lead-rule {
  border-top: 2px solid var(--accent);
  height: 0;
  width: 100%;
  margin-top: 14px;
}

.lead-statement p.say {
  font-size: clamp(20px, 2.3vw, 26px);
  line-height: 1.24;
  letter-spacing: -0.026em;
  color: var(--ink);
  font-weight: 500;
  margin: 0 0 14px;
  max-width: 30ch;
}

.lead-statement p {
  color: var(--ink-2);
  margin: 0 0 14px;
  max-width: 62ch;
}

.lead-statement p:last-child { margin-bottom: 0; }

/* ===== Schedule (a contract's schedule of terms) ===== */

.schedule { margin: 0; }

.sched-row {
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, 1fr);
  gap: 6px var(--gap);
  border-top: 1px solid var(--rule);
  padding: 15px 0;
}

.sched-row:first-of-type { border-top: 1px solid var(--rule-strong); }

.sched-row dt {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink);
  line-height: 1.5;
}

.sched-row dt span {
  display: block;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.1em;
  margin-bottom: 5px;
}

.sched-row dd {
  margin: 0;
  color: var(--ink-2);
  font-size: 15px;
  max-width: 64ch;
}

.sched-row dd a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--rule-strong);
}

.sched-row dd a:hover { color: var(--accent); border-color: var(--accent); }

.schedule + p { margin-top: 22px; }

/* ===== Numbered procedure ===== */

.procedure {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  max-width: 58ch;
  counter-reset: step;
}

/* A hanging indent, not a grid: a grid would make inline children
   (a <code> span) into grid items of their own. */
.procedure li {
  counter-increment: step;
  position: relative;
  border-top: 1px solid var(--rule);
  padding: 11px 0 11px 52px;
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.55;
}

.procedure li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 14px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.procedure li:first-child { border-top-color: var(--rule-strong); }

/* ===== Understated links ===== */

.out-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 22px 0 0;
}

.out {
  display: inline-block;
  border: 1px solid var(--rule-strong);
  padding: 9px 14px;
  font-size: 13.5px;
  white-space: nowrap;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.008em;
}

.out span {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  margin-left: 11px;
}

.out:hover { border-color: var(--ink-3); background: var(--bg-2); }
.out:hover span { color: var(--ink-2); }

.out.key { border-color: var(--accent); color: var(--accent); }
.out.key span { color: var(--accent-deep); }
.out.key:hover { background: var(--accent); color: var(--ink-base); border-color: var(--accent); }
.out.key:hover span { color: var(--ink-base); }

/* Prose links inside a clause are underlined; bordered links are not. */
.clause-body a.out { border-color: var(--rule-strong); color: var(--ink); }
.clause-body a.out:hover { border-color: var(--ink-3); color: var(--ink); background: var(--bg-2); }
.clause-body a.out.key { border-color: var(--accent); color: var(--accent); }
.clause-body a.out.key:hover { border-color: var(--accent); background: var(--accent); color: var(--ink-base); }

/* ===== Footer ===== */

.doc-foot {
  margin-top: clamp(52px, 8vw, 92px);
  border-top: 1px solid var(--rule-strong);
  padding: 22px 0 44px;
}

.doc-foot-in {
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, 1fr);
  gap: 14px var(--gap);
}

.doc-foot .fine {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.75;
  letter-spacing: 0.02em;
  color: var(--ink-3);
  margin: 0;
  max-width: 88ch;
}

.doc-foot .fine a {
  color: var(--ink-2);
  text-decoration: none;
  border-bottom: 1px solid var(--rule-strong);
}

.doc-foot .fine a:hover { color: var(--accent); border-color: var(--accent); }

.doc-foot .stamp {
  margin: 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  line-height: 1.8;
}

.doc-foot .stamp a { color: var(--ink-3); text-decoration: none; }
.doc-foot .stamp a:hover { color: var(--accent); }

/* ===== Figure row: numbers on a ruled line, never on cards ===== */

.figures {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  border-top: 1px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule-strong);
  margin: clamp(30px, 4vw, 48px) 0;
}

.figure { padding: 20px 20px 18px; border-left: 1px solid var(--rule); }
.figure:first-child { border-left: 0; padding-left: 0; }

.figure b {
  display: block;
  font-family: var(--mono);
  font-size: clamp(26px, 3vw, 38px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.035em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.figure b i { font-style: normal; font-size: 0.55em; color: var(--ink-3); }

.figure span {
  display: block;
  margin-top: 11px;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.6;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}

.figure.key b { color: var(--accent); }
.figure.key span { color: var(--ink-2); }

.clause-note {
  color: var(--ink-3) !important;
  font-size: 13.5px;
  max-width: 62ch;
}

/* ===== Guide furniture ===== */

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 30px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-top: 1px solid var(--rule);
  padding-top: 14px;
  margin-top: 26px;
}

.meta-row b { color: var(--ink); font-weight: 500; }

/* A callout is a marginal note, not an alert box. */
.callout {
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, 1fr);
  gap: var(--gap);
  border-top: 1px solid var(--rule-strong);
  margin-top: clamp(30px, 4vw, 44px);
  padding-top: 20px;
}

.callout-label {
  margin: 0;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  line-height: 1.6;
}

.callout-cta .callout-label { color: var(--accent); }

.callout-body {
  color: var(--ink-2);
  font-size: 14.5px;
  max-width: 68ch;
}

.callout-body b, .callout-body strong { color: var(--ink); font-weight: 600; }

.callout-body a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--rule-strong);
}

.callout-body a:hover { color: var(--accent); border-color: var(--accent); }

.callout-cta-row { margin-top: 15px; }

.callout-cta-row .nav-app-btn {
  display: inline-block;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 9px 14px;
  font-size: 13.5px;
  text-decoration: none;
  white-space: nowrap;
}

.callout-cta-row .nav-app-btn:hover { background: var(--accent); color: var(--ink-base); }

.context-cta { margin: 18px 0 0; color: var(--ink-3); font-size: 13px; }
.context-cta a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule-strong); }
.context-cta a:hover { color: var(--accent); border-color: var(--accent); }

.clause-body ul, .clause-body ol {
  color: var(--ink-2);
  margin: 0 0 16px;
  padding-left: 21px;
  max-width: 64ch;
}

.clause-body li { margin-bottom: 8px; }
.clause-body li::marker { color: var(--ink-3); }
.clause-body li b, .clause-body li strong { color: var(--ink); font-weight: 600; }

.code-block {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  background: var(--bg-2);
  border: 1px solid var(--rule);
  padding: 16px 18px;
  margin: 18px 0 22px;
  overflow-x: auto;
  color: var(--ink-2);
  white-space: pre;
}

.code-block .err { color: #E38B8B; }
.code-block .ok { color: var(--ink); }
.code-block .dim { color: var(--ink-3); }

/* ===== Rule lists (hard stops, error translator) ===== */

.rid {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: var(--bg-3);
  border: 1px solid var(--rule-strong);
  padding: 2px 7px;
  white-space: nowrap;
}

.rid.warn { color: var(--ink-3); background: transparent; }

.rule-section {
  margin: clamp(38px, 5vw, 54px) 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--rule-strong);
  scroll-margin-top: calc(var(--guide-header-height, 80px) + 16px);
}

.rule-section:first-child { margin-top: 0; }

.rule-section h2 {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0 0 4px;
  font-weight: 500;
  font-size: clamp(19px, 2.2vw, 24px);
  letter-spacing: -0.024em;
  color: var(--ink);
}

.rule-copy .rule-section h2::before {
  counter-increment: sec;
  content: counter(sec, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.rule-section h2 .count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 400;
}

.rule-list { list-style: none; margin: 14px 0 0; padding: 0; }

.rule-item {
  position: relative;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 13.5px;
  line-height: 1.55;
}

.rule-item:last-child { border-bottom: 0; }

.rule-item > a[id] {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  scroll-margin-top: calc(var(--guide-header-height, 80px) + 16px);
  pointer-events: none;
}

.rid-group { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.rule-item .txt { color: var(--ink-2); max-width: 74ch; overflow-wrap: anywhere; }

.rule-item .sub {
  display: block;
  margin-bottom: 3px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ===== Cross-links: an index, not a row of cards ===== */

.guide-links {
  display: block;
  border-top: 1px solid var(--rule-strong);
  margin: clamp(44px, 6vw, 68px) 0 0;
}

.guide-links a {
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, 1fr);
  gap: var(--gap);
  padding: 13px 0;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
}

.guide-links a:hover .gl-t { color: var(--accent); }

.gl-k {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.gl-t { font-size: 15px; color: var(--ink); letter-spacing: -0.012em; }

.guide-links a[aria-current="page"] { cursor: default; }
.guide-links a[aria-current="page"] .gl-t { color: var(--ink-3); }

@media (max-width: 820px) {
  .callout, .guide-links a { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .rule-item { grid-template-columns: minmax(0, 1fr); gap: 5px; }
  .rid-group { flex-direction: row; flex-wrap: wrap; }
  .rule-section h2 .count { margin-left: 0; flex-basis: 100%; }
}

/* ===== Responsive ===== */

/* The running slug is a luxury: it yields to the index and the action. */
@media (max-width: 1400px) {
  .doc-slug { display: none; }
}

/* The guide index drops to its own row long before it could crowd the action. */
@media (max-width: 1100px) {
  :root { --head-h: 80px; }

  .doc-nav {
    order: 3;
    flex-basis: 100%;
    margin-left: 0;
  }

  .doc-open { margin-left: auto; }
}

@media (max-width: 1000px) {
  :root { --gutter: 128px; --gap: 26px; }
}

@media (max-width: 900px) {
  .figures { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figure { border-top: 1px solid var(--rule); }
  .figure:first-child, .figure:nth-child(2) { border-top: 0; }
  .figure:nth-child(odd) { border-left: 0; padding-left: 0; }
}

@media (max-width: 820px) {
  .masthead-foot,
  .clause,
  .clause-annex,
  .lead-statement,
  .sched-row,
  .doc-foot-in {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .clause-annex > h2 { font-size: 17px; }

  .clause-mark {
    font-size: 12px;
    letter-spacing: 0.16em;
    line-height: 1.4;
    color: var(--ink-3);
  }

  .clause-mark small { display: inline; margin: 0 0 0 12px; }
  .lead-statement .lead-rule { margin-top: 0; width: 40px; }
  .sched-row { padding: 14px 0 16px; }
  .sched-row dt span { display: inline; margin: 0 11px 0 0; }
}

/* Two rows of guide links at phone width. */
@media (max-width: 620px) {
  :root { --head-h: 104px; }
}

@media (max-width: 480px) {
  .figures { grid-template-columns: minmax(0, 1fr); border-top: 0; }
  .figure,
  .figure:first-child,
  .figure:nth-child(2),
  .figure:nth-child(odd) {
    padding: 15px 0 14px;
    border-left: 0;
    border-top: 1px solid var(--rule);
  }

  body { font-size: 14.5px; }
  h1.doc-title { font-size: clamp(27px, 8.4vw, 34px); max-width: none; }
  .doc-mark b { font-size: 15px; }
  .clause-body h2 { max-width: none; }
  .procedure li { padding-left: 40px; }
  .out { font-size: 12.5px; padding: 8px 12px; }
}
