/**
 * Ekoinstal Header Enhancements
 * Fixed header, custom burger, sector buttons, fullscreen menu overlay.
 *
 * Extracted from inline <style> in ekoinstal-seo-engine.php to reduce
 * page weight by ~15KB per page and enable browser caching.
 */

/* === FIXED HEADER — override Astra's "position:absolute" on transparent header === */
#masthead,
.ast-theme-transparent-header #masthead,
body #masthead {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 9999 !important;
    background: #ffffff;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

/* Offset body content so it doesn't hide behind fixed header */
body:not(.home) {
    padding-top: 80px;
}

.ast-primary-header-bar {
    transition: background 0.3s ease, box-shadow 0.3s ease;
    border: none !important;
}

/* Remove backgrounds/borders from header inner containers for true transparency */
.ast-primary-header-bar .site-primary-header-wrap,
.ast-primary-header-bar .ast-builder-grid-row,
.ast-primary-header-bar .ast-builder-layout-element,
.ast-primary-header-bar .site-header-primary-section-left,
.ast-primary-header-bar .site-header-primary-section-center,
.ast-primary-header-bar .site-header-primary-section-right,
.ast-primary-header-bar .ast-header-primary-container {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* === LOGO: bigger and proportional === */
.ast-site-identity .custom-logo-link img,
.site-logo-img .custom-logo,
.ast-header-custom-item .custom-logo,
.custom-logo {
    max-height: 60px !important;
    width: auto !important;
    height: auto !important;
    max-width: 200px !important;
}

@media (min-width: 769px) {
    .custom-logo {
        max-height: 70px !important;
        max-width: 240px !important;
    }
}

/* === HOMEPAGE: transparent initially === */
body.home #masthead {
    background: transparent;
    box-shadow: none;
}
body.home .ast-primary-header-bar {
    background: transparent !important;
}

/* === HOMEPAGE: white on scroll === */
body.home #masthead.header-scrolled {
    background: #ffffff;
    box-shadow: 0 .5rem 1rem rgba(0,0,0,0.15);
}
.home .ast-primary-header-bar.ast-header-sticked,
.home .ast-primary-header-bar.header-scrolled {
    background: #ffffff !important;
    box-shadow: 0 .5rem 1rem rgba(0,0,0,0.15) !important;
}

/* Homepage hero overlaps the header */
.home .hero-section {
    margin-top: -90px;
    padding-top: 90px;
}

/* Hero dim overlay: lighter for more vibrant image */
.hero-section .wp-block-cover__background {
    opacity: 0.35 !important;
}

/* Logo must NOT be dimmed by hero overlay */
.home .ast-primary-header-bar .custom-logo {
    opacity: 1 !important;
    filter: none !important;
}

/* Hero section: full width edge-to-edge */
.hero-section.alignfull {
    width: 100vw !important;
    max-width: 100vw !important;
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
}

.hero-section .wp-block-cover__image-background {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Hero outline button: ensure white border + text */
.hero-section .wp-block-button.is-style-outline .wp-block-button__link {
    color: #ffffff !important;
    border-color: #ffffff !important;
    border-width: 2px !important;
    background: transparent !important;
}

.hero-section .wp-block-button.is-style-outline .wp-block-button__link:hover {
    background: rgba(255,255,255,0.15) !important;
    color: #ffffff !important;
}

/* === NON-HOMEPAGE: always white with shadow === */
body:not(.home) #masthead {
    background: #ffffff;
    box-shadow: 0 2px 10px rgba(0,7,63,0.08);
}
body:not(.home) .ast-primary-header-bar {
    background: #ffffff !important;
    box-shadow: none !important;
}

/* === CUSTOM BURGER MENU (OHK style — staggered lines) === */
/* Hide default Astra hamburger SVG/icon */
.ast-mobile-menu-trigger-minimal .mobile-menu-toggle-icon,
.ast-mobile-menu-trigger-minimal .ast-mobile-svg,
.ast-mobile-menu-trigger-minimal svg,
.menu-toggle .mobile-menu-toggle-icon,
.menu-toggle .ast-mobile-svg,
.menu-toggle svg,
[data-type="dropdown"] > svg,
.ast-button-wrap .menu-toggle .mobile-menu-wrap {
    display: none !important;
}

/* Hide any duplicate toggle buttons — keep only the first one */
.ast-mobile-header-wrap .ast-button-wrap:nth-of-type(n+2) .menu-toggle {
    display: none !important;
}

/* Style the toggle button */
.ast-mobile-menu-trigger-minimal,
.menu-toggle.main-header-menu-toggle {
    width: 40px !important;
    height: 30px !important;
    padding: 0 !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    cursor: pointer;
}

