/* ============================================================================
   Mundbora unified site header
   Single source of truth for header styles on BOTH:
     - mundbora.com static marketing pages (public/{index,about,press,contact}/index.html)
     - shop.mundbora.com Shopify theme (theme/snippets/mundbora-site-header.liquid)

   The build script (scripts/build.sh) copies this file to:
     - public/assets/css/mundbora-header.css   (served by Cloudflare Pages)
     - theme/assets/mundbora-header.css        (served by Shopify CDN)

   Both delivery paths render the IDENTICAL DOM (<header class="site-header">)
   from this stylesheet, so the header is pixel-identical across both sites.

   Edit this file, then run `npm run build` (or just `bash scripts/build.sh`)
   to propagate the change.
   ========================================================================= */

/* ── Header colors (intentionally hardcoded so the header renders
       identically whether or not the host page defines Mundbora CSS vars). */
:root {
  --mundbora-header-green: #5b8f58;
  --mundbora-header-ink:   #1a1a1a;
  --mundbora-header-paper: #f5f3ec;
  --mundbora-header-rule:  rgba(0, 0, 0, 0.08);
}

/* ── Defensive resets for hosts that wrap us in opinionated CSS (Shopify Dawn).
       The header lives inside an existing <header-wrapper> / <sticky-header>,
       so we MUST keep its background/text inheritance neutral. */
.site-header,
.site-header * {
  box-sizing: border-box;
}

.site-header a {
  text-decoration: none;
  color: inherit;
}

/* ── Header
       Bottom-align all three zones (nav links, MUNDBORA logo, icons) so the
       VISIBLE bottoms of the text/letterforms/icons land on a single
       horizontal line. We use the tight-cropped MUNDBORA PNG (no whitespace
       below letterforms) and `line-height: 1` on nav text so the line-box
       bottom = visible cap baseline. */
.site-header {
  padding: 32px 50px 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  column-gap: 26px;
  align-items: end;
  background: transparent;
  font-family: inherit;
}

.nav-left,
.nav-right {
  display: flex;
  gap: 32px;
  font-size: 16px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  align-items: flex-end;
  min-width: 0;
  flex-wrap: nowrap;
}

/* Anchor nav-left so its first link sits half an inch (0.5in) to the left
   of the hero eyebrow ("THE TRAINING BAG — SPRING 2026"), which begins
   at the hero's left padding of 142px. Header has 50px left padding, so
   this offset is calc(142px - 0.5in - 50px) ≈ 44px. */
.nav-left  { justify-self: start; margin-left: calc(142px - 0.5in - 50px); }
.nav-right { justify-self: end; align-items: flex-end; gap: 24px; }

.nav-left a { color: var(--mundbora-header-green); }
.nav-left a.is-active {
  color: #000000;
  border-bottom: 2px solid var(--mundbora-header-green);
  padding-bottom: 2px;
}
.nav-left a:hover,
.nav-right a:hover {
  opacity: 0.55;
  transition: opacity 0.2s;
}

.header-logo {
  justify-self: center;
  align-self: end;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  line-height: 0;
}

.header-logo img {
  width: min(280px, 26vw);
  height: auto;
  display: block;
  max-width: 100%;
  object-fit: contain;
}

.header-icon {
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px 6px 0;
  color: var(--mundbora-header-green);
  line-height: 0;
  position: relative;
}

/* <cart-icon-bubble> wraps the cart anchor on the Shopify-rendered header
   (so Dawn's global.js cart-update code can find/update it). It is an
   unknown custom element which defaults to display:inline — that makes
   the anchor inside baseline-align with the surrounding nav-right flex
   container instead of bottom-aligning, so the cart icon sits ~2px above
   the account icon. Forcing it to inline-flex with align-items:flex-end
   propagates the bottom-alignment through to its child <a>. */
.nav-right cart-icon-bubble {
  display: inline-flex;
  align-items: flex-end;
  line-height: 0;
}

.header-icon svg {
  display: block;
  width: 22px;
  height: 22px;
}

.header-icon:hover {
  opacity: 0.7;
  transition: opacity 0.2s;
}

/* Cart count badge — visible only when count > 0 (renderer omits the span
   when the cart is empty). Position over the bag icon's top-right. */
.header-icon .cart-count {
  position: absolute;
  top: 2px;
  right: -2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--mundbora-header-green);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
}

.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--mundbora-header-green);
}

.mobile-menu-toggle svg { display: block; }
.mobile-menu-toggle .icon-close { display: none; }
.mobile-menu-toggle[aria-expanded="true"] .icon-hamburger { display: none; }
.mobile-menu-toggle[aria-expanded="true"] .icon-close { display: block; }

