/*
 * Clevo Header Styles
 * Scope: .clevo-header
 *
 * All variables are scoped to .clevo-header so this stylesheet
 * is safe to include on any page alongside other stylesheets.
 *
 * @package clevo
 */

/* ── TOKENS ─────────────────────────────────────────────────────────── */
.clevo-header {
    --ch-brand: #2563eb;
    /* Royal Blue – matches footer / LP theme */
    --ch-brand-dark: #1e40af;
    --ch-text: #1e293b;
    /* Slate 800 – dark text on white */
    --ch-text-muted: #64748b;
    /* Slate 500 */
    --ch-text-light: #f1f5f9;
    /* Slate 100 – on dark bg */
    --ch-bg: #ffffff;
    --ch-bg-topbar: #0f172a;
    /* Slate 900 – matches footer dark bg */
    --ch-border: rgba(0, 0, 0, 0.08);
    --ch-shadow: 0 1px 12px rgba(0, 0, 0, 0.08);
    --ch-radius: 8px;
    --ch-container: 1340px;
    --ch-font: 'Inter', system-ui, -apple-system, sans-serif;
    --ch-font-heading: 'Outfit', 'Inter', sans-serif;
    --ch-topbar-h: 36px;
    --ch-main-h: 68px;
    --ch-drawer-w: 300px;
    --ch-transition: 0.2s ease;
}

/* FSE wrapper fix: remove WordPress global padding/margins on template-part header */
.wp-site-blocks .wp-block-template-part .clevo-header.has-global-padding {
    padding-top: 0 !important;
    padding-right: 0 !important;
    padding-bottom: 0 !important;
    padding-left: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.wp-site-blocks .wp-block-template-part .clevo-header.is-layout-constrained {
    max-width: none !important;
}

/* ── RESET (scoped) ─────────────────────────────────────────────────── */
.clevo-header *,
.clevo-header *::before,
.clevo-header *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.clevo-header {
    font-family: var(--ch-font);
    -webkit-font-smoothing: antialiased;
    /* Reserve space so sticky header doesn't overlap content */
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
}

.clevo-header a {
    color: inherit;
    text-decoration: none;
}

/* Remove focus ring on mouse/touch click — preserve it for keyboard nav */
.clevo-header a:focus:not(:focus-visible),
.clevo-header button:focus:not(:focus-visible) {
    outline: none;
}

.clevo-header ul {
    list-style: none;
}

.clevo-header button {
    cursor: pointer;
    background: none;
    border: none;
    font: inherit;
}

/* ── SKIP TO CONTENT ────────────────────────────────────────────────── */
.ch-skip-link {
    position: absolute;
    top: -999px;
    left: 1rem;
    padding: 0.5rem 1rem;
    background: var(--ch-brand);
    color: #fff !important;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0 0 var(--ch-radius) var(--ch-radius);
    z-index: 9999;
    transition: top var(--ch-transition);
}

.ch-skip-link:focus {
    top: 0;
    outline: 3px solid var(--ch-brand-dark);
    outline-offset: 2px;
}

/* ── CONTAINER ──────────────────────────────────────────────────────── */
.ch-container {
    width: 100%;
    max-width: var(--ch-container);
    margin-inline: auto;
    padding-inline: 1.5rem;
}

/* ── TOP BAR ────────────────────────────────────────────────────────── */
.ch-topbar {
    background-color: var(--ch-bg-topbar);
    height: var(--ch-topbar-h);
    display: flex;
    align-items: center;
}

.ch-topbar__inner {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ch-topbar__text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--ch-text-light);
    letter-spacing: 0.015em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ch-topbar__text svg {
    flex-shrink: 0;
    color: var(--ch-brand);
}

/* ── MAIN HEADER BAR ────────────────────────────────────────────────── */
.ch-main {
    background-color: var(--ch-bg);
    border-bottom: 1px solid var(--ch-border);
    box-shadow: var(--ch-shadow);
    height: var(--ch-main-h);
    display: flex;
    align-items: center;
}

.ch-main__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    height: 100%;
}

/* ── LOGO ───────────────────────────────────────────────────────────── */
.ch-logo {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    color: var(--ch-text);
    transition: color var(--ch-transition);
}

