/* ===================================================================
   Jyotiṣa — Yuga · PRINT STYLESHEET
   Linked with media="print", so every rule here applies only to the
   printed / "Save as PDF" output. Two layers:
     1. base print rules   — apply to any print (native Ctrl/Cmd-P too)
     2. body.printing*      — the designed full-reading book that the
                              "Print / Save PDF" button assembles
   Keep this file editable in isolation; it must not affect the screen.
   =================================================================== */

/* ---- 1. PALETTE: always print on warm paper with near-black ink,
        even when dark mode is active, so SVG var() fills resolve. ---- */
html.dark, html:not(.dark){
  --paper:#ece5d6; --paper-2:#e6dece; --paper-3:#ddd3bf;
  /* Muted tones run DARKER in print than on screen. Toner and ink spread lighten
     fine type, and there is no backlight to carry a low-contrast grey — so the
     screen value (#5f584a, 5.6:1) is pushed to 7.7:1 here. The previous #6f685a
     was the pre-accessibility value and printed visibly faint. */
  --ink:#12100d; --ink-2:#2e2a22; --ink-soft:#4a4438;
  --red:#992f22; --red-deep:#7d2419;
  --rule:#a2947a; --rule-soft:#b9ab8c;
  --benefic:#33573b; --debil:#992f22;
  --gold:#8a6626; --gold-soft:#a3822f;
}
/* Parchment on every sheet. The root-element background propagates to each printed
   page box, so the whole reading sits on warm paper — and transparent charts blend
   into it seamlessly instead of reading as tinted boxes. */
