/**
 * The shop header, styled to match the Next.js site's header exactly (2026-09-18).
 *
 * Ported from site/src/components/layout/Nav.tsx (inline styles + its <style> block), ThemeToggle.tsx and
 * SoundDemo.tsx, plus .frame / .btn--sm from site/src/styles/globals.css. Values are copied, not eyeballed —
 * if the site's header changes, change it here in the same pass.
 *
 * The bridge below maps the site's token names onto the shop's, so the rules underneath can stay identical to
 * the site's. ⚠️ The class names are namespaced `sfh-*` on purpose: the OLD header's rules in product-page.css
 * and checkout.css are full of !important and would otherwise win. Those rules are now dead for shop, product,
 * checkout and legal pages (they still style the one-off page-manual/page-app/page-demo headers) — removing
 * them is a separate cleanup. The four classes the theme-toggle script drives by name (sf-theme-dot,
 * sf-theme-label, sf-logo-light, sf-logo-dark) keep their original names deliberately.
 */
#sfh-nav {
  /* The theme's body line-height (24px) leaked in and made every control taller than the site's:
     the price button 46px against 37px, the nav links 28px against 20px. The site's header inherits
     `normal`, so the header re-establishes it and its children inherit from here (measured 2026-09-18). */
  line-height: normal;
  --line: var(--sf-nav-border, rgba(26, 26, 26, .12));
  --fg: var(--sf-fg, #1a1a1a);
  --bg: var(--sf-bg, #f4f3f0);
  --nav-bg: var(--sf-nav-bg, rgba(244, 243, 240, .88));
  --burgundy: #a0153a;
  --gray: #adb9ca;
  --accent: var(--burgundy);
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --sans: 'Inter Tight', system-ui, sans-serif;
  --frame-max: 1440px;
  --frame-pad: 40px;

  position: sticky;
  position: -webkit-sticky;
  top: 0;
  z-index: 50;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  background: var(--nav-bg);
  border-bottom: 1px solid var(--line);
  font-family: var(--sans);
  color: var(--fg);
}

html[data-theme='dark'] #sfh-nav {
  --accent: var(--gray);
}

/* .frame on the site: max-width 1440, 40px gutters (20px under 900px) */
#sfh-nav .sfh-frame {
  max-width: var(--frame-max);
  margin: 0 auto;
  padding: 0 var(--frame-pad);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 68px;
}

#sfh-nav .sfh-logo { display: flex; align-items: center; }
#sfh-nav .sfh-logo img { display: block; width: auto; height: auto; max-width: 77px; }
/* Both wordmarks are in the DOM and the theme script swaps them by inline style; CSS decides the first paint.
   These selectors carry the `img` type on purpose — without it the rule above wins and BOTH logos show. */
#sfh-nav .sfh-logo img.sf-logo-dark { display: none; }
html[data-theme='dark'] #sfh-nav .sfh-logo img.sf-logo-light { display: none; }
html[data-theme='dark'] #sfh-nav .sfh-logo img.sf-logo-dark { display: block; }

#sfh-nav .sfh-links { display: flex; gap: 28px; }
#sfh-nav .sfh-links a {
  font-size: 13px;
  letter-spacing: .02em;
  font-weight: 400;
  opacity: .75;
  color: inherit;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  padding-bottom: 2px;
}
#sfh-nav .sfh-links a.is-active {
  font-weight: 600;
  opacity: 1;
  border-bottom-color: var(--accent);
}

#sfh-nav .sfh-right {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-self: end;
}

/* HEAR button and the day/night pill share the site's pill shape */
#sfh-nav .sfh-hear-btn,
#sfh-nav .sfh-theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all .2s ease;
}
#sfh-nav .sfh-theme-btn { gap: 8px; }
#sfh-nav .sf-theme-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--burgundy);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--fg) 10%, transparent);
}
html[data-theme='dark'] #sfh-nav .sf-theme-dot { background: var(--gray); }

#sfh-nav .sfh-hear-btn.is-open {
  background: #fdf0f2;
  border-color: var(--accent);
  color: var(--accent);
}
html[data-theme='dark'] #sfh-nav .sfh-hear-btn.is-open {
  background: #050510;
  border-color: #00f5ff;
  color: #00f5ff;
}

/* .btn.btn--sm with the burgundy modifier */
#sfh-nav .sfh-cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  border: 1px solid var(--burgundy);
  border-radius: 999px;
  background: var(--burgundy);
  color: #fff;
  text-decoration: none;
  transition: transform .2s ease, background .2s, color .2s;
}
#sfh-nav .sfh-cta:hover { transform: translateY(-1px); }

