/* ============================================
   Cheetah Theme - Header Styles
   ============================================ */

/* Dynamic header height — updated live by header.js.
   Fallback values prevent content from jumping before JS runs. */
:root {
    --cheetah-header-height: 82px;
    /* Total vertical space from the viewport top to the header's bottom edge,
       including any visible admin bar. Drawers and slide-in panels use this
       so they start exactly where the header ends instead of being covered
       by it. */
    --cheetah-header-offset: var(--cheetah-header-height);
}

/* Admin bar adds its own offset above the fixed header. */
.admin-bar {
    --cheetah-header-offset: calc(var(--cheetah-header-height) + 32px);
}

@media screen and (max-width: 782px) {
    .admin-bar {
        --cheetah-header-offset: calc(var(--cheetah-header-height) + 46px);
    }
}

/* Push all page content below the fixed header */
body {
    padding-top: var(--cheetah-header-offset);
}

/* Site Header
--------------------------------------------- */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 9999;
    /* Keep the header itself free of transform/filter containing-block
     * properties so the mobile product-search overlay can remain fixed to
     * the viewport. The visual blur layer is rendered by ::before instead. */
    background: transparent;
    border-bottom: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.05);
    overflow: visible;
    transition:
            transform 0.4s cubic-bezier(0.22, 0.61, 0.36, 1),
            opacity 0.35s ease,
            background 0.35s ease,
            box-shadow 0.35s ease;
}

.site-header.hidden {
    transform: translateY(-120%);
    opacity: 0;
}

/*
 * When a drawer (mobile menu / filter sidebar / product-search overlay) is
 * open, force the header back to its untransformed, opaque state.
 *
 * A transformed ancestor becomes the containing block for `position: fixed`
 * descendants, and its translateY(-120%) would also leave a visible gap
 * above drawers that start at --cheetah-header-offset. Clearing the
 * transform for the duration of the drawer interaction keeps the header
 * flush with the top of the viewport.
 */
body.cheetah-menu-open .site-header,
body.cheetah-menu-open .site-header.hidden,
body.cheetah-filter-open .site-header,
body.cheetah-filter-open .site-header.hidden,
body.cheetah-search-overlay-open .site-header,
body.cheetah-search-overlay-open .site-header.hidden,
body.cheetah-cart-drawer-open .site-header,
body.cheetah-cart-drawer-open .site-header.hidden {
    transform: none !important;
    transition: none !important;
    opacity: 1 !important;
}

.site-header::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    pointer-events: none;
}

.site-header.visible {
    opacity: 1;
    animation: fadeUp 0.4s ease;
}

