/* Prose-first documentation layer. Loads after site.css and keeps the shared light/dark palette. */

body.doc-mode::before,
body.doc-mode::after { display: none; }

body.doc-mode .site-header { background: color-mix(in srgb, var(--paper) 95%, transparent); border-bottom: 1px solid var(--line); box-shadow: none; }
body.doc-mode .header-inner { max-width: 1180px; min-height: 64px; padding: 0 20px; gap: 16px; }
body.doc-mode .brand { min-width: auto; font-family: var(--serif); font-size: 18px; font-weight: 560; letter-spacing: 0; }
body.doc-mode .brand small { display: none; }
body.doc-mode .primary-nav a { padding: 8px 10px; font-size: 13.5px; letter-spacing: 0; text-transform: none; }
body.doc-mode .theme-toggle { width: auto; height: auto; padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--muted); font: 500 11px var(--mono); cursor: pointer; }
body.doc-mode .nav-toggle { font-size: 13px; }

.doc-wrap { max-width: 820px; margin: 0 auto; padding: 58px 20px 104px; }
.limits-wrap { max-width: 980px; }
.doc-wrap > h1 { max-width: 780px; margin: 8px 0 14px; font-size: clamp(34px, 4.3vw, 48px); line-height: 1.13; font-weight: 520; }
.doc-wrap h2 { margin: 50px 0 13px; font-size: clamp(25px, 2.7vw, 31px); line-height: 1.24; font-weight: 540; }
.doc-wrap h3 { margin: 30px 0 8px; font-size: 19px; line-height: 1.35; font-weight: 650; }
.doc-wrap h4 { margin: 24px 0 7px; font-size: 16px; }
.doc-wrap p,
.doc-wrap li { color: var(--ink); font-size: 16px; line-height: 1.7; }
.doc-wrap p { margin: 0 0 15px; }
.doc-wrap ul,
.doc-wrap ol { margin: 0 0 18px; padding-left: 25px; }
.doc-wrap li { margin-bottom: 7px; }
.doc-wrap a { color: var(--blue); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--blue) 34%, transparent); }
.doc-wrap a:hover { border-bottom-color: var(--blue); }
.doc-wrap code { padding: .08em .32em; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-2); font-size: .9em; }

.doc-meta { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-bottom: 14px; color: var(--muted); font: 11.5px/1.5 var(--mono); text-transform: uppercase; letter-spacing: .045em; }
.doc-meta b { color: var(--ink-2); font-weight: 600; }
.doc-dateline { margin: 0 0 34px; color: var(--muted); font: 12px/1.5 var(--mono); }
.doc-lede { max-width: 760px; margin: 0 0 32px !important; color: var(--ink-2) !important; font-size: 18px !important; line-height: 1.62 !important; }
.status-label,
.task-number,
.phase-label { margin: 0 0 7px !important; color: var(--cyan) !important; font: 600 10.5px/1.4 var(--mono) !important; letter-spacing: .085em; text-transform: uppercase; }

.ref { padding: 0 1px; border-bottom: 0 !important; color: var(--cyan) !important; font: 500 12px var(--mono); white-space: nowrap; }
.ref:hover { text-decoration: underline; }

.doc-note,
.boundary-note { margin: 22px 0; padding: 15px 18px; border-left: 3px solid var(--line-strong); border-radius: 0 8px 8px 0; background: color-mix(in srgb, var(--surface) 82%, transparent); }
.doc-note p,
.boundary-note p { margin-bottom: 8px; color: var(--ink-2); }
.doc-note p:last-child,
.boundary-note p:last-child { margin-bottom: 0; }
.limitation-note { border-left-color: var(--amber); background: color-mix(in srgb, var(--amber) 6%, var(--surface)); }

.jump-nav { display: flex; flex-wrap: wrap; gap: 7px; margin: 26px 0 42px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.jump-nav a { padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink-2); background: var(--paper); font-size: 12.5px; font-weight: 600; }
.jump-nav a:hover { border-color: var(--line-strong); color: var(--ink); }

.doc-wrap table { width: 100%; border-collapse: collapse; margin: 18px 0 24px; font-size: 14px; }
.doc-wrap th { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line-strong); color: var(--muted); text-align: left; vertical-align: bottom; font: 600 10.5px/1.4 var(--mono); letter-spacing: .05em; text-transform: uppercase; }
.doc-wrap td { padding: 11px 12px 11px 0; border-bottom: 1px solid var(--line); color: var(--ink-2); vertical-align: top; line-height: 1.55; }
.doc-wrap tfoot th,
.doc-wrap tfoot td { background: color-mix(in srgb, var(--cyan) 5%, transparent); color: var(--ink); font-weight: 650; }
.table-scroll { width: 100%; overflow-x: auto; margin: 18px 0 24px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.table-scroll table { min-width: 720px; margin: 0; }
.table-scroll th:first-child,
.table-scroll td:first-child { padding-left: 14px; }
.table-scroll th:last-child,
.table-scroll td:last-child { padding-right: 14px; }

.doc-wrap pre { overflow-x: auto; padding: 15px 17px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); color: var(--ink-2); font-size: 12.5px; line-height: 1.58; }
.doc-wrap blockquote { margin: 16px 0 16px 18px; padding-left: 16px; border-left: 2px solid var(--line-strong); color: var(--ink-2); font-style: italic; }
.doc-wrap blockquote p { color: inherit; font-size: 15px; }
.doc-wrap hr { margin: 44px 0; border: 0; border-top: 1px solid var(--line); }

