/**
 * Minimal Header Fix for Custom Templates
 * Version: 1.1.1
 * 
 * Fixes specific issues while preserving theme functionality
 */

/* ============================================
   HEADER-BOX: LOGO + MENU LAYOUT
============================================ */

/* Center the entire header block container */
body.post-type-archive-pn_magazine_issue .main-header,
body.single-pn_magazine_issue .main-header,
body.post-type-archive-pn_video .main-header,
body.single-pn_video .main-header,
body.single.tag-frea-area .main-header,
body.free-article-layout .main-header {
    margin: 0 auto !important;
    padding: 0 !important;
    max-width: 100% !important;
}

/* Let WordPress handle global padding naturally - removed custom overrides */

/* Match normal pages: set padding to 0 and use auto margins with max-width */
body.post-type-archive-pn_magazine_issue .header-top,
body.single-pn_magazine_issue .header-top,
body.post-type-archive-pn_video .header-top,
body.single-pn_video .header-top,
body.single.tag-frea-area .header-top,
body.free-article-layout .header-top {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin-left: auto !important;
    margin-right: auto !important;
}


/* Let the intermediate wrapper (.wp-block-group.is-layout-flow) be full width, then constrain header-box */
body.post-type-archive-pn_magazine_issue .header-bottom.is-layout-constrained > *,
body.single-pn_magazine_issue .header-bottom.is-layout-constrained > *,
body.post-type-archive-pn_video .header-bottom.is-layout-constrained > *,
body.single-pn_video .header-bottom.is-layout-constrained > *,
body.single.tag-frea-area .header-bottom.is-layout-constrained > *,
body.free-article-layout .header-bottom.is-layout-constrained > * {
    margin-left: auto !important;
    margin-right: auto !important;
    width: 100% !important;
    max-width: var(--wp--style--global--content-size, 999px) !important;
}

