/**
 * Header Sticky Fix
 *
 * Moves sticky positioning from nested divs to the header element itself
 */

/* When header contains a sticky element, make the header sticky instead */
header.site-header:has(.is-position-sticky) {
    position: sticky !important;
    top: 0;
    z-index: 999;
    background: inherit;
}

/* Account for WordPress admin bar when logged in */
/* Mobile admin bar (< 783px) is 46px tall */
.admin-bar header.site-header:has(.is-position-sticky) {
    top: 46px;
}

/* Desktop admin bar (>= 783px) is 32px tall */
@media screen and (min-width: 783px) {
    .admin-bar header.site-header:has(.is-position-sticky) {
        top: 32px;
    }
}

/* Remove sticky from nested elements - the header is sticky now */
header.site-header .is-position-sticky {
    position: static !important;
}

/* Smooth transition */
header.site-header:has(.is-position-sticky) {
    transition: box-shadow 0.3s ease;
}

/* Animate children of sticky headers (padding, sizing, visibility) */
header.site-header:has(.is-position-sticky) .wp-block-group,
header.site-header:has(.is-position-sticky) .wp-block-button__link {
    transition: padding 0.3s ease, font-size 0.3s ease;
}

/* Add shadow when scrolled (via JavaScript) */
header.site-header.is-scrolled {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* --- Compact mode: reduce padding on scroll --- */
header.site-header.is-scrolled > .wp-block-group {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
}

/* --- Compact mode: logo swap --- */

/* Both logos transition smoothly */
header.site-header:has(.is-position-sticky) .header-logo-default,
header.site-header:has(.is-position-sticky) .header-logo-compact {
    transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease;
    overflow: hidden;
}

/* Default logo: visible at top */
header.site-header:has(.is-position-sticky) .header-logo-default {
    opacity: 1;
    max-height: 200px;
}

/* Compact logo: hidden at top */
header.site-header:has(.is-position-sticky) .header-logo-compact {
    opacity: 0;
    max-height: 0;
    position: absolute;
    pointer-events: none;
}

/* Default logo: hidden on scroll */
header.site-header.is-scrolled .header-logo-default {
    opacity: 0;
    max-height: 0;
    position: absolute;
    pointer-events: none;
}

/* Compact logo: visible on scroll */
header.site-header.is-scrolled .header-logo-compact {
    opacity: 1;
    max-height: 200px;
    position: static;
    pointer-events: auto;
}

/* Logo container needs relative positioning for absolute children */
header.site-header:has(.is-position-sticky) :has(> .header-logo-default) {
    position: relative;
}

/* --- Compact mode: CTA button shrink --- */
header.site-header.is-scrolled .wp-block-button__link {
    padding: 0.4rem 1rem !important;
    font-size: 0.85rem !important;
}
