/* =============================================================================
 * AMC Hungary — Header (Hermès-grade icon-led pattern)
 * Loaded AFTER style.css so its rules cascade over the legacy `.site-header*`
 * declarations that remain there for any view still using the old markup.
 * Existing `.cart-icon`, `.wishlist-icon`, `.header-tier-badge` rules in
 * style.css + phase8.css are intentionally kept; header.css only refines them
 * through the new wrapper classes (`.amc-header__icon`, `.amc-header__tier`).
 * ============================================================================= */

/* ── Tokens reused from :root in style.css ────────────────────────────────────
 * We DO NOT redeclare tokens here. If a future palette migration happens, all
 * three files (style.css, header.css, phase8.css) inherit from the same source.
 * --color-soft-white, --color-ink-black, --color-border-gray, --color-smoke-gray,
 * --color-champagne-gold, --color-charcoal, --color-pearl-white,
 * --duration-quick (220ms), --duration-base (420ms), --ease-product, --motion-checkout
 * are all defined in style.css and used directly below.
 * --motion-overlay is local — explicit cubic-bezier from the brief so this file
 * is self-documenting even if the user reads it in isolation.
 * ─────────────────────────────────────────────────────────────────────────── */
:root {
    --motion-overlay: var(--amc-ease-premium, cubic-bezier(0.22, 1, 0.36, 1));
    --header-icon-size: 22px;
    --header-icon-button: 40px;
    --header-bar-height: 64px;
    --header-bar-height-desktop: 76px;
    --header-cluster-gap: 4px;
    --header-cluster-gap-desktop: 8px;
}

/* ── Header shell ────────────────────────────────────────────────────────── */
.amc-header {
    background: var(--color-soft-white);
    border-bottom: 1px solid var(--color-border-gray);
    position: relative;
    z-index: 50;
}

/* The single bar that hosts every breakpoint. On mobile the logo is absolute-
 * centered against this element so the centering is independent of how many
 * icons sit on the left vs right cluster — drop a button on either side and
 * the logo stays put. On desktop we override `position:absolute` to `static`
 * and the logo flows naturally as the leftmost flex child. */
.amc-header__bar {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--header-cluster-gap);
    max-width: var(--container-max);
    margin-inline: auto;
    padding: 12px var(--container-padding);
    min-height: var(--header-bar-height);
}

/* ── Clusters ────────────────────────────────────────────────────────────── */
.amc-header__cluster {
    display: inline-flex;
    align-items: center;
    gap: var(--header-cluster-gap);
}
.amc-header__cluster--right {
    margin-left: auto;
}

/* Visibility helpers — keep them generic so future header tweaks reuse them
 * without inventing yet another modifier. */
.amc-header__cluster--mobile-only,
.amc-header__icon--mobile-only,
.amc-header__nav--mobile-only { display: inline-flex; }
.amc-header__cluster--desktop-only,
.amc-header__icon--desktop-only,
.amc-header__nav--desktop-only,
.amc-header__tier--desktop-only { display: none; }

/* ── Logo ────────────────────────────────────────────────────────────────── */
/* Mobile default: absolute-centered. Pointer-events:auto on the inner img so
 * the link stays clickable; the parent's left:50% positioning is purely
 * geometric. */
.amc-header__logo {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: inline-flex;
    align-items: center;
    height: 100%;
    text-decoration: none;
    color: var(--color-ink-black);
}
.amc-header__logo-img {
    display: block;
    height: 32px;
    width: auto;
    max-width: 60vw;
    object-fit: contain;
}
.amc-header__logo--in-drawer {
    position: static;
    transform: none;
}
.amc-header__logo--in-drawer .amc-header__logo-img {
    height: 28px;
}

/* ── Icon buttons (single shared shape across breakpoints) ──────────────── */
.amc-header__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--header-icon-button);
    height: var(--header-icon-button);
    padding: 0;
    background: transparent;
    border: none;
    color: var(--color-ink-black);
    cursor: pointer;
    text-decoration: none;
    position: relative;
    transition: color var(--duration-quick) var(--motion-overlay), transform var(--duration-quick) var(--motion-overlay);
}
.amc-header__icon:hover { color: var(--color-deep-gold); transform: translateY(-1px); }
.amc-header__icon:focus-visible {
    outline: 2px solid var(--color-champagne-gold);
    outline-offset: 2px;
    border-radius: 2px;
}
.amc-header__icon-svg {
    display: block;
    width: var(--header-icon-size);
    height: var(--header-icon-size);
    stroke: currentColor;
}

