/* ============================================================
   print.css — engineering-drawing print stylesheet
   Preserves: hairline rules, registration marks, title block.
   Drops: nav chrome, theme toggle, tweaks panel, sticky TOC,
          live readout, scroll snapping, decorative grids.
   ============================================================ */

@page {
  size: A4;
  margin: 14mm 16mm;
}
@page :first {
  margin-top: 18mm;
}

@media print {

  /* Force the paper palette regardless of theme */
  html, body {
    background: #ffffff !important;
    color: #0e2b30 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body.theme-dusk, body.theme-sea {
    background: #ffffff !important;
  }

  /* Hide interactive chrome */
  .topbar,
  .theme-toggle,
  .topbar .rss,
  .topbar .status .dot,
  .tweaks-panel,
  #tp-root,
  [id^="tp-"],
  .live-readout,
  .scrubber,
  button {
    display: none !important;
  }

  /* Topbar reduces to a slim folio line */
  body::before {
    content: "overlay.social  \00B7  Draft Rev. C  \00B7  2026-05-09";
    display: block;
    font-family: "JetBrains Mono", monospace;
    font-size: 8pt;
    letter-spacing: 1.2pt;
    text-transform: uppercase;
    color: #0e2b30;
    border-bottom: 0.4pt solid #0e2b30;
    padding-bottom: 4mm;
    margin-bottom: 8mm;
  }

  .page {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }

  /* Registration marks — keep visible on every page */
  .regmark {
    position: fixed !important;
    width: 6mm;
    height: 6mm;
    border-color: #0e2b30 !important;
    opacity: 1 !important;
  }
  .regmark.tl { top: 6mm;  left: 8mm; }
  .regmark.tr { top: 6mm;  right: 8mm; }
  .regmark.bl { bottom: 6mm; left: 8mm; }
  .regmark.br { bottom: 6mm; right: 8mm; }

  /* Hairlines: keep them thin on paper */
  hr,
  .rule,
  table th,
  table td,
  .section-grid > * + *,
  .code-artifact,
  .channels .ch,
  .matrix-variant table {
    border-color: #0e2b30 !important;
  }
  table th, table td { border-width: 0.3pt !important; }
  .code-artifact, .live-readout { border-width: 0.4pt !important; }

  /* Typography for paper */
  h1, h2, h3, .display, .section-title {
    color: #0e2b30 !important;
    page-break-after: avoid;
  }
  h1 { font-size: 28pt !important; line-height: 1.05 !important; }
  h2.section, h2 { font-size: 18pt !important; }
  h3 { font-size: 13pt !important; }
  p, li {
    font-size: 10.5pt !important;
    line-height: 1.45 !important;
    color: #1a3b40 !important;
    orphans: 3;
    widows: 3;
  }

  /* Sections each start on a new page — feels like a spec */
  section.scroll {
    page-break-before: always;
    min-height: auto !important;
    padding: 0 !important;
    margin: 0 0 8mm !important;
  }
  section.scroll:first-of-type { page-break-before: avoid; }

  /* Section grid: keep the §NN gutter visible */
  .section-grid {
    display: grid !important;
    grid-template-columns: 14mm 1fr !important;
    gap: 8mm !important;
  }
  .section-num {
    font-family: "JetBrains Mono", monospace !important;
    font-size: 9pt !important;
    color: #0e2b30 !important;
    border-right: 0.3pt solid #0e2b30 !important;
    padding-right: 4mm !important;
  }

  /* Figures and code artifacts stay together */
  figure, .code-artifact, table, pre, blockquote {
    page-break-inside: avoid;
    break-inside: avoid;
  }
  figcaption {
    font-family: "JetBrains Mono", monospace !important;
    font-size: 7.5pt !important;
    color: #1a3b40 !important;
    letter-spacing: 0.6pt !important;
  }

  /* Code: must remain legible mono */
  pre, code, .code-artifact pre {
    font-family: "JetBrains Mono", monospace !important;
    font-size: 8.5pt !important;
    background: #fafafa !important;
    color: #0e2b30 !important;
  }
  .code-artifact .ann {
    font-family: "Newsreader", serif !important;
    font-size: 9pt !important;
    color: #5a6e6f !important;
  }
  .code-artifact .hi { color: #c8421f !important; }

  /* Links: print URL after the text on outbound */
  a[href^="http"]:not(.no-deco-print)::after {
    content: " (" attr(href) ")";
    font-family: "JetBrains Mono", monospace;
    font-size: 7pt;
    color: #5a6e6f;
    word-break: break-all;
  }
  a { color: #0e2b30 !important; text-decoration: none !important; }

  /* TOC for spec-template: collapse the sticky sidebar inline */
  .spec-body {
    display: block !important;
  }
  .spec-toc {
    position: static !important;
    border-left: none !important;
    border-top: 0.3pt solid #0e2b30 !important;
    border-bottom: 0.3pt solid #0e2b30 !important;
    padding: 4mm 0 !important;
    margin-bottom: 6mm !important;
    columns: 2;
  }
  .spec-toc ol { gap: 4pt !important; }

  /* Title block — render at end of doc on its own page */
  .titleblock {
    page-break-before: always;
    page-break-inside: avoid;
    display: grid !important;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr !important;
    border: 0.4pt solid #0e2b30 !important;
    margin-top: 0 !important;
  }
  .titleblock .cell {
    padding: 4mm !important;
    border-right: 0.3pt solid #0e2b30 !important;
    border-bottom: none !important;
  }
  .titleblock .cell:last-child { border-right: none !important; }
  .titleblock .cell .k {
    font-family: "JetBrains Mono", monospace !important;
    font-size: 7pt !important;
    letter-spacing: 0.8pt !important;
    color: #5a6e6f !important;
    margin-bottom: 1mm !important;
  }
  .titleblock .cell .v {
    font-family: "Newsreader", serif !important;
    font-size: 10pt !important;
    color: #0e2b30 !important;
  }
  .titleblock .cell.title .v {
    font-family: "Instrument Serif", serif !important;
    font-size: 16pt !important;
  }

  /* Builder CTAs read fine but force one-column on paper */
  .builder { grid-template-columns: 1fr !important; }
  .builder .cta { min-height: auto !important; page-break-inside: avoid; }

  /* Hide the matrix variant B if A is already on paper — keep it, but smaller */
  .matrix-variant { page-break-before: always; }

  /* No animations, no decorative pulse */
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
