/*
 * Kundli report: print and "Save as PDF" (A4 portrait). Loaded with media="print", so it never touches the screen.
 *
 * Every rule is scoped to a print mode chosen from the report's Print / PDF menu (or set on beforeprint when the
 * browser's own Print is used). It keeps only the report's path through the page, shows the panels of that mode
 * even though the tab script has marked them [hidden], and lets tables and charts run at full width instead of
 * scrolling. Selectors carry the same two ids the theme uses (:is(html#kl-fresh-root, html) :is(body#page-top, body)) so they
 * outrank the screen rules that hide
 * inactive panels (.has-generated-report .kl-report-tab-panel-*[hidden]).
 */

@page {
    size: A4 portrait;
    margin: 10mm 9mm 11mm;
}

/* 1. Only the report reaches the paper: site header, notices, breadcrumb, landing hero, the "change birth
      details" bar, the report menu, footer and floating widgets are dropped. */
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] > *:not(main),
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] main > *:not(.site-container),
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .site-container.kl-page > *:not(.site-two-column-layout),
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .site-two-column-layout > *:not(.site-two-column-main),
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .site-two-column-main > *:not(.kl-kundli-entry-card),
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-kundli-entry-card > *:not(.kl-report-tabs-shell),
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tabs-shell > *:not(.kl-report-tab-body),
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tab-body > *:not(.kl-report-panel-viewport) {
    display: none !important;
}

:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"],
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] main,
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .site-container.kl-page,
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .site-two-column-layout,
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .site-two-column-main,
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-kundli-entry-card,
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tabs-shell,
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tab-body,
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-panel-viewport {
    display: block !important;
    width: auto !important;
    max-width: none !important;
    min-height: 0 !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
    overflow: visible !important;
    position: static !important;
}

:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    font-size: 11pt;
}

/* 2. The panels of each mode. Locked sections show a sales preview on screen; that is not printed. */
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tab-panel {
    display: none !important;
}

:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report.kl-print-mode-summary .kl-report-tab-panel.kl-report-tab-panel-birth:not(.kl-has-preview),
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report.kl-print-mode-charts .kl-report-tab-panel.kl-report-tab-panel-charts:not(.kl-has-preview),
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report.kl-print-mode-charts .kl-report-tab-panel.kl-report-tab-panel-chart-analysis:not(.kl-has-preview),
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report.kl-print-mode-yogas .kl-report-tab-panel.kl-report-tab-panel-yogas:not(.kl-has-preview),
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report.kl-print-mode-yogas .kl-report-tab-panel.kl-report-tab-panel-sade-sati:not(.kl-has-preview),
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report.kl-print-mode-timing .kl-report-tab-panel.kl-report-tab-panel-timing:not(.kl-has-preview),
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report.kl-print-mode-kundli-summary .kl-report-tab-panel.kl-report-tab-panel-summary:not(.kl-has-preview),
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report.kl-print-mode-full .kl-report-tab-panel:not(.kl-report-tab-panel-home):not(.kl-report-tab-panel-chat):not(.kl-has-preview):not(:empty) {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    break-after: auto !important;
}

/* The complete report starts each major part on a new page; the short companions (Sade Sati after the yogas,
   the chart analysis after the charts) follow on the same page. */
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report.kl-print-mode-full .kl-report-tab-panel:not(.kl-report-tab-panel-birth):not(.kl-report-tab-panel-sade-sati):not(.kl-report-tab-panel-chart-analysis) {
    break-before: page !important;
}

/* 3. Wide tables sit in horizontal scroll boxes (.kl-table-wrap) with a minimum width wider than A4; on paper
      the box opens up and the table fits the printable width instead of being cut at the right edge.
      Collapsed accordions are left alone: only what the reader opened is printed. */
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tab-panel .kl-table-wrap {
    overflow: visible !important;
    width: auto !important;
    max-width: 100% !important;
}

:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tab-panel .kl-table-wrap > table {
    min-width: 0 !important;
}

/* Two-column screen layouts (the Dasha tables beside the transit chart, the yoga workspace) stack on A4.
   Only the panels' contents: whether a panel prints at all is decided in section 2. */
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tab-panel-timing > *,
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-yoga-sade-workspace {
    display: block !important;
    width: auto !important;
    max-width: none !important;
}

:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tab-panel table {
    width: 100% !important;
    max-width: 100% !important;
    table-layout: auto !important;
    font-size: 9.5pt !important;
    border-collapse: collapse !important;
}

:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tab-panel th,
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tab-panel td {
    padding: 3px 5px !important;
    white-space: normal !important;
    word-break: normal;
    overflow-wrap: anywhere;
}

:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tab-panel thead {
    display: table-header-group;
}

:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tab-panel tr,
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tab-panel svg,
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tab-panel figure,
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tab-panel .kl-validated-chart-grid > *,
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tab-panel .kl-advanced-subsection,
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tab-panel article {
    break-inside: avoid;
    page-break-inside: avoid;
}

:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tab-panel h2,
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tab-panel h3,
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tab-panel h4 {
    break-after: avoid;
    page-break-after: avoid;
}

/* Charts keep their proportions and never exceed the printable width. */
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tab-panel svg {
    max-width: 100% !important;
    height: auto;
}

/* 4. Screen-only controls inside the report: the chart style switch, Dasha paging arrows and the print menu. */
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-summary-sheet-tools,
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-print-menu,
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .klp,
:is(html#kl-fresh-root, html) :is(body#page-top, body).has-generated-report[class*="kl-print-mode-"] .kl-report-tab-panel details > summary::marker {
    display: none !important;
}