html, html.dark, html:not(.dark){ background:var(--paper) !important; }
body, html.dark body{ background:transparent !important; color:#000; }
*{ -webkit-print-color-adjust:exact; print-color-adjust:exact; }

/* ---- decorative double frame, repeated on every page ---- */
.print-frame{ display:none; }
body.printing .print-frame{ display:block; position:fixed; inset:0; z-index:4; pointer-events:none; }
body.printing .print-frame .pf-outer{ position:absolute; inset:0;
  border:1.2px solid var(--red-deep); }
body.printing .print-frame .pf-inner{ position:absolute; inset:2.4mm;
  border:.5px solid var(--gold-soft); }
/* breathing room so content never touches the frame */
body.printing #bookPage{ padding:0 5mm; }

/* ---- page geometry + running head/feet ----
   Margin boxes render in Chromium 131+ (and any CSS Paged Media engine);
   older browsers simply omit the running header/footer — nothing breaks.
   @top-right (the native's name) is injected per-report by printAll(), since
   Chrome's print engine doesn't support string-set / named strings. */
@page{
  margin:18mm 14mm 18mm 14mm;
  @top-left{ content:"Jyotiṣa · Yuga"; font-family:"Cormorant","Cormorant Garamond","EB Garamond",serif;
    font-size:8pt; letter-spacing:.16em; color:#a3782f; }
  @bottom-left{ content:"Prepared by Deepak Singh"; font-family:"Cormorant","Cormorant Garamond","EB Garamond",serif;
    font-size:8pt; letter-spacing:.14em; color:#a3782f; }
  @bottom-center{ content:"Confidential personal reading"; font-family:"EB Garamond",serif;
    font-style:italic; font-size:7.5pt; color:#6f685a; }
  @bottom-right{ content:counter(page) " / " counter(pages); font-family:"JetBrains Mono",monospace;
    font-size:7.5pt; color:#6f685a; }
}
/* the cover carries no running header or footer */
@page:first{
  @top-left{ content:none; } @top-right{ content:none; }
  @bottom-left{ content:none; } @bottom-center{ content:none; } @bottom-right{ content:none; }
}
/* table-heavy folios print landscape so numbers stay legible (no 6px type) */
@page wide{ size:A4 landscape; margin:14mm 12mm; }

/* ---- hide all interactive chrome from any printout ---- */
.topband, nav.bar, .hero, .cast-grid, footer, .sechead .rt, .prefbar,
.export-btn, .natal-export, .bs-btn, .page-nav, .emblem-toggle,
.folio-jump-wrap, .nav-scrim, .chart-modal, #homeBg{ display:none !important; }
#results{ display:block !important; }
.sec{ padding-top:18px; }

/* ---- charts: one unified cap; scale to column, never overflow/split ---- */
.chartsvg{ width:100% !important; height:auto !important; max-width:330px !important;
  display:block; margin:0 auto; }
.chart-img{ width:auto !important; height:auto !important; max-width:330px !important;
  display:block !important; margin:10px auto !important;
  break-inside:avoid; page-break-inside:avoid; }
/* safety net for arbitrary media; chart rules above intentionally win */
img, svg:not(.chartsvg):not(.barsvg){ max-width:100% !important; }

/* Keep charts, small cards and the pull-quote whole; keep headings with their body.
   Tables are intentionally NOT in this list — a tall table must be allowed to break
   across pages (rows kept whole, header repeated) so it fills the page instead of
   jumping wholesale to the next one and leaving a blank gap behind. */
.natal-chart, .spec-chart, .transit-chart, .previewcard, .graha-card,
.synth-emph, figure{ break-inside:avoid; page-break-inside:avoid; }
tr{ break-inside:avoid; page-break-inside:avoid; }
thead{ display:table-header-group; }
h2, h3, h4{ break-after:avoid; page-break-after:avoid; }

/* ---- SEAMLESS CHARTS: drop the on-screen box (border + tinted fill) so the
        chart floats on the parchment page. The chart's own square outline stays. */
.diabox, .spec-chart, .diagrid .diabox{
  background:transparent !important; border:none !important; padding:0 !important;
  box-shadow:none !important; }
.diabox h3, .spec-chart-label{ margin-top:0; }
.varga-reading-wrap{ margin-top:10px; }

/* ---- WIDE DATA TABLES: collapse min-widths so columns fit the page ---- */
.divscroll, .graha-wrap, .sarvato-wrap, .poruttam-table, .match-planet-table,
.gochara-table, .match-charts-grid{ overflow:visible !important; max-width:100% !important; }
table.graha, table.divtab, .match-planet-table table, .poruttam-table table{
  min-width:0 !important; width:100% !important; font-size:8.5px !important; table-layout:fixed; }
table.graha th, table.graha td, table.divtab th, table.divtab td,
.match-planet-table th, .match-planet-table td{ white-space:normal !important;
  overflow-wrap:anywhere; word-break:break-word; padding:3px 4px !important; }
.sarvato-grid{ min-width:0 !important; width:100% !important; font-size:7px !important; table-layout:fixed; }
.sarvato-grid td, .sarvato-grid th{ padding:1px !important; white-space:normal !important; }

/* nothing may exceed the printable width */
#results, .book-page, .print-folio, .sec{ max-width:100% !important; overflow:visible !important; }

/* ===================================================================
   2. THE DESIGNED FULL READING  (body.printing — Print button path)
   =================================================================== */
body.printing .topband, body.printing nav.bar, body.printing .hero,
body.printing .cast-grid, body.printing footer, body.printing .book-tabs,
body.printing .book-subtabs, body.printing .page-nav,
body.printing .book-spine .bs-right, body.printing .book-foot{ display:none !important; }
body.printing .book-page{ min-height:auto; overflow:visible; }

/* sub-tab + vertical-menu panes expand so nothing is hidden in print */
.printing .sb-tabwrap{ display:block; }
.printing .sb-vmenu{ display:none; }
.printing .sb-pane, .printing .match-pane{ display:block !important; margin-top:18px; }
.printing .hsub-pane{ display:block !important; }

/* ---- COVER FOLIO — framed, with the birth-particulars card ---- */
/* min-height stays safely under the printable area (page height minus @page
   margins) so the cover never spills a near-blank second page. */
.print-cover{ break-after:page; page-break-after:always; break-inside:avoid;
  page-break-inside:avoid; text-align:center;
  position:relative; display:flex; flex-direction:column; align-items:center;
  justify-content:center; min-height:82vh; padding:8mm 10mm 0; }
.print-cover .pc-inner{ position:relative; display:flex; flex-direction:column;
  align-items:center; width:100%; }
.print-cover .pc-seal{ width:60px; height:60px; margin-bottom:22px; }
.print-cover .pc-kicker{ font-family:var(--mono); font-size:9.5px; letter-spacing:.34em;
  text-transform:uppercase; color:var(--gold); margin-bottom:18px; font-weight:600; }
.print-cover .pc-title{ font-family:var(--disp); font-size:46px; font-weight:600;
  letter-spacing:.01em; line-height:1; }
.print-cover .pc-title em{ font-style:italic; font-weight:500; color:var(--red-deep); }
.print-cover .pc-sub{ font-family:var(--body); font-style:italic; font-size:16px;
  color:var(--ink-soft); margin-top:10px; }
.print-cover .pc-rule{ width:110px; height:1px; background:var(--gold); opacity:.7; margin:20px 0 22px; }
.print-cover .pc-native{ font-family:var(--disp); font-size:31px; font-style:italic;
  color:var(--ink); margin-bottom:18px; }
.print-cover .pc-card{ width:126mm; max-width:92%; border:.7px solid var(--rule);
  background:var(--paper-2); padding:7mm 9mm; text-align:left; }
.print-cover .pc-row{ display:flex; justify-content:space-between; gap:14px;
  font-size:11.5px; padding:5px 0; border-bottom:1px dotted var(--rule-soft); }
.print-cover .pc-row:last-child{ border-bottom:none; }
.print-cover .pc-k{ font-family:var(--mono); font-size:9px; letter-spacing:.14em;
  text-transform:uppercase; color:var(--ink-soft); padding-top:2px; }
.print-cover .pc-v{ font-family:var(--body); font-weight:600; color:var(--ink); text-align:right; }
.print-cover .pc-v small{ font-weight:400; color:var(--ink-soft); }
.print-cover .pc-foot{ margin-top:26px; font-family:var(--body); font-style:italic;
  font-size:11.5px; color:var(--ink-soft); line-height:1.7; }
.print-cover .pc-brand{ font-family:var(--disp); font-style:normal; font-size:13px;
  letter-spacing:.18em; text-transform:uppercase; color:var(--red-deep); margin-top:10px; }
.print-cover .pc-brand-role{ font-family:var(--body); font-style:italic; font-size:11px;
  color:var(--gold); margin-top:3px; letter-spacing:.04em; }

/* ---- CONTENTS PAGE ---- */
.print-contents{ break-after:page; page-break-after:always; padding-top:10mm; }
.print-contents h2{ font-family:var(--disp); font-size:30px; font-weight:600;
  border-bottom:1.5px solid var(--red-deep); padding-bottom:10px; margin:0 0 22px; }
.print-contents .pc-toc{ list-style:none; margin:0; padding:0; columns:2; column-gap:32px; }
.print-contents .pc-toc li{ display:flex; align-items:baseline; gap:12px;
  padding:7px 0; border-bottom:1px dotted var(--rule-soft); break-inside:avoid; }
.print-contents .pc-toc li.toc-part{ display:block; border-bottom:none; padding:14px 0 3px;
  font-family:var(--mono); font-size:9px; letter-spacing:.26em; text-transform:uppercase;
  color:var(--gold); font-weight:700; }
.print-contents .pc-toc li.toc-part:first-child{ padding-top:0; }
.print-contents .toc-rn{ font-family:var(--mono); font-size:10px; letter-spacing:.16em;
  color:var(--red-deep); min-width:34px; }
.print-contents .toc-name{ font-family:var(--body); font-size:15px; color:var(--ink); }

/* ---- PER-FOLIO SECTION DIVIDER ----
   Folios FLOW into leftover space; only the first folio of each Part forces a
   fresh page. This kills the trailing whitespace that a break-before-every-folio
   rule leaves after a short folio. */
body.printing .print-folio{ break-before:auto; page-break-before:auto;
  margin:26px 0 22px; padding-top:16px; border-top:1px solid var(--rule-soft); }
body.printing .print-folio.part-start{ break-before:page; page-break-before:always;
  border-top:none; margin-top:0; padding-top:0; }
body.printing .print-folio:first-child{ break-before:auto; page-break-before:auto;
  border-top:none; margin-top:0; padding-top:0; }
body.printing .print-folio.landscape{ page:wide; }
/* header + at least its lede stay together — never orphan a folio title */
body.printing .folio-head{ border-bottom:1.5px solid var(--red-deep); margin-bottom:22px;
  padding-bottom:14px; break-inside:avoid; break-after:avoid; page-break-inside:avoid; page-break-after:avoid; }
body.printing .folio-kicker{ display:block; font-family:var(--mono); font-size:9px;
  letter-spacing:.3em; text-transform:uppercase; color:var(--gold); font-weight:700;
  margin-bottom:8px; }
body.printing .folio-rn{ display:inline-block; font-family:var(--mono); font-size:10px;
  letter-spacing:.28em; text-transform:uppercase; color:var(--red-deep); margin-bottom:6px; }
body.printing .folio-title{ font-family:var(--disp); font-size:30px; font-weight:600;
  margin:0 0 6px; line-height:1.05; }
body.printing .folio-blurb{ font-family:var(--body); font-style:italic; font-size:14px;
  line-height:1.5; color:var(--ink-soft); margin:0; max-width:62ch; }

/* ---- PANE HEADERS — label each vertical pane as it stacks in print ---- */
body.printing .pane-print-head{ display:flex !important; align-items:baseline; gap:10px;
  margin:20px 0 10px; padding:6px 0 6px 12px; border-left:3px solid var(--gold);
  break-after:avoid; page-break-after:avoid; break-inside:avoid; }
body.printing .pane-print-head b{ font-family:var(--disp); font-size:17px; font-weight:600;
  color:var(--red-deep); letter-spacing:.01em; }
body.printing .pane-print-head span{ font-family:var(--body); font-style:italic;
  font-size:12px; color:var(--ink-soft); }
body.printing .sb-pane{ margin-top:0 !important; }

/* the per-folio judgment reads as a framed pull-quote in print */
body.printing .synth-emph{ border-left:3px solid var(--red); background:var(--paper-2);
  padding:12px 16px; margin:14px 0; break-inside:avoid; page-break-inside:avoid; }

/* ---- TABLES — bound-almanac treatment: banded header, warm zebra rows ---- */
body.printing .print-folio table th{ background:var(--red-deep) !important; color:#f3ecdd !important;
  font-family:var(--mono); font-weight:600; text-transform:uppercase; letter-spacing:.06em;
  border-bottom:none; }
body.printing .print-folio table.sarvato-grid th{ background:var(--paper-3) !important;
  color:var(--ink-2) !important; }  /* the 27×27 grid stays quiet — a solid band overwhelms it */
body.printing .print-folio tbody tr:nth-child(even) td{ background:rgba(163,120,47,.05); }
body.printing .print-folio td{ border-bottom:.5px solid var(--rule-soft); }
body.printing thead{ display:table-header-group; }

/* ---- STATUS CHIPS — print as solid pills so verdicts read at a glance ---- */
body.printing .chip{ border:none !important; color:#fff !important; font-weight:700;
  padding:1px 7px !important; border-radius:8px; }
body.printing .chip.exalt{ background:var(--benefic) !important; }
body.printing .chip.debil{ background:var(--debil) !important; }
body.printing .chip.own{ background:var(--gold) !important; }
body.printing .chip.vg{ background:#2e5f8a !important; }
body.printing .chip.R, body.printing .chip.C{ background:var(--ink-soft) !important; }

/* ---- CALLOUTS — insights and in-sum blocks get the gold-rule treatment ---- */
body.printing .insight-box, body.printing .pane-insight, body.printing .folio-insight,
body.printing .synth-sum{ background:#f4ecd8 !important; border:.6px solid var(--gold-soft) !important;
  border-left:3px solid var(--gold) !important; break-inside:avoid; page-break-inside:avoid; }

body.printing .sc-shell{max-width:580px}


body.printing .natal-chart, body.printing .spec-chart, body.printing .transit-chart,
body.printing .graha-card, body.printing .previewcard{
  break-inside:avoid; page-break-inside:avoid; }
/* tall tables flow across pages (rows whole, header repeated) — no wholesale jump */
body.printing tr{ break-inside:avoid; page-break-inside:avoid; }
body.printing thead{ display:table-header-group; }
body.printing .chartsvg{ width:100% !important; height:auto !important; max-width:330px !important;
  display:block; margin:0 auto; }
body.printing .chart-img{ width:auto !important; height:auto !important; max-width:330px !important;
  display:block !important; margin:10px auto !important; break-inside:avoid; page-break-inside:avoid; }

/* ===================================================================
   MATCHING DETAILS — stack every compatibility pane
   =================================================================== */
body.printing-match #mcTabs, body.printing-match .sb-vmenu,
body.printing-match .book-foot,
body.printing-match .page-nav{ display:none !important; }
body.printing-match .book-page-wrap,
body.printing-match .sb-tabwrap, body.printing-match .sb-panebox{ display:block !important; }
body.printing-match .match-pane{ display:block !important; break-before:auto;
  page-break-before:auto; border-top:1px solid var(--rule); margin-top:22px; padding-top:16px; }
body.printing-match .match-pane:first-of-type{ break-before:auto; page-break-before:auto;
  border-top:none; margin-top:0; }
body.printing-match .match-charts-grid,
body.printing-match .match-chart-box, body.printing-match .dm-state,
body.printing-match .rel-rem-card, body.printing-match .synth-composite{ break-inside:avoid; page-break-inside:avoid; }
/* tall tables flow across pages, rows kept whole and the header repeated — the same
   policy the birth-chart book uses; `table{break-inside:avoid}` here was forcing a
   page flush for every table taller than a sheet. */
body.printing-match tr{ break-inside:avoid; page-break-inside:avoid; }
body.printing-match thead{ display:table-header-group; }
body.printing-match .match-charts-grid{ display:grid !important; grid-template-columns:1fr 1fr; }
body.printing-match .pane-insight{ break-inside:avoid; }
body.printing-match .divscroll, body.printing-match .graha-wrap,
body.printing-match .poruttam-table, body.printing-match .match-planet-table,
body.printing-match .match-kuta-table{ overflow:visible !important; max-width:100% !important; }
body.printing-match table{ min-width:0 !important; width:100% !important;
  table-layout:fixed; font-size:7.5px !important; }
body.printing-match .match-planet-table table{ font-size:6px !important; }
body.printing-match th, body.printing-match td{ padding:2px 3px !important;
  white-space:normal !important; overflow-wrap:anywhere; word-break:break-word; }
/* One chart cap across BOTH reports. This was pinned at 230px while the birth-chart
   book used 330px, so the same kuṇḍalī printed 43% smaller in Matching — and in a
   two-column print cell (~277px at A4) the 230px cap left dead space either side.
   width:100% now fills the cell, and the shared 330px ceiling stops it exceeding the
   book when the layout is wider. */
body.printing-match .match-chart-svg img, body.printing-match .match-chart-svg svg{
  max-width:330px !important; width:100% !important; height:auto !important; margin:0 auto; display:block; }
body.printing-match img, body.printing-match svg{ max-width:100% !important; }

/* ---- bar charts (ṣaḍbala ranking, bhāva bala, SAV bindus) ----------------
   These are wide bar graphics, not square kuṇḍalīs, so the 330px .chartsvg cap
   would squash them. They also carry an inline `max-width:620/640px` from the
   generator, which beats a non-!important stylesheet rule — hence !important
   here. Give them the full column and let the aspect ratio do the rest. */
.barsvg, body.printing .barsvg{
  width:100% !important; max-width:100% !important; height:auto !important;
  display:block; margin:0 auto;
  break-inside:avoid; page-break-inside:avoid;
}

/* ---- collapsed <details> would print as summary-only stubs ----------------
   JS opens them on beforeprint (expandDetailsForPrint); this is the fallback
   for engines where that event does not fire. The marker is hidden because an
   expanded card has nothing left to toggle. */
details:not([open]) > *{ display:revert !important; }
details > summary{ list-style:none; }
details > summary::-webkit-details-marker{ display:none !important; }
.sb-card > summary::after, .faq-q > summary::after{ content:"" !important; }
.faq-q, .sb-card, .cs-md{ break-inside:avoid; page-break-inside:avoid; }

/* ===================================================================
   KEEP-WITH RULES
   The export showed lead-ins stranded at the foot of a page while the
   table or chart they introduce started the next one, and insight boxes
   opening a page entirely alone. Headings already had break-after:avoid
   (see h2,h3,h4 above); the intro paragraphs and summary boxes did not.
   =================================================================== */

/* An introduction must stay with what it introduces. This was the cause of the
   page that carried only "The weighted layers behind the score…" while its bar
   table began overleaf. */
.varga-intro, .folio-blurb, .ch-sk, .spec-lede, .cs-source p,
.print-contents .toc-name{ break-after:avoid; page-break-after:avoid; }

/* An insight summarises what precedes it, so it must never open a page alone —
   one page of the export contained nothing but an orphaned INSIGHT block. */
.pane-insight, .insight-box, .cs-caution{ break-before:avoid; page-break-before:avoid; }

/* Table captions / sub-heads bind forward to their table. */
table + .varga-intro{ break-before:avoid; page-break-before:avoid; }
.sechead, .sb-grp-h, .faq-sec > h3{ break-after:avoid; page-break-after:avoid; }

/* No single stranded line either side of a break. */
p, li, td, dd{ orphans:3; widows:3; }

/* No trailing blank sheet: the last section must not force a break after itself. */
body.printing-match .match-pane:last-of-type,
body.printing .print-folio:last-child,
body.printing #bookPage > *:last-child{ break-after:avoid; page-break-after:avoid; }
body.printing #bookPage > *:last-child{ margin-bottom:0 !important; padding-bottom:0 !important; }