/* ── Desktop nav links ──────────────────────────────────────────────────── */
.amc-header__nav {
    display: flex;
    align-items: center;
    gap: 28px;
    margin-left: 32px;
}
.amc-header__nav-link {
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.02em;
    color: var(--color-ink-black);
    padding: 8px 0;
    border-bottom: 1px solid transparent;
    background: none;
    border-top: none; border-left: none; border-right: none;
    cursor: pointer;
    text-decoration: none;
    transition: color var(--duration-quick) ease, border-color var(--duration-quick) ease;
}
.amc-header__nav-link:hover {
    border-bottom-color: var(--color-champagne-gold);
}
.amc-header__nav-item { position: relative; }

/* ── AMC Klub badge (typographic monogram, SVG-based) ───────────────────── */
/* The badge ships as a static SVG per tier (klub-tag.svg / klub-plus.svg /
 * elite.svg) — see views/partials/components/klub-badge.php for the markup
 * contract. The wrapper here owns sizing + interaction states ONLY; every
 * pixel of the monogram itself comes from the SVG. The visual progression
 * (klub_tag inner-box → klub_plus "+" mark → elite gold inner hairline +
 * ELITE word) is baked into the SVGs themselves, not the CSS. */
.amc-klub-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    line-height: 1;
    /* The chip outline + corner radius are part of the SVG. CSS only adds a
     * faint hover lift and the press snap to keep clicks legible. */
    transition: opacity var(--duration-quick) var(--motion-overlay),
                filter var(--duration-quick) var(--motion-overlay);
}
.amc-klub-badge__img {
    display: block;
    /* Native SVG aspect ratio is 140×80 (= 1.75). Fixing height + width:auto
     * lets every consumer (header, drawer, account page) drive scale via a
     * single height value. */
    height: 32px;
    width: auto;
}
/* Hover — subtle 6% lighten via brightness filter. Restrained on purpose:
 * the SVG already does the heavy visual work, anything more would feel
 * promotional. */
.amc-klub-badge:hover { filter: brightness(0.94); }
.amc-klub-badge:focus-visible {
    outline: 2px solid var(--color-champagne-gold);
    outline-offset: 3px;
    border-radius: 2px;
}
.amc-klub-badge:active {
    transform: translateY(1px);
    transition: transform 100ms var(--motion-overlay);
}

/* Guest fallback — text-link, NOT a badge. Mirrors the brief verbatim
 * ("Vendég NEM badge — szöveg-link"). Sized to match the badge's visual
 * weight in the same slot so the right cluster doesn't reflow when a
 * visitor logs in/out. */
.amc-klub-link {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 14px;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--color-ink-black);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--duration-quick) ease, color var(--duration-quick) ease;
}
.amc-klub-link:hover {
    border-bottom-color: var(--color-champagne-gold);
}

/* Slot — the desktop-only wrapper around the badge. Owns the 72px detach-
 * from-icon-row whitespace requested by the brief. The badge component itself
 * stays sizing-agnostic so it can be reused on the account hero (bigger),
 * email footers, or anywhere else without forking rules. */
.amc-header__tier-slot {
    display: none; /* mobile/tablet — slot lives only inside the drawer */
    align-items: center;
}

@media (prefers-reduced-motion: reduce) {
    .amc-klub-badge,
    .amc-klub-badge:active { transition: none; transform: none; filter: none; }
}

/* ── Cart + wishlist legacy classes — refine sizing for the new icon row ─ */
/* The base `.cart-icon` (style.css:1772) and `.wishlist-icon` (phase8.css:468)
 * already have their badges and SVGs styled. We only normalise their footprint
 * to match the new 40×40 icon button shell. The badge offsets stay coherent
 * because the SVG is still 22px centred in the new 40px button. */
