/* Header + mobile nav + cart bubble */
.header {
  position: relative;
  z-index: 40;
  border-bottom: 1px solid var(--color-border);
}
/* Frosted-glass bar lives on a pseudo-element, NOT on .header itself.
   A non-none backdrop-filter makes its element the containing block for
   position:fixed descendants — which would trap .header__overlay and
   .header__mobile inside the ~68px header box instead of the viewport. */
.header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: color-mix(in srgb, var(--color-bg) 82%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.header--sticky { position: sticky; top: 0; }
/* When the mobile nav is open, lift the whole header (and its fixed drawer +
   overlay children) above the grain overlay (z-9999) so nothing renders over it. */
.header.is-open { z-index: 10000; }

.header__inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  min-height: 68px;
}

.header__logo {
  font-size: clamp(1.1rem, 2.4vw, 1.5rem);
  letter-spacing: 0.18em;
  white-space: nowrap;
}

.header__nav { justify-self: center; }
.header__menu { display: flex; gap: 1.75rem; }
.header__link {
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding-block: 0.5rem;
  position: relative;
  transition: color var(--dur) var(--ease);
}
.header__link::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 1px;
  background: var(--glow);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur) var(--ease);
}
.header__link:hover,
.header__link.is-active { color: var(--color-text); }
.header__link:hover::after,
.header__link.is-active::after { transform: scaleX(1); }

.header__actions { display: flex; align-items: center; gap: 0.35rem; justify-self: end; }
.header__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  border-radius: 50%;
  color: var(--color-text);
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.header__icon-btn:hover { background: var(--color-surface); color: var(--glow); }

.header__nav-toggle { display: none; }

/* cart bubble */
.cart-bubble { position: relative; display: inline-flex; }
.cart-bubble__count {
  position: absolute;
  top: -6px; right: -8px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  color: #0a0a0c;
  background: var(--glow);
  border-radius: 999px;
  box-shadow: 0 0 12px -2px var(--glow-soft);
}

/* mobile full-screen nav — the page becomes a menu, not a panel over it */
.header__overlay {
  position: fixed;
  inset: 0;
  z-index: 44;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.header.is-open .header__overlay { opacity: 1; }

.header__mobile {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  flex-direction: column;
  padding-inline: var(--gutter);
  padding-top: env(safe-area-inset-top);
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
  /* Site's own atmosphere — near-black base lit by a soft ember bloom from
     the top — rather than a distinct lighter surface with a hard edge. */
  background:
    radial-gradient(125% 80% at 50% -10%, color-mix(in srgb, var(--glow) 15%, transparent), transparent 55%),
    var(--color-bg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease),
    visibility 0s linear var(--dur);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.header.is-open .header__mobile {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}

/* top row mirrors the real header bar so opening reads as an expansion */
.header__mobile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  margin-bottom: clamp(1rem, 6vh, 3rem);
  border-bottom: 1px solid var(--color-border);
}
.header__mobile-head .h3 { letter-spacing: 0.18em; }

/* links centered in the remaining space, large gothic display */
.header__mobile-menu {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: clamp(0.5rem, 3vh, 1.25rem);
  text-align: center;
}
.header__mobile-menu li { width: 100%; }
.header__mobile-link {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  font-family: var(--font-heading);
  font-size: clamp(1.9rem, 8vw, 2.75rem);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text);
  transition: color var(--dur) var(--ease), text-shadow var(--dur) var(--ease);
}
.header__mobile-link:hover,
.header__mobile-link:active {
  color: var(--glow);
  text-shadow: 0 0 24px var(--glow-soft);
}

/* staggered rise-in of each link as the menu opens */
.header.is-open .header__mobile-link { animation: menuLinkIn var(--dur) var(--ease) both; }
.header.is-open li:nth-child(1) .header__mobile-link { animation-delay: 0.08s; }
.header.is-open li:nth-child(2) .header__mobile-link { animation-delay: 0.14s; }
.header.is-open li:nth-child(3) .header__mobile-link { animation-delay: 0.20s; }
.header.is-open li:nth-child(4) .header__mobile-link { animation-delay: 0.26s; }
.header.is-open li:nth-child(5) .header__mobile-link { animation-delay: 0.32s; }
.header.is-open li:nth-child(6) .header__mobile-link { animation-delay: 0.38s; }
@keyframes menuLinkIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

body.overflow-hidden { overflow: hidden; }

@media (max-width: 900px) {
  .header__nav { display: none; }
  .header__nav-toggle { display: inline-flex; }
  .header__inner { grid-template-columns: auto 1fr auto; }
  .header__logo { justify-self: center; }
}
