/**
 * Print Styles
 *
 * Loaded with media="print" for proper specificity and non-blocking performance.
 * These styles only apply when printing.
 *
 * @package TMW_Core_Child
 */

/* ----- Page Setup ----- */

/* Set page margins to 0 to hide browser headers/footers (URL, date, page numbers) */

/* Content padding is added to body to compensate */
@page {
    margin: 0;
    size: auto;
}

/* ----- Hide Non-Essential Elements ----- */
.site-navigation,
.header-buttons,
.announcement-bar,
.nav-menu,
.nav-menu--mobile,
.sidebar,
.sidebar-cta,
.social-share-links,
.social-links,
.back-to-top,
.cookie-banner,
.popup,
.modal,
.no-print,
form,
audio,
video,
iframe:not(.print-iframe),
/* Feedback tools - BugHerd, etc. */
[id^="BugHerd"],
[class*="bugherd"],
.us-widget,
.us-launcher,
#us-entrypoint,
#cookie-notice,
.cky-consent-container,
.cky-consent-bar,
/* Single post elements that don't make sense in print */
.post-navigation,
.posts-navigation,
.nav-links,
.share-buttons,
.share-links,
[class*="share"],
.related-posts,
.related-blog-posts,
[class*="related-posts"],
.post-nav,
.prev-next-nav,
a[rel="prev"],
a[rel="next"] {
    display: none !important;
}

/* ----- Collapse Header Completely -----
   Hide header and remove all space it occupies to prevent blank first page */
.site-header,
header,
.header,
#masthead,
.masthead {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
}

/* ----- Hide Sticky/Fixed Navigation & CTAs -----
   Remove sub-navigation, sticky CTAs, and floating elements for print */
