/* ==========================================================================
   Header — sticky, auto-hides on scroll down, returns on scroll up
   ========================================================================== */

.header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--u-paper);
  will-change: transform;
}

.header__bar {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 3vw, 2.5rem);
  height: var(--header-h);
}

/* --- Logo: die-cut sticker treatment -------------------------------------- */

.header__logo {
  flex: 0 0 auto;
  display: block;
  line-height: 0;
  transition: rotate var(--t-mid) var(--ease-back);
}
.header__logo img {
  width: auto;
  height: 54px;
  filter: drop-shadow(3px 3px 0 var(--u-accent));
}
.header__logo:hover { rotate: -4deg; }

/* --- Nav ------------------------------------------------------------------ */

.header__nav { flex: 1 1 auto; }

.header__links {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 2vw, 1.75rem);
}

.header__link {
  position: relative;
  display: inline-block;
  padding: 0.4rem 0.2rem;
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 400;
  /* Scramble hover swaps characters; a fixed width stops the row twitching. */
  font-variant-numeric: tabular-nums;
}

.header__link::after {
  content: '';
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 3px;
  border-radius: 2px;
  background: var(--u-primary);
  scale: 0 1;
  transform-origin: left center;
  transition: scale var(--t-mid) var(--ease-out);
}

.header__link:hover::after,
.header__link:focus-visible::after,
.header__link.is-active::after { scale: 1 1; }

.header__link.is-active { color: var(--u-primary); }

@media (max-width: 900px) { .header__nav { display: none; } }

/* --- Actions -------------------------------------------------------------- */

.header__actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
}

.header__icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--r-pill);
  color: var(--u-ink);
  transition: background-color var(--t-fast), color var(--t-fast), scale var(--t-fast) var(--ease-back);
}
.header__icon svg { width: 22px; height: 22px; }
.header__icon:hover { background: var(--u-primary); color: var(--on-primary); scale: 1.08; }

.header__cart { position: relative; }

.header__count {
  position: absolute;
  top: 2px;
  right: 2px;
  display: grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding-inline: 4px;
  border: 2px solid var(--u-ink);
  border-radius: var(--r-pill);
  background: var(--u-accent);
  color: var(--u-ink);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 400;
  line-height: 1;
}

/* --- Burger --------------------------------------------------------------- */

.header__burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  padding: 0 9px;
}
.header__burger span {
  display: block;
  height: 3px;
  border-radius: 2px;
  background: var(--u-ink);
  transition: translate var(--t-mid) var(--ease-out), rotate var(--t-mid) var(--ease-out), opacity var(--t-fast);
}
.header__burger[aria-expanded='true'] span:nth-child(1) { translate: 0 8px; rotate: 45deg; }
.header__burger[aria-expanded='true'] span:nth-child(2) { opacity: 0; }
.header__burger[aria-expanded='true'] span:nth-child(3) { translate: 0 -8px; rotate: -45deg; }

@media (max-width: 900px) { .header__burger { display: flex; } }

/* --- Torn edge ------------------------------------------------------------ */

.header__edge {
  position: absolute;
  inset-inline: 0;
  bottom: -11px;
  width: 100%;
  height: 12px;
  pointer-events: none;
}

/* --- Mobile curtain menu -------------------------------------------------- */

.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: var(--z-menu);
  display: grid;
  place-items: center;
  background: var(--u-secondary);
  color: var(--u-white);
  /* JS animates this open; the closed state is the authored default. */
  clip-path: inset(0 0 100% 0);
}

.mobile-menu[hidden] { display: none; }

.mobile-menu__links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  text-align: center;
}

.mobile-menu__item { overflow: hidden; }

.mobile-menu__link {
  display: inline-block;
  padding: 0.4rem 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 9vw, 3.25rem);
  font-weight: 400;
  line-height: 1.15;
}