/* Custom burger lines (injected by JS) */
.eko-burger { display: flex; flex-direction: column; justify-content: space-between; height: 24px; }
.eko-burger span { display: block; height: 3.5px; border-radius: 12px; transition: all 0.3s ease; background: #00073F; }
.eko-burger .eko-line-1 { width: 34px; }
.eko-burger .eko-line-2 { width: 26px; }
.eko-burger .eko-line-3 { width: 18px; }

/* Non-home: always navy burger */
body:not(.home) .eko-burger span { background: #00073F !important; }

/* Homepage (transparent header): white burger */
body.home .eko-burger span { background: #ffffff; }

/* Homepage scrolled (white header): navy burger — must override the white above */
body.home .ast-header-sticked .eko-burger span,
body.home .header-scrolled .eko-burger span { background: #00073F !important; }

/* Menu OPEN on DESKTOP: white burger on navy bg */
@media (min-width: 922px) {
    body.ast-main-header-nav-open .eko-burger span,
    .ast-mobile-menu-trigger-minimal.toggled .eko-burger span {
        background: #ffffff !important;
    }
}

/* Menu OPEN on MOBILE: navy burger on white header */
@media (max-width: 921px) {
    body.ast-main-header-nav-open .eko-burger span,
    .ast-mobile-menu-trigger-minimal.toggled .eko-burger span {
        background: #00073F !important;
    }
}

/* === INLINE MENU (Astra Header Builder): Desktop & Mobile === */
/* Prevent body scroll when menu open */
body.ast-main-header-nav-open {
    overflow: hidden !important;
}

/* When menu open: header bar gets navy bg */
body.ast-main-header-nav-open .ast-primary-header-bar {
    background: #00073F !important;
}

/* The dropdown content area — make it scrollable within the viewport */
.ast-desktop-header-content,
.ast-mobile-header-content {
    max-height: calc(100vh - 92px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    background: #00073F !important;
}

/* Menu list styling when toggled open */
.main-header-bar-navigation .main-header-menu {
    background: #00073F !important;
}

/* Menu items styling */
body.ast-main-header-nav-open .main-header-menu .menu-item > .menu-link {
    color: #ffffff !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    padding: 14px 24px !important;
    border-bottom: 1px solid rgba(255,255,255,0.1) !important;
    height: auto !important;
}

/* Submenu toggle arrow — grid keeps text + arrow on one line at any width */
body.ast-main-header-nav-open .menu-item-has-children {
    display: grid !important;
    grid-template-columns: 1fr 40px !important;
    border-bottom: 1px solid rgba(255,255,255,0.1) !important;
}
body.ast-main-header-nav-open .menu-item-has-children > .menu-link {
    grid-column: 1 !important;
    grid-row: 1 !important;
    width: auto !important;
    min-width: 0 !important;
    border-bottom: none !important;
}
body.ast-main-header-nav-open .menu-item-has-children > .ast-menu-toggle {
    grid-column: 2 !important;
    grid-row: 1 !important;
    width: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #ffffff !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    cursor: pointer !important;
    position: static !important;
    padding: 0 !important;
}
body.ast-main-header-nav-open .menu-item-has-children > .sub-menu {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
}
body.ast-main-header-nav-open .menu-item-has-children .dropdown-menu-toggle {
    color: #ffffff !important;
    font-size: 12px !important;
}

/* Submenus: hidden by default when menu is open */
body.ast-main-header-nav-open .main-header-menu .sub-menu {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: static !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Submenus: visible when parent toggled (gets .ast-submenu-expanded) */
body.ast-main-header-nav-open .ast-submenu-expanded > .sub-menu {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    background: rgba(0,0,0,0.3) !important;
    border-left: 3px solid #70B221 !important;
    padding: 5px 0 !important;
}

/* Submenu links */
body.ast-main-header-nav-open .sub-menu .menu-item > .menu-link {
    font-size: 14px !important;
    font-weight: 500 !important;
    padding: 10px 24px 10px 32px !important;
    text-transform: none !important;
    color: #ffffff !important;
    border-bottom: 1px solid rgba(255,255,255,0.05) !important;
}

/* Active menu items */
body.ast-main-header-nav-open .current-menu-item > .menu-link {
    color: #70B221 !important;
}

/* === MOBILE-SPECIFIC ADJUSTMENTS === */
@media (max-width: 921px) {
    /* Mobile header stays WHITE when menu open */
    body.ast-main-header-nav-open #ast-mobile-header .ast-primary-header-bar {
        background: #ffffff !important;
    }

    /* Mobile menu content scrollable */
    .ast-mobile-header-content {
        max-height: calc(100vh - 70px) !important;
    }

    /* Hide sector buttons when menu is open */
    body.ast-main-header-nav-open .eko-sector-buttons {
        display: none !important;
    }
}

/* === "DLA DOMU" / "DLA BIZNESU" — OHK Energy style === */

/* --- DESKTOP: connected pill in header right area (OHK style) --- */
@media (min-width: 769px) {
    .eko-sector-buttons {
        position: fixed;
        top: 20px;
        right: 24px;
        z-index: 10000;
        display: flex;
        flex-direction: row;
        gap: 0;
        border-radius: 22px;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
        transition: top 0.3s ease;
    }

    .eko-sector-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        writing-mode: horizontal-tb;
        text-orientation: initial;
        padding: 10px 22px;
        font-family: "Montserrat", sans-serif;
        font-weight: 700;
        font-size: 14px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        text-decoration: none;
        border: none;
        cursor: pointer;
        transition: background 0.3s ease;
        border-radius: 0;
        min-height: auto;
    }

    .eko-sector-btn--dom {
        background: #70B221;
        color: #ffffff;
    }

    .eko-sector-btn--dom:hover {
        background: #5a9a18;
        color: #ffffff;
    }

    .eko-sector-btn--biz {
        background: #007EC8;
        color: #ffffff;
    }

    .eko-sector-btn--biz:hover {
        background: #006ba8;
        color: #ffffff;
    }
}

/* --- MOBILE: vertical floating tabs on right side (OHK style) --- */
@media (max-width: 768px) {
    .eko-sector-buttons {
        position: fixed;
        right: 0;
        top: auto;
        bottom: 132px;
        transform: none;
        z-index: 9998;
        display: flex;
        flex-direction: column;
        gap: 3px;
    }

    .eko-sector-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        writing-mode: vertical-lr;
        text-orientation: mixed;
        padding: 10px 7px;
        font-family: "Montserrat", sans-serif;
        font-weight: 700;
        font-size: 10px;
        text-transform: uppercase;
        letter-spacing: 0.7px;
        text-decoration: none;
        border: none;
        cursor: pointer;
        transition: all 0.3s ease;
        border-radius: 24px 0 0 24px;
        min-height: 72px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    }

    body.ekoinstal-cookie-visible .eko-sector-buttons {
        display: none !important;
    }

    #ekoinstal-cookie-banner {
        padding: 14px 16px !important;
        font-size: 13px !important;
        line-height: 1.45 !important;
    }

    #ekoinstal-cookie-banner > div {
        gap: 12px !important;
        align-items: stretch !important;
    }

    #ekoinstal-cookie-banner p {
        line-height: 1.45 !important;
    }

    #ekoinstal-cookie-banner button {
        flex: 1 1 auto !important;
        padding: 10px 14px !important;
        font-size: 13px !important;
    }

    .eko-sector-btn--dom {
        background: #70B221;
        color: #ffffff;
    }

    .eko-sector-btn--dom:hover {
        background: #5a9a18;
        padding-right: 12px;
        color: #ffffff;
    }

    .eko-sector-btn--biz {
        background: #007EC8;
        color: #ffffff;
    }

    .eko-sector-btn--biz:hover {
        background: #006ba8;
        padding-right: 12px;
        color: #ffffff;
    }
}

