/**
 * Zhex Dynamic Island Header
 * Floating navbar: transparent at top, clip-path pill with blur on scroll.
 * All selectors scoped under #zhex-header
 */

/* ========================================
   VARIABLES
   ======================================== */

#zhex-header {
    --hd-bg: rgba(13, 13, 13, 0.85);
    --hd-bg-solid: #0d0d0d;
    --hd-border: rgba(30, 30, 30, 0.6);
    --hd-text: #a0a0a0;
    --hd-text-hover: #ffffff;
    --hd-accent: #6aa9ff;
    --hd-btn-bg: #6aa9ff;
    --hd-btn-text: #000;
}

/* ========================================
   BODY OFFSET — compensate fixed header
   ======================================== */

body {
    padding-top: 84px !important;
}

/* ========================================
   NAV WRAPPER — fixed, full width
   ======================================== */

#zhex-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    padding: 8px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1;
    pointer-events: none;
}

#zhex-header *,
#zhex-header *::before,
#zhex-header *::after {
    box-sizing: border-box;
}

/* ========================================
   INNER CONTAINER — bg + blur + clip-path live here
   ======================================== */

#zhex-header .zhex-hd-inner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 100%;
    margin: 0 auto;
    padding: 20px 28px;
    pointer-events: auto;
    background-color: transparent;
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    clip-path: polygon(
        0 0, 100% 0,
        100% 0, 100% 100%,
        100% 100%, 0 100%,
        0 100%, 0 0
    );
    will-change: clip-path, background-color;
    transition: max-width 0.6s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.6s cubic-bezier(0.4, 0, 0.2, 1),
                background-color 0.6s cubic-bezier(0.4, 0, 0.2, 1),
                backdrop-filter 0.6s cubic-bezier(0.4, 0, 0.2, 1),
                -webkit-backdrop-filter 0.6s cubic-bezier(0.4, 0, 0.2, 1),
                clip-path 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Scrolled — contract + bg + clip-path */
#zhex-header[data-scrolled="true"] .zhex-hd-inner {
    max-width: 1620px;
    padding: 18px 24px;
    background-color: var(--hd-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    clip-path: polygon(
        16px 0, calc(100% - 16px) 0,
        100% 16px, 100% calc(100% - 16px),
        calc(100% - 16px) 100%, 16px 100%,
        0 calc(100% - 16px), 0 16px
    );
}

/* ========================================
   LOGO
   ======================================== */

#zhex-header .zhex-hd-logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    text-decoration: none;
    z-index: 2;
}

#zhex-header .zhex-hd-logo-img {
    height: 32px;
    width: auto;
    display: block;
    transition: height 0.3s ease;
}

#zhex-header[data-scrolled="true"] .zhex-hd-logo-img {
    height: 28px;
}

/* ========================================
   CENTER NAV — desktop only
   ======================================== */

#zhex-header .zhex-hd-nav {
    display: none;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 8px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
}

@media (min-width: 1025px) {
    #zhex-header .zhex-hd-nav {
        display: flex;
    }
}

#zhex-header .zhex-hd-nav li {
    padding: 0;
    margin: 0;
}

#zhex-header .zhex-hd-nav a {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    color: var(--hd-text);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

#zhex-header .zhex-hd-nav a svg {
    display: none;
}

/* ========================================
   RIGHT ACTIONS — desktop only
   ======================================== */

#zhex-header .zhex-hd-actions {
    display: none;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    z-index: 2;
}

@media (min-width: 1025px) {
    #zhex-header .zhex-hd-actions {
        display: flex;
    }
}

/* Dashboard / Sign In button — uses zap-hdr-btn from zhex-auth-popup */
#zhex-header .zhex-hd-actions .zap-hdr-btn {
    white-space: nowrap;
}

/* Cart link */
#zhex-header .zhex-hd-cart {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: var(--hd-text);
    text-decoration: none;
    transition: color 0.2s ease;
}

#zhex-header .zhex-hd-cart:hover {
    color: var(--hd-text-hover);
}

#zhex-header .zhex-hd-cart svg {
    width: 20px;
    height: 20px;
}

