/*
 * Vendex Lite — Compact Header
 * Loads on every page, AFTER css/global.css, so these rules win over any
 * legacy .hp-* header rules still sitting in global.css.
 *
 * Two layers only:
 *   1. .vx-announcement-bar — slim, scrolls away with the page
 *   2. .vx-header           — single row, sticky, RTL-first
 *
 * Colors consume the new --vx-color-* tokens owned by the color-system
 * agent (with fallbacks) — no orange, no hardcoded brand hex values here.
 */

/* ===== RESET FOR OLD HEADER MARKUP (defensive) =====
 * If .hp-custom-header / .hp-announcement-bar markup still exists anywhere
 * (cache, stale template), don't let it double up with the new header. */
.hp-custom-header,
.hp-announcement-bar,
.hp-menu-bar {
    display: none !important;
}

/* ========================================
   ANNOUNCEMENT BAR — slim, ~32px
   ======================================== */
.vx-announcement-bar {
    width: 100%;
    background: var(--vx-color-ink, #0b0f14);
    color: var(--vx-cta-text, #ffffff);
    overflow: hidden;
    white-space: nowrap;
    position: relative;
    padding: 8px 0;
    font-size: 12px;
    line-height: 16px;
    font-weight: 500;
}

.vx-announcement-track {
    display: inline-flex;
    animation: vx-marquee 35s linear infinite;
    width: max-content;
}

.vx-announcement-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 28px;
}

.vx-announcement-item svg {
    width: 13px;
    height: 13px;
    min-width: 13px;
    min-height: 13px;
    flex-shrink: 0;
    fill: var(--vx-color-accent, #4aa8ff);
}

@keyframes vx-marquee {
    0%   { transform: translateX(50%); }
    100% { transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
    .vx-announcement-track {
        animation: none;
    }
}

/* ========================================
   STICKY HEADER
   ======================================== */
.vx-sticky-sentinel {
    height: 1px;
}

.vx-header {
    position: sticky;
    top: 0;
    z-index: 500;
    background: var(--vx-color-surface, #ffffff);
    border-bottom: 1px solid var(--vx-color-border, #e5e7eb);
    /* GPU compositing hints — avoids iOS Safari jitter when the URL bar
       shows/hides while the header is stuck (see homepage.js mobile nav
       for the same pattern used elsewhere in this theme). */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
}

.vx-header.vx-header--stuck {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

/* ========================================
   HEADER ROW — single row, compact
   ======================================== */
.vx-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
    max-width: 1400px;
    margin: 0 auto;
    box-sizing: border-box;
    min-height: 40px; /* + padding = ~60px total on mobile */
}

.vx-header-logo {
    flex: 1 1 auto;
    display: flex;
    justify-content: center;
    min-width: 0;
}
.vx-header-logo a {
    display: block;
    text-decoration: none;
    max-width: 100%;
}
.vx-header-logo img {
    height: 30px;
    width: auto;
    max-width: 100%;
    display: block;
}
.vx-header-logo-text {
    font-size: 18px;
    font-weight: 800;
    color: var(--vx-color-ink, #0b0f14);
    white-space: nowrap;
}

.vx-header-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ===== ICON BUTTONS (real <button>, accessible) ===== */
.vx-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--vx-color-ink, #0b0f14);
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.vx-icon-btn svg {
    width: 21px;
    height: 21px;
    pointer-events: none;
}
.vx-icon-btn:hover {
    background: var(--vx-color-surface, #f3f4f6);
}
.vx-icon-btn:focus-visible {
    outline: 2px solid var(--vx-color-primary, #2563eb);
    outline-offset: 2px;
}

/* ===== CART ===== */
.vx-cart-wrap {
    position: relative;
}
.vx-cart-badge {
    position: absolute;
    top: 2px;
    inset-inline-end: 2px;
    background: var(--vx-cta-bg, var(--vx-color-primary, #2563eb));
    color: var(--vx-cta-text, #ffffff);
    min-width: 16px;
    height: 16px;
    padding: 0 3px;
    border-radius: 999px;
    font-size: 10px;
    line-height: 16px;
    font-weight: 700;
    text-align: center;
    box-shadow: 0 0 0 2px var(--vx-color-surface, #ffffff);
}
.vx-cart-badge[hidden] {
    display: none;
}

.vx-cart-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    inset-inline-start: auto;
    inset-inline-end: 0;
    width: min(340px, 92vw);
    background: var(--vx-color-surface, #ffffff);
    border: 1px solid var(--vx-color-border, #e5e7eb);
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 600;
    overflow: hidden;
}
.vx-cart-dropdown[hidden] {
    display: none;
}

.vx-cart-dropdown-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--vx-color-border, #e5e7eb);
    font-weight: 700;
    font-size: 15px;
    color: var(--vx-color-ink, #0b0f14);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.vx-cart-dropdown-header span:last-child {
    font-size: 12px;
    font-weight: 500;
    color: var(--vx-color-muted, #6b7280);
}

.vx-cart-dropdown-items {
    max-height: 280px;
    overflow-y: auto;
    padding: 8px 0;
    scrollbar-width: thin;
}
.vx-cart-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    transition: background 0.15s;
}
.vx-cart-dropdown-item:hover {
    background: var(--vx-color-surface, #f3f4f6);
}
.vx-cart-dropdown-item img {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--vx-color-border, #e5e7eb);
}
.vx-cart-dropdown-item-info {
    flex: 1;
    min-width: 0;
}
.vx-cart-dropdown-item-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--vx-color-ink, #0b0f14);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}
.vx-cart-dropdown-item-meta {
    font-size: 12px;
    color: var(--vx-color-muted, #6b7280);
}
.vx-cart-dropdown-item-price {
    font-size: 14px;
    font-weight: 700;
    color: var(--vx-color-primary, #2563eb);
    white-space: nowrap;
}

.vx-cart-dropdown-empty {
    padding: 30px 18px;
    text-align: center;
    color: var(--vx-color-muted, #6b7280);
    font-size: 14px;
}
.vx-cart-dropdown-empty svg {
    width: 40px;
    height: 40px;
    margin-bottom: 8px;
    opacity: 0.4;
}

.vx-cart-dropdown-footer {
    padding: 14px 18px;
    border-top: 1px solid var(--vx-color-border, #e5e7eb);
}
.vx-cart-dropdown-footer[hidden] {
    display: none;
}
.vx-cart-dropdown-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 15px;
    font-weight: 700;
    color: var(--vx-color-ink, #0b0f14);
}
.vx-cart-total-amount {
    color: var(--vx-color-primary, #2563eb);
    font-size: 17px;
}
.vx-cart-dropdown-btn {
    display: block;
    width: 100%;
    padding: 13px 24px;
    background: var(--vx-cta-bg, var(--vx-color-primary, #2563eb));
    color: var(--vx-cta-text, #ffffff);
    border: none;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    box-sizing: border-box;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.vx-cart-dropdown-btn:hover,
.vx-cart-dropdown-btn:focus,
.vx-cart-dropdown-btn:visited {
    color: var(--vx-cta-text, #ffffff);
    text-decoration: none;
    transform: translateY(-2px);
}

/* ========================================
   SEARCH OVERLAY (expanding, not a permanent row)
   ======================================== */
.vx-search-overlay {
    position: fixed;
    inset: 0;
    z-index: 700;
    background: rgba(11, 15, 20, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.vx-search-overlay[hidden] {
    display: none;
}
.vx-search-overlay-inner {
    background: var(--vx-color-surface, #ffffff);
    max-width: 720px;
    margin: 0 auto;
    padding: 14px 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    max-height: 100vh;
    overflow-y: auto;
}

.vx-search-field {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 2px solid var(--vx-color-primary, #2563eb);
    border-radius: 12px;
    padding: 0 10px;
    background: var(--vx-color-bg, #f9fafb);
}
.vx-search-field-icon {
    width: 18px;
    height: 18px;
    color: var(--vx-color-muted, #6b7280);
    flex-shrink: 0;
}
.vx-search-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    padding: 14px 0;
    font-size: 16px;
    font-family: inherit;
    color: var(--vx-color-ink, #0b0f14);
    outline: none;
}
.vx-search-close {
    width: 34px;
    height: 34px;
}

.vx-search-results {
    margin-top: 10px;
}
.vx-search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px;
    text-decoration: none;
    border-radius: 10px;
    transition: background 0.15s;
}
.vx-search-result-item:hover {
    background: var(--vx-color-bg, #f9fafb);
}
.vx-search-result-item img {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--vx-color-border, #e5e7eb);
}
.vx-search-result-info {
    flex: 1;
    min-width: 0;
}
.vx-search-result-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--vx-color-ink, #0b0f14);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.vx-search-result-price {
    font-size: 13px;
    font-weight: 700;
    color: var(--vx-color-primary, #2563eb);
    margin-top: 2px;
}
.vx-search-empty,
.vx-search-hint {
    padding: 20px 8px;
    text-align: center;
    color: var(--vx-color-muted, #6b7280);
    font-size: 13px;
}
.vx-search-loading {
    padding: 20px;
    text-align: center;
}
.vx-search-loading::after {
    content: "";
    display: inline-block;
    width: 22px;
    height: 22px;
    border: 2px solid var(--vx-color-border, #e5e7eb);
    border-radius: 50%;
    border-top-color: var(--vx-color-primary, #2563eb);
    animation: vx-spin 0.8s linear infinite;
}
@keyframes vx-spin {
    to { transform: rotate(360deg); }
}
.vx-search-viewall {
    display: block;
    text-align: center;
    margin-top: 6px;
    padding: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--vx-color-ink, #0b0f14);
    border: 1.5px solid var(--vx-color-ink, #0b0f14);
    border-radius: 8px;
    text-decoration: none;
}
.vx-search-viewall:hover {
    background: var(--vx-color-ink, #0b0f14);
    color: var(--vx-cta-text, #fff);
}

/* ========================================
   DRAWER (mobile / primary nav)
   ======================================== */
.vx-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 800;
    background: rgba(11, 15, 20, 0.45);
}
.vx-drawer-backdrop[hidden] {
    display: none;
}

.vx-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-end: 0;
    width: min(320px, 86vw);
    background: var(--vx-color-surface, #ffffff);
    z-index: 900;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
}
[dir="rtl"] .vx-drawer {
    transform: translateX(-100%);
}
.vx-drawer.vx-open {
    transform: translateX(0);
}

.vx-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--vx-color-border, #e5e7eb);
}
.vx-drawer-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--vx-color-ink, #0b0f14);
}

.vx-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}
.vx-drawer-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}
.vx-drawer-menu li a {
    display: block;
    padding: 14px 20px;
    color: var(--vx-color-ink, #0b0f14);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    border-bottom: 1px solid var(--vx-color-border, #e5e7eb);
}
.vx-drawer-menu li a:hover,
.vx-drawer-menu li.current-menu-item > a {
    background: var(--vx-color-bg, #f9fafb);
    color: var(--vx-color-primary, #2563eb);
}

/* ========================================
   RESPONSIVE — desktop (≥768px)
   ======================================== */
@media (min-width: 768px) {
    .vx-header-row {
        padding: 14px 32px;
        min-height: 44px; /* + padding = ~72px total on desktop */
    }
    .vx-header-logo {
        flex: 0 0 auto;
    }
    .vx-header-logo img {
        height: 38px;
    }
    .vx-icon-btn {
        width: 44px;
        height: 44px;
    }
    .vx-icon-btn svg {
        width: 22px;
        height: 22px;
    }
    .vx-search-overlay-inner {
        padding: 24px 32px;
    }
    .vx-drawer {
        width: min(360px, 40vw);
    }
}

/* Prevent body scroll while drawer/search overlay is open (class toggled by JS) */
body.vx-scroll-lock {
    overflow: hidden;
}
