/**
 * GEC Academy site header.
 *
 * @package GEC_Academy_Child
 * @since 6.4.0
 */

.gec-header {
    /* Always sticky, as in the design master; navigation.js only toggles the
       .is-sticky shadow once the page has scrolled. */
    position: sticky;
    inset-block-start: var(--wp-admin--admin-bar--height, 0px);
    z-index: var(--z-sticky);
    inline-size: 100%;
    border-block-end: var(--border-width) var(--border-style) var(--color-border);
    background: var(--color-surface);
}

.gec-header__container {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: clamp(var(--space-5), 3vw, var(--space-10));
    inline-size: min(100% - (2 * var(--container-padding)), var(--container-2xl));
    min-block-size: 84px;
    margin-inline: auto;
}

.gec-branding {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    color: var(--color-text-primary);
    text-decoration: none;
}

.gec-branding__logo,
.gec-branding__image {
    display: block;
}

/* Scoped to .gec-header on purpose. WooCommerce ships
   `.woocommerce img, .woocommerce-page img { height: auto; max-width: 100% }`,
   and `.woocommerce-page img` (0,1,1) outranks a bare `.gec-branding__image`
   (0,1,0) — `height` and `max-width` are the same properties as `block-size`
   and `max-inline-size`, so on every WooCommerce page (cart, checkout, account,
   shop) the logo lost its box and expanded to the full container width.
   The parent scope wins the cascade without reaching for !important. */
.gec-header .gec-branding__image {
    inline-size: auto;
    max-inline-size: 13.2rem;
    block-size: 3.3rem; /* 2.75rem + 20% */
    object-fit: contain;
    object-position: left center;
}

.gec-branding__text {
    color: var(--color-text-primary);
    font-family: var(--font-family-heading);
    font-size: 2rem;
    font-weight: var(--font-weight-bold);
    line-height: 1;
    letter-spacing: -.08em;
}

.gec-branding__tagline {
    max-inline-size: 24rem;
    margin-inline-start: var(--space-4);
    padding-inline-start: var(--space-4);
    border-inline-start: var(--border-width) var(--border-style) var(--color-border);
    /* Same orange as the footer title (.gec-footer__title). */
    color: var(--color-footer-accent);
    /* The header's own face (Inter), as the navigation and actions set it;
       before, it only inherited it from the page. */
    font-family: var(--font-family-base);
    font-size: 1.25rem; /* doubled from .625rem */
    font-weight: var(--font-weight-medium);
    line-height: 1.35;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.gec-header__tools,
.gec-header__actions,
.gec-header__account {
    display: flex;
    align-items: center;
}

.gec-header__tools { justify-content: flex-end; gap: var(--space-4); }
.gec-header__actions { gap: var(--space-4); }

.gec-header__action {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-block-size: 44px;
    padding-inline: var(--space-1);
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--color-icon-navy);
    font-family: var(--font-family-base);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.gec-header__action-icon { flex-shrink: 0; }

.gec-header__action:hover { background: transparent; color: var(--color-primary-600); }

.gec-header__action:focus-visible,
.gec-mobile-nav__toggle:focus-visible {
    outline: calc(var(--border-width) * 2) var(--border-style) var(--color-primary-500);
    outline-offset: var(--focus-ring-offset);
}

.gec-cart-trigger__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-inline-size: 1.5rem;
    block-size: 1.5rem;
    padding-inline: .375rem;
    border-radius: var(--radius-full);
    background: var(--color-primary-500);
    color: var(--color-white);
    font-size: .6875rem;
    font-weight: var(--font-weight-semibold);
}

.gec-mobile-nav__actions {
    display: flex;
    flex-direction: column;
    margin-block-start: var(--space-4);
    padding-block-start: var(--space-4);
    border-block-start: var(--border-width) var(--border-style) var(--color-border);
}

.gec-mobile-nav__actions .gec-header__action {
    inline-size: 100%;
    padding-block: var(--space-3);
    padding-inline: var(--space-2);
}