.ch-logo:hover {
    color: var(--ch-brand);
}

.ch-logo__wordmark {
    font-family: var(--ch-font-heading);
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: inherit;
}

/* ── PRIMARY NAV ────────────────────────────────────────────────────── */
.ch-nav {
    display: flex;
    align-items: center;
    flex: 1;
    justify-content: flex-end;
    margin-right: 0.5rem;
}

.ch-nav__list {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.ch-nav__link {
    display: inline-block;
    position: relative;
    padding: 0.35rem 0.65rem;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--ch-text);
    border-radius: 6px;
    transition: color var(--ch-transition), background-color var(--ch-transition);
    padding-bottom: calc(0.35rem + 2px);
    /* room for underline */
}

/* animated underline – same mechanic as footer cf-col__link */
.ch-nav__link::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 0.65rem;
    right: 0.65rem;
    height: 2px;
    background-color: var(--ch-brand);
    border-radius: 2px;
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 0.25s ease;
}

.ch-nav__link:hover {
    color: var(--ch-brand);
}

.ch-nav__link:hover::after,
.ch-nav__link[aria-current="page"]::after {
    transform: scaleX(1);
}

/* ── ACTIONS ────────────────────────────────────────────────────────── */
.ch-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ── CART ICON ──────────────────────────────────────────────────────── */
.ch-cart {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--ch-text);
    transition: color var(--ch-transition), background-color var(--ch-transition);
}

.ch-cart:hover {
    color: var(--ch-brand);
    background-color: rgba(37, 99, 235, 0.08);
}

/* cart badge – shown only when WooCommerce sets a count via JS */
.ch-cart__badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    background-color: var(--ch-brand);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
    border-radius: 10px;
    display: none;
    /* hidden until count > 0 */
}

.ch-cart__badge:not(:empty) {
    display: block;
}

/* ── HAMBURGER ──────────────────────────────────────────────────────── */
.ch-hamburger {
    display: none;
    /* hidden on desktop */
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    width: 40px;
    height: 40px;
    border-radius: var(--ch-radius);
    color: var(--ch-text);
    transition: background-color var(--ch-transition);
}

.ch-hamburger:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.ch-hamburger__bar {
    display: block;
    width: 22px;
    height: 2px;
    background-color: currentColor;
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease, width 0.3s ease;
    transform-origin: center;
}

/* X state when drawer is open */
.ch-hamburger.is-active .ch-hamburger__bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.ch-hamburger.is-active .ch-hamburger__bar:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.ch-hamburger.is-active .ch-hamburger__bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ── DRAWER OVERLAY ─────────────────────────────────────────────────── */
.ch-drawer {
    display: none;
    /* hidden on desktop */
    position: fixed;
    inset: 0;
    z-index: 1100;
    pointer-events: none;
}

.ch-drawer__backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.45);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ch-drawer__panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--ch-drawer-w);
    max-width: 90vw;
    background-color: var(--ch-bg);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

/* Open state */
.ch-drawer.is-open {
    pointer-events: auto;
}

.ch-drawer.is-open .ch-drawer__backdrop {
    opacity: 1;
}

.ch-drawer.is-open .ch-drawer__panel {
    transform: translateX(0);
}

/* Drawer header */
.ch-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.25rem;
    border-bottom: 1px solid var(--ch-border);
}

.ch-drawer__brand {
    font-family: var(--ch-font-heading);
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--ch-text);
}

.ch-drawer__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    color: var(--ch-text-muted);
    transition: color var(--ch-transition), background-color var(--ch-transition);
}

.ch-drawer__close:hover {
    color: var(--ch-text);
    background-color: rgba(0, 0, 0, 0.06);
}

/* Drawer nav */
.ch-drawer__nav {
    flex: 1;
    padding: 1rem 0;
}

.ch-drawer__list {
    display: flex;
    flex-direction: column;
}

.ch-drawer__link {
    display: flex;
    align-items: center;
    padding: 0.85rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--ch-text);
    border-left: 3px solid transparent;
    transition: color var(--ch-transition), border-color var(--ch-transition), background-color var(--ch-transition);
}

