/* ============================================================
   Section: header — desktop 3446:63 (1440x106) · mobile 3446:1113 (375x94)
   Pattern B-edge: .container on <header> + .container--bleed; each band
   (announcement bar, nav row) paints its own full-bleed bg and pads itself.
   Mobile-first: base = <768 (anchor 375) · 768-1023 pseudo-tablet · 1024+ desktop.
   Fluid math: pipeline/components/fluid-formulas.md (values in brief/header.md §2).
   ============================================================ */

/* ---------- Local scale (MOBILE base, 0-767) ---------- */
.header {
  /* BA-H1 / D-H1: mobile bar unit — 1px at 375-767, shrinks below 375 so the
     row (Figma 381 in a 375 frame) always fits the viewport. */
  --bar-u: min(1px, calc(100vw / 375));

  --hd-bar-pad-block: clamp(10px, calc(12px + (var(--max-vw) - 375px) * 0.015), 12px);
  --hd-bar-pad-inline: var(--gutter);
  --hd-bar-gap: calc(6 * var(--bar-u));            /* Figma 10 (BA-H1) */
  --hd-chip-gap: calc(6 * var(--bar-u));           /* Figma 10 (BA-H1) */
  --hd-chip-pad-block: calc(4 * var(--bar-u));
  --hd-chip-pad-inline: calc(8 * var(--bar-u));    /* Figma 10 (BA-H1) */
  --hd-chip-radius: 4px;
  --hd-bar-fs: min(var(--text-small), calc(14 * var(--bar-u)));

  /* Cart: M-max = max(M, D) = M → holds M above 375 */
  --hd-cart: clamp(27px, calc(32px + (var(--max-vw) - 375px) * 0.015), 32px);
  --hd-icon: clamp(17px, calc(20px + (var(--max-vw) - 375px) * 0.015), 20px);
  --hd-badge: clamp(12px, calc(14px + (var(--max-vw) - 375px) * 0.015), 14px);
  --hd-badge-fs: clamp(10px, calc(12px + (var(--max-vw) - 375px) * 0.015), 12px);

  display: block;
  position: relative;
}

/* ---------- Band 1: announcement bar ---------- */
.header__bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: var(--hd-bar-gap);
  height: var(--header-bar-h);
  padding-block: var(--hd-bar-pad-block);
  padding-inline: var(--hd-bar-pad-inline);
  background: var(--color-brand);
  color: var(--color-white);
}

.header__offer,
.header__chip-text {
  font-family: var(--font-body);
  font-size: var(--hd-bar-fs);
  font-weight: 500;
  line-height: var(--lh-ui);
  letter-spacing: 0;
  color: var(--color-white);
  white-space: nowrap;
}

/* D-H2: Figma textCase TITLE — source copy kept verbatim */
.header__offer {
  flex: 0 0 auto;
  text-transform: capitalize;
}

.header__countdown {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: var(--hd-chip-gap);
  font-variant-numeric: tabular-nums;   /* D-H5: no jitter each second */
}

.header__chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-block: var(--hd-chip-pad-block);
  padding-inline: var(--hd-chip-pad-inline);
  border-radius: var(--hd-chip-radius);
  background: rgba(217, 220, 198, 0.1);   /* sage-2 @10% */
}

/* D-H5 realised: Poppins (Google Fonts build) has NO `tnum` feature — measured "41" 13.97px
   vs "00" 17.95px with and without font-feature-settings "tnum" — so tabular-nums alone is a
   no-op and the centred row would shift ~2px every second. A fixed 2-digit cell (2ch = width
   of "00") keeps every chip width constant; cost vs Figma at the drawn 15/27/42 state:
   chips +4.1 / +2.0 / +0.8 px. */
.header__chip-text [data-countdown] {
  display: inline-block;
  width: 2ch;
  text-align: center;
}

/* ---------- Band 2: nav row ---------- */
/* D-H6: one 1fr | auto | 1fr grid on every layer — logo centred, cart flush right.
   The hidden desktop nav-left is not emitted; the first 1fr track balances the row. */
.header__nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: var(--header-nav-h);
  padding-inline: var(--gutter);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-nav);   /* D-H10: INSIDE stroke, bottom only */
}

.header__logo {
  grid-column: 2;
  display: block;
  font-family: var(--font-body);
  font-size: var(--text-logo);
  font-weight: 500;
  line-height: var(--lh-logo);
  letter-spacing: var(--ls-logo);
  /* D-H3: cancel the trailing tracking after "N" so the INK is centred */
  margin-inline-end: calc(-1 * var(--ls-logo));
  color: var(--color-brand);
  white-space: nowrap;
}