.amc-header__icon.cart-icon,
.amc-header__icon.wishlist-icon {
    width: var(--header-icon-button);
    height: var(--header-icon-button);
    margin-right: 0;
    border: none;
}
.amc-header__icon.cart-icon:hover,
.amc-header__icon.wishlist-icon:hover {
    border-color: transparent;
    color: var(--color-deep-gold);
}

/* ── Search overlay (premium modal, fades + slides 12px) ────────────────── */
.amc-search-overlay {
    position: fixed;
    inset: 0;
    z-index: 110;
    opacity: 0;
    visibility: hidden;
    transition: opacity 420ms var(--motion-overlay), visibility 420ms var(--motion-overlay);
}
.amc-search-overlay[hidden] {
    /* Keep `display:flex` so the transition has dimensions to animate from.
     * Visibility:hidden pulls it out of the AT tree; hidden attr stays set
     * for non-CSS clients. */
    display: flex;
}
.amc-search-overlay.is-open {
    opacity: 1;
    visibility: visible;
}
.amc-search-overlay__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 11, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    cursor: pointer;
}
.amc-search-overlay__panel {
    position: relative;
    margin: 80px auto 0;
    width: min(640px, calc(100vw - 32px));
    background: var(--color-soft-white);
    border: 1px solid var(--color-border-gray);
    box-shadow: 0 24px 48px rgba(10, 10, 11, 0.12);
    transform: translateY(-10px);
    transition: transform 520ms var(--motion-overlay), box-shadow 520ms var(--motion-overlay);
}
.amc-search-overlay.is-open .amc-search-overlay__panel { transform: translateY(0); }
.amc-search-overlay__form {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 18px 18px 22px;
}
.amc-search-overlay__leading-icon {
    flex-shrink: 0;
    color: var(--color-smoke-gray);
    display: inline-flex;
    align-items: center;
}
.amc-search-overlay__input {
    flex: 1 1 auto;
    border: none;
    background: transparent;
    padding: 8px 0;
    font-family: var(--font-sans);
    font-size: 16px; /* iOS Safari avoids zoom-on-focus at 16px+ */
    color: var(--color-ink-black);
    outline: none;
    min-width: 0;
}
.amc-search-overlay__input::placeholder { color: var(--color-smoke-gray); }
.amc-search-overlay__close {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: var(--color-smoke-gray);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color var(--duration-quick) var(--motion-overlay), transform var(--duration-quick) var(--motion-overlay);
}
.amc-search-overlay__close:hover { color: var(--color-ink-black); transform: rotate(90deg); }
.amc-search-overlay__close:focus-visible {
    outline: 2px solid var(--color-champagne-gold);
    outline-offset: 2px;
}

/* ── Profile icon wrapper — anchors the dropdown to the icon ────────────── */
/* Wrapping the trigger + dropdown in a `position: relative` shell pins the
 * dropdown to the icon regardless of how many siblings sit on either side
 * of it. Previously the dropdown was positioned against `.amc-header` with
 * a hard `right: var(--container-padding)` value; that worked when the
 * tier badge was the rightmost element, but the moment the layout shifted
 * (e.g. the badge gained margin or moved) the dropdown drifted away from
 * its trigger. The wrapper-relative anchor is deformation-proof. */
.amc-header__profile-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* ── Profile dropdown (desktop hover) ───────────────────────────────────── */
/* `right:0; left:auto` is intentional belt-and-suspenders — the explicit
 * `left:auto` blocks any inherited or leaked `left` value from the legacy
 * style.css blocks (the project has 5,600 lines of CSS and the dropdown's
 * earlier iterations were positioned against `.amc-header` directly with
 * various `right:` overrides at media-query boundaries). With both
 * declarations present, the right-edge anchor is the only positioning
 * source the browser can apply, regardless of cascade order. */
