.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: color-mix(in srgb, var(--cream) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 84px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.nav-brand img {
  height: 40px;
  width: auto;
  display: block;
}
.nav-brand-mark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.6rem;
  color: var(--navy);
}
.nav-brand-name {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--charcoal);
  letter-spacing: 0.01em;
}

.nav { display: none; }
.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}
.nav-links > li > a,
.nav-trigger {
  display: inline-block;
  padding: 10px 14px;
  color: var(--charcoal);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
}
.nav-links > li > a:hover,
.nav-trigger:hover,
.nav-links > li > a.is-active { background: var(--cream-tint); color: var(--navy-mid); text-decoration: none; }

.nav-actions { display: flex; align-items: center; gap: 14px; }
.nav-actions .btn-primary { display: none; flex-shrink: 0; }

/* ---- Mega menu ----
   Two states. Opening the menu shows ONLY the seven category names in a narrow
   column; hovering a category unfolds the panel to the right. The width
   transition is what sells it, so the panel must be measured, not instant. */
.nav-item.has-mega { position: relative; }
/* Anchored to the trigger's left edge so it can only ever grow rightwards —
   a centred panel overflowed the viewport at 1024-1280px. The expanded width
   (and, in the tight case, a leftward nudge) is measured in js/mega-menu.js;
   296px here is the collapsed width and the no-JS fallback. */
.mega {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  width: 296px;                    /* collapsed: category column only */
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding-top: 4px;
  overflow: hidden;                /* clips the panel column while collapsed */
  transition: width 420ms cubic-bezier(0.22, 1, 0.36, 1),
              left 420ms cubic-bezier(0.22, 1, 0.36, 1);
}
.mega.is-open { display: block; }

.mega-inner { display: grid; grid-template-columns: 260px 1fr; }
.mega-cats { list-style: none; padding: 20px 0; border-right: 1px solid transparent; transition: border-color 260ms ease; }
.mega.is-expanded .mega-cats { border-right-color: var(--line); }
.mega-cat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 22px;
  color: var(--charcoal);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.92rem;
  border-left: 2px solid transparent;
  transition: background 200ms ease, color 200ms ease, border-color 200ms ease;
}
/* The chevron is the affordance that says "there is more behind this row" */
.mega-cat::after {
  content: '';
  width: 6px;
  height: 6px;
  flex-shrink: 0;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg) translateX(-2px);
  opacity: 0.35;
  transition: opacity 200ms ease, transform 200ms ease;
}
.mega-cat.is-active,
.mega-cat:hover,
.mega-cat:focus-visible {
  background: var(--cream-tint);
  color: var(--navy-mid);
  border-left-color: var(--navy-mid);
  text-decoration: none;
}
.mega-cat.is-active::after,
.mega-cat:hover::after,
.mega-cat:focus-visible::after { opacity: 1; transform: rotate(-45deg) translateX(1px); }

.mega-panels { position: relative; }
.mega-panel { display: none; padding: 28px 32px; }
/* An `animation` (not a transition) because the panel goes display:none ->
   block, and transitions never fire across a display change. */
.mega-panel.is-shown { display: block; animation: megaPanelIn 360ms cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes megaPanelIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: none; }
}
/* Sublinks arrive just behind the panel, staggered — reads as unfolding
   rather than a hard swap. Capped at 10 so a long list never lags. */
.mega-panel.is-shown .mega-sublinks li { animation: megaLinkIn 320ms ease both; }
.mega-panel.is-shown .mega-sublinks li:nth-child(1) { animation-delay: 90ms; }
.mega-panel.is-shown .mega-sublinks li:nth-child(2) { animation-delay: 120ms; }
.mega-panel.is-shown .mega-sublinks li:nth-child(3) { animation-delay: 150ms; }
.mega-panel.is-shown .mega-sublinks li:nth-child(4) { animation-delay: 180ms; }
.mega-panel.is-shown .mega-sublinks li:nth-child(5) { animation-delay: 210ms; }
.mega-panel.is-shown .mega-sublinks li:nth-child(6) { animation-delay: 240ms; }
.mega-panel.is-shown .mega-sublinks li:nth-child(7) { animation-delay: 265ms; }
.mega-panel.is-shown .mega-sublinks li:nth-child(n+8) { animation-delay: 290ms; }
@keyframes megaLinkIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.mega-blurb { color: var(--charcoal-soft); font-size: 0.92rem; margin-bottom: 16px; }
.mega-sublinks { list-style: none; columns: 2; column-gap: 24px; margin-bottom: 18px; }
.mega-sublinks li { break-inside: avoid; margin-bottom: 8px; }
.mega-sublinks a { color: var(--charcoal); font-size: 0.9rem; text-decoration: none; }
.mega-sublinks a:hover { color: var(--navy-mid); text-decoration: underline; }
.mega-cta { font-weight: 600; color: var(--navy-mid); font-size: 0.92rem; }

/* Respect the OS setting — the unfold becomes an instant state change. */
@media (prefers-reduced-motion: reduce) {
  .mega { transition: none; }
  .mega-panel.is-shown,
  .mega-panel.is-shown .mega-sublinks li { animation: none; }
}

/* ---- Hamburger ---- */
.nav-toggle {
  display: inline-flex;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  padding: 8px;
}
.nav-toggle span {
  width: 22px;
  height: 2px;
  background: var(--navy);
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---- Mobile nav panel ---- */
.nav-mobile {
  display: none;
  position: fixed;
  inset: 84px 0 0 0;
  background: var(--cream);
  z-index: 999;
  overflow-y: auto;
  padding: 24px clamp(20px, 4vw, 48px) 40px;
}
.nav-mobile.is-open { display: block; }
.nav-mobile-links { list-style: none; }
.nav-mobile-links > li { border-bottom: 1px solid var(--line); }
.nav-mobile-links > li > a {
  display: block;
  padding: 16px 4px;
  color: var(--navy);
  text-decoration: none;
  font-weight: 500;
  font-size: 1.05rem;
}
.mega-mobile summary {
  padding: 16px 4px;
  font-weight: 500;
  font-size: 1.05rem;
  color: var(--navy);
  cursor: pointer;
  list-style: none;
}
.mega-mobile summary::-webkit-details-marker { display: none; }
.mega-mobile summary::after { content: '+'; float: right; color: var(--navy-mid); }
.mega-mobile[open] summary::after { content: '\2212'; }
.mega-mobile-list { list-style: none; padding-left: 8px; }
.mega-mobile-cat { border-top: 1px solid var(--line); padding: 4px 0; }
.mega-mobile-cat summary { font-size: 0.95rem; font-weight: 600; }
.mega-mobile-cat ul { list-style: none; padding: 4px 0 12px 12px; }
.mega-mobile-cat ul li { margin-bottom: 8px; }
.mega-mobile-cat a { color: var(--charcoal); font-size: 0.9rem; text-decoration: none; }
.mega-mobile-view { color: var(--navy-mid) !important; font-weight: 600; }
.nav-mobile .btn { margin-top: 20px; }

@media (min-width: 1024px) {
  .nav { display: block; }
  .nav-toggle { display: none; }
  .nav-actions .btn-primary { display: inline-flex; }
  .nav-mobile { display: none !important; }
}