/* Cart count badge */
#zhex-header .zhex-hd-cart-count {
    position: absolute;
    top: -2px;
    right: -4px;
    background: var(--hd-accent);
    color: #000;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ========================================
   MOBILE — hamburger button
   ======================================== */

#zhex-header .zhex-hd-burger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    z-index: 2;
    -webkit-tap-highlight-color: transparent;
}

@media (min-width: 1025px) {
    #zhex-header .zhex-hd-burger {
        display: none;
    }
}

#zhex-header .zhex-hd-burger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--hd-text);
    transition: transform 0.3s ease, opacity 0.3s ease, background 0.2s ease;
}

/* Hamburger → X animation */
#zhex-header .zhex-hd-burger[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
    background: var(--hd-text-hover);
}

#zhex-header .zhex-hd-burger[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

#zhex-header .zhex-hd-burger[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
    background: var(--hd-text-hover);
}

/* ========================================
   MOBILE — cart icon (visible < 1025px)
   ======================================== */

#zhex-header .zhex-hd-mobile-cart {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: var(--hd-text);
    text-decoration: none;
    z-index: 2;
    transition: color 0.2s ease;
}

@media (min-width: 1025px) {
    #zhex-header .zhex-hd-mobile-cart {
        display: none;
    }
}

#zhex-header .zhex-hd-mobile-cart:hover {
    color: var(--hd-text-hover);
}

#zhex-header .zhex-hd-mobile-cart svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   MOBILE MENU PANEL
   ======================================== */

.zhex-hd-mobile {
    position: fixed;
    top: 84px;
    left: 8px;
    right: 8px;
    background: var(--hd-bg-solid, #0d0d0d);
    border: 1px solid rgba(30, 30, 30, 0.6);
    border-radius: 16px;
    padding: 20px 24px 24px;
    z-index: 9998;
    transform: translateY(-10px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.zhex-hd-mobile[aria-hidden="false"] {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

@media (min-width: 1025px) {
    .zhex-hd-mobile {
        display: none;
    }
}

/* Mobile menu links */
.zhex-hd-mobile ul {
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
}

.zhex-hd-mobile ul li {
    padding: 0;
    margin: 0;
}

.zhex-hd-mobile ul a {
    display: flex;
    align-items: center;
    padding: 12px 0;
    color: #a0a0a0;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    border-bottom: 1px solid rgba(30, 30, 30, 0.4);
}

.zhex-hd-mobile ul a svg {
    display: none;
}

.zhex-hd-mobile ul li:last-child a {
    border-bottom: none;
}

/* Mobile dashboard / sign-in button — wrapper for full width */
.zhex-hd-mobile .zhex-hd-mobile-dashboard {
    display: flex !important;
    width: 100% !important;
    justify-content: center !important;
    margin-top: 12px !important;
}

.zhex-hd-mobile .zhex-hd-mobile-dashboard .zap-hdr-btn {
    width: 100% !important;
    justify-content: center !important;
}

/* ========================================
   RESPONSIVE — TABLET
   ======================================== */

@media (max-width: 1024px) {
    #zhex-header .zhex-hd-inner {
        padding: 14px 16px;
    }

    #zhex-header[data-scrolled="true"] .zhex-hd-inner {
        max-width: 100%;
        padding: 14px 16px;
    }

    /* Logo centered, burger left, cart right */
    #zhex-header .zhex-hd-inner {
        display: grid;
        grid-template-columns: 36px 1fr 36px;
        align-items: center;
        gap: 8px;
    }

    #zhex-header .zhex-hd-burger {
        justify-self: start;
        order: 1;
    }

    #zhex-header .zhex-hd-logo {
        justify-self: center;
        order: 2;
    }

    #zhex-header .zhex-hd-mobile-cart {
        justify-self: end;
        order: 3;
    }
}

/* ========================================
   RESPONSIVE — SMALL MOBILE
   ======================================== */

@media (max-width: 480px) {
    #zhex-header .zhex-hd-inner {
        padding: 14px 12px;
    }

    .zhex-hd-mobile {
        left: 4px;
        right: 4px;
        padding: 16px 20px 20px;
    }
}
