/**
 * hwc-quicksight – print.css (loaded with media="print")
 *
 * Fits the embedded QuickSight dashboard to the printed page width.
 *
 * The iframe is kept at the size it has on screen (so QuickSight does not
 * re-render) and scaled down with transform: scale(). CSS `zoom` cannot be
 * used: browsers ignore it inside cross-origin iframes when printing, which
 * crops the right-hand side of the dashboard.
 *
 * The on-screen iframe size is published by assets/js/print-fit.js as the
 * custom properties --hwc-qs-w / --hwc-qs-h (unitless px) on
 * `.hwc-qs-print-host`.
 *
 * Page size and margins (@page) are handled by the theme stylesheet.
 */
@media print {

    .hwc-qs-print-host {
        display: block;
        width: 100% !important;
        max-width: 100% !important;

        /* Fallback scale (set by print-fit.js) for browsers without typed
           calc() support. Assumes a landscape Letter page. */
        --hwc-qs-scale: var(--hwc-qs-scale-fb, 0.8);
    }

    /* No container-type here: its layout containment makes the host
       unbreakable, so the footer would print over the dashboard's later pages. */
    @supports (scale: calc(1px / 1px)) {
        .hwc-qs-print-host {
            --hwc-qs-scale: min(1, calc((100vw - 48px) / (var(--hwc-qs-w, 1280) * 1px)));
        }
    }

    /* Takes up the scaled height, so following content starts after the dashboard. */
    .hwc-qs-print-host .hwc-qs-container {
        position: relative !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        height: calc(var(--hwc-qs-h, 900) * 1px * var(--hwc-qs-scale)) !important;
    }

    .hwc-qs-print-host .hwc-qs-container iframe {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        display: block !important;
        border: 0 !important;
        max-width: none !important;
        width: calc(var(--hwc-qs-w, 1280) * 1px) !important;
        height: calc(var(--hwc-qs-h, 900) * 1px) !important;
        transform-origin: 0 0;
        transform: scale(var(--hwc-qs-scale)) !important;
    }

    /* Keep chart colours when "Background graphics" is enabled. */
    .hwc-qs-print-host,
    .hwc-qs-print-host * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
