:root {
  --header-h:  64px;
  /* Shared by .menu-bar/.cart-btn/.save-btn below, which all stack right
     to left off the same slot width and gap — kept as variables so the
     three positions can't drift out of sync with each other. */
  --icon-slot: clamp(60px, 7vw, 70px);
  --icon-gap:  5px;
}

header {
  position: fixed;
  width: auto;
  height:var(--header-h);
  padding:0 clamp(16px,3vw,36px);
  z-index: 9999;
  display: flex;
  align-items: center;
  font-size: clamp(20px, 3vw, 70px);
  font-family: HDLargeFont;
  color: var(--header-text);
  transform: none;
  opacity: 1;
  visibility: visible;
}

.header img {
  width: clamp(36px, 4vw, 90px);
  height: auto;
  display: block;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: clamp(6px, 1vw, 12px);
  /* .header-inner is the home link itself now — keep it unclickable
     while faded out (scrolled down) so there's no invisible click
     target; .header.is-visible below re-enables it once it's actually
     on screen. Its children stay pointer-events:none regardless (see
     below) so a click anywhere in the logo/title always resolves to
     this anchor rather than being swallowed by a child element. */
  pointer-events: none;
}

.header.is-visible .header-inner {
  pointer-events: auto;
}

.title {
  display: flex;
  gap: clamp(3px, 0.4vw, 5px);
}

.header-inner > * {
  pointer-events: none;
  transform: translateX(-50px);
  opacity: 0;
  transition:
    transform 0.45s ease,
    opacity 0.45s ease;
}

.header.is-visible .header-inner > * {
  transform: translateX(0);
  opacity: 1;
}

.header.is-visible .header-inner > *:nth-child(1) {
  transition-delay: 0.15s;
}

.header.is-visible .header-inner > *:nth-child(2) {
  transition-delay: 0.45s;
}

/* Right-side menu bar — short at every page/width now (previously only on
   /customizev5 via a --no-cart modifier); the cart icon lives in its own
   .cart-btn element instead of inside this bar (see below), since it
   needs to stay visible even when this bar hides on scroll. */
.menu-bar {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--icon-slot);
  height: clamp(60px, 10lvh, 80px);
  max-height: var(--header-h);
  background: var(--highlight);
  z-index: 9999;
  border-radius: 0.5rem 0 0 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.4s ease, opacity 0.3s ease, background-color 0.3s ease;
}

.menu-bar:hover {
  background-color: color-mix(in srgb, var(--highlight) 70%, black 30%);
}

.menu-bar.is-hidden {
  transform: translateX(100%);
  opacity: 0;
}

/* Hamburger icon */
.menu-icon {
  display: flex;
  flex-direction: column;
  gap: 5px;          /* fixed gap too */
  padding-top: 0;    /* let flexbox centering handle position */
}

.menu-icon span {
  width: 28px;       /* fixed width — no vw scaling */
  height: 3px;       /* fixed height */
  background: white;
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease;
  transform-origin: center;
}

/* Shopping cart — sits flush against the menu bar (deliberately no gap
   between them), and now mirrors .menu-bar's scroll-hide behavior
   (header2.js toggles .is-hidden on this too). .cart-btn itself is just
   a fixed positioning box, not the clickable element — pointer-events:
   none here means only the icon's own box (.cart-btn img, re-enabled
   below) is actually clickable/hoverable, not the whole padded slot
   around it. */
.cart-btn {
  position: fixed;
  top: 0;
  right: var(--icon-slot);
  width: var(--icon-slot);
  height: clamp(60px, 10lvh, 80px);
  max-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  pointer-events: none;
  transition: transform 0.4s ease, opacity 0.3s ease;
}

.cart-btn.is-hidden {
  transform: translateX(100%);
  opacity: 0;
}

.cart-btn img {
  width: clamp(42px, 5vw, 56px);
  height: auto;
  aspect-ratio: 1 / 1;
  display: block;
  pointer-events: auto;
  cursor: pointer;
}

/* Item-count badge — a plain positioned element overlaid on the icon
   rather than baked into the PNG, so any digit count "just works" without
   needing a separate image per number. .cart-btn is already position:fixed
   (a valid containing block for this), so no extra wrapper is needed. Color
   follows --header-text — the same token the header logo/text already uses
   to be white everywhere except black on the cart page — so this needs no
   page-specific override. */
