/* ==========================================================================
   Phone Exchange – Header Styles
   1:1 port of React Header component layout and behavior.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Header Container
   -------------------------------------------------------------------------- */
.pe-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background-color: hsl(0, 0%, 8%);
    border-bottom: 1px solid hsl(0, 0%, 15%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.pe-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 3.5rem; /* h-14 mobile */
    gap: 1rem;
}

@media (min-width: 768px) {
    .pe-header__inner {
        height: 4rem; /* h-16 desktop */
    }
}

/* --------------------------------------------------------------------------
   Skip Link (a11y)
   -------------------------------------------------------------------------- */
.pe-skip-link {
    position: absolute;
    left: -9999px;
    z-index: 100;
    padding: 0.5rem 1rem;
    background: var(--pe-primary);
    color: var(--pe-primary-foreground);
    text-decoration: none;
    border-radius: var(--pe-radius);
}
.pe-skip-link:focus {
    left: 1rem;
    top: 0.5rem;
}

/* --------------------------------------------------------------------------
   Logo
   -------------------------------------------------------------------------- */
.pe-header__logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    text-decoration: none;
}

.pe-header__logo-img {
    height: 2rem;
    width: auto;
}

@media (min-width: 768px) {
    .pe-header__logo-img {
        height: 2.5rem;
    }
}

.pe-header__logo-text {
    font-family: "Plus Jakarta Sans", system-ui, sans-serif;
    font-weight: 700;
    font-size: 1.25rem;
    color: white;
    letter-spacing: -0.025em;
}

/* --------------------------------------------------------------------------
   Desktop Navigation
   -------------------------------------------------------------------------- */
.pe-header__nav {
    flex: 1;
    display: flex;
    justify-content: center;
}

.pe-header__nav-list {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.pe-header__nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    color: hsla(0, 0%, 100%, 0.85);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--pe-radius);
    transition: color 0.2s ease, background-color 0.2s ease;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}

.pe-header__nav-link:hover,
.pe-header__nav-link:focus-visible {
    color: white;
    background-color: hsla(0, 0%, 100%, 0.08);
}

.pe-header__nav-link--active {
    color: white;
}

.pe-header__nav-link--disabled {
    color: hsla(0, 0%, 100%, 0.3);
    cursor: default;
    pointer-events: none;
}

.pe-header__nav-link--dropdown .pe-icon--chevron {
    transition: transform 0.2s ease;
}

/* --------------------------------------------------------------------------
   Header CTA Button
   -------------------------------------------------------------------------- */
.pe-header__cta {
    margin-left: 0.5rem;
    padding: 0.375rem 1rem !important;
    font-size: 0.8125rem !important;
    background-color: white !important;
    color: hsl(0, 0%, 8%) !important;
    border-radius: 9999px !important;
    font-weight: 600;
    transition: opacity 0.2s ease;
}
.pe-header__cta:hover {
    opacity: 0.9;
}

/* --------------------------------------------------------------------------
   Icon Bar
   -------------------------------------------------------------------------- */
.pe-header__icons {
    display: flex;
    align-items: center;
    gap: 0.125rem;
}

.pe-header__icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0 !important; /* Override Storefront button padding */
    color: hsla(0, 0%, 100%, 0.85);
    background: transparent !important;
    border: none !important;
    border-radius: var(--pe-radius);
    cursor: pointer;
    text-decoration: none;
    transition: color 0.2s ease, background-color 0.2s ease;
    box-shadow: none !important;
    line-height: 1;
}

/* Prevent SVG icons from collapsing in flex containers */
.pe-header__icon-btn .pe-icon,
.pe-header__icon-btn svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.pe-header__icon-btn:hover,
.pe-header__icon-btn:focus-visible {
    color: white;
    background-color: hsla(0, 0%, 100%, 0.08);
}

.pe-header__badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 1rem;
    height: 1rem;
    padding: 0 0.25rem;
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 1rem;
    text-align: center;
    color: white;
    background-color: var(--pe-accent);
    border-radius: 9999px;
}

.pe-header__badge:empty {
    display: none;
}

