/* ===================================================================
   VocaGift canonical header — single source of truth for the top bar.

   Used by every published page: the five homepages (index), the core
   app pages (wizard, studio, samples, my-songs, …) and the occasion /
   SEO landing pages. Those three families ship three different CSS
   architectures (app.min.css utilities, inline :root variables, and
   bare inline styles), so this file is deliberately self-contained:
   it needs no Tailwind, no CDN and no page-level stylesheet.

   Dark is the default. Every light rule is scoped under html.light so
   the existing dark rendering is untouched.

   Naming: every class is prefixed `vgh-` (VocaGift Header) so it can
   never collide with a page's own `.brand` / `.nav-link` / utility
   classes.
   =================================================================== */

.vg-header {
  /* Dark palette (default) */
  --vgh-bg: rgba(7, 11, 20, 0.92);
  --vgh-line: rgba(255, 255, 255, 0.10);
  --vgh-fg: #f1f5f9;
  --vgh-mut: #9aa4b8;
  --vgh-capsule: rgba(255, 255, 255, 0.06);
  --vgh-hover: rgba(255, 255, 255, 0.06);
  --vgh-soft: rgba(168, 85, 247, 0.16);
  --vgh-soft-line: rgba(168, 85, 247, 0.38);
  --vgh-accent-fg: #ddd0ff;

  /* Reset the bare `header { … }` rules the legacy occasion pages carry
     (display:flex, padding-bottom, margin-bottom) so the bar renders
     identically on every page family. */
  display: block;
  margin: 0;
  padding: 0;
  text-align: left;

  position: sticky;
  top: 0;
  z-index: 40;
  width: 100%;
  background: var(--vgh-bg);
  border: 0;
  border-bottom: 1px solid var(--vgh-line);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: background-color .2s ease, border-color .2s ease;
}

/* index.html keeps a `dark` class on <html> as well as `light`, so the
   light rules below are keyed on `.light` with higher specificity than a
   bare `.vg-header` rather than on the absence of `dark`. */
html.light .vg-header,
html.dark.light .vg-header {
  --vgh-bg: rgba(255, 255, 255, 0.96);
  --vgh-line: #dfe1ef;
  --vgh-fg: #1b1d2e;
  --vgh-mut: #596178;
  --vgh-capsule: rgba(15, 23, 42, 0.04);
  --vgh-hover: rgba(15, 23, 42, 0.05);
  --vgh-soft: rgba(147, 51, 234, 0.10);
  --vgh-soft-line: rgba(147, 51, 234, 0.28);
  --vgh-accent-fg: #6d28d9;
  background-color: var(--vgh-bg);
}

