/* Smart Sticky Header v1.4.0 — Frontend */

/* ── Shell ── */
#ssh-sticky-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 9999;
    background-color: var(--ssh-bg-rgba);
    color: var(--ssh-text);
    transition:
        background-color var(--ssh-speed) ease,
        color            var(--ssh-speed) ease,
        transform        var(--ssh-speed) ease,
        box-shadow       var(--ssh-speed) ease;
}

#ssh-sticky-header.ssh-hidden {
    transform: translateY(-110%);
}

#ssh-sticky-header.ssh-scrolled {
    background-color: var(--ssh-scrolled-bg-rgba);
    color: var(--ssh-scrolled-text);
    box-shadow: 0 2px 20px rgba(0,0,0,.12);
}

/* ── Inner row ──────────────────────────────────────────────────
   CSS Grid with 1fr auto 1fr columns.
   Column widths are defined on the PARENT — the theme cannot
   override them by targeting child elements.
   .ssh-logo  = column 1 (1fr, left-aligned)
   .ssh-nav   = column 2 (auto = content width, always centred)
   .ssh-end   = column 3 (1fr, right-aligned)
   Both outer columns are equal 1fr so the centre is always
   mathematically in the middle of the container.
   .ssh-end is always a visible div (hamburger inside is just
   hidden), so column 3 never collapses.
──────────────────────────────────────────────────────────────── */
#ssh-sticky-header .ssh-inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    max-width: var(--ssh-content-width);
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--ssh-padding, 40px);
    padding-right: var(--ssh-padding, 40px);
    height: var(--ssh-height);
    transition: height var(--ssh-speed) ease;
    box-sizing: border-box;
}

#ssh-sticky-header.ssh-shrunk .ssh-inner {
    height: var(--ssh-shrunk-height);
}

/* ── Logo — column 1 ── */
#ssh-sticky-header .ssh-logo {
    grid-column: 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

#ssh-sticky-header .ssh-logo a {
    display: flex;
    align-items: center;
    text-decoration: none;
}

#ssh-sticky-header .ssh-logo img {
    display: block;
    width: auto;
    height: auto;
    max-height: var(--ssh-logo-max-h, 44px);
    max-width: var(--ssh-logo-max-w, 260px);
    object-fit: contain;
    transition: max-height var(--ssh-speed) ease, max-width var(--ssh-speed) ease;
}

#ssh-sticky-header.ssh-shrunk .ssh-logo img {
    max-height: calc( var(--ssh-logo-max-h, 44px)  * var(--ssh-shrink-ratio, 0.75) );
    max-width:  calc( var(--ssh-logo-max-w, 260px) * var(--ssh-shrink-ratio, 0.75) );
}

#ssh-sticky-header .ssh-site-title {
    font-size: clamp(1rem, 1.5vw, 1.4rem);
    font-weight: 700;
    text-decoration: none;
    color: inherit;
    letter-spacing: -.02em;
    white-space: nowrap;
}

/* ── Nav — column 2 ── */
#ssh-sticky-header .ssh-nav {
    grid-column: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

#ssh-sticky-header .ssh-nav nav {
    display: flex;
    align-items: center;
}

#ssh-sticky-header .ssh-menu-list {
    list-style: none;
    display: flex;
    flex-direction: row;
    gap: clamp(.75rem, 2vw, 2rem);
    align-items: center;
    margin: 0;
    padding: 0;
}

#ssh-sticky-header .ssh-menu-list a {
    color: inherit;
    text-decoration: none;
    font-size: .9rem;
    font-weight: 500;
    opacity: .85;
    padding: .3em 0;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: opacity var(--ssh-speed) ease, border-color var(--ssh-speed) ease;
    display: block;
}

#ssh-sticky-header .ssh-menu-list a:hover,
#ssh-sticky-header .ssh-menu-list .current-menu-item > a {
    opacity: 1;
    border-bottom-color: currentColor;
}

/* Sub-menus */
#ssh-sticky-header .ssh-menu-list .menu-item-has-children {
    position: relative;
}

#ssh-sticky-header .ssh-menu-list .sub-menu {
    display: none;
    position: absolute;
    top: calc(100% + .75rem);
    left: 50%;
    transform: translateX(-50%);
    background: var(--ssh-bg-solid);
    color: var(--ssh-text);
    list-style: none;
    min-width: 180px;
    border-radius: 6px;
    box-shadow: 0 8px 32px rgba(0,0,0,.14);
    overflow: hidden;
    z-index: 10000;
    padding: 0;
    margin: 0;
}

#ssh-sticky-header.ssh-scrolled .ssh-menu-list .sub-menu {
    background: var(--ssh-scrolled-bg-solid);
    color: var(--ssh-scrolled-text);
}

#ssh-sticky-header .ssh-menu-list .menu-item-has-children:hover > .sub-menu,
#ssh-sticky-header .ssh-menu-list .menu-item-has-children:focus-within > .sub-menu {
    display: block;
}

#ssh-sticky-header .ssh-menu-list .sub-menu li a {
    display: block;
    padding: .6rem 1.2rem;
    border-bottom: none;
    font-size: .85rem;
    white-space: nowrap;
    opacity: 1;
}

#ssh-sticky-header .ssh-menu-list .sub-menu li + li {
    border-top: 1px solid rgba(127,127,127,.15);
}

/* ── End — column 3 ── */
#ssh-sticky-header .ssh-end {
    grid-column: 3;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

/* Hamburger hidden on desktop */
#ssh-sticky-header .ssh-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: inherit;
}

#ssh-sticky-header .ssh-hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform .25s, opacity .25s;
}