.sub-navigation,
.sub-nav,
.sticky-nav,
.fixed-nav,
.sticky-cta,
.floating-cta,
.book-a-demo,
.book-demo,
[class*="book-a-demo"],
[class*="sticky-"],
[class*="fixed-cta"],
.product-nav,
.page-nav,
.section-nav,
.anchor-nav {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* ----- Reset Backgrounds & Colors ----- */
*,
*::before,
*::after {
    background: transparent !important;
    color: #000000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

/* ----- Reduce Section Padding for Print ----- */
section,
.section-padding-xs,
.section-padding-sm,
.section-padding-md,
.section-padding-lg,
.section-padding-xl,
.section-padding-2xl,
.section-padding-3xl {
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
    background: transparent !important;
    page-break-inside: avoid;
    break-inside: avoid;
    overflow: visible !important;
}

.section-header {
    margin-bottom: 0.5rem !important;
}

/* Reduce hero/banner height */
.hero,
[class*="hero"] {
    min-height: auto !important;
    height: auto !important;
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
}

/* Reduce gaps in grids */
.row,
.grid,
[class*="-grid"] .row,
[class*="-grid"] .grid {
    gap: 0.5rem !important;
}

/* Remove min-heights that create empty space */
[class*="min-height"],
[style*="min-height"] {
    min-height: auto !important;
}

/* ----- Buttons as Outline Style ----- */
button,
.btn,
.btn-primary,
.btn-secondary,
.btn-light,
.wp-block-button__link {
    display: inline-block !important;
    background: transparent !important;
    border: 1px solid #000000 !important;
    padding: 0.5em 1em !important;
    color: #000000 !important;
    text-decoration: none !important;
    font-weight: normal !important;
}

button::after,
.btn::after {
    background: transparent !important;
}

/* ----- Gutenberg Color Class Overrides -----
   Override all Gutenberg has-*-color and has-*-background-color classes */
[class*="has-"][class*="-color"],
[class*="has-"][class*="-background-color"],
[class*="has-"][class*="-gradient-background"] {
    background: transparent !important;
    color: #000000 !important;
}

/* Hide button arrows/icons */
.btn::after,
.btn svg,
.wp-block-button__link::after {
    display: none !important;
}

/* ----- Typography ----- */
body {
    padding: 1cm;
    padding-top: 0.5cm;
    font-size: 12pt;
    line-height: 1.5;
}

/* Ensure main content starts at top without extra space */
main,
#main,
.site-main,
.main-content,
#content,
.site-content {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

h1 {
    font-size: 24pt;
}

h2 {
    font-size: 20pt;
}

h3 {
    font-size: 16pt;
}

h4,
h5,
h6 {
    font-size: 14pt;
}

p,
li,
td,
th {
    orphans: 3;
    widows: 3;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    page-break-after: avoid;
    break-after: avoid;
}

/* ----- Links ----- */
a,
a:visited {
    text-decoration: underline;
}

/* ----- Images ----- */
img {
    max-width: 100% !important;
    page-break-inside: avoid;
    break-inside: avoid;
}

/* ----- Tables ----- */
table {
    border-collapse: collapse;
}

table,
th,
td {
    border: 1px solid #000000;
}

thead {
    display: table-header-group;
}

tr {
    page-break-inside: avoid;
    break-inside: avoid;
}

/* ----- Page Breaks ----- */
.page-break-before {
    break-before: page;
}

.page-break-after {
    break-after: page;
}

.no-break {
    page-break-inside: avoid;
    break-inside: avoid;
}

/* ----- Content Width ----- */
.container,
.wp-block-group,
main,
article {
    max-width: 100% !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* ----- Carousel to Grid Conversion -----
   Convert horizontal scroll carousels to static grids for print */

/* Hide carousel navigation elements */
.carousel-navigation,
.carousel-nav-arrow,
.carousel-nav-dot,
.carousel-progress-container,
.swiper-pagination,
.swiper-button-next,
.swiper-button-prev,
.swiper-scrollbar {
    display: none !important;
}

/* Convert carousel tracks to grid layout */
.carousel-track-container,
.swiper-wrapper,
.swiper-container,
.swiper {
    overflow: visible !important;
    height: auto !important;
}

.carousel-track,
.swiper-wrapper {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 1rem !important;
    flex-wrap: wrap !important;
    transform: none !important;
}

.carousel-card,
.swiper-slide {
    flex-shrink: 1 !important;
    min-width: 0 !important;
    max-width: none !important;
    width: 100% !important;
    scroll-snap-align: unset !important;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    position: static !important;
}

/* Anika Solutions grid - ensure all cards visible */
.anika-solutions-grid,
.content-card-carousel,
.content-card-carousel--grid {
    overflow: visible !important;
}

.anika-solutions-grid .carousel-track,
.content-card-carousel .carousel-track {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
}

/* ----- Anika Solutions Grid Cards -----
   These cards use CSS background-image which doesn't print by default.
   Convert to simple bordered cards with visible content */

.anika-solutions-grid .column-container {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 0.5rem !important;
}

.anika-solutions-grid .column-card {
    min-height: auto !important;
    height: auto !important;
    padding: 1rem !important;
    border: 1px solid #cccccc !important;
    border-radius: 4px !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: static !important;
    transform: none !important;
}

/* Remove the gradient overlay pseudo-element */
.anika-solutions-grid .column-card::before {
    display: none !important;
}

/* Make card title and content visible */
.anika-solutions-grid .column-title,
.anika-solutions-grid .column-content {
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    position: static !important;
}

/* Show the CTA button */
.anika-solutions-grid .btn-arrow {
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    pointer-events: auto !important;
    display: inline-block !important;
}

/* ----- Resource Cards -----
   Ensure resource cards and their content render properly */

.resource-card,
.card,
[class*="-card"] {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    border: 1px solid #cccccc !important;
    padding: 1rem !important;
    margin-bottom: 1rem !important;
}

/* Show card images */
.resource-card img,
.card img,
.card-image,
.card-thumbnail {
    display: block !important;
    max-width: 100% !important;
    height: auto !important;
}

/* Ensure card content is visible */
.card-content,
.card-body,
.card-title,
.card-description,
.card-meta {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* ----- Button Text Fixes -----
   Prevent duplicate button text from ::before/::after pseudo-elements */

.btn-arrow::before,
.btn-arrow::after,
.btn::before,
.btn::after,
.wp-block-button__link::before,
.wp-block-button__link::after {
    display: none !important;
    content: none !important;
}

/* Hide sr-only and visually-hidden text that may become visible in print */
.sr-only,
.screen-reader-text,
.visually-hidden,
[aria-hidden="true"] {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
}

/* Ensure button text is not duplicated from data attributes */
.btn[data-text]::after,
.wp-block-button__link[data-text]::after {
    content: none !important;
    display: none !important;
}

/* ----- Featured Posts & Content Grids -----
   Ensure dynamic grids display properly */

.featured-recent-posts,
.dynamic-archive-grid,
[class*="-grid"] {
    overflow: visible !important;
}

.featured-recent-posts .grid,
.dynamic-archive-grid .grid,
.row {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 1rem !important;
}

/* 2-column layouts */
.featured-recent-posts .grid.cols-2,
.row.cols-2 {
    grid-template-columns: repeat(2, 1fr) !important;
}

/* ----- Preserve Important Images -----
   Ensure logos, icons, and product images print */

.site-logo img,
.logo img,
.card-icon img,
.product-image img,
.feature-icon img {
    /* Reset the global transparent background rule for these specific images */
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

/* ----- Hide CTA Sections -----
   CTAs are for web interaction and don't serve a purpose in print */
.cta-section,
.cta-block,
.cta-banner,
[class*="cta-"],
.wp-block-acf-cta,
.contact-cta,
.newsletter-signup,
.newsletter-cta {
    display: none !important;
}

/* ----- Footer: Hide All Except Copyright -----
   Reduce footer to just the copyright line for cleaner print output */

.site-footer,
footer,
.footer,
#colophon {
    padding: 0.5rem 1cm !important;
    margin-top: 0 !important;
}

/* Hide all footer content except copyright */
.site-footer .footer-widgets,
.site-footer .footer-menu,
.site-footer .footer-navigation,
.site-footer .footer-social,
.site-footer .footer-logo,
.site-footer .footer-cta,
.site-footer .footer-newsletter,
.site-footer .widget-area,
.site-footer .menu,
.site-footer ul,
.site-footer nav,
.site-footer a:not([class*="copyright"] a),
footer .footer-widgets,
footer .footer-menu,
footer .footer-navigation,
footer .footer-social,
footer .footer-logo,
footer .footer-cta,
footer .footer-newsletter,
footer .widget-area,
footer nav,
footer ul:not([class*="copyright"]),
footer .menu,
/* Hide specific footer sections */
.footer-top,
.footer-middle,
.footer-main,
.footer-columns,
.footer-links,
.footer-nav,
[class*="footer-col"],
[class*="footer-widget"] {
    display: none !important;
}

/* Show only copyright */
.site-footer .copyright,
.site-footer .footer-copyright,
.site-footer .footer-bottom,
.site-footer [class*="copyright"],
footer .copyright,
footer .footer-copyright,
footer .footer-bottom,
footer [class*="copyright"],
.copyright {
    display: block !important;
    text-align: center !important;
    font-size: 10pt !important;
    padding: 0.25rem 0 !important;
}

/* Ensure copyright links are visible */
.copyright a,
.footer-copyright a,
[class*="copyright"] a {
    display: inline !important;
}

/* ----- Prevent Text Overlap Between Sections -----
   Add spacing between major content sections to prevent overlap */
.content-card-carousel,
.anika-solutions-grid,
.featured-recent-posts,
.dynamic-archive-grid,
[class*="wp-block-group"] {
    page-break-inside: avoid;
    break-inside: avoid;
    margin-bottom: 1rem !important;
}

/* Ensure text content has adequate spacing */
.section-content,
.block-content,
.entry-content {
    overflow: visible !important;
    position: relative !important;
}