.cart-count-badge {
  position: absolute;
  top: 15px;
  left: 3px;
  color: var(--header-text);
  font-family: HDSmallFont, sans-serif;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

.cart-count-badge[hidden] {
  display: none;
}

/* ── Save button (customize page only — outlined, left of the cart icon,
   with the one --icon-gap in this row; the cart icon sits flush against
   the menu bar with no gap, by design) ── */
.save-btn {
  position: fixed;
  top: calc(var(--header-h) / 2);
  transform: translateY(-50%);
  right: calc(var(--icon-slot) * 2 + var(--icon-gap));
  padding: 6px clamp(10px, 1.2vw, 16px);
  background: transparent;
  color: white;
  border: 1px solid var(--highlight);
  border-radius: 2px;
  display: flex;
  align-items: center;
  gap: 7px;
  z-index: 9999;
  font-family: HDSmallFont;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  transition: background-color 0.2s ease;
}

.save-btn:hover {
  background-color: rgba(122, 106, 69, 0.2);
}

.save-btn__icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

@media (max-width: 500px) {
  .save-btn { display: none; }
}

/* Flyout menu */
.flyout-menu {
  position: fixed;
  top: 0;
  right: 0;
  transform: translateX(100%);
  pointer-events: none; /* ← FIX: prevents clicks when off-screen */
  width: clamp(200px, 25vw, 300px);
  height: 100vh;
  height: 100dvh;
  font-family: HDSmallFont;
  background: var(--main-bg);
  color: var(--main-text);
  display: flex;
  flex-direction: column;
  padding: clamp(40px, 6vh, 60px) clamp(14px, 2vw, 20px);
  transition: transform 0.4s ease;
  z-index: 10000;
}

.flyout-menu.active {
  transform: translateX(0);
  pointer-events: auto; /* ← re-enable when visible */
}

.close-btn {
  position: absolute;
  top: clamp(14px, 2vh, 20px);
  left: clamp(14px, 2vw, 20px);
  font-size: clamp(24px, 3vw, 32px);
  cursor: pointer;
  color: var(--main-text);
  z-index: 1001;
  transition: color 0.2s ease;
}

.close-btn:hover {
  color: red;
}

.flyout-links-top,
.flyout-links-bottom {
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 2vh, 20px);
}

.flyout-menu ul {
  list-style: none;
  padding: 0;
  margin-top: clamp(20px, 3vh, 30px);
}

.flyout-menu li {
  margin-bottom: clamp(16px, 2.5vh, 24px);
}

/* Flyout link styles — accent color + underline on hover/touch */
.flyout-menu a {
  color: var(--main-text);
  text-decoration: none;
  font-size: clamp(14px, 1.8vw, 18px);
  font-weight: 500;
  letter-spacing: 0.1em;
  position: relative;
  display: inline-block;
  transform: translateX(50px);
  opacity: 0;
  /* color transition stays undelayed (0s) so hover feedback is instant;
     only transform/opacity pick up the per-link fly-in stagger via --fly-delay */
  transition-property: color, transform, opacity;
  transition-duration: 0.2s, 0.4s, 0.4s;
  transition-timing-function: ease, ease, ease;
  transition-delay: 0s, var(--fly-delay, 0s), var(--fly-delay, 0s);
}

.flyout-menu a::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--highlight);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.2s ease;
}

/* Desktop hover */
@media (hover: hover) {
  .flyout-menu a:hover {
    color: var(--highlight);
  }
  .flyout-menu a:hover::after {
    transform: scaleX(1);
  }
}

/* Mobile touch — uses :active for tap feedback */
.flyout-menu a:active {
  color: var(--highlight);
}
.flyout-menu a:active::after {
  transform: scaleX(1);
}

.flyout-menu a.is-touched {
  color: var(--highlight);
}
.flyout-menu a.is-touched::after {
  transform: scaleX(1);
}

/* Fly-in state — stagger timing is applied per-link via inline transitionDelay
   set in header2.js, mirroring header.js's mobile menu behavior */
.flyout-menu a.active {
  transform: translateX(0);
  opacity: 1;
}

/* Overlay */
#mobileOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  visibility: hidden;
  z-index: 2;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

#mobileOverlay.active {
  opacity: 1;
  visibility: visible;
}