#ssh-sticky-header .ssh-hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
#ssh-sticky-header .ssh-hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
#ssh-sticky-header .ssh-hamburger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Mobile ── */
@media (max-width: 768px) {

    /* 2-column: logo | hamburger */
    #ssh-sticky-header .ssh-inner {
        grid-template-columns: 1fr auto;
    }

    #ssh-sticky-header .ssh-hamburger {
        display: flex;
    }

    /* Nav hidden by default, drops below bar when open */
    #ssh-sticky-header .ssh-nav {
        display: none;
        grid-column: 1 / -1;
        position: absolute;
        top: 100%; left: 0; right: 0;
        justify-content: flex-start;
        background: var(--ssh-bg-solid);
        border-top: 1px solid rgba(127,127,127,.1);
        padding: 1rem var(--ssh-padding, 16px);
        box-shadow: 0 8px 24px rgba(0,0,0,.1);
    }

    #ssh-sticky-header.ssh-scrolled .ssh-nav {
        background: var(--ssh-scrolled-bg-solid);
    }

    #ssh-sticky-header .ssh-nav.ssh-nav-open {
        display: flex;
    }

    #ssh-sticky-header .ssh-nav nav {
        width: 100%;
    }

    #ssh-sticky-header .ssh-menu-list {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        gap: .25rem;
    }

    #ssh-sticky-header .ssh-menu-list a {
        font-size: 1rem;
        padding: .5rem 0;
    }

    #ssh-sticky-header .ssh-menu-list .sub-menu {
        position: static;
        transform: none;
        box-shadow: none;
        border-radius: 0;
        padding-left: 1rem;
        display: none;
    }

    #ssh-sticky-header .ssh-menu-list .menu-item-has-children.ssh-open > .sub-menu {
        display: block;
    }
}

.ssh-body-offset {
    scroll-padding-top: var(--ssh-height);
}

/* ── Full-screen mobile overlay ─────────────────────────────────
   .ssh-nav-fullscreen is appended to <body> by JS so position:fixed
   is always relative to the viewport — no CSS containment issues.
────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {

    .ssh-nav-fullscreen {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        width: 100%;
        height: 100%;
        display: none;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        background: var(--ssh-bg-solid);
        z-index: 9998;
        padding: 2rem;
        box-sizing: border-box;
        overflow-y: auto;
    }

    .ssh-nav-fullscreen.ssh-nav-open {
        display: flex;
    }

    /* Large centred menu items */
    .ssh-nav-fullscreen .ssh-menu-list {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1.75rem;
        width: 100%;
        padding: 0;
        margin: 0;
        list-style: none;
    }

    .ssh-nav-fullscreen .ssh-menu-list a {
        font-size: 1.75rem;
        font-weight: 600;
        opacity: 1;
        padding: 0;
        border-bottom: none;
        color: var(--ssh-text);
        text-decoration: none;
        white-space: nowrap;
    }

    /* Use scrolled colours if the header has scrolled */
    .ssh-nav-fullscreen.ssh-scrolled-overlay {
        background: var(--ssh-scrolled-bg-solid);
    }

    .ssh-nav-fullscreen.ssh-scrolled-overlay .ssh-menu-list a {
        color: var(--ssh-scrolled-text);
    }

    /* Sub-menus in fullscreen */
    .ssh-nav-fullscreen .ssh-menu-list .menu-item-has-children { position: relative; }

    .ssh-nav-fullscreen .ssh-menu-list .sub-menu {
        position: static;
        transform: none;
        box-shadow: none;
        border-radius: 0;
        text-align: center;
        background: transparent;
        display: none;
        opacity: 1;
        pointer-events: auto;
        padding: .5rem 0 0;
        margin: 0;
        list-style: none;
    }

    .ssh-nav-fullscreen .ssh-menu-list .menu-item-has-children.ssh-open > .sub-menu {
        display: block;
    }

    .ssh-nav-fullscreen .ssh-menu-list .sub-menu li a {
        font-size: 1.1rem;
        font-weight: 400;
        padding: .35rem 0;
        display: block;
        opacity: .75;
    }
}

/* ── WooCommerce elements ──────────────────────────────────── */
#ssh-sticky-header .ssh-woo-account,
#ssh-sticky-header .ssh-woo-cart {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    color: inherit;
    text-decoration: none;
    opacity: .85;
    transition: opacity var(--ssh-speed) ease;
    margin-left: .75rem;
    position: relative;
    flex-shrink: 0;
}

#ssh-sticky-header .ssh-woo-account:hover,
#ssh-sticky-header .ssh-woo-cart:hover { opacity: 1; }

#ssh-sticky-header .ssh-woo-account svg,
#ssh-sticky-header .ssh-woo-cart svg { display: block; flex-shrink: 0; }

#ssh-sticky-header .ssh-woo-account-label {
    font-size: .85rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Cart count badge */
#ssh-sticky-header .ssh-cart-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 .3rem;
    font-size: .7rem;
    font-weight: 700;
    line-height: 1;
    border-radius: 999px;
    background: currentColor;
    color: var(--ssh-bg-solid, #ffffff);
    /* invert so count is readable against the icon colour */
    filter: invert(1) grayscale(1) contrast(9);
}

/* Hide account label on smaller desktops */
@media (max-width: 1024px) {
    #ssh-sticky-header .ssh-woo-account-label { display: none; }
}

/* Hide both on mobile — they go in the overlay instead */
@media (max-width: 768px) {
    #ssh-sticky-header .ssh-woo-account,
    #ssh-sticky-header .ssh-woo-cart { display: none; }
}