.amc-profile-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    margin-top: 0;
    z-index: 60;
    width: max-content;
    min-width: 200px;
    max-width: 280px;
    background: var(--color-soft-white);
    border: 1px solid var(--color-border-gray);
    box-shadow: 0 16px 32px rgba(10, 10, 11, 0.10);
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition:
        opacity 320ms var(--motion-overlay),
        transform 320ms var(--motion-overlay);
}
/* Hover bridge — an invisible 8px tall band immediately above the panel.
 * The visible margin-top:8px gap (above) leaves a hover dead-zone the
 * cursor would have to cross when traversing from the trigger icon down
 * to the dropdown. The ::before fills exactly that gap with a transparent
 * region whose mouseenter still counts as "in the dropdown" for hover-
 * intent purposes — so the dropdown does NOT close while the cursor is
 * in flight. Pseudo-elements receive pointer events and bubble them to
 * their parent for hover/mouseenter handling. */
.amc-profile-dropdown::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    height: 8px;
}
.amc-profile-dropdown.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.amc-profile-dropdown.is-closing {
    /* JS keeps a short exit state before removing
     * .is-open; CSS keeps a separate state for that duration so the values
     * never need to change at the same time as visibility. */
    transition-duration: 240ms;
}
.amc-profile-dropdown[hidden] { display: block; } /* hidden attr is the off-state during SSR */
.amc-profile-dropdown__inner { padding: 12px 0; }
.amc-profile-dropdown__greeting {
    margin: 0;
    padding: 8px 18px 10px;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--color-smoke-gray);
}
.amc-profile-dropdown__link {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 18px;
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--color-ink-black);
    background: transparent;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--duration-quick) var(--motion-overlay), color var(--duration-quick) var(--motion-overlay), transform var(--duration-quick) var(--motion-overlay);
}
.amc-profile-dropdown__link:hover {
    background: var(--color-pearl-white);
    color: var(--color-ink-black);
    transform: translateX(3px);
}
.amc-profile-dropdown__link:focus-visible {
    outline: 2px solid var(--color-champagne-gold);
    outline-offset: -2px;
}
.amc-profile-dropdown__link--logout { color: var(--color-smoke-gray); }
.amc-profile-dropdown__divider {
    margin: 8px 0;
    border: 0;
    border-top: 1px solid var(--color-border-gray);
}
.amc-profile-dropdown__logout-form { margin: 0; }

/* ── Mobile drawer greeting paragraph (used in the drawer reflow) ─────── */
.mobile-nav-greeting {
    margin: 8px 0 6px;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--color-smoke-gray);
    text-transform: none;
}

/* ── Body scroll lock while overlay is open ─────────────────────────────── */
body[data-amc-search-open="true"] {
    overflow: hidden;
}

/* ── Desktop breakpoint (≥1025px) ───────────────────────────────────────── */
@media (min-width: 1025px) {
    /* 5-COLUMN GRID — `auto | 1fr | auto | 1fr | auto`.
     * Logo (col 1), nav (col 3), right-cluster (col 5) sit on `auto` tracks
     * so each column is exactly content-sized. The two `1fr` spacer tracks
     * (col 2 + col 4) split the remaining horizontal space EQUALLY by
     * definition of `fr` — which means the nav block's geometric centre
     * lands precisely at the midpoint between the logo's right edge and
     * the right-cluster's left edge.
     *
     * The previous flexbox approach (`margin-left: auto` on the nav)
     * pushed the nav as far right as possible, putting it adjacent to the
     * right-cluster instead of centred between the two anchors — that's
     * the slip Ricsi flagged in the screenshot. Grid with two equal `fr`
     * spacers is the lowest-footprint way to enforce true symmetric
     * centring without absolute positioning + transform tricks. */
    .amc-header__bar {
        display: grid;
        grid-template-columns: auto 1fr auto 1fr auto;
        align-items: center;
        gap: 0;
        padding: 16px var(--container-padding);
        min-height: var(--header-bar-height-desktop);
    }
    /* Logo joins the grid flow — no longer absolute-centered. */
    .amc-header__logo {
        grid-column: 1;
        position: static;
        transform: none;
        height: auto;
    }
    .amc-header__logo-img { height: 40px; }

    .amc-header__cluster--mobile-only,
    .amc-header__icon--mobile-only { display: none; }
    .amc-header__cluster--desktop-only,
    .amc-header__icon--desktop-only,
    .amc-header__nav--desktop-only,
    .amc-header__tier--desktop-only { display: inline-flex; }

    /* Nav lives in the middle `auto` track (col 3); its content width
     * defines the cell, the two `1fr` spacers around it absorb the rest. */
    .amc-header__nav.amc-header__nav--desktop-only {
        grid-column: 3;
        margin: 0;
        gap: 28px;
    }

    /* Right cluster — col 5. `margin-left: 0` clears the legacy auto-margin
     * the mobile/tablet cascade applied; grid placement handles all gap
     * arithmetic now. */
    .amc-header__cluster--right {
        grid-column: 5;
        margin-left: 0;
        gap: 6px;
    }

    /* Klub badge slot — desktop-only standalone CTA. The brief calls for
     * 64–80px gap between the cart icon and the badge so the badge reads
     * as its own element rather than a tail-on-the-icon-row. With the
     * cluster's flex gap of 6px already in place, a 72px margin-left lands
     * the visible gap at 78px (right in the 64-80 target band). */
    .amc-header__tier-slot--desktop-only { display: inline-flex; }
    .amc-header__tier-slot { margin-left: 72px; }

    /* Dropdown anchoring: see `.amc-header__profile-wrap` and
     * `.amc-profile-dropdown` rules above. The wrapper provides
     * position:relative; the panel uses `top:100% right:0 left:auto` so
     * the right edge of the panel pins to the right edge of the icon
     * regardless of how many siblings sit on either side. No desktop
     * override needed. */
}

