/* astrochart — shared print stylesheet.
 *
 * Single source of truth for paper output. Used by three places:
 *   1. shell.py @media print (every reading page)
 *   2. interactive.py @media print (the chart page)
 *   3. pdf.css (the dedicated WeasyPrint document path)
 *
 * Theme-aware via the existing CSS custom properties — the active
 * theme's accent (gold/blue/etc.) carries onto headings + the brand
 * mark, body copy stays near-black for legibility, and decorative
 * backgrounds collapse to white to spare toner.
 *
 * If a page needs a print-specific override (e.g. the chart page
 * needs `.chart-stage svg .chart-bg { fill: #fff }`), that lives at
 * the calling site; this file holds only the cross-page rules.
 */
@media print {
  /* Generous Letter margins. US Letter beats A4 in North America;
     the rest of the world's PDF readers handle Letter fine. */
  @page { margin: 0.75in 0.75in 0.85in 0.75in; size: Letter; }

  html, body {
    background: #fff !important; color: #111 !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
    font-size: 11pt; line-height: 1.45;
  }

  /* Strip every shred of UI chrome that doesn't belong on paper. */
  .topbar, .starfield, .footer, #beta-welcome,
  .tt-bar, .shell-skip, .glyph-tip,
  .tweaks, .nav-toggle, .nav-instruments,
  .chart-header, .chart-controls, .chart-modal-overlay {
    display: none !important;
  }

  .page {
    max-width: none;
    padding: 0 !important; margin: 0 !important;
  }

  /* Theme accent rides along on H1/H2 so the print still feels like
     Asteria; H3+ stays ink-dark for hierarchy. */
  h1 {
    color: var(--accent-gold) !important;
    font-size: 22pt; line-height: 1.15;
    margin: 0 0 0.4em !important;
    page-break-after: avoid;
  }
  h2 {
    color: var(--accent-gold) !important;
    font-size: 14pt; line-height: 1.25;
    margin: 1.4em 0 0.4em !important;
    page-break-after: avoid;
  }
  h3 {
    color: #111 !important;
    font-size: 12pt; line-height: 1.3;
    margin: 1.0em 0 0.3em !important;
    page-break-after: avoid;
  }
  p, li, td, th, .lead {
    color: #1a1a1a !important;
    font-size: 11pt; line-height: 1.5;
  }
  .lead { margin: 0.5em 0 1em; max-width: none; }
  .eyebrow {
    color: var(--accent-gold) !important;
    font-size: 8.5pt; letter-spacing: 0.14em;
    text-transform: uppercase;
    opacity: 0.8;
    margin-bottom: 0.3em;
  }

  /* Cards / blocks: outline-only, no ink-waste backgrounds, but
     keep the structural border so sections still read as units. */
  [class*="-card"], [class*="-block"], .pv-section, .pv-ecl,
  .pv-rx-card, .td-headline, .td-moon-card, .td-tt, .td-prof-card,
  .pg-moon-card, .pg-phase, .sky-card, .sky-aspect-card {
    background: #fff !important;
    border: 0.5pt solid #c8c8c8 !important;
    box-shadow: none !important;
    padding: 0.45cm !important;
    page-break-inside: avoid;
    margin-bottom: 0.4cm !important;
  }

  /* Tables — bigger type, alternating rows for scan-ability,
     no mid-row breaks. */
  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10.5pt;
    page-break-inside: auto;
    margin: 0.5em 0 1em;
  }
  thead { display: table-header-group; }
  tbody tr { page-break-inside: avoid; }
  th, td {
    padding: 5pt 8pt !important;
    border-bottom: 0.5pt solid #d8d8d8 !important;
    vertical-align: top;
    text-align: left;
  }
  thead th {
    font-family: 'IBM Plex Mono', monospace !important;
    font-size: 8pt; letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #666 !important;
    border-bottom: 0.5pt solid #999 !important;
  }
  tbody tr:nth-child(even) td { background: #f7f7f3 !important; }

  /* Avoid orphan / widow rules — a heading at the bottom of a page
     with its section starting on the next is the most common
     complaint. */
  section, article { page-break-inside: auto; }
  section > h2 + *, article > h2 + *,
  section > h3 + *, article > h3 + * {
    page-break-before: avoid;
  }

  /* SVG wheels, charts, illustrations — keep on a single page. */
  svg, figure, .chart, .wheel, .sky-wheel-wrap {
    page-break-inside: avoid;
  }

  /* Links print without the underline cruft. */
  a { color: inherit !important; text-decoration: none !important; }

  /* Tighten the gap between sequential blocks. */
  p + p { margin-top: 0.5em; }
  ul, ol { margin: 0.3em 0 0.8em 1.2em; padding: 0; }
  li + li { margin-top: 0.25em; }

  /* The cross-link chips are navigation, not content. */
  .td-xref-line, .sky-xref, .rd-swap-foot, .sa-swap-foot {
    display: none !important;
  }
}