/* Style header-box: fill the constrained width, center, logo and menu separated edge-to-edge */
body:is(.post-type-archive-pn_magazine_issue,
.single-pn_magazine_issue,
.post-type-archive-pn_video,
.single-pn_video,
.single.tag-frea-area,
.free-article-layout)
:is(.main-header .header-bottom .wp-block-group .header-box,
.main-header .header-bottom .header-box,
.header-box) {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    padding-top: 6px !important;
    padding-bottom: 6px !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    gap: 20px !important; /* Keep logo and menu spaced evenly */
    justify-content: space-between !important; /* Let logo hug the left and menu hug the right */
    margin-left: auto !important; /* Center the container */
    margin-right: auto !important; /* Center the container */
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Reduce line-height and remove extra spacing from navigation */
body.post-type-archive-pn_magazine_issue .header-menu,
body.single-pn_magazine_issue .header-menu,
body.post-type-archive-pn_video .header-menu,
body.single-pn_video .header-menu,
body.single.tag-frea-area .header-menu,
body.free-article-layout .header-menu {
    line-height: 1 !important;
}

/* Remove extra margin/padding from groups inside header */
body.post-type-archive-pn_magazine_issue .header-bottom > .wp-block-group,
body.single-pn_magazine_issue .header-bottom > .wp-block-group,
body.post-type-archive-pn_video .header-bottom > .wp-block-group,
body.single-pn_video .header-bottom > .wp-block-group,
body.single.tag-frea-area .header-bottom > .wp-block-group,
body.free-article-layout .header-bottom > .wp-block-group {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding: 0 !important;
}

/* Ensure logo and menu stay on the same row */
body.post-type-archive-pn_magazine_issue .header-box.is-layout-flex,
body.single-pn_magazine_issue .header-box.is-layout-flex,
body.post-type-archive-pn_video .header-box.is-layout-flex,
body.single-pn_video .header-box.is-layout-flex,
body.single.tag-frea-area .header-box.is-layout-flex,
body.free-article-layout .header-box.is-layout-flex {
    flex-wrap: nowrap !important;
}

/* Ensure logo doesn't grow */
body.post-type-archive-pn_magazine_issue .header-logo,
body.single-pn_magazine_issue .header-logo,
body.post-type-archive-pn_video .header-logo,
body.single-pn_video .header-logo,
body.single.tag-frea-area .header-logo,
body.free-article-layout .header-logo {
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
}

/* Ensure menu can grow to fill space and aligns right */
body.post-type-archive-pn_magazine_issue .header-menu,
body.single-pn_magazine_issue .header-menu,
body.post-type-archive-pn_video .header-menu,
body.single-pn_video .header-menu,
body.single.tag-frea-area .header-menu,
body.free-article-layout .header-menu {
    flex-grow: 1 !important;
    flex-shrink: 1 !important;
}

/* ============================================
   LOGO SIZING - RESPONSIVE
============================================ */

/* Base logo sizing */
body:is(.post-type-archive-pn_magazine_issue,
.single-pn_magazine_issue,
.post-type-archive-pn_video,
.single-pn_video,
.single.tag-frea-area,
.free-article-layout) .header-logo img {
    height: auto !important;
    width: auto !important;
}

/* Desktop: larger logo */
@media (min-width: 960px) {
    body:is(.post-type-archive-pn_magazine_issue,
    .single-pn_magazine_issue,
    .post-type-archive-pn_video,
    .single-pn_video,
    .single.tag-frea-area,
    .free-article-layout) .header-logo img {
        max-height: 82px !important;
    }
}

/* Mobile: smaller logo */
@media (max-width: 959px) {
    body:is(.post-type-archive-pn_magazine_issue,
    .single-pn_magazine_issue,
    .post-type-archive-pn_video,
    .single-pn_video,
    .single.tag-frea-area,
    .free-article-layout) .header-logo img {
        max-height: 42px !important;
    }
}

/* ============================================
   NAVIGATION MENU STYLING
============================================ */

/* Override has-heading-color and make menu text orange (primary color) */
body.post-type-archive-pn_magazine_issue .header-menu.wp-block-navigation a,
body.post-type-archive-pn_magazine_issue .header-menu.wp-block-navigation .wp-block-navigation-item a,
body.post-type-archive-pn_magazine_issue .header-menu.wp-block-navigation .wp-block-navigation-item__content,
body.single-pn_magazine_issue .header-menu.wp-block-navigation a,
body.single-pn_magazine_issue .header-menu.wp-block-navigation .wp-block-navigation-item a,
body.single-pn_magazine_issue .header-menu.wp-block-navigation .wp-block-navigation-item__content,
body.post-type-archive-pn_video .header-menu.wp-block-navigation a,
body.post-type-archive-pn_video .header-menu.wp-block-navigation .wp-block-navigation-item a,
body.post-type-archive-pn_video .header-menu.wp-block-navigation .wp-block-navigation-item__content,
body.single-pn_video .header-menu.wp-block-navigation a,
body.single-pn_video .header-menu.wp-block-navigation .wp-block-navigation-item a,
body.single-pn_video .header-menu.wp-block-navigation .wp-block-navigation-item__content,
body.single.tag-frea-area .header-menu.wp-block-navigation a,
body.single.tag-frea-area .header-menu.wp-block-navigation .wp-block-navigation-item a,
body.single.tag-frea-area .header-menu.wp-block-navigation .wp-block-navigation-item__content,
body.free-article-layout .header-menu.wp-block-navigation a,
body.free-article-layout .header-menu.wp-block-navigation .wp-block-navigation-item a,
body.free-article-layout .header-menu.wp-block-navigation .wp-block-navigation-item__content {
    color: var(--wp--preset--color--primary) !important;
}

/* Menu items align right, wrapped lines also right-aligned */
body.post-type-archive-pn_magazine_issue .header-menu.wp-block-navigation.is-layout-flex,
body.post-type-archive-pn_magazine_issue .header-menu.wp-block-navigation.is-content-justification-center,
body.post-type-archive-pn_magazine_issue .header-menu.wp-block-navigation,
body.single-pn_magazine_issue .header-menu.wp-block-navigation.is-layout-flex,
body.single-pn_magazine_issue .header-menu.wp-block-navigation.is-content-justification-center,
body.single-pn_magazine_issue .header-menu.wp-block-navigation,
body.post-type-archive-pn_video .header-menu.wp-block-navigation.is-layout-flex,
body.post-type-archive-pn_video .header-menu.wp-block-navigation.is-content-justification-center,
body.post-type-archive-pn_video .header-menu.wp-block-navigation,
body.single-pn_video .header-menu.wp-block-navigation.is-layout-flex,
body.single-pn_video .header-menu.wp-block-navigation.is-content-justification-center,
body.single-pn_video .header-menu.wp-block-navigation,
body.single.tag-frea-area .header-menu.wp-block-navigation.is-layout-flex,
body.single.tag-frea-area .header-menu.wp-block-navigation.is-content-justification-center,
body.single.tag-frea-area .header-menu.wp-block-navigation,
body.free-article-layout .header-menu.wp-block-navigation.is-layout-flex,
body.free-article-layout .header-menu.wp-block-navigation.is-content-justification-center,
body.free-article-layout .header-menu.wp-block-navigation {
    justify-content: flex-end !important;
    text-align: right !important;
}

/* Menu container and lists align right */
body.post-type-archive-pn_magazine_issue .header-menu .wp-block-navigation__container,
body.post-type-archive-pn_magazine_issue .header-menu ul,
body.single-pn_magazine_issue .header-menu .wp-block-navigation__container,
body.single-pn_magazine_issue .header-menu ul,
body.post-type-archive-pn_video .header-menu .wp-block-navigation__container,
body.post-type-archive-pn_video .header-menu ul,
body.single-pn_video .header-menu .wp-block-navigation__container,
body.single-pn_video .header-menu ul,
body.single.tag-frea-area .header-menu .wp-block-navigation__container,
body.single.tag-frea-area .header-menu ul,
body.free-article-layout .header-menu .wp-block-navigation__container,
body.free-article-layout .header-menu ul {
    justify-content: flex-end !important;
    margin-left: auto !important;
    display: flex !important;
    flex-wrap: wrap !important;
}

/* ============================================
   ORANGE BAR STYLING
============================================ */

/* Orange bar text should be black, not white - override has-secondary-color */
body.post-type-archive-pn_magazine_issue .header-top.has-primary-background-color p,
body.post-type-archive-pn_magazine_issue .header-top.has-primary-background-color a,
body.post-type-archive-pn_magazine_issue .header-top p.has-secondary-color,
body.post-type-archive-pn_magazine_issue .header-top a.has-secondary-color,
body.single-pn_magazine_issue .header-top.has-primary-background-color p,
body.single-pn_magazine_issue .header-top.has-primary-background-color a,
body.single-pn_magazine_issue .header-top p.has-secondary-color,
body.single-pn_magazine_issue .header-top a.has-secondary-color,
body.post-type-archive-pn_video .header-top.has-primary-background-color p,
body.post-type-archive-pn_video .header-top.has-primary-background-color a,
body.post-type-archive-pn_video .header-top p.has-secondary-color,
body.post-type-archive-pn_video .header-top a.has-secondary-color,
body.single-pn_video .header-top.has-primary-background-color p,
body.single-pn_video .header-top.has-primary-background-color a,
body.single-pn_video .header-top p.has-secondary-color,
body.single-pn_video .header-top a.has-secondary-color,
body.single.tag-frea-area .header-top.has-primary-background-color p,
body.single.tag-frea-area .header-top.has-primary-background-color a,
body.single.tag-frea-area .header-top p.has-secondary-color,
body.single.tag-frea-area .header-top a.has-secondary-color,
body.free-article-layout .header-top.has-primary-background-color p,
body.free-article-layout .header-top.has-primary-background-color a,
body.free-article-layout .header-top p.has-secondary-color,
body.free-article-layout .header-top a.has-secondary-color {
    color: #000000 !important;
}

/* Reset typography/padding for orange bar on free article pages where other MU CSS inflates it */
body.free-article-layout .main-header .header-top {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
}

body.free-article-layout .main-header .header-top .header-info-boxes {
    align-items: center !important;
    gap: 12px !important;
}

body.free-article-layout .main-header .header-top .wp-block-column {
    display: flex !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
}

body.free-article-layout .main-header .header-top p,
body.free-article-layout .main-header .header-top a,
body.free-article-layout .main-header .header-top span,
body.free-article-layout .main-header .header-top .wp-block-column {
    font-size: 14px !important;
    line-height: 1.4 !important;
    font-weight: 400 !important;
    letter-spacing: normal !important;
    font-family: var(--wp--preset--font-family--poppins, "Poppins", sans-serif) !important;
    text-transform: none !important;
    margin: 0 !important;
}

body.free-article-layout .main-header .header-top p::first-letter,
body.free-article-layout .main-header .header-top a::first-letter {
    float: none !important;
    font-size: inherit !important;
    margin: 0 !important;
    color: inherit !important;
}

/* Remove hover effect on orange bar links */
body.post-type-archive-pn_magazine_issue .header-top a:hover,
body.single-pn_magazine_issue .header-top a:hover,
body.post-type-archive-pn_video .header-top a:hover,
body.single-pn_video .header-top a:hover,
body.single.tag-frea-area .header-top a:hover,
body.free-article-layout .header-top a:hover {
    color: #000000 !important;
    opacity: 1 !important;
    text-decoration: none !important;
}

/* Prevent viewport overflow and add side padding */
body.post-type-archive-pn_magazine_issue .header-top,
body.single-pn_magazine_issue .header-top,
body.post-type-archive-pn_video .header-top,
body.single-pn_video .header-top,
body.single.tag-frea-area .header-top,
body.free-article-layout .header-top {
    overflow-x: hidden !important;
    max-width: 100vw !important;
}

/* Orange bar columns - phone and email shrink only if needed */
body.post-type-archive-pn_magazine_issue .header-phone-box,
body.single-pn_magazine_issue .header-phone-box,
body.post-type-archive-pn_video .header-phone-box,
body.single-pn_video .header-phone-box,
body.single.tag-frea-area .header-phone-box,
body.free-article-layout .header-phone-box {
    flex: 0 1 auto !important;
    min-width: 0 !important;
}

body.post-type-archive-pn_magazine_issue .header-mail-box,
body.single-pn_magazine_issue .header-mail-box,
body.post-type-archive-pn_video .header-mail-box,
body.single-pn_video .header-mail-box,
body.single.tag-frea-area .header-mail-box,
body.free-article-layout .header-mail-box {
    flex: 0 1 auto !important;
    min-width: 0 !important;
}

/* Text box grows but can also shrink if viewport is narrow */
body.post-type-archive-pn_magazine_issue .header-text-box,
body.single-pn_magazine_issue .header-text-box,
body.post-type-archive-pn_video .header-text-box,
body.single-pn_video .header-text-box,
body.single.tag-frea-area .header-text-box,
body.free-article-layout .header-text-box {
    flex: 1 1 auto !important;
    min-width: 0 !important;
}

/* Orange bar flexbox settings - centered with tight gaps */
body.post-type-archive-pn_magazine_issue .header-info-boxes,
body.single-pn_magazine_issue .header-info-boxes,
body.post-type-archive-pn_video .header-info-boxes,
body.single-pn_video .header-info-boxes,
body.single.tag-frea-area .header-info-boxes,
body.free-article-layout .header-info-boxes {
    flex-wrap: nowrap !important;
    max-width: 80% !important;
    gap: 4px !important; /* Tighter spacing between orange bar items */
    justify-content: center !important; /* Center all items */
}

/* Further reduce gap on smaller screens to prevent wrapping */
@media (max-width: 1024px) {
    body.post-type-archive-pn_magazine_issue .header-info-boxes,
    body.single-pn_magazine_issue .header-info-boxes,
    body.post-type-archive-pn_video .header-info-boxes,
    body.single-pn_video .header-info-boxes,
    body.single.tag-frea-area .header-info-boxes,
    body.free-article-layout .header-info-boxes {
        gap: 8px !important;
    }
}

/* Prevent text wrapping only on wider screens */
@media (min-width: 900px) {
    body.post-type-archive-pn_magazine_issue .header-phone-box p,
    body.post-type-archive-pn_magazine_issue .header-mail-box p,
    body.post-type-archive-pn_magazine_issue .header-text-box p,
    body.single-pn_magazine_issue .header-phone-box p,
    body.single-pn_magazine_issue .header-mail-box p,
    body.single-pn_magazine_issue .header-text-box p,
    body.post-type-archive-pn_video .header-phone-box p,
    body.post-type-archive-pn_video .header-mail-box p,
    body.post-type-archive-pn_video .header-text-box p,
    body.single-pn_video .header-phone-box p,
    body.single-pn_video .header-mail-box p,
    body.single-pn_video .header-text-box p,
    body.single.tag-frea-area .header-phone-box p,
    body.single.tag-frea-area .header-mail-box p,
    body.single.tag-frea-area .header-text-box p,
    body.free-article-layout .header-phone-box p,
    body.free-article-layout .header-mail-box p,
    body.free-article-layout .header-text-box p {
        white-space: nowrap !important;
    }
}

/* On smaller screens, allow wrapping to prevent overflow */
@media (max-width: 899px) {
    body.post-type-archive-pn_magazine_issue .header-text-box p,
    body.single-pn_magazine_issue .header-text-box p,
    body.post-type-archive-pn_video .header-text-box p,
    body.single-pn_video .header-text-box p,
    body.single.tag-frea-area .header-text-box p,
    body.free-article-layout .header-text-box p {
        white-space: normal !important;
    }
}

/* ============================================
   RESPONSIVE BEHAVIOR
============================================ */

/* Mobile (<1000px): hide inline list, show hamburger, hide panel until opened */
@media (max-width: 999px) {
    body:is(.post-type-archive-pn_magazine_issue,
            .single-pn_magazine_issue,
            .post-type-archive-pn_video,
            .single-pn_video,
            .single.tag-frea-area,
            .free-article-layout)
    .header-menu.is-responsive > .wp-block-navigation__container {
        display: none !important;
        visibility: hidden !important;
    }

    body:is(.post-type-archive-pn_magazine_issue,
            .single-pn_magazine_issue,
            .post-type-archive-pn_video,
            .single-pn_video,
            .single.tag-frea-area,
            .free-article-layout)
    .header-menu.is-responsive .wp-block-navigation__responsive-container-open {
        display: flex !important;
        visibility: visible !important;
    }

    body:is(.post-type-archive-pn_magazine_issue,
            .single-pn_magazine_issue,
            .post-type-archive-pn_video,
            .single-pn_video,
            .single.tag-frea-area,
            .free-article-layout)
    .wp-block-navigation__responsive-container:not(.is-menu-open) {
        display: none !important;
    }
}

/* Desktop: show inline list, hide hamburger */
@media (min-width: 1000px) {
    body:is(.post-type-archive-pn_magazine_issue,
            .single-pn_magazine_issue,
            .post-type-archive-pn_video,
            .single-pn_video,
            .single.tag-frea-area,
            .free-article-layout)
    .header-menu.is-responsive > .wp-block-navigation__container {
        display: flex !important;
        visibility: visible !important;
    }

    body:is(.post-type-archive-pn_magazine_issue,
            .single-pn_magazine_issue,
            .post-type-archive-pn_video,
            .single-pn_video,
            .single.tag-frea-area,
            .free-article-layout)
    .header-menu.is-responsive .wp-block-navigation__responsive-container-open {
        display: none !important;
        visibility: hidden !important;
    }
}

/* Responsive menu panel: ensure it can open on mobile */
body:is(.post-type-archive-pn_magazine_issue,
        .single-pn_magazine_issue,
        .post-type-archive-pn_video,
        .single-pn_video,
        .single.tag-frea-area,
        .free-article-layout)
.wp-block-navigation__responsive-container.is-menu-open {
    display: flex !important;
    visibility: visible !important;
    position: fixed !important;
    inset: 0 !important;
    z-index: 999999 !important;
    flex-direction: column !important;
    background: var(--wp--preset--color--white, #fff) !important;
}

body:is(.post-type-archive-pn_magazine_issue,
        .single-pn_magazine_issue,
        .post-type-archive-pn_video,
        .single-pn_video,
        .single.tag-frea-area,
        .free-article-layout)
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
    display: block !important;
    visibility: visible !important;
    overflow-y: auto !important;
}

/* Match standard icon style (orange, correct sizing) */
body:is(.post-type-archive-pn_magazine_issue,
        .single-pn_magazine_issue,
        .post-type-archive-pn_video,
        .single-pn_video,
        .single.tag-frea-area,
        .free-article-layout)
.header-menu.is-responsive .wp-block-navigation__responsive-container-open svg,
body:is(.post-type-archive-pn_magazine_issue,
        .single-pn_magazine_issue,
        .post-type-archive-pn_video,
        .single-pn_video,
        .single.tag-frea-area,
        .free-article-layout)
.header-menu.is-responsive .wp-block-navigation__responsive-container-close svg {
    width: 26px !important;
    height: 26px !important;
    fill: var(--wp--preset--color--primary) !important;
}

/* Ensure responsive menu content is right-aligned like standard pages */
body:is(.post-type-archive-pn_magazine_issue,
        .single-pn_magazine_issue,
        .post-type-archive-pn_video,
        .single-pn_video,
        .single.tag-frea-area,
        .free-article-layout)
.wp-block-navigation__responsive-container-content ul.wp-block-navigation__container {
    justify-content: flex-end !important;
    align-items: flex-end !important;
    text-align: right !important;
}

body:is(.post-type-archive-pn_magazine_issue,
        .single-pn_magazine_issue,
        .post-type-archive-pn_video,
        .single-pn_video,
        .single.tag-frea-area,
        .free-article-layout)
.wp-block-navigation__responsive-container-content ul.wp-block-navigation__container li.wp-block-navigation-item {
    justify-content: flex-end !important;
}
