/*
   docs.css — single unified stylesheet for all three doc types
   (PRD, build plan, design spec). One typography system, one heading
   hierarchy, one set of table / list / code rules. Applies to both PDF
   and HTML; on HTML it's scoped to .doc-main by render.scope_css(), so
   nothing leaks into the sidebar chrome.

   Generic professional-but-friendly theme — slate, teal, amber accents
   on a warm cream surface. Project-specific brand illustrations (the
   .brand-gradient, .neon-sample classes used inside the design-spec
   page) remain on their own colours and are documented as overrides at
   the bottom of this file.
*/

/* ========== Page setup (PDF only — ignored in screen rendering) ========== */
@page {
  size: A4;
  margin: 22mm 20mm 22mm 20mm;
}

.doc-main, .doc-main * { box-sizing: border-box; }

/* ========== Body ========== */
.doc-main {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
               "Helvetica Neue", Arial, sans-serif;
  font-size: 10.5pt;
  line-height: 1.55;
  color: #2B2B2A;
  background: #F5F2EC;
  margin: 0;
  padding: 0;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* ========== Title page (first H1 + first metadata table) ==========
   Every doc opens with `# Title` followed by a bold subtitle paragraph
   and a 2-column metadata table. We style those three pieces directly
   via :first-of-type so no special markup is needed.
*/

.doc-main h1:first-of-type {
  font-size: 36pt;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #2B2B2A;
  margin: 32pt 0 6pt 0;
  padding-bottom: 14pt;
  border-bottom: 5pt solid #1F3D5C;
  page-break-before: avoid;
}

.doc-main h1:first-of-type + p {
  margin: 0 0 18pt 0;
}
.doc-main h1:first-of-type + p strong {
  font-size: 14pt;
  font-weight: 500;
  color: #2A5F65;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.doc-main h1:first-of-type ~ table:first-of-type {
  width: auto;
  font-size: 10pt;
  margin: 0 0 12pt 0;
  border: none;
  page-break-inside: avoid;
}
.doc-main h1:first-of-type ~ table:first-of-type th {
  background: transparent;
  border: none;
  padding: 4pt 24pt 4pt 0;
  color: #2A5F65;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 8.5pt;
  font-weight: 600;
  white-space: nowrap;
  text-align: left;
  vertical-align: top;
}
.doc-main h1:first-of-type ~ table:first-of-type td {
  border: none;
  padding: 4pt 0;
  vertical-align: top;
}
.doc-main h1:first-of-type ~ table:first-of-type tr:last-child td, .doc-main h1:first-of-type ~ table:first-of-type tr:last-child th {
  border-bottom: none;
}

/* ========== Subsequent headings ========== */

.doc-main h1 {
  font-size: 22pt;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #2B2B2A;
  margin: 0 0 10pt 0;
  padding-bottom: 8pt;
  border-bottom: 3pt solid #1F3D5C;
  page-break-before: always;
  page-break-after: avoid;
}

.doc-main h2 {
  font-size: 16pt;
  font-weight: 700;
  color: #2B2B2A;
  margin: 22pt 0 8pt 0;
  padding-bottom: 5pt;
  border-bottom: 1.5pt solid #3E8B93;
  page-break-after: avoid;
}

.doc-main h3 {
  font-size: 13pt;
  font-weight: 600;
  color: #2B2B2A;
  margin: 16pt 0 6pt 0;
  page-break-after: avoid;
}

.doc-main h4 {
  font-size: 11.5pt;
  font-weight: 600;
  color: #2B2B2A;
  margin: 12pt 0 4pt 0;
  page-break-after: avoid;
}

.doc-main h5, .doc-main h6 {
  font-size: 11pt;
  font-weight: 600;
  color: #2B2B2A;
  margin: 10pt 0 4pt 0;
  page-break-after: avoid;
}

/* ========== Body text ========== */

.doc-main p { margin: 0 0 8pt 0; }
.doc-main p + p { margin-top: 0; }

/* ========== Lists ========== */

.doc-main ul, .doc-main ol { margin: 0 0 10pt 0; padding-left: 22pt; }
.doc-main li { margin-bottom: 4pt; line-height: 1.55; }
.doc-main li > p:first-child { margin-bottom: 4pt; }

/* ========== Inline ========== */

.doc-main a {
  color: #1F3D5C;
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px dotted #1F3D5C;
}
.doc-main a:hover { border-bottom-style: solid; }
.doc-main strong { font-weight: 600; color: #2B2B2A; }
.doc-main em { font-style: italic; }

/* ========== Code ========== */

.doc-main code {
  font-family: "JetBrains Mono", "Cascadia Code", "Consolas", monospace;
  font-size: 0.92em;
  background: #EAF1F1;
  padding: 1px 5px;
  border-radius: 3px;
  color: #1F3D5C;
}

.doc-main pre {
  background: #FAF7F1;
  border-left: 3pt solid #1F3D5C;
  padding: 12pt 14pt;
  border-radius: 4pt;
  overflow-x: auto;
  font-family: "JetBrains Mono", "Cascadia Code", "Consolas", monospace;
  font-size: 8.8pt;
  line-height: 1.45;
  page-break-inside: avoid;
  margin: 8pt 0 12pt 0;
  color: #2B2B2A;
}
.doc-main pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
  white-space: pre;
  color: inherit;
}

/* ========== Tables ========== */

.doc-main table {
  border-collapse: collapse;
  width: 100%;
  margin: 8pt 0 14pt 0;
  font-size: 9.5pt;
  page-break-inside: avoid;
  background: #FFFFFF;
}
.doc-main th {
  text-align: left;
  background: #E8EEF4;
  font-weight: 600;
  padding: 7pt 9pt;
  border-bottom: 1.5pt solid #1F3D5C;
  color: #2B2B2A;
  vertical-align: top;
}
.doc-main td {
  padding: 6pt 9pt;
  border-bottom: 0.5pt solid #D9D5CC;
  vertical-align: top;
}
.doc-main tr:last-child td { border-bottom: 0.5pt solid #B5B0A4; }
.doc-main table.wide-table { page-break-inside: auto; }

/* ========== Mermaid diagrams ==========
   Diagrams are inline ```mermaid blocks rewritten to <div class="mermaid">.
   The mermaid runtime emits a fixed-size SVG; bound it to the parent doc
   column so wide flows scale down instead of overflowing. `overflow-x:auto`
   on the wrapper is a fallback for diagrams that genuinely cannot scale
   (e.g. sequence diagrams with long actor names). */

.doc-main .mermaid {
  display: block;
  margin: 18pt auto;
  text-align: center;
  overflow-x: auto;
  max-width: 100%;
}

.doc-main .mermaid svg {
  display: block;
  max-width: 100% !important;
  height: auto !important;
  margin: 0 auto;
}

@media print {
  .doc-main .mermaid { page-break-inside: avoid; overflow: visible; }
}

/* ========== Hr & blockquote ========== */

.doc-main hr {
  border: none;
  border-top: 0.5pt solid #D9D5CC;
  margin: 18pt 0;
}

.doc-main blockquote {
  border-left: 3pt solid #E8A857;
  padding: 8pt 14pt;
  margin: 10pt 0;
  background: #FAF1E0;
  color: #5A3E14;
  border-radius: 0 4pt 4pt 0;
}

/* ========== Phase tags (used in PRD + build plan) ========== */

.doc-main .phase-tag {
  display: inline-block;
  padding: 0px 6px;
  border-radius: 3px;
  font-size: 0.86em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 0.5pt solid currentColor;
  vertical-align: 1pt;
}
.doc-main .phase-mvp { background: #EAF1EC; color: #2E5A3A; border-color: #4F8A5E; }
.doc-main .phase-alpha { background: #FAF1E0; color: #5A3E14; border-color: #B07820; }
.doc-main .phase-beta { background: #E8EEF4; color: #1F3D5C; border-color: #1F3D5C; }
.doc-main .phase-production { background: #EAF1F1; color: #2A5F65; border-color: #3E8B93; }
.doc-main .phase-stretch { background: #F8E8E6; color: #7A2424; border-color: #B83A3A; }
.doc-main .phase-compound { background: #F5F2EC; color: #6B6962; border-color: #D9D5CC; }
.doc-main h2 .phase-tag { font-size: 10pt; vertical-align: 3pt; margin-left: 8pt; }

/* ========== App-scope chips (next to section headers) ========== */

.doc-main .scope-chips { display: inline-block; margin-left: 8pt; vertical-align: 1pt; }
.doc-main .scope-chip {
  display: inline-block;
  padding: 0px 5px;
  margin-left: 3pt;
  border-radius: 2pt;
  font-size: 0.78em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 0.5pt solid currentColor;
}
.doc-main .scope-project { background: #F5F2EC; color: #6B6962; border-color: #D9D5CC; }
.doc-main .scope-designer { background: #FAF1E0; color: #5A3E14; border-color: #B07820; }
.doc-main .scope-host { background: #E8EEF4; color: #1F3D5C; border-color: #1F3D5C; }
.doc-main .scope-client { background: #EAF1F1; color: #2A5F65; border-color: #3E8B93; }
.doc-main .scope-remote { background: #EAF1EC; color: #2E5A3A; border-color: #4F8A5E; }

/* ========== Table of contents (PRD) ========== */

.doc-main .toc-list { list-style: none; padding-left: 0; }
.doc-main .toc-list li {
  border-bottom: 0.5pt dotted #D9D5CC;
  padding: 4pt 0;
  margin: 0;
}
.doc-main .toc-list a { font-weight: 500; }

/* ========== Avoid orphaned headings ========== */

.doc-main h2 + p, .doc-main h2 + ul, .doc-main h2 + ol, .doc-main h2 + table, .doc-main h3 + p, .doc-main h3 + ul, .doc-main h3 + ol, .doc-main h3 + table {
  page-break-before: avoid;
}
.doc-main ul li { page-break-inside: avoid; }

/* ========== Build plan foldouts + task checkboxes ========== */

/* Each <h2> section in the build plan is wrapped in <details><summary>
   by post_process_build_plan_foldouts() in render.py. This collapses
   sections so the user sees the feature list first and expands details
   only when interested. */

.doc-main details.bp-section {
  background: #FFFFFF;
  border: 0.75pt solid #D9D5CC;
  border-radius: 5pt;
  padding: 0;
  margin: 8pt 0;
  page-break-inside: avoid;
}
.doc-main details.bp-section[open] {
  border-color: #3E8B93;
  box-shadow: 0 1pt 4pt rgba(31, 61, 92, 0.06);
}
.doc-main details.bp-section > summary {
  cursor: pointer;
  list-style: none;
  padding: 10pt 14pt;
  font-size: 13pt;
  font-weight: 600;
  color: #1F3D5C;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12pt;
  border-radius: 5pt;
  user-select: none;
}
.doc-main details.bp-section > summary::-webkit-details-marker { display: none; }
.doc-main details.bp-section > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8pt;
  color: #6B6962;
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
.doc-main details.bp-section[open] > summary::before { transform: rotate(90deg); }
.doc-main details.bp-section > summary:hover { background: #FAF7F1; }
.doc-main details.bp-section > summary .bp-summary-text { flex: 1; }
.doc-main details.bp-section > summary .bp-progress {
  font-size: 0.78em;
  font-weight: 500;
  color: #6B6962;
  background: #F5F2EC;
  padding: 2pt 8pt;
  border-radius: 10pt;
  border: 0.5pt solid #D9D5CC;
  white-space: nowrap;
  flex-shrink: 0;
}
.doc-main details.bp-section > summary .bp-progress.bp-progress-complete {
  background: #EAF1EC;
  color: #2E5A3A;
  border-color: #4F8A5E;
}
.doc-main details.bp-section > .bp-body {
  padding: 4pt 16pt 12pt 16pt;
  border-top: 0.5pt solid #D9D5CC;
}
.doc-main details.bp-section > .bp-body > h3:first-child { margin-top: 8pt; }

/* Print + PDF: force every section open so nothing is hidden in the artefact. */
@media print {
  .doc-main details.bp-section { border: none; box-shadow: none; }
  .doc-main details.bp-section > summary { padding: 0; cursor: default; }
  .doc-main details.bp-section > summary::before { display: none; }
  .doc-main details.bp-section > .bp-body { padding: 0; border-top: none; }
}

/* Task checkboxes — post_process_task_checkboxes() rewrites
   `<li>[ ] text</li>` and `<li>[x] text</li>` into spans. */
.doc-main li.task {
  list-style: none;
  margin-left: -16pt;
  padding-left: 22pt;
  position: relative;
  margin-bottom: 5pt;
  min-height: 14pt;
}
.doc-main li.task::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.18em;
  width: 12pt;
  height: 12pt;
  border-radius: 2.5pt;
  border: 1pt solid #6B6962;
  background: #FFFFFF;
  box-sizing: border-box;
}
.doc-main li.task.done::before {
  background: #4F8A5E;
  border-color: #4F8A5E;
}
.doc-main li.task.done::after {
  content: "";
  position: absolute;
  left: 2.8pt;
  top: calc(0.18em + 3.5pt);
  width: 6.5pt;
  height: 3pt;
  border-left: 1.4pt solid #FFFFFF;
  border-bottom: 1.4pt solid #FFFFFF;
  transform: rotate(-45deg);
}
.doc-main li.task.done {
  color: #6B6962;
  text-decoration: line-through;
  text-decoration-color: #B5B0A4;
}
.doc-main li.task.done strong { color: #6B6962; font-weight: 500; }

/* ========== Color swatch (design spec — auto-injected next to <code>#XXXXXX</code>) ========== */

.doc-main .swatch {
  display: inline-block;
  width: 22pt;
  height: 12pt;
  margin-left: 6pt;
  border-radius: 2pt;
  border: 0.5pt solid rgba(0, 0, 0, 0.15);
  vertical-align: -2pt;
}

/* Generic sample-frame styling for design-spec gradient swatches.
   The actual gradient + sample-class definitions live in project-side
   overrides (e.g. `.claude/context/styles/design-spec-extras.css`). */
.doc-main .gradient-sample {
  height: 60pt;
  border-radius: 4pt;
  margin: 8pt 0 16pt 0;
  border: 0.5pt solid rgba(0, 0, 0, 0.15);
  page-break-inside: avoid;
}

/* ========== Mermaid diagrams (inline blocks) ========== */
/* `useMaxWidth: false` in the init JSON makes Mermaid render the SVG at its
   natural size — readable text, no shrink. The wrapper provides horizontal
   scroll if the diagram is wider than the column, and a soft paper backdrop
   matching the rest of the chrome. */
.doc-main .mermaid {
  background: #F8F5F0;
  border: 1px solid #DDD5C8;
  border-radius: 12px;
  padding: 24px;
  margin: 24px 0;
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
  box-shadow: 0 1px 2px rgba(31, 25, 51, 0.04);
}
.doc-main .mermaid svg { max-width: none !important; height: auto; display: inline-block; }
/* While Mermaid hasn't yet replaced the source text with an SVG, hide the
   raw text so the page doesn't flash unstyled mermaid source. */
.doc-main .mermaid:not([data-processed="true"]) { color: transparent; }

/* ========== HTML-only: hide nav in print previews ========== */
@media print { .doc-main .docs-nav { display: none !important; } }