/* ── Bar ─────────────────────────────────────────────────────────── */
.vgh-bar {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1rem;
  min-height: 4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* The header used to sit inside each page's own container, which supplied
   the gap above the content. At body level that buffer is gone, and the
   CTA's glow overlapped the first card on terms/privacy/refunds.
   A margin on the header itself is the only reliable hook: several pages
   put out-of-flow decoration layers (orbs, overlays) immediately after
   <body>, so a `+ *` sibling rule would target those instead of the real
   content. The header is sticky and therefore still in flow, so its
   bottom margin is what separates it from everything below. */
.vg-header {
  margin-bottom: 1.25rem;
}

@media (min-width: 640px) {
  .vgh-bar { padding: 0 1.5rem; min-height: 5rem; }
}

/* ── Brand ───────────────────────────────────────────────────────── */
.vgh-brand {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  flex: 0 0 auto;
  text-decoration: none;
  color: inherit;
}
.vgh-brand img {
  width: 2.5rem;
  height: 2.5rem;
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 2px 10px rgba(250, 204, 21, 0.3));
  transition: transform .2s ease;
}
@media (min-width: 640px) {
  .vgh-brand img { width: 2.75rem; height: 2.75rem; }
}
.vgh-brand:hover img { transform: scale(1.05); }
.vgh-word {
  font-weight: 900;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--vgh-fg);
  white-space: nowrap;
}
@media (min-width: 640px) { .vgh-word { font-size: 1.5rem; } }
.vgh-word span {
  background: linear-gradient(135deg, #a78bfa, #ec4899);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
html.light .vgh-word span {
  background: linear-gradient(135deg, #7c3aed, #db2777);
  -webkit-background-clip: text;
  background-clip: text;
}

/* ── Centre capsule (Wizard | Studio) ────────────────────────────── */
.vgh-capsule {
  display: none;
  align-items: center;
  gap: .375rem;
  padding: .375rem;
  border-radius: 1rem;
  background: var(--vgh-capsule);
  border: 1px solid var(--vgh-line);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .18);
}
@media (min-width: 640px) { .vgh-capsule { display: flex; } }

.vgh-cap-link {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .5rem 1.25rem;
  border-radius: .75rem;
  font-size: .875rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--vgh-mut);
  transition: color .15s ease, background-color .15s ease;
  white-space: nowrap;
}
.vgh-cap-link:hover {
  color: var(--vgh-fg);
  background: var(--vgh-hover);
}
.vgh-cap-link[aria-current="page"] {
  background: linear-gradient(135deg, #9333ea, #db2777);
  color: #fff;
  box-shadow: 0 4px 14px rgba(147, 51, 234, 0.32);
}
.vgh-cap-link[aria-current="page"]:hover {
  background: linear-gradient(135deg, #9333ea, #db2777);
  color: #fff;
}

/* ── Right cluster (desktop) ─────────────────────────────────────── */
/* Breakpoints come from measuring the real parts, not from guessing:
     brand 159px · capsule 232px · links+CTA 347px · lang+theme 177px
     burger 42px · bar gap 1rem

       < 640     brand + burger                            (~240px) ok
       640-859   brand + capsule + burger                  (~470px) ok
       860-1119  brand + capsule + links + CTA + burger    (~820px) ok
       >= 1120   everything inline, burger gone           (~1010px) ok

   Whatever does not fit moves into the drawer, which stays reachable
   through the burger, so no control is ever lost. */
.vgh-right {
  display: none;
  align-items: center;
  gap: .5rem;
  min-width: 0;
}

/* Links + CTA appear once the bar can hold them next to the capsule.
   960px, not 860: the bar is narrower than the viewport on pages whose
   <body> adds horizontal padding, and at 860-900 the CTA still spilled
   over on terms.html and business.html. */
@media (min-width: 960px) {
  .vgh-right { display: flex; }
}

/* Secondary controls (language + theme) wait for the widest layout;
   below that they live in the drawer. */
@media (max-width: 1119px) {
  .vgh-right .vgh-lang,
  .vgh-right .vgh-theme { display: none !important; }
}

@media (min-width: 1120px) {
  .vgh-right { gap: .75rem; }
  .vgh-right .vgh-lang,
  .vgh-right .vgh-theme { display: inline-flex; }
}

.vgh-nav-link {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .875rem;
  border-radius: .75rem;
  font-size: .875rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--vgh-mut);
  border: 1px solid transparent;
  transition: color .15s ease, background-color .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.vgh-nav-link:hover {
  color: var(--vgh-fg);
  background: var(--vgh-hover);
  border-color: var(--vgh-line);
}
.vgh-nav-link--songs {
  font-weight: 700;
  color: var(--vgh-accent-fg);
  background: var(--vgh-soft);
  border-color: var(--vgh-soft-line);
}
.vgh-nav-link--songs:hover {
  color: var(--vgh-fg);
  background: var(--vgh-soft);
  border-color: var(--vgh-soft-line);
}

/* Primary CTA */
.vgh-cta {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .625rem 1.25rem;
  border-radius: .75rem;
  font-size: .875rem;
  font-weight: 800;
  text-decoration: none;
  color: #fff;
  /* #db2777 instead of #ec4899: white on the pinkest end measures 4.60:1
     (WCAG AA for normal text) where #ec4899 only reached 3.53:1. */
  background: linear-gradient(135deg, #9333ea, #db2777);
  box-shadow: 0 8px 22px rgba(168, 85, 247, 0.28);
  transition: transform .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.vgh-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(236, 72, 153, 0.34);
  color: #fff;
}
.vgh-cta:active { transform: translateY(0); }

/* ── Language selector ───────────────────────────────────────────── */
.vgh-lang {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--vgh-capsule);
  color: var(--vgh-fg);
  color-scheme: dark;
  border: 1px solid var(--vgh-line);
  border-radius: .75rem;
  font-size: .75rem;
  font-weight: 700;
  padding: .4rem 1.6rem .4rem .6rem;
  cursor: pointer;
  outline: none;
  transition: background-color .15s ease, border-color .15s ease;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%239aa4b8'%3E%3Cpath d='M4 6l4 4 4-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .45rem center;
  background-size: .7rem;
}
html.light .vgh-lang {
  color-scheme: light;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23596178'%3E%3Cpath d='M4 6l4 4 4-4z'/%3E%3C/svg%3E");
}
.vgh-lang:hover { border-color: var(--vgh-soft-line); }
.vgh-lang option {
  background-color: #0b0f19;
  color: #fff;
}
html.light .vgh-lang option {
  background-color: #fff;
  color: #1b1d2e;
}

/* ── Theme toggle (painted by assets/vg-theme.js) ────────────────── */
.vgh-theme {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .5rem .75rem;
  border-radius: .75rem;
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--vgh-mut);
  background: var(--vgh-capsule);
  border: 1px solid var(--vgh-line);
  transition: color .15s ease, background-color .15s ease;
  white-space: nowrap;
}
.vgh-theme:hover {
  color: var(--vgh-fg);
  background: var(--vgh-hover);
}
.vgh-theme:focus-visible,
.vgh-burger:focus-visible,
.vgh-cap-link:focus-visible,
.vgh-nav-link:focus-visible,
.vgh-cta:focus-visible,
.vgh-lang:focus-visible {
  outline: 2px solid #a855f7;
  outline-offset: 2px;
}

/* ── Mobile burger ───────────────────────────────────────────────── */
.vgh-burger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .5rem;
  border-radius: .75rem;
  cursor: pointer;
  color: var(--vgh-mut);
  background: var(--vgh-capsule);
  border: 1px solid var(--vgh-line);
  transition: color .15s ease;
}
@media (min-width: 1120px) { .vgh-burger { display: none; } }
.vgh-burger:hover { color: var(--vgh-fg); }
.vgh-burger svg { width: 1.5rem; height: 1.5rem; display: block; }

/* ── Mobile drawer ───────────────────────────────────────────────── */
.vgh-drawer {
  display: none;
  flex-direction: column;
  gap: .5rem;
  padding: .5rem 1rem 1rem;
  border-top: 1px solid var(--vgh-line);
  background: var(--vgh-bg);
}
.vgh-drawer[data-open="true"] { display: flex; }
/* The drawer stays available until the full desktop cluster appears. */
@media (min-width: 1120px) { .vgh-drawer { display: none !important; } }

.vgh-drawer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--vgh-line);
  margin-bottom: .25rem;
}
.vgh-drawer-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--vgh-mut);
}
.vgh-drawer-capsule {
  display: flex;
  align-items: center;
  gap: .25rem;
  padding: .25rem;
  border-radius: .75rem;
  background: var(--vgh-capsule);
  border: 1px solid var(--vgh-line);
  margin-bottom: .25rem;
}
.vgh-drawer-capsule .vgh-cap-link {
  flex: 1;
  justify-content: center;
  padding: .5rem .25rem;
  font-size: .75rem;
  text-align: center;
}
.vgh-drawer-link {
  display: block;
  padding: .625rem .75rem;
  border-radius: .75rem;
  font-size: .875rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--vgh-fg);
  background: var(--vgh-capsule);
  transition: background-color .15s ease;
}
.vgh-drawer-link:hover { background: var(--vgh-hover); }
.vgh-drawer-link--songs {
  color: var(--vgh-accent-fg);
  background: var(--vgh-soft);
}
.vgh-drawer .vgh-theme {
  justify-content: flex-start;
  font-size: .875rem;
  padding: .625rem .75rem;
}

/* Body scroll lock while the drawer is open */
body.vgh-lock { overflow: hidden; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .vg-header *,
  .vg-header *::before,
  .vg-header *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