.ch-drawer__link:hover {
    color: var(--ch-brand);
    border-left-color: var(--ch-brand);
    background-color: rgba(37, 99, 235, 0.05);
}

/* Drawer footer */
.ch-drawer__footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--ch-border);
}

.ch-drawer__cart-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    background-color: var(--ch-brand);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--ch-radius);
    justify-content: center;
    transition: background-color var(--ch-transition);
}

.ch-drawer__cart-link:hover {
    background-color: var(--ch-brand-dark);
    color: #fff;
}

/* ── RESPONSIVE ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .ch-nav {
        display: none;
        /* replaced by mobile drawer */
    }

    .ch-hamburger {
        display: flex;
    }

    .ch-drawer {
        display: block;
    }
}

@media (max-width: 480px) {
    .ch-topbar__text {
        font-size: 0.72rem;
        gap: 0.35rem;
    }
}

/* ── WOOCOMMERCE MINI-CART OVERRIDES ────────────────────────────────── */
/*
 * Scope: .clevo-header .wc-block-mini-cart
 * Makes the native WooCommerce mini-cart button look identical to our
 * custom .ch-cart icon — fits seamlessly in the header.
 * Uses !important where needed to beat WooCommerce's own specificity.
 */

/* Wrapper div — remove any WooCommerce block margins */
.clevo-header .wc-block-mini-cart {
    display: flex !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* The button itself */
.clevo-header .wc-block-mini-cart__button {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    background: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    color: var(--ch-text) !important;
    cursor: pointer !important;
    transition: color var(--ch-transition), background-color var(--ch-transition) !important;
}

.clevo-header .wc-block-mini-cart__button:hover {
    color: var(--ch-brand) !important;
    background-color: rgba(37, 99, 235, 0.08) !important;
}

/* Hide price text */
.clevo-header .wc-block-mini-cart__amount {
    display: none !important;
}

/* Badge (item count bubble) */
.clevo-header .wc-block-mini-cart__badge {
    position: absolute !important;
    top: 2px !important;
    right: 2px !important;
    min-width: 17px !important;
    height: 17px !important;
    padding: 0 4px !important;
    background-color: var(--ch-brand) !important;
    color: #fff !important;
    font-size: 0.65rem !important;
    font-weight: 700 !important;
    line-height: 17px !important;
    text-align: center !important;
    border-radius: 10px !important;
    border: none !important;
    box-shadow: none !important;
}

/* Cart icon SVG */
.clevo-header .wc-block-mini-cart__button svg,
.clevo-header .wc-block-mini-cart__quantity-badge svg {
    width: 22px !important;
    height: 22px !important;
    stroke: currentColor !important;
    fill: none !important;
    color: inherit !important;
}

/* The mini-cart drawer — let WooCommerce handle its own styling, just lift z-index */
.wc-block-mini-cart__drawer {
    z-index: 1200 !important;
}

/* Keep mini-cart product links on-brand (avoid browser blue/purple). */
.wc-block-mini-cart__drawer a.wc-block-components-product-name,
.wc-block-mini-cart__drawer .wc-block-cart-item__product a {
    color: var(--ch-text) !important;
    text-decoration: none !important;
}

.wc-block-mini-cart__drawer a.wc-block-components-product-name:visited,
.wc-block-mini-cart__drawer .wc-block-cart-item__product a:visited {
    color: var(--ch-text) !important;
}

.wc-block-mini-cart__drawer a.wc-block-components-product-name:hover,
.wc-block-mini-cart__drawer a.wc-block-components-product-name:focus-visible,
.wc-block-mini-cart__drawer .wc-block-cart-item__product a:hover,
.wc-block-mini-cart__drawer .wc-block-cart-item__product a:focus-visible {
    color: var(--ch-text) !important;
    text-decoration: underline !important;
    text-underline-offset: 2px;
}

/* Remove item-count fragment from drawer title, e.g. "(emner: 4)". */
.wc-block-mini-cart__drawer .wc-block-mini-cart__title-items-counter,
.wc-block-mini-cart__drawer .wc-block-mini-cart__title .wc-block-mini-cart__badge,
.wc-block-mini-cart__drawer .wc-block-mini-cart__title .wc-block-mini-cart__quantity-badge {
    display: none !important;
}