/* Task-oriented technical guide */
.task-section { margin-top: 48px; padding-top: 10px; border-top: 1px solid var(--line); scroll-margin-top: 92px; }
.task-section h2 { margin-top: 8px; }
.priority-task { padding: 26px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); }
.task-links { display: grid; gap: 10px; margin-top: 20px; }
.task-link { display: grid; gap: 4px; padding: 16px 18px; border: 1px solid var(--line) !important; border-radius: 8px; background: var(--surface); }
.task-link:hover { border-color: var(--line-strong) !important; }
.task-link b { color: var(--ink); }
.task-link span { color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.primary-task-link { border-left: 3px solid var(--cyan) !important; }
.task-steps li { padding-left: 4px; }
.inline-resource-list { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 20px 0; }
.reference-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.reference-grid a { display: grid; gap: 5px; padding: 18px; border: 1px solid var(--line) !important; border-radius: 8px; background: var(--surface); }
.reference-grid b { color: var(--ink); }
.reference-grid span { color: var(--muted); font-size: 13.5px; line-height: 1.5; }

.status-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 22px 0; }
.status-grid article { padding: 18px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.status-grid strong { display: block; color: var(--ink); font-family: var(--serif); font-size: 24px; font-weight: 520; }
.status-grid span { display: block; margin-top: 6px; color: var(--muted); font-size: 13px; line-height: 1.45; }

/* Decision page */
.decision-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 30px 0 38px; }
.decision-summary > div { padding: 20px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.decision-summary > div:first-child { border-top: 3px solid var(--green); }
.decision-summary > div:last-child { border-top: 3px solid var(--red); }
.decision-summary strong { display: block; line-height: 1.5; }
.two-column-list { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.two-column-list > div { padding: 22px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.two-column-list h3 { margin-top: 0; }
.facts-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.facts-grid article { padding: 18px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.facts-grid h3 { margin: 0 0 7px; font-size: 17px; }
.facts-grid p { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.55; }
.planning-note { color: var(--ink-2) !important; font-size: 14px !important; }

.decision-card { margin: 20px 0; padding: 22px 24px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--surface); box-shadow: none; }
.decision-form { margin: 20px 0; padding: 26px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--surface); }
.decision-form fieldset { display: grid; gap: 9px; margin: 0 0 22px; padding: 0; border: 0; }
.decision-form legend { margin-bottom: 10px; color: var(--ink); font-weight: 650; }
.decision-form fieldset label { display: flex; gap: 9px; align-items: flex-start; color: var(--ink-2); font-size: 14.5px; }
.form-row { display: grid; gap: 7px; margin-bottom: 16px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.form-row input,
.form-row textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--paper); color: var(--ink); font: 400 15px/1.45 var(--sans); }
.form-row textarea { min-height: 104px; resize: vertical; }
.form-row input:focus,
.form-row textarea:focus { border-color: var(--cyan); outline: 2px solid color-mix(in srgb, var(--cyan) 20%, transparent); outline-offset: 1px; }
.two-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.routing-note { margin: 14px 0 0 !important; color: var(--muted) !important; font-size: 12.5px !important; line-height: 1.55 !important; }
.decision-output { margin-top: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.output-heading { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 10px; }
.text-button { padding: 3px 0; border: 0; background: transparent; color: var(--blue); cursor: pointer; font: 600 12px var(--sans); }
.decision-output pre { margin: 0; padding: 0; border: 0; background: transparent; white-space: pre-wrap; }
.copy-status { margin: 8px 0 0 !important; color: var(--green) !important; font-size: 12px !important; }

/* Pilot */
.checklist-list { list-style: none; padding-left: 0 !important; }
.checklist-list li { position: relative; padding-left: 26px; }
.checklist-list li::before { content: 'OK'; position: absolute; left: 0; color: var(--green); font-weight: 700; }
.phase-list { display: grid; gap: 12px; margin: 22px 0; }
.phase-card { padding: 20px 22px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.phase-card h3 { margin: 3px 0 8px; }
.phase-card p:last-child { margin-bottom: 0; }
.outcome-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.outcome-list article { padding: 18px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.outcome-list h3 { margin: 0 0 7px; }
.outcome-list p { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.55; }

/* Capability limits */
.master-limit { margin: 30px 0 18px; padding: 28px; border-radius: 12px; color: #f2eee3; background: var(--navy-2); }
.master-limit .status-label { color: #86c9c4 !important; }
.master-limit h2 { margin: 5px 0 12px; color: #f2eee3; font-size: clamp(27px, 3.2vw, 36px); }
.master-limit p:last-child { margin: 0; color: rgba(242,238,227,.78); font-size: 16px; }
.limits-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0 26px; }
.limits-summary article { padding: 20px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.limits-summary h3 { margin: 0 0 8px; font-size: 17.5px; }
.limits-summary p:last-child { margin: 0; color: var(--ink-2); font-size: 13.5px; line-height: 1.55; }
.limits-jump { position: sticky; top: 76px; z-index: 4; background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(12px); }
.limits-content-section,
.limit-section { scroll-margin-top: 142px; }
.limits-content-section { margin-top: 46px; }
.limit-section { margin-top: 24px; padding: 28px 30px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.limit-section > h2 { margin: 0 0 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); font-size: clamp(24px, 2.6vw, 30px); }
.limit-section > p > strong:first-child { color: var(--ink); }
.limit-section ul,
.limit-section ol { margin-bottom: 18px; }
.limits-wrap #worked-example + p,
.limits-wrap #inside-limits + p,
.limits-wrap #checklist + p { font-size: 16.5px; }

/* Existing ledger, decision-register, and library surfaces */
.entry { padding: 18px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 90px; }
.entry-head { margin-bottom: 6px; color: var(--muted); font: 12px var(--mono); }
.entry-head b { color: var(--ink); }
.entry p.claim { margin-bottom: 8px; font-size: 15px; }
.entry .meta { margin: 3px 0; color: var(--ink-2); font-size: 13.5px; line-height: 1.55; }
.entry details { margin: 6px 0 0; }
.entry summary { color: var(--muted); cursor: pointer; font: 11.5px var(--mono); }
.entry summary:hover { color: var(--cyan); }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 18px 0 6px; }
.controls input[type="search"] { flex: 1 1 220px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--ink); font: 14px var(--sans); }
.controls button { padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; background: none; color: var(--muted); cursor: pointer; font: 12px var(--mono); }
.controls button.active { border-color: var(--line-strong); background: var(--surface-2); color: var(--ink); }
.count-line { margin: 4px 0 12px; color: var(--muted); font: 12px var(--mono); }
.decision { padding: 6px 0 10px; scroll-margin-top: 90px; }
.decision .facts { margin: 2px 0 10px; color: var(--muted); font: 13.5px var(--mono); }
.evrow { display: block; margin: 4px 0; color: var(--ink-2); font-size: 14.5px; line-height: 1.55; }

.next-block { margin-top: 52px; padding-top: 22px; border-top: 2px solid var(--line-strong); }
.next-block p { margin-bottom: 8px; }
.doc-footer { max-width: 820px; margin: 0 auto; padding: 24px 20px 66px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; line-height: 1.6; }
.limits-footer { max-width: 980px; }
.doc-footer p { margin: 0; }
.doc-footer a { color: var(--blue); }

@media (max-width: 980px) {
  body.doc-mode .header-inner { min-height: 64px; }
  body.doc-mode .primary-nav { inset: 64px 0 auto 0; padding: 12px 20px 18px; background: var(--paper); }
  body.doc-mode .primary-nav a { padding: 10px 12px; }
  .limits-jump { position: static; backdrop-filter: none; }
}

@media (max-width: 720px) {
  .doc-wrap { padding: 42px 16px 84px; }
  .doc-wrap > h1 { font-size: 34px; }
  .doc-lede { font-size: 17px !important; }
  .status-grid,
  .decision-summary,
  .two-column-list,
  .facts-grid,
  .outcome-list,
  .limits-summary,
  .reference-grid { grid-template-columns: 1fr; }
  .two-field-row { grid-template-columns: 1fr; gap: 0; }
  .priority-task,
  .limit-section,
  .master-limit,
  .decision-form { padding: 20px; }
  .jump-nav { margin-bottom: 32px; }
  .doc-footer { padding-inline: 16px; }
}

@media print {
  body.doc-mode .site-header,
  .jump-nav,
  .decision-form,
  .decision-bar,
  .reading-progress,
  .back-to-top { display: none !important; }
  .doc-wrap { max-width: none; padding: 24px 0; }
  .master-limit { color: #000; background: #fff; border: 1px solid #999; }
  .master-limit h2,
  .master-limit p:last-child,
  .master-limit .status-label { color: #000 !important; }
  .limit-section,
  .task-link,
  .phase-card,
  .facts-grid article,
  .outcome-list article { break-inside: avoid; background: #fff; }
  .doc-footer { max-width: none; }
}

/* Buttons inside doc pages: .doc-wrap a is more specific than .button and
   would repaint button text with the link color. */
.doc-wrap a.button { color: #f3efe4; border-bottom: none; }
.doc-wrap a.button:hover { color: #fff; }
.doc-wrap a.button-secondary { color: var(--ink); }
.doc-wrap a.button-secondary:hover { color: var(--ink); }
html[data-theme="dark"] .doc-wrap a.button { color: var(--navy-2); }
html[data-theme="dark"] .doc-wrap a.button:hover { color: var(--navy-2); }
html[data-theme="dark"] .doc-wrap a.button-secondary { color: var(--ink); }