#sfh-nav .sfh-burger {
  display: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--fg);
  cursor: pointer;
}
#sfh-nav .sfh-burger span {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  margin: 4px 0;
}

/* ── mobile drawer — copied from Nav.tsx's <style> block ─────────────────────── */
@media (max-width: 900px) {
  #sfh-nav .sfh-links { display: none !important; }
  #sfh-nav .sfh-burger { display: inline-block !important; }
  #sfh-nav .sfh-top-theme { display: none !important; }
  /* logo | content-sized right cluster → cluster flush-right, no pill-shrink */
  #sfh-nav .sfh-frame { grid-template-columns: 1fr auto !important; padding: 0 20px; }
}

#sfh-nav .sfh-drawer {
  display: grid;
  padding: 6px 20px 18px;
  border-top: 1px solid var(--line);
  background: var(--nav-bg);
}
#sfh-nav .sfh-drawer[hidden] { display: none; }
#sfh-nav .sfh-drawer-link {
  font-size: 17px;
  font-weight: 500;
  color: var(--fg);
  text-decoration: none;
  padding: 15px 14px;
  min-height: 50px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
#sfh-nav .sfh-drawer-link:last-of-type { border-bottom: none; }
#sfh-nav .sfh-drawer-link.is-active {
  color: var(--burgundy);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--burgundy);
}
#sfh-nav .sfh-drawer-theme {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 4px;
  margin-top: 6px;
  border-top: 1px solid var(--line);
}
#sfh-nav .sfh-drawer-theme > span {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: .6;
}

/* ── sound demo panel — SoundDemo.tsx ────────────────────────────────────────── */
#sfh-nav .sfh-hear-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  overflow: hidden;
  max-height: 0;
  transition: max-height .28s cubic-bezier(.4, 0, .2, 1);
  z-index: 49;
}
#sfh-nav .sfh-hear-panel.is-open { max-height: 420px; }
#sfh-nav .sfh-hear-inner {
  background: color-mix(in oklch, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  padding: 14px 24px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
#sfh-nav .sfh-hear-play {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--burgundy);
  color: #fff;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
html[data-theme='dark'] #sfh-nav .sfh-hear-play { background: #00f5ff; color: #050510; }
#sfh-nav #sfh-hear-canvas { flex-shrink: 0; }
#sfh-nav .sfh-hear-modes {
  display: flex;
  border: 1px solid color-mix(in oklch, var(--accent) 33%, transparent);
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
}
#sfh-nav .sfh-hear-mode {
  padding: 7px 14px;
  background: transparent;
  color: color-mix(in oklch, var(--accent) 85%, transparent);
  border: none;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  transition: all .2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
#sfh-nav .sfh-hear-mode.is-active { background: var(--burgundy); color: #fff; }
html[data-theme='dark'] #sfh-nav .sfh-hear-mode.is-active { background: #00f5ff; color: #050510; }
#sfh-nav .sfh-hear-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  display: none;
  animation: sfHearDot 1s ease-in-out infinite;
}
#sfh-nav .sfh-hear-mode.is-active .sfh-hear-dot { display: inline-block; }
#sfh-nav .sfh-hear-pills { display: flex; gap: 5px; flex-wrap: wrap; }
#sfh-nav .sfh-hear-pills[hidden] { display: none; }
#sfh-nav .sfh-hear-pill {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid color-mix(in oklch, var(--accent) 27%, transparent);
  background: transparent;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .08em;
  cursor: pointer;
  transition: all .15s;
}
#sfh-nav .sfh-hear-pill.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
html[data-theme='dark'] #sfh-nav .sfh-hear-pill.is-active { color: #050510; }
#sfh-nav .sfh-hear-caption {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  opacity: .55;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}
#sfh-nav .sfh-hear-caption.is-detecting {
  opacity: 1;
  animation: sfHearPulse .35s ease-in-out infinite alternate;
}

/* Scrim behind the open panel — a sibling of the header, as on the site */
.sfh-hear-scrim {
  position: fixed;
  inset: 0;
  z-index: 48;
  background: rgba(0, 0, 0, .45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.sfh-hear-scrim.is-open { opacity: 1; pointer-events: auto; }

@keyframes sfHearPulse { from { opacity: .4; } to { opacity: 1; } }
@keyframes sfHearDot { 0%, 100% { opacity: .6; } 50% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  #sfh-nav .sfh-hear-panel,
  .sfh-hear-scrim,
  #sfh-nav .sfh-cta { transition: none; }
  #sfh-nav .sfh-hear-caption.is-detecting,
  #sfh-nav .sfh-hear-dot { animation: none; }
}
