/*
 * ==========================================================
 * WP Angel Header
 * File: header-style.css
 * Purpose: Universal header layout
 *
 * Responsibilities:
 * - Header shell
 * - Header inner layout
 * - Branding and logo sizing
 * - GeneratePress compatibility
 * - Mobile header grid
 * - Sticky/admin-bar offsets
 * - Accessibility helpers
 *
 * Excludes:
 * - Navigation item styling
 * - Dropdown behavior
 * - Header buttons
 * - Language switcher styling
 * - Client-specific colors
 *
 * Dependencies:
 * - GeneratePress
 * - reset.css
 * ==========================================================
 */


/* ==========================================================
   1. CSS Variables
   ========================================================== */

:root {
    --wa-header-container-width: 1200px;

    --wa-header-height: 76px;
    --wa-header-height-mobile: 64px;

    --wa-header-padding-x: 24px;
    --wa-header-padding-x-mobile: 16px;

    --wa-header-padding-y: 10px;
    --wa-header-padding-y-mobile: 8px;

    --wa-header-gap: 24px;
    --wa-header-gap-mobile: 12px;

    --wa-header-logo-height: 48px;
    --wa-header-logo-height-mobile: 40px;

    --wa-header-z-index: 1000;

    --wa-header-bg: var(--header-bg, #ffffff);
    --wa-header-text: var(--header-text, #1f2937);
    --wa-header-border: var(--header-border, rgba(17, 24, 39, 0.10));
    --wa-header-shadow: var(
        --header-shadow,
        0 1px 3px rgba(17, 24, 39, 0.08)
    );

    --wa-header-transition: 180ms ease;
}


/* ==========================================================
   2. Site Header
   ========================================================== */

.site-header,
.wa-header {
    position: relative;
    z-index: var(--wa-header-z-index);
    width: 100%;
    margin: 0;
    border-bottom: 1px solid var(--wa-header-border);
    background: var(--wa-header-bg);
    color: var(--wa-header-text);
    box-shadow: var(--wa-header-shadow);
    transition:
        background-color var(--wa-header-transition),
        border-color var(--wa-header-transition),
        box-shadow var(--wa-header-transition),
        color var(--wa-header-transition);
}

.site-header *,
.wa-header * {
    box-sizing: border-box;
}


/* ==========================================================
   3. Inside Header
   ========================================================== */

.site-header .inside-header,
.wa-header__inner {
    display: flex;
    width: min(100%, var(--wa-header-container-width));
    min-height: var(--wa-header-height);
    margin-inline: auto;
    padding:
        var(--wa-header-padding-y)
        var(--wa-header-padding-x);
    align-items: center;
    justify-content: space-between;
    gap: var(--wa-header-gap);
}

/*
 * GeneratePress may attach .grid-container to .inside-header.
 * Keep WP Angel's header width as the source of truth.
 */
.site-header .inside-header.grid-container {
    width: min(100%, var(--wa-header-container-width));
    max-width: var(--wa-header-container-width);
    margin-inline: auto;
}


/* ==========================================================
   4. Branding
   ========================================================== */

.site-branding-container,
.wa-header__branding {
    display: flex;
    min-width: 0;
    flex: 0 1 auto;
    align-items: center;
    gap: 12px;
}

.site-header .site-branding,
.wa-header__text-branding {
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    line-height: 1.2;
}

.site-header .main-title,
.wa-header__title {
    margin: 0;
    color: var(--wa-header-text);
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1.2;
}

.site-header .main-title a,
.wa-header__title a {
    color: inherit;
    text-decoration: none;
}

.site-header .site-description,
.wa-header__description {
    margin: 3px 0 0;
    color: color-mix(
        in srgb,
        var(--wa-header-text) 68%,
        transparent
    );
    font-size: 0.78rem;
    line-height: 1.3;
}


/*
 * Hide text branding only when WordPress confirms
 * that a custom logo is active.
 */
.wp-custom-logo .site-header .site-branding {
    display: none;
}


/* ==========================================================
   5. Logo
========================================================== */

.site-header .site-logo,
.wa-header__logo {
    display: flex;
    min-width: 0;
    align-items: center;
    flex: 0 0 auto;
}

.site-header .site-logo a,
.wa-header__logo-link {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    line-height: 0;
}

.site-header .site-logo img,
.site-header .site-logo a img,
.site-header .custom-logo,
.wa-header__logo img {
    display: block;
    width: auto;
    max-width: min(220px, 42vw);
    height: auto;
    max-height: var(--wa-header-logo-height);
    object-fit: contain;
}

/* ==========================================================
   6. Header Regions
   ========================================================== */

.site-header .secondary-nav-wrapper.menu-location-nav-in-header,
.wa-header__navigation {
    display: flex;
    width: auto;
    max-width: none;
    flex: 0 1 auto;
    align-items: center;
    margin: 0 0 0 auto;
    padding: 0;
    background: transparent;
    z-index: calc(var(--wa-header-z-index) + 1);
}

.site-header
.secondary-nav-wrapper.menu-location-nav-in-header.grid-container {
    width: auto;
    max-width: none;
    margin-left: auto;
    padding: 0;
}

.site-header .secondary-navigation,
.site-header .secondary-navigation .inside-navigation,
.wa-header__navigation-inner {
    width: auto;
    background: transparent;
}

.site-header .secondary-navigation .inside-navigation,
.wa-header__navigation-inner {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}


/* ==========================================================
   7. Layout Helpers
   ========================================================== */

.wa-header__spacer {
    flex: 1 1 auto;
}

.wa-header__left,
.wa-header__center,
.wa-header__right {
    display: flex;
    min-width: 0;
    align-items: center;
}

.wa-header__left {
    justify-content: flex-start;
}

.wa-header__center {
    justify-content: center;
}

.wa-header__right {
    justify-content: flex-end;
}

.u-hidden,
.hidden {
    display: none !important;
}

.u-visually-hidden,
.visually-hidden,
.screen-reader-text {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(1px, 1px, 1px, 1px) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
}


/* ==========================================================
   8. Sticky Header Support
========================================================== */

body.has-overlay-header .site-header,
body.has-transparent-banner-header .site-header {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: var(--wa-header-z-index);
    border: none;
    box-shadow: none;
    background-color: transparent;
    color: #ffffff;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

body.has-overlay-header .site-header.is-scrolled,
body.has-transparent-banner-header .site-header.is-scrolled,
body.home.scrolled .site-header {
    border-bottom-color: rgba(17, 24, 39, 0.10);
    background: rgba(255, 255, 255, 0.08);
    color: var(--wa-header-text);
    box-shadow: 0 0 10px rgba(0, 0, 0, .06);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

body.admin-bar.has-overlay-header .site-header,
body.admin-bar.has-transparent-banner-header .site-header {
    top: 32px;
}


/* ==========================================================
   8.1. Branding & Navigation on Overlay Header
========================================================== */

body.has-overlay-header .site-header .main-title a,
body.has-overlay-header .site-header .wa-header__title a,
body.has-transparent-banner-header .site-header .main-title a,
body.has-transparent-banner-header .site-header .wa-header__title a,
body.has-overlay-header .site-header .secondary-navigation .secondary-menu-toggle.menu-toggle,
body.has-overlay-header .site-header .wa-nav__toggle,
body.has-transparent-banner-header .site-header .secondary-navigation .secondary-menu-toggle.menu-toggle,
body.has-transparent-banner-header .site-header .wa-nav__toggle,
body.has-overlay-header .site-header .secondary-menu > li > a,
body.has-overlay-header .site-header .wa-nav__menu > li > a,
body.has-transparent-banner-header .site-header .secondary-menu > li > a,
body.has-transparent-banner-header .site-header .wa-nav__menu > li > a {
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
}

body.has-overlay-header .site-header.is-scrolled .main-title a,
body.has-overlay-header .site-header.is-scrolled .wa-header__title a,
body.has-transparent-banner-header .site-header.is-scrolled .main-title a,
body.has-transparent-banner-header .site-header.is-scrolled .wa-header__title a,
body.has-overlay-header .site-header.is-scrolled .secondary-navigation .secondary-menu-toggle.menu-toggle,
body.has-overlay-header .site-header.is-scrolled .wa-nav__toggle,
body.has-transparent-banner-header .site-header.is-scrolled .secondary-navigation .secondary-menu-toggle.menu-toggle,
body.has-transparent-banner-header .site-header.is-scrolled .wa-nav__toggle,
body.has-overlay-header .site-header.is-scrolled .secondary-menu > li > a,
body.has-overlay-header .site-header.is-scrolled .wa-nav__menu > li > a,
body.has-transparent-banner-header .site-header.is-scrolled .secondary-menu > li > a,
body.has-transparent-banner-header .site-header.is-scrolled .wa-nav__menu > li > a,
body.home.scrolled .site-header .main-title a,
body.home.scrolled .site-header .secondary-menu > li > a {
    color: var(--wa-header-text);
    text-shadow: none;
}

.site-header.is-sticky,
.site-header.sticky-enabled,
.wa-header.is-sticky {
    position: sticky;
    top: 0;
}

body:not(.scrolled):not(.has-overlay-header):not(.has-transparent-banner-header) .site-header.is-sticky,
body:not(.scrolled):not(.has-overlay-header):not(.has-transparent-banner-header) .site-header.sticky-enabled,
body:not(.scrolled):not(.has-overlay-header):not(.has-transparent-banner-header) .wa-header.is-sticky {
    box-shadow: none;
    border-bottom-color: transparent;
}


/* ==========================================================
   9. Tablet and Mobile
========================================================== */

@media (max-width: 768px) {
    .site-header .inside-header,
    .wa-header__inner {
        display: grid;
        min-height: var(--wa-header-height-mobile);
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "brand toggle"
            "menu menu";
        gap: 0 var(--wa-header-gap-mobile);
        padding:
            var(--wa-header-padding-y-mobile)
            var(--wa-header-padding-x-mobile);
        align-items: center;
        text-align: left;
    }

    .site-branding-container,
    .wa-header__branding {
        grid-area: brand;
        min-width: 0;
        justify-self: start;
    }

    .site-header .site-logo img,
    .site-header .site-logo a img,
    .site-header .custom-logo,
    .wa-header__logo img {
        max-width: min(190px, 58vw);
        max-height: var(--wa-header-logo-height-mobile);
    }

    .site-header .site-branding,
    .wa-header__text-branding {
        min-width: 0;
    }

    .site-header .main-title,
    .wa-header__title {
        overflow: hidden;
        max-width: 58vw;
        font-size: 1rem;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .site-header .site-description,
    .wa-header__description {
        display: none;
    }

    /*
     * These wrappers must not create additional layout boxes
     * on mobile. Navigation controls define their own grid areas
     * inside header-navigation.css.
     */
    .site-header
    .secondary-nav-wrapper.menu-location-nav-in-header,
    .site-header
    .secondary-nav-wrapper.menu-location-nav-in-header.grid-container,
    .site-header .secondary-navigation,
    .site-header .secondary-navigation .inside-navigation {
        display: contents;
    }
}


/* ==========================================================
   10. Very Small Screens
   ========================================================== */

@media (max-width: 420px) {
    :root {
        --wa-header-padding-x-mobile: 14px;
    }

    .site-header .site-logo img,
    .site-header .site-logo a img,
    .site-header .custom-logo,
    .wa-header__logo img {
        max-width: min(170px, 55vw);
    }
}


/* ==========================================================
   11. WordPress Admin Bar
   ========================================================== */

@media (max-width: 782px) {
    body.admin-bar.home.has-overlay-header .site-header {
        top: 46px;
    }

    body.admin-bar .site-header.is-sticky,
    body.admin-bar .site-header.sticky-enabled,
    body.admin-bar .wa-header.is-sticky {
        top: 46px;
    }
}


/* ==========================================================
   12. Accessibility
   ========================================================== */

.site-header a:focus-visible,
.site-header button:focus-visible,
.site-header select:focus-visible,
.wa-header a:focus-visible,
.wa-header button:focus-visible,
.wa-header select:focus-visible {
    outline-offset: 3px;
}

/* ==========================================================
   13. Reduced Motion
   ========================================================== */

@media (prefers-reduced-motion: reduce) {
    .site-header *,
    .site-header *::before,
    .site-header *::after,
    .wa-header *,
    .wa-header *::before,
    .wa-header *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