@media (max-width: 480px) {
    .eko-sector-buttons {
        bottom: 112px;
    }
}

/* Hide sector buttons when scrolled to footer */
.eko-sector-buttons.hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* === HIDE AUTHOR BOX & COMMENTS === */
.ast-author-box,
.author-box,
.ast-single-author-box,
.about-author,
.entry-author-box { display: none !important; }

.comments-area,
.comment-respond,
#comments,
.ast-comment-list { display: none !important; }

/* === HIDE POST METADATA (date/author) ON SEO PAGES === */
/* service_location, location_page, realizacja — date/author not relevant */
body.single-service_location .entry-meta,
body.single-service_location .posted-on,
body.single-service_location .byline,
body.single-location_page .entry-meta,
body.single-location_page .posted-on,
body.single-location_page .byline,
body.single-realizacja .entry-meta,
body.single-realizacja .posted-on,
body.single-realizacja .byline,
body.ast-custom-post-type .entry-meta,
body.ast-custom-post-type .ast-single-post-meta { display: none !important; }

/* Also hide post navigation on SEO pages (prev/next post links) */
body.single-service_location .ast-single-post-nav,
body.single-service_location .post-navigation,
body.single-location_page .ast-single-post-nav,
body.single-location_page .post-navigation,
body.single-realizacja .ast-single-post-nav,
body.single-realizacja .post-navigation { display: none !important; }
