/* ==========================================================================
   Section: header  →  assets/section-header.css
   Tinted and blurred over the hero (Figma 1164-2247); solid white after scrolling
   (values from the Figma "Menu" component 930-249).
   Sticky rather than fixed: it starts below the announcement bar and pins once that has scrolled
   away. The negative margin takes it out of the flow so the hero still starts underneath it.
   ========================================================================== */
.header {
  --header-bg: rgba(0, 0, 0, 0.1);
  --header-fg: var(--color-text-inverse);
  --header-icon: var(--color-icon-inverse);
  --header-line: var(--color-line-inverse);
  --logo-stop-start: #ffffff;
  --logo-stop-end: #e9d8ce;

  display: block;
  position: sticky;
  z-index: 100;
  top: 0;
  box-sizing: content-box; /* 56px row + 1px line → the line sits at y=56 exactly like Figma */
  height: var(--header-height);
  margin-bottom: calc(-1 * (var(--header-height) + 1px));
  border-bottom: 1px solid var(--header-line);
  background: var(--header-bg);
  background-clip: padding-box; /* the tint stops above the 1px line, as in Figma */
  color: var(--header-fg);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  transition: background-color var(--duration-base) ease, color var(--duration-base) ease, border-color var(--duration-base) ease;
}

.header[data-transparent="false"],
.header.is-solid {
  --header-bg: var(--color-white);
  --header-fg: var(--color-text-menu);
  --header-icon: var(--color-text-menu);
  --header-line: var(--color-border-menu);
  --logo-stop-start: #242424;
  --logo-stop-end: #111111;

  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

/* The mark's white inner shadow is a highlight for dark backgrounds; on white it would read as a halo */
.header[data-transparent="false"] .icon-logo__bevel,
.header.is-solid .icon-logo__bevel {
  filter: none;
}

.header__inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

/* First-load entrance over the hero. CSS rather than GSAP so it runs from the first painted frame —
   a deferred-script intro hid the already visible row and slid it in again. */
@media (prefers-reduced-motion: no-preference) {
  .header[data-transparent="true"] .header__inner {
    animation: header-intro 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.1s both; /* GSAP power2.out */
  }
}

@keyframes header-intro {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* Primary navigation — Inter 500 12px, 16px apart, 4px vertical padding.
   Figma sets this row 1px below the centre line the logo and icons share. */
.header__nav {
  position: relative;
  top: 1px;
}

.header__menu {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
  font-size: var(--text-body-s-size);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
}

/* Hover / keyboard focus: a 1px line as wide as the item (label + chevron) laid over the header's
   bottom border (Figma 1694-3321: #f6f6f6, 76×1 at y=56). The link is centred in the row and the nav
   sits 1px low, so its centre is at 50% + 1px: half the row height minus that 1px reaches the border. */
.header__link::after {
  content: "";
  position: absolute;
  top: calc(50% + var(--header-height) / 2 - 1px);
  right: 0;
  left: 0;
  height: 1px;
  background: var(--header-icon);
  opacity: 0;
  transition: opacity var(--duration-fast) ease, background-color var(--duration-base) ease;
}

.header__link:hover::after,
.header__link:focus-visible::after {
  opacity: 1;
}

.header__link > span,
.header__currency,
.header__logo-text > span:not(.header__logo-turned) {
  width: var(--width-whole-px);
}

/* Chevrons are the icon colour (#f6f6f6), a shade off the white labels */
.header__link .icon-chevron-down {
  color: var(--header-icon);
  transition: color var(--duration-base) ease;
}

/* Logo — 20px mark + the OCHOA wordmark, centred on the row (Figma's 113px row lands at x=664) */
.header__logo {
  position: absolute;
  top: 50%;
  left: calc(50% + 0.5px);
  display: flex;
  align-items: center;
  gap: 6px;
  transform: translate(-50%, -50%);
}

.header__logo-text {
  display: flex;
  align-items: center;
  font-family: var(--font-logo);
  font-size: var(--text-logo-size);
  font-style: italic;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

/* The H lies on its side: a 19×22 light upright glyph turned into a 22×19 slot */
.header__logo-turned {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 19px;
}

.header__logo-turned > span {
  display: block;
  flex: none;
  width: 19px;
  height: 22px;
  font-style: normal;
  font-weight: 300;
  line-height: 0.9;
  transform: rotate(90deg);
}

/* Right cluster — localization + icons, 16px apart, #f6f6f6 */
.header__actions {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--header-icon);
  transition: color var(--duration-base) ease;
}

.header__localization {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 18px;
}

.header__localization-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.header__currency {
  padding: 4px 0;
  font-size: var(--text-body-s-size);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
}

.header__icons {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header__icon-link {
  display: flex;
  align-items: flex-start;
}

/* Cart badge starts 8px into the 18px bag and overhangs it by 2px (Figma: badge 12×12 at x=8) */
.header__cart .icon-bag {
  margin-right: -10px;
}

.header__cart-count {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  border-radius: 8px;
  background: var(--color-black);
  color: var(--color-text-inverse);
  font-size: var(--text-label-s-size);
  font-weight: 500;
  line-height: 1;
}

@media (max-width: 989px) {
  /* No mobile navigation in the Figma file yet — the drawer is a later section */
  .header__nav {
    display: none;
  }

  .header__actions {
    margin-left: auto;
  }
}

@media (max-width: 749px) {
  .header__currency {
    display: none;
  }

  /* Centred, the 113px wordmark runs into the flag; with the nav hidden the left side is free */
  .header__logo {
    position: static;
    transform: none;
  }
}