.header__logo:focus-visible,
.header__cart:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 4px;
}

.header__cart {
  grid-column: 3;
  justify-self: end;
  position: relative;               /* D-H4: badge is an abs-overlay */
  display: grid;
  place-items: center;
  width: var(--hd-cart);
  height: var(--hd-cart);
  color: var(--color-ink);
}

.header__cart-icon {
  width: var(--hd-icon);
  height: var(--hd-icon);
  max-width: none;
}

.header__badge {
  position: absolute;
  right: 0;
  bottom: 0;
  display: grid;
  place-items: center;
  width: var(--hd-badge);
  height: var(--hd-badge);
  border-radius: var(--radius-round);
  background: var(--color-cart-badge);
  color: var(--color-white);
  font-family: var(--font-body);    /* BA-P1: Asta Sans → Poppins */
  font-size: var(--hd-badge-fs);
  font-weight: 400;
  line-height: 1;
}

/* ---------- PSEUDO-TABLET 768-1023 (desktop-compressed; Figma bar values restored) ---------- */
@media (min-width: 768px) {
  .header {
    --hd-bar-pad-block: 12px;
    --hd-bar-pad-inline: var(--gutter);
    /* label → chips: M 10 / D 20 → M-767 15.88, capped at M-max 20 */
    --hd-bar-gap: clamp(15.88px, calc(15.88px + (var(--max-vw) - 768px) * 0.025), 20px);
    --hd-chip-gap: 10px;
    --hd-chip-pad-block: 4px;
    --hd-chip-pad-inline: 10px;
    --hd-bar-fs: var(--text-small);
    --hd-cart: 32px;
    --hd-icon: 20px;
    --hd-badge: 14px;
    --hd-badge-fs: 12px;
  }
}

/* ---------- DESKTOP 1024+ (scales from --vw-base 1440, capped at 1920) ---------- */
@media (min-width: 1024px) {
  .header {
    --hd-s: calc(var(--max-vw) / var(--vw-base));
    --hd-bar-pad-block: clamp(9px, calc(12px * var(--hd-s)), 16px);
    --hd-bar-pad-inline: clamp(34px, calc(48px * var(--hd-s)), 64px);
    --hd-bar-gap: clamp(14px, calc(20px * var(--hd-s)), 27px);
    --hd-chip-gap: clamp(7px, calc(10px * var(--hd-s)), 13px);
    --hd-chip-pad-block: clamp(3px, calc(4px * var(--hd-s)), 5px);
    --hd-chip-pad-inline: clamp(7px, calc(10px * var(--hd-s)), 13px);
    --hd-chip-radius: clamp(3px, calc(4px * var(--hd-s)), 5px);
    --hd-bar-fs: var(--text-small);
    --hd-cart: clamp(23px, calc(32px * var(--hd-s)), 43px);
    --hd-icon: clamp(14px, calc(20px * var(--hd-s)), 27px);
    --hd-badge: clamp(10px, calc(14px * var(--hd-s)), 19px);
    --hd-badge-fs: clamp(9px, calc(12px * var(--hd-s)), 16px);
  }
}

/* ---------- Sticky on scroll-up (post-delivery, = Shopify Dawn `sticky-header` on-scroll-up, as on
   thestrom.co): the announcement bar scrolls away with the page; past the header the nav row hides
   while scrolling down and slides back in on any scroll up. Classes are set by js/header.js;
   --hdr-bar-h / --hdr-h are measured there (fluid heights). ---------- */
.header {
  position: sticky;
  top: auto;
  z-index: var(--z-header);
}
.header.is-sticky {
  top: calc(-1 * var(--hdr-bar-h, 0px));   /* bar above the viewport, nav row pinned at 0 */
}
.header.is-hidden {
  top: calc(-1 * var(--hdr-h, 100vh));     /* whole header above the viewport */
}
.header.is-animate {
  transition: top 0.15s ease-out;          /* Dawn: .section-header.animate */
}
@media (prefers-reduced-motion: reduce) {
  .header.is-animate { transition: none; }
}

/* CTA anchors scroll UP to the product block, which reveals the pinned nav row — keep the
   block's top clear of it. */
#product {
  scroll-margin-top: calc(var(--hdr-h, 0px) - var(--hdr-bar-h, 0px));
}