/* --------------------------------------------------------------------------
   Mega Menu (Desktop Dropdown)
   -------------------------------------------------------------------------- */
.pe-mega-menu-trigger {
    position: relative;
}

.pe-mega-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;
    min-width: 20rem;
    padding-top: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
}

.pe-mega-menu--open {
    opacity: 1;
    visibility: visible;
}

.pe-mega-menu__inner {
    background: white;
    border-radius: var(--pe-radius);
    box-shadow: 0 10px 40px hsla(0, 0%, 0%, 0.15);
    padding: 1.25rem;
    border: 1px solid hsl(0, 0%, 90%);
}

.pe-mega-menu__top-link {
    display: block;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--pe-primary);
    text-decoration: none;
    border-radius: calc(var(--pe-radius) - 2px);
    transition: background-color 0.15s ease;
}
.pe-mega-menu__top-link:hover {
    background-color: var(--pe-secondary);
}

.pe-mega-menu__heading {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: hsl(0, 0%, 50%);
    padding: 0 0.75rem;
    margin: 0 0 0.5rem;
}

.pe-mega-menu__brand-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.pe-mega-menu__brand-link {
    display: block;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    color: var(--pe-foreground);
    text-decoration: none;
    border-radius: calc(var(--pe-radius) - 2px);
    transition: background-color 0.15s ease;
}
.pe-mega-menu__brand-link:hover {
    background-color: var(--pe-secondary);
}

/* --------------------------------------------------------------------------
   Responsive: Desktop-only / Mobile-only
   -------------------------------------------------------------------------- */
.pe-desktop-only {
    display: none !important;
}

@media (min-width: 768px) {
    .pe-desktop-only {
        display: flex !important;
    }
    .pe-mobile-only {
        display: none !important;
    }
}

/* --------------------------------------------------------------------------
   Mobile Actions (Heart, Cart, Hamburger)
   -------------------------------------------------------------------------- */
.pe-header__mobile-actions {
    display: flex;
    align-items: center;
    gap: 0.125rem;
}

/* Hamburger icon swap: show menu icon when closed, X when open */
.pe-mobile-menu-toggle .pe-icon--close {
    display: none;
}
.pe-mobile-menu-toggle[aria-expanded="true"] .pe-icon--menu {
    display: none;
}
.pe-mobile-menu-toggle[aria-expanded="true"] .pe-icon--close {
    display: block;
}

/* --------------------------------------------------------------------------
   Mobile Navigation Panel
   -------------------------------------------------------------------------- */
.pe-mobile-nav {
    display: none;
    background-color: hsl(0, 0%, 8%);
    border-top: 1px solid hsl(0, 0%, 15%);
    padding: 1rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.pe-mobile-nav--open {
    display: block;
    max-height: 80vh;
    overflow-y: auto;
}

@media (min-width: 768px) {
    .pe-mobile-nav {
        display: none !important;
    }
}

.pe-mobile-nav__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.pe-mobile-nav__link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.75rem 0;
    color: hsla(0, 0%, 100%, 0.85);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    border-bottom: 1px solid hsl(0, 0%, 15%);
}

.pe-mobile-nav__link:hover {
    color: white;
}

.pe-mobile-nav__link--disabled {
    color: hsla(0, 0%, 100%, 0.3);
    cursor: default;
}

/* Mobile accordion */
.pe-mobile-accordion-trigger .pe-icon--chevron {
    transition: transform 0.2s ease;
}
.pe-accordion-trigger--open .pe-icon--chevron {
    transform: rotate(180deg);
}

.pe-accordion-panel {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.pe-accordion--open {
    max-height: 50vh;
    padding-bottom: 0.5rem;
}

.pe-mobile-nav__sublink {
    display: block;
    padding: 0.5rem 1rem;
    color: hsla(0, 0%, 100%, 0.7);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.15s ease;
}
.pe-mobile-nav__sublink:hover {
    color: white;
}

.pe-mobile-nav__sublink--featured {
    color: var(--pe-accent);
    font-weight: 600;
}

.pe-mobile-nav__cta {
    margin-top: 1rem;
}