.gec-language-switcher ul {
    display: flex;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.gec-language-switcher a {
    color: var(--color-text-primary);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    text-decoration: none;
}

.gec-mobile-nav { display: none; }

/* A sticky element only sticks inside its parent. The GlobalShell wrapper is
   exactly as tall as announcement + header, so the header scrolled away after
   ~120px. `display: contents` drops the wrapper's box (the element, its data
   attribute and its keydown listener stay) and lets the header stick against
   <body> for the whole page, while the announcement bar scrolls away as in the
   design master. */
.gec-global-shell--header { display: contents; }

.gec-header.is-sticky {
    box-shadow: 0 1px 0 var(--color-border);
}

/* Below 600px the WordPress admin bar scrolls with the page. */
@media (max-width: 600px) {
    .gec-header { inset-block-start: 0; }
}

/* Between 62rem and 75rem the full navigation and the signed-in actions (cart
   with its count, "Lớp học", "Thoát ra") share one row with the logo; measured
   at 992px they need every pixel, so the tagline stays out there. */
@media (max-width: 74.99rem) {
    .gec-header__container { gap: var(--space-5); }
    .gec-branding__tagline { display: none; }
}

/* Below 62rem the navigation folds into "Menu" and the tagline has the row to
   itself, so it comes back on tablet and phone (owner request 2026-09-18). */
@media (max-width: 61.99rem) {
    .gec-branding__tagline {
        display: block;
        font-size: 1rem;
        letter-spacing: .08em;
    }
}

@media (max-width: 61.99rem) {
    .gec-navbar,
    .gec-header__actions,
    .gec-language-switcher { display: none; }

    .gec-header__container {
        grid-template-columns: minmax(0, 1fr) auto;
        min-block-size: 72px;
    }

    .gec-header__tools { gap: 0; }
    .gec-mobile-nav { display: block; position: static; }

    .gec-mobile-nav__toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        /* Icon and "Menu"/"Đóng" label sit side by side; a fixed 44px box
           made the label overflow on top of the icon. */
        gap: var(--space-2);
        min-inline-size: 44px;
        block-size: 44px;
        padding: 0 var(--space-2);
        border: 0;
        background: transparent;
        color: var(--color-text-primary);
        cursor: pointer;
    }

    .gec-mobile-nav__icon,
    .gec-mobile-nav__icon::before,
    .gec-mobile-nav__icon::after {
        display: block;
        inline-size: 1.375rem;
        block-size: 2px;
        background: currentColor;
        transition: transform var(--transition-fast), opacity var(--transition-fast);
    }

    .gec-mobile-nav__icon { position: relative; flex-shrink: 0; }
    .gec-mobile-nav__icon::before,
    .gec-mobile-nav__icon::after { content: ""; position: absolute; inset-inline-start: 0; }
    .gec-mobile-nav__icon::before { transform: translateY(-.4rem); }
    .gec-mobile-nav__icon::after { transform: translateY(.4rem); }
    .gec-mobile-nav.is-open .gec-mobile-nav__icon { background: transparent; }
    .gec-mobile-nav.is-open .gec-mobile-nav__icon::before { transform: rotate(45deg); }
    .gec-mobile-nav.is-open .gec-mobile-nav__icon::after { transform: rotate(-45deg); }

    .gec-mobile-nav__panel {
        position: absolute;
        inset: 100% 0 auto;
        max-block-size: calc(100dvh - 72px);
        padding: var(--space-4) var(--container-padding) var(--space-8);
        overflow-y: auto;
        border-block-start: var(--border-width) var(--border-style) var(--color-border);
        background: var(--color-surface);
        box-shadow: var(--shadow-md);
    }

    .gec-mobile-nav__menu {
        display: flex;
        flex-direction: column;
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .gec-mobile-nav__menu li { margin: 0; }
    .gec-mobile-nav__menu a {
        display: flex;
        min-block-size: 52px;
        align-items: center;
        justify-content: space-between;
        border-block-end: var(--border-width) var(--border-style) var(--color-border);
        color: var(--color-text-primary);
        font-weight: var(--font-weight-medium);
        text-decoration: none;
    }

    /**
     * The dropdown panel is positioned and hidden globally in navbar-dropdown.css
     * (position:absolute, visibility:hidden, opacity:0) and revealed only by :hover
     * or :focus-within — neither of which a finger can hold. Inside this panel there
     * is nothing to reveal it, so the submenu measured 0x0 and the parent row, being
     * a plain link, just navigated away and took the menu with it. Put the panel back
     * into flow here as an indented list so the child pages are reachable by tapping.
     */
    .gec-mobile-nav__menu .gec-navbar__submenu {
        position: static;
        visibility: visible;
        opacity: 1;
        transform: none;
        min-inline-size: 0;
        margin: 0;
        padding: 0;
        padding-inline-start: var(--space-5);
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        list-style: none;
        transition: none;
    }

    /* The hover bridge only has a job when the panel floats. */
    .gec-mobile-nav__menu .gec-navbar__submenu::before { content: none; }

    /* Nothing collapses here, so a caret would promise an action that does not exist. */
    .gec-mobile-nav__menu .gec-navbar__caret { display: none; }
}

@media (max-width: 30rem) {
    .gec-header__container {
        inline-size: min(100% - (2 * var(--space-4)), var(--container-2xl));
        min-block-size: 64px;
    }
    .gec-header .gec-branding__image { max-inline-size: 10.8rem; block-size: 2.7rem; }
    .gec-branding__text { font-size: 1.75rem; }
    /* Phone: smaller, and it wraps before it can push the "Menu" button out. */
    .gec-branding__tagline {
        min-inline-size: 0;
        font-size: .8125rem;
        letter-spacing: .05em;
    }
    .gec-mobile-nav__panel { max-block-size: calc(100dvh - 64px); padding-inline: var(--space-4); }
}