@keyframes fadeUp {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Admin Bar Offset */
.admin-bar .site-header {
    top: 32px;
}

@media screen and (max-width: 782px) {
    .admin-bar .site-header {
        top: 46px;
    }
}

/* Header Inner
--------------------------------------------- */
.header-inner {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 82px;
    padding: 0 40px;
    overflow: visible;
}

/* Branding
--------------------------------------------- */
.site-branding {
    position: relative;
    z-index: 3;
    flex-shrink: 0;
}

/* Product Search
--------------------------------------------- */
.header-product-search {
    /* Center in the header without transform so position:fixed
       descendants are not trapped in a transformed containing block. */
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    margin: auto;
    width: min(420px, 42vw);
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    overflow: visible;
    pointer-events: none; /* let clicks pass except on the search itself */
}

.header-product-search .cheetah-product-search {
    pointer-events: auto;
    width: 100%;
}

.header-product-search .cheetah-product-search {
    display: block;
    width: 100%;
    max-width: none;
}

.header-product-search .cheetah-product-search__panel {
    min-width: 0;
}

.header-product-search .cheetah-product-search__form {
    min-height: 44px;
}

/*
 * The header input uses the same padding-right (6.5rem) as the base rule
 * in product-search.css so the submit button, the loading spinner and the
 * browser's native search clear "X" all fit without overlapping:
 *
 *   right: 0.3rem  →  submit button
 *   ~3-4rem        →  native clear "X" (shifted right via margin-right on
 *                     ::-webkit-search-cancel-button in product-search.css)
 *   right: 4.4rem  →  loading spinner
 */
.header-product-search .cheetah-product-search__input {
    min-height: 44px;
    height: 44px;
    padding: 0 6.5rem 0 1.15rem;
    border: 1px solid var(--cheetah-border-color, #e2e8f0);
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    font-size: 0.9375rem;
}

.header-product-search .cheetah-product-search__input:focus {
    border-color: var(--cheetah-primary-color, #2563eb);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
    outline: none;
}

.header-product-search .cheetah-product-search__submit {
    position: absolute;
    right: 0.3rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    border-radius: 50%;
    background: var(--cheetah-primary-color, #2563eb);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    z-index: 2;
    transition: background-color 0.15s ease;
}

.header-product-search .cheetah-product-search__submit:hover,
.header-product-search .cheetah-product-search__submit:focus {
    background: #1d4ed8;
    outline: none;
}

.header-product-search .cheetah-product-search__results {
    z-index: 100050;
}

.header-product-search .cheetah-product-search,
.header-product-search .cheetah-product-search__panel {
    overflow: visible;
}

.header-product-search .cheetah-product-search__submit {
    color: #ffffff;
}

.header-product-search .cheetah-product-search__submit .cheetah-product-search__icon {
    color: #ffffff;
    stroke: currentColor;
}

.desktop-menu,
.header-btn,
.hamburger {
    position: relative;
    z-index: 3;
}

.header-product-search .cheetah-product-search--auto .cheetah-product-search__trigger {
    margin: 0 auto;
}

.logo {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-decoration: none;
    color: #111;
    line-height: 1;
}

.logo span {
    color: #2563eb;
}

.custom-logo img {
    max-height: 42px;
    width: auto;
    display: block;
}

/* Desktop Menu
--------------------------------------------- */
.desktop-menu .primary-menu {
    display: flex;
    gap: 42px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.desktop-menu .primary-menu a {
    text-decoration: none;
    color: #222;
    font-weight: 500;
    position: relative;
    transition: color 0.25s ease;
    font-size: 0.95rem;
}

.desktop-menu .primary-menu a::after {
    content: "";
    position: absolute;
    bottom: -8px;
    left: 0;
    height: 2px;
    width: 0;
    background: #2563eb;
    transition: width 0.35s ease;
}

.desktop-menu .primary-menu a:hover,
.desktop-menu .primary-menu a:focus {
    color: #2563eb;
}

.desktop-menu .primary-menu a:hover::after,
.desktop-menu .primary-menu a:focus::after {
    width: 100%;
}

/* Header Actions
--------------------------------------------- */
/*
 * Groups the Cart Drawer mini-cart, any currency switcher, and the primary
 * CTA into a single flex row so the header's outer `space-between` still
 * distributes the header into three visual zones — branding / navigation
 * / actions — instead of spreading every action item apart individually.
 *
 * A `.header-actions` wrapper is required because both the Cart Drawer
 * header mini-cart (hooked to `cheetah_header_tools`) and the currency
 * switcher (also hooked to `cheetah_header_tools`) need to sit next to
 * the CTA. Without the wrapper they would be spread across the header.
 */
.header-actions {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

/* Header Button
--------------------------------------------- */
.header-btn,
.header-btn:visited {
    padding: 13px 28px;
    border-radius: 50px;
    background: #2563eb;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.28);
    flex-shrink: 0;
}

.header-btn:hover,
.header-btn:focus {
    transform: translateY(-2px);
    box-shadow: 0 16px 35px rgba(37, 99, 235, 0.35);
    color: #fff;
    text-decoration: none;
}

/* Hamburger
--------------------------------------------- */
.hamburger {
    display: none;
    width: 42px;
    height: 42px;
    cursor: pointer;
    position: relative;
    background: none;
    border: none;
    padding: 0;
    flex-shrink: 0;
}

.hamburger span {
    position: absolute;
    width: 28px;
    height: 2px;
    left: 7px;
    background: #111;
    transition: 0.35s ease;
}

.hamburger span:nth-child(1) {
    top: 12px;
}

.hamburger span:nth-child(2) {
    top: 20px;
}

.hamburger span:nth-child(3) {
    top: 28px;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg);
    top: 20px;
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg);
    top: 20px;
}

/* Mobile Menu
--------------------------------------------- */
/*
 * The drawer begins where the fixed header ends and runs to the bottom of
 * the viewport. Using top + bottom (instead of top: 0 + height: 100vh)
 * makes it impossible for the header to overlap any part of the panel,
 * and it automatically accounts for the admin bar via
 * --cheetah-header-offset.
 */
.mobile-menu {
    position: fixed;
    top: var(--cheetah-header-offset, 82px);
    right: -100%;
    bottom: 0;
    width: 320px;
    max-width: 85vw;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    transition: right 0.45s cubic-bezier(0.22, 0.61, 0.36, 1);
    padding: 40px 40px 40px;
    box-shadow: -20px 0 40px rgba(0, 0, 0, 0.15);
    z-index: 9998;
    overflow-y: auto;
}

.mobile-menu.open {
    right: 0;
}

.mobile-menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.mobile-menu-list a {
    text-decoration: none;
    font-size: 20px;
    font-weight: 600;
    color: #222;
    transition: all 0.25s ease;
    display: inline-block;
}

.mobile-menu-list a:hover,
.mobile-menu-list a:focus {
    color: #2563eb;
    padding-left: 10px;
}

/* Overlay
--------------------------------------------- */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: all 0.35s ease;
    z-index: 9997;
}

.overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Responsive
--------------------------------------------- */
@media (max-width: 980px) {
    .desktop-menu,
    .header-btn {
        display: none;
    }

    .hamburger {
        display: block;
    }

    .header-inner {
        padding: 0 24px;
    }

    .header-product-search {
        width: min(420px, calc(100vw - 220px));
    }

    .logo {
        font-size: 24px;
    }

    /*
     * On tablet the CTA is hidden but the mini-cart and currency switcher
     * remain visible, so the actions cluster keeps its gap and alignment
     * from the base rule. No additional positioning is required.
     */
}

@media (max-width: 767px) {
    .header-product-search {
        position: static;
        width: auto;
        height: auto;
        margin: 0;
        pointer-events: auto;
        display: block;
    }

    .header-product-search .cheetah-product-search--auto {
        width: auto;
    }

    .header-product-search .cheetah-product-search--auto .cheetah-product-search__trigger {
        width: 42px;
        height: 42px;
        border: 0;
        border-radius: 50%;
        background: transparent;
        color: #111;
    }

    .header-product-search .cheetah-product-search--auto .cheetah-product-search__trigger:hover,
    .header-product-search .cheetah-product-search--auto .cheetah-product-search__trigger:focus {
        background: rgba(37, 99, 235, 0.08);
        color: var(--cheetah-primary, #2563eb);
        outline: none;
    }

    /*
     * Header actions on mobile: the CTA is already hidden by the 980px
     * rule above, so the mini-cart and (if present) the currency switcher
     * are the only visible items in the cluster. Reduce the gap slightly
     * so the header stays compact next to the hamburger.
     */
    .header-actions {
        gap: 0.5rem;
    }

    /*
     * On the smallest viewports the running total duplicates information
     * the drawer already shows at the top of the cart. Hiding it here
     * leaves just the icon and badge, which is the standard mobile pattern
     * for a header mini-cart.
     */
    .cheetah-mini-cart__total {
        display: none;
    }
}

@media (max-width: 480px) {
    :root {
        --cheetah-header-height: 72px;
    }

    .header-inner {
        height: 72px;
    }

    .logo {
        font-size: 22px;
    }

    .custom-logo img {
        max-height: 36px;
    }
}

/* Reduced Motion
--------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .site-header,
    .hamburger span,
    .mobile-menu,
    .overlay,
    .desktop-menu .primary-menu a::after {
        transition: none;
    }

    .site-header.visible {
        animation: none;
    }
}