/**
 * The Next Street - Print Stylesheet
 * Optimized for clean paper/PDF export.
 * Deprioritized for non-blocking load (media="print", fetchpriority="low").
 */

@media print {
    /* =========================================================
       1. HIDE COOKIEYES, ANNOUNCEMENTS, OVERLAYS & FLOATING UI
       ========================================================= */
    .cky-consent-container,
    .cky-modal,
    .cky-overlay,
    .cky-btn-revisit-wrapper,
    .tns-announcement-bar,
    .ast-mobile-popup-drawer,
    .ast-mobile-popup-overlay,
    #ast-scroll-top,
    .userway,
    [aria-label*="accessibility" i],
    iframe {
        display: none !important;
    }

    /* =========================================================
       2. HIDE ALL BUTTONS & CTAS
       ========================================================= */
    button,
    .wp-block-button,
    .wp-block-premium-buttons,
    .wp-block-premium-button,
    .premium-button-group,
    .premium-button,
    .ast-custom-button-link,
    .ast-custom-button {
        display: none !important;
    }

    /* =========================================================
       2b. CONTACT INFO EXCEPTIONS
       ========================================================= */
    /* Icon-box buttons carry contact info (email, phone, text); print them as plain text */
    .wp-block-premium-icon-box .wp-block-premium-buttons,
    .wp-block-premium-icon-box .premium-button-group,
    .wp-block-premium-icon-box .premium-button-group_wrap,
    .wp-block-premium-icon-box .wp-block-premium-button {
        display: block !important;
    }

    .wp-block-premium-icon-box .premium-button {
        display: inline-block !important;
        background: none !important;
        border: 0 !important;
        box-shadow: none !important;
        padding: 0 !important;
        color: #1a1a1a !important;
        font-weight: 700 !important;
    }

    .wp-block-premium-icon-box .premium-button * {
        color: #1a1a1a !important;
        fill: #1a1a1a !important;
    }

    /* Student login is not useful on paper */
    .wp-block-premium-icon-box:has(a[href*="tds.ms"]) {
        display: none !important;
    }

    /* Contact page hero photos (CT, MA) */
    .wp-block-premium-image:has(img.wp-image-5089),
    .wp-block-premium-image:has(img.wp-image-6190) {
        display: none !important;
    }

    /* =========================================================
       2c. TABS & ACCORDIONS: PRINT EXPANDED
       Labels are injected as h2.tns-print-tab-heading by the beforeprint script in functions.php.
       ========================================================= */
    [role="tablist"],
    .premium-tabs-nav {
        display: none !important;
    }

    [role="tabpanel"],
    .premium-tabs-content-section,
    .wp-block-accordion-panel,
    details > :not(summary) {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        content-visibility: visible !important;
    }

    .premium-tabs-content,
    .premium-content-wrap {
        display: block !important;
        height: auto !important;
    }

    .tns-print-tab-heading {
        margin: 24px 0 8px !important;
        break-after: avoid !important;
        page-break-after: avoid !important;
    }

    /* Core accordion headings are buttons; keep the title, drop the toggle icon */
    .wp-block-accordion-heading__toggle {
        display: inline-block !important;
        background: none !important;
        border: 0 !important;
        padding: 0 !important;
        font: inherit !important;
        color: inherit !important;
    }

    .wp-block-accordion-heading__toggle-icon {
        display: none !important;
    }

    /* =========================================================
       3. HEADER: SHOW ONLY LOGO
       ========================================================= */
    .site-header {
        display: block !important;
        position: static !important;
        padding: 10px 0 !important;
        border-bottom: 1px solid #e2e2e2 !important;
    }

    /* Hide header navigation, widgets, and mobile toggle */
    .site-header .main-header-bar-navigation,
    .site-header .ast-above-header-wrap,
    .site-header .ast-below-header-wrap,
    .site-header .site-header-primary-section-right,
    .site-header nav,
    .site-header .ast-mobile-menu-trigger-minimal {
        display: none !important;
    }

    /* Keep header logo visible */
    .site-header .site-branding,
    .site-header .site-logo-img,
    .site-header .custom-logo-link,
    .site-header .custom-logo {
        display: inline-block !important;
        visibility: visible !important;
    }

    /* Lazy-load classes can leave logos at opacity 0 in the print snapshot */
    .site-header .custom-logo,
    .site-footer .footer-logo img {
        opacity: 1 !important;
        visibility: visible !important;
    }

    .site-header .custom-logo {
        width: 280px !important;
        min-width: 280px !important;
        max-width: none !important;
        height: auto !important;
    }

    /* Keep only the .site-header bottom border */
    .site-header .ast-primary-header-bar,
    .site-header .ast-above-header-bar {
        border-bottom: none !important;
    }

    /* =========================================================
       4. UNIFORM MARGINS & NATURAL FLOW
       ========================================================= */
    .ast-plain-container #content .ast-container,
    .entry-content {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
    }

    .wp-block-premium-container,
    .premium-container-inner-blocks-wrap {
        display: block !important;
        height: auto !important;
        min-height: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Even padding on every section; exact color adjust keeps section backgrounds in print */
    .wp-block-premium-container.premium-is-root-container {
        padding: 15px 20px !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .wp-block-premium-container > .premium-container-inner-blocks-wrap {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .wp-block-premium-container .wp-block-premium-container {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Completely hide empty background-image containers from print */
    .wp-block-premium-container:has(> .premium-container-inner-blocks-wrap:empty) {
        display: none !important;
    }

    /* Icon boxes center their icon on the card's left edge; leave room so it isn't clipped */
    .wp-block-premium-icon-box {
        margin-left: 40px !important;
        width: calc(100% - 40px) !important;
    }

    /* Flex gap is lost when wrappers become block; restore spacing between stacked cards */
    .wp-block-premium-icon-box + .wp-block-premium-icon-box {
        margin-top: 20px !important;
    }

    .wp-block-premium-icon-box {
        break-inside: avoid !important;
    }

    /* Lay icon-box cards out in two columns; the per-row wrappers are flattened so cards flow across rows */
    .premium-container-inner-blocks-wrap:has(> .wp-block-premium-container > .premium-container-inner-blocks-wrap > .wp-block-premium-icon-box) {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 56px;
        row-gap: 20px;
    }

    .wp-block-premium-container:has(> .premium-container-inner-blocks-wrap > .wp-block-premium-icon-box),
    .wp-block-premium-container:has(> .premium-container-inner-blocks-wrap > .wp-block-premium-icon-box) > .premium-container-inner-blocks-wrap {
        display: contents !important;
    }

    .premium-container-inner-blocks-wrap:has(> .wp-block-premium-container > .premium-container-inner-blocks-wrap > .wp-block-premium-icon-box) .wp-block-premium-icon-box {
        margin-top: 0 !important;
    }

    /* Left-align the contact link under its description and drop the decorative button icon */
    .wp-block-premium-icon-box .premium-button-group_wrap,
    .wp-block-premium-icon-box .wp-block-premium-button {
        justify-content: flex-start !important;
        text-align: left !important;
    }

    .wp-block-premium-icon-box .premium-button-icon {
        display: none !important;
    }

    /* Collapse the button wrappers' spacing so the link sits directly under the description */
    .wp-block-premium-icon-box .wp-block-premium-buttons,
    .wp-block-premium-icon-box .premium-button-group_wrap,
    .wp-block-premium-icon-box .wp-block-premium-button {
        margin: 0 !important;
        padding: 0 !important;
        min-height: 0 !important;
        height: auto !important;
    }

    .wp-block-premium-icon-box .wp-block-premium-section {
        padding-top: 10px !important;
        padding-bottom: 10px !important;
    }

    .wp-block-premium-icon-box .premium-icon-box-content {
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }

    /* Stretch each card to the tallest card in its grid row */
    .wp-block-premium-icon-box,
    .wp-block-premium-icon-box .premium-icon-box-content {
        align-items: stretch !important;
        height: 100% !important;
    }

    .wp-block-premium-icon-box .wp-block-premium-section {
        align-self: stretch !important;
    }

    /* Prevent awkward orphan headings */
    h1, h2, h3, .wp-block-premium-heading {
        break-after: avoid !important;
        page-break-after: avoid !important;
    }

    /* =========================================================
       4b. SINGLE PRODUCT PAGES
       Photo left, details right, description full width below; no thumbs, extra slides or related products.
       ========================================================= */
    .single-product div.type-product {
        display: grid !important;
        grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
        column-gap: 24px;
        align-items: start;
    }

    .single-product div.type-product > * {
        min-width: 0;
    }

    .single-product div.type-product > .tns-single-product-description,
    .single-product div.type-product > .woocommerce-notices-wrapper {
        grid-column: 1 / -1;
    }

    .single-product .related,
    .single-product .upsells,
    .single-product .onsale,
    .single-product .woocommerce-product-gallery__trigger,
    .single-product .flex-control-nav {
        display: none !important;
    }

    /* The gallery is a slider track; collapse it to the first slide at column width */
    .single-product .woocommerce-product-gallery,
    .single-product .woocommerce-product-gallery__wrapper,
    .single-product .woocommerce-product-gallery__image,
    .single-product .summary {
        width: 100% !important;
        float: none !important;
    }

    .single-product .woocommerce-product-gallery .flex-viewport {
        height: auto !important;
    }

    .single-product .woocommerce-product-gallery__wrapper {
        transform: none !important;
    }

    .single-product .woocommerce-product-gallery__image:not(:first-child) {
        display: none !important;
    }

    .single-product .woocommerce-product-gallery__image img {
        width: 100% !important;
        height: auto !important;
    }

    .single-product .summary {
        margin: 0 !important;
    }

    /* =========================================================
       4c. LOCATION PAGES, SCHEDULE TABLES & HELP CENTER
       ========================================================= */
    .ip-kb-search-form {
        display: none !important;
    }

    /* Two-tab blocks (Details | Location Hours) sit side by side */
    .single-wpsl_stores .premium-tabs-content:has(> .premium-tabs-content-section:nth-child(2):last-child) {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 24px;
        align-items: start;
    }

    .single-wpsl_stores .premium-tabs-content > .premium-tabs-content-section {
        margin: 0 !important;
        min-width: 0;
    }

    /* Heading block: tighter name and address, no Directions link or interactive map */
    .single-wpsl_stores .wpsl-location-directions,
    .single-wpsl_stores .wpsl-gmap-canvas {
        display: none !important;
    }

    .single-wpsl_stores .premium-is-root-container:has(> .premium-container-inner-blocks-wrap > .wp-block-premium-container > .premium-container-inner-blocks-wrap > .wpsl-gmap-canvas) {
        display: none !important;
    }

    .single-wpsl_stores .wpsl-locations-details,
    .single-wpsl_stores .wpsl-location-address {
        margin-bottom: 0 !important;
        line-height: 1.5 !important;
    }

    .single-wpsl_stores h1 {
        margin-bottom: 8px !important;
    }

    /* Schedule tables: drop the paging, search and length controls */
    .dataTables_paginate,
    .dataTables_filter,
    .dataTables_length,
    .dataTables_info {
        display: none !important;
    }

    table.wpDataTable tr {
        break-inside: avoid;
    }

    table.wpDataTable thead {
        display: table-header-group;
    }

    /* =========================================================
       5. FOOTER: CENTERED, SEAMLESS BLEND (NO BG / BORDER)
       ========================================================= */
    .site-footer,
    .site-primary-footer-wrap,
    .site-below-footer-wrap {
        display: block !important;
        background: transparent !important;
        background-color: transparent !important;
        border: none !important;
        border-top: none !important;
        border-bottom: none !important;
        padding: 0 !important;
        text-align: center !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    .site-footer {
        margin-top: 20px !important;
        padding-top: 16px !important;
        border-top: 1px solid #e2e2e2 !important;
    }

    /* Hide footer navigation link columns & unused widget sections */
    .site-footer-primary-section-2,
    .site-footer-primary-section-3,
    .site-footer-primary-section-4,
    .site-footer-below-section-2,
    .site-footer-below-section-3 {
        display: none !important;
    }

    /* Astra footer rows are CSS grids; collapse to a single full-width column */
    .site-footer .ast-builder-footer-grid-columns {
        display: block !important;
        width: 100% !important;
    }

    .site-footer .footer-widget-area,
    .site-footer .wp-block-group,
    .site-footer .ast-builder-layout-element {
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
    }

    /* Center footer logo, blurb, and copyright line */
    .site-footer-primary-section-1,
    .site-footer-primary-section-1 .footer-logo,
    .site-footer-primary-section-1 .premium-text,
    .site-footer-below-section-1,
    .site-below-footer-wrap {
        display: block !important;
        width: 100% !important;
        text-align: center !important;
        margin: 0 auto !important;
    }

    .site-footer-primary-section-1 .footer-logo img {
        max-width: 180px !important;
        height: auto !important;
        margin: 0 auto 12px auto !important;
        display: block !important;
    }

    .site-footer-primary-section-1 .premium-text {
        max-width: 500px !important;
        margin: 0 auto 10px auto !important;
        text-align: center !important;
    }

    .site-footer-below-section-1 {
        margin-top: 6px !important;
        font-size: 0.9em !important;
        color: #666 !important;
        text-align: center !important;
    }
}