/* ── Tablet breakpoint (≤1024px, ≥769px) ─────────────────────────────────── */
/* Logo grows to ~44px so the absolute-centered mark reads as the visual
 * anchor of the strip rather than a tucked-in afterthought. The bar's
 * vertical padding shrinks from 12px to 8px, so even at 44px the logo
 * still has 10px breathing room top/bottom inside the 64px bar — header
 * overall height is preserved exactly per the brief. The icon hit target
 * stays at 44px so they align vertically with the logo's baseline. */
@media (max-width: 1024px) {
    .amc-header__nav--desktop-only,
    .amc-header__icon--desktop-only,
    .amc-header__tier-slot--desktop-only { display: none !important; }
    .amc-header__bar { padding: 8px 16px; min-height: var(--header-bar-height); gap: 0; }
    .amc-header__cluster--left { gap: 0; }
    .amc-header__cluster--right { gap: 0; }
    .amc-header__icon { width: 44px; height: 44px; } /* WCAG 44px touch target */
    .amc-header__logo-img { height: 44px; max-height: 48px; }

    /* Profile dropdown never opens on touch — the entire div stays hidden so
     * the icon's link semantics carry the experience. */
    .amc-profile-dropdown { display: none !important; }

    /* Drawer rendition — bump the badge to 40px tall so the touch target
     * matches the icon row and the SVG ornaments (inner box, "+" mark,
     * ELITE word) stay legible inside the drawer. */
    .mobile-drawer-tier .amc-klub-badge__img { height: 40px; }
}

/* ── Mobile fine-tune (≤768px) ──────────────────────────────────────────── */
/* Phone-sized logo lands at 38px — still meaningfully larger than the
 * pre-refinement 28px, but tuned so the icon row + logo never crowd at
 * the smallest portrait widths. */
@media (max-width: 768px) {
    .amc-header__logo-img { height: 38px; }
}

/* ── Small mobile (≤480px) ──────────────────────────────────────────────── */
/* Iphone-SE width and below — bar collapses to 56px tall; logo and icons
 * shrink one notch (36px / 40px) so the strip never wraps onto two rows. */
@media (max-width: 480px) {
    .amc-header__bar { padding: 6px 12px; min-height: 56px; }
    .amc-header__icon { width: 40px; height: 40px; }
    .amc-header__logo-img { height: 36px; }
}

/* ── Reduced motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .amc-search-overlay,
    .amc-search-overlay__panel,
    .amc-profile-dropdown {
        transition: opacity 0.01ms linear, visibility 0.01ms linear, transform 0.01ms linear !important;
    }
    .amc-search-overlay__backdrop { backdrop-filter: none; -webkit-backdrop-filter: none; }
}