/* ── Responsive ─────────────────────────────────────────────────────────── */

/* Below 990px (small laptops / tablets) the header collapses to a hamburger
   drawer because the 4-item inline nav would crash into the centered MUNDBORA
   logo. From 990px+ the full inline nav stays visible to match the catalog
   header (single horizontal row). */
@media (min-width: 769px) and (max-width: 989px) {
  .site-header {
    position: relative;
    z-index: 50;
    grid-template-columns: auto 1fr auto;
    column-gap: 24px;
  }
  .mobile-menu-toggle { display: block; }
  .nav-left {
    margin-left: 0;
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    grid-column: 1 / -1;
    justify-self: stretch;
    background: var(--mundbora-header-paper);
    z-index: 40;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 8px 50px 24px;
    font-size: 16px;
    text-align: left;
    border-top: 1px solid var(--mundbora-header-rule);
    box-shadow: 0 12px 20px -8px rgba(0, 0, 0, 0.08);
  }
  .nav-left.is-open { display: flex; }
  .nav-left a {
    width: 100%;
    padding: 14px 0;
    font-size: 16px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 700;
  }
  .nav-left .mobile-close { display: none; }
  .header-logo { justify-self: center; }
}

/* Narrow-desktop range: keep the inline nav (matches catalog header) but
   tighten spacing and shrink the logo so all three zones fit on one
   horizontal line with MUNDBORA as the centered anchor. */
@media (min-width: 990px) and (max-width: 1280px) {
  .site-header { padding: 32px 32px 20px; column-gap: 20px; }
  .nav-left {
    margin-left: 0;
    gap: 22px;
    font-size: 14px;
  }
  .nav-right { gap: 18px; }
  .header-logo img { width: min(220px, 22vw); }
}

/* Hamburger kicks in with the stacked hero so preview/tablet widths do
   not wrap nav. */
@media (max-width: 960px) {
  .site-header {
    display: grid;
    padding: 14px 18px;
    grid-template-columns: 1fr auto 1fr;
    column-gap: 12px;
    align-items: end;
    position: relative;
    z-index: 50;
  }
  .mobile-menu-toggle {
    display: inline-flex;
    align-items: flex-end;
    justify-content: flex-start;
    justify-self: start;
    align-self: end;
    z-index: 2;
    padding: 0;
    line-height: 0;
  }
  .mobile-menu-toggle svg { display: block; width: 26px; height: 26px; }
  /* Mobile nav becomes a top-anchored dropdown panel BELOW the header,
     leaving the logo + account/cart icons fully visible.

     `grid-column: 1 / -1` makes the drawer's grid AREA span the entire
     header row (otherwise its containing-block for absolute positioning
     would shrink to the tiny first-column area). `justify-self: stretch`
     overrides the base rule's `justify-self: start` so the absolutely
     positioned element fills that area instead of shrinking to its
     intrinsic content width (which would collapse the drawer to ~140px). */
  .nav-left {
    margin-left: 0;
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    grid-column: 1 / -1;
    justify-self: stretch;
    background: var(--mundbora-header-paper);
    z-index: 40;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 8px 28px 24px;
    font-size: 18px;
    text-align: left;
    border-top: 1px solid var(--mundbora-header-rule);
    box-shadow: 0 12px 20px -8px rgba(0, 0, 0, 0.08);
  }
  .nav-left.is-open { display: flex; }
  .nav-left a {
    width: 100%;
    padding: 14px 0;
    font-size: 18px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 700;
  }
  .nav-left .mobile-close { display: none; }
  .nav-right {
    gap: 14px;
    font-size: 12px;
    margin-left: 0;
    grid-column: 3;
    justify-self: end;
    align-self: end;
    align-items: flex-end;
    z-index: 2;
  }
  .nav-right .header-icon { padding: 0; line-height: 0; }
  .nav-right .header-icon svg { display: block; width: 22px; height: 22px; }
  .header-logo {
    position: static;
    justify-self: center;
    align-self: end;
    margin-left: 0;
    min-width: 0;
    max-width: 100%;
    z-index: 1;
    transform: none;
  }
  .header-logo img { height: 26px; width: auto; max-width: 100%; display: block; }
}

@media (max-width: 480px) {
  .site-header { padding: 12px 14px; }
  .header-logo img { height: 22px; width: auto; }
  .nav-right .header-icon svg { width: 20px; height: 20px; }
  .mobile-menu-toggle svg { width: 22px; height: 22px; }
}

@media (max-width: 380px) {
  .header-logo img { height: 20px; width: auto; }
  .nav-right { gap: 6px; font-size: 11px; }
}
