/**
 * Fablely shared site navigation
 * ==============================
 * Sticky header with hamburger drawer on mobile (≤820px), horizontal nav on desktop.
 * Designed to drop into every page that includes a <nav class="site-nav">.
 *
 * Markup contract (see index.html for the canonical version):
 *
 *   <nav class="site-nav" id="site-nav">
 *     <div class="container nav-inner">
 *       <a href="/" class="site-logo">✦ Fablely</a>
 *       <button class="nav-hamburger" id="nav-hamburger"
 *               aria-label="Menu" aria-expanded="false" aria-controls="nav-collapse">
 *         <span class="bar"></span><span class="bar"></span><span class="bar"></span>
 *       </button>
 *       <div class="nav-collapse" id="nav-collapse">
 *         <div class="nav-links">
 *           <a class="nav-link" href="/app"     data-page="app"     data-i18n="nav.naming">Naming</a>
 *           <a class="nav-link" href="/story"   data-page="story"   data-i18n="nav.voice">Voice stories</a>
 *           <a class="nav-link" href="/vault"   data-page="vault"   data-i18n="nav.vault">Voice vault</a>
 *           <a class="nav-link" href="/pricing" data-page="pricing" data-i18n="nav.pricing">Pricing</a>
 *           <a class="nav-link" href="/about"   data-page="about"   data-i18n="nav.about">About</a>
 *         </div>
 *         <div class="nav-utility">
 *           <select id="lang-switcher" class="lang-switcher" aria-label="Language">…</select>
 *           <div id="auth-nav"></div>
 *         </div>
 *       </div>
 *     </div>
 *   </nav>
 *
 * Wire-up JS lives in /public/nav.js (hamburger toggle, active-link, auth widget).
 */

/* ===== Sticky header shell ===== */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 248, 240, 0.92);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid rgba(244, 232, 214, 0.6);
  /* CLS-safe — reserve height before fonts/JS load */
  min-height: 64px;
}
.site-nav .nav-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  min-height: 64px;
}
.site-nav .site-logo {
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -0.02em;
  color: #1A1F25;
  text-decoration: none;
  flex-shrink: 0;
  line-height: 1;
}
.site-nav .site-logo .star { color: #F4A261; margin-right: 4px; }

/* Hamburger button — hidden on desktop, shown on mobile */
.nav-hamburger {
  display: none;
  width: 44px;
  height: 44px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  padding: 10px;
  margin-left: auto;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  transition: background 0.15s, border-color 0.15s;
}
.nav-hamburger:hover,
.nav-hamburger:focus-visible { background: #FFF1DC; border-color: #F4D8B6; outline: none; }
.nav-hamburger .bar {
  display: block;
  width: 22px;
  height: 2.5px;
  background: #1A1F25;
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.2s ease;
}
.nav-hamburger[aria-expanded="true"] .bar:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
.nav-hamburger[aria-expanded="true"] .bar:nth-child(2) { opacity: 0; }
.nav-hamburger[aria-expanded="true"] .bar:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }

/* Collapse area — desktop: row, mobile: drawer */
.nav-collapse {
  display: flex;
  align-items: center;
  gap: 22px;
  flex: 1;
  justify-content: flex-end;
}
.site-nav .nav-links {
  display: flex;
  gap: 22px;
  align-items: center;
}
.site-nav .nav-link {
  font-weight: 700;
  color: #5A6470;
  font-size: 15px;
  text-decoration: none;
  padding: 8px 4px;
  border-radius: 6px;
  white-space: nowrap;
  transition: color 0.15s;
  position: relative;
}
.site-nav .nav-link:hover,
.site-nav .nav-link:focus-visible { color: #C76F1F; outline: none; }
.site-nav .nav-link:focus-visible {
  box-shadow: 0 0 0 3px rgba(244, 162, 97, 0.35);
}
.site-nav .nav-link.active { color: #C76F1F; }
.site-nav .nav-link.active::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 0;
  height: 2px;
  background: #F4A261;
  border-radius: 2px;
}
.nav-utility {
  display: flex;
  align-items: center;
  gap: 12px;
}
.lang-switcher {
  border: 1px solid #F4E8D6;
  background: #fff;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 700;
  color: #5A6470;
  cursor: pointer;
  font-family: inherit;
}

/* Body lock when drawer open */
body.nav-drawer-open { overflow: hidden; }

/* ===== Mobile (≤820px) ===== */
@media (max-width: 820px) {
  .nav-hamburger { display: flex; }

  /* Drawer */
  .nav-collapse {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    background: #FFF8F0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0;
    border-bottom: 1px solid #F4E8D6;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.28s ease;
  }
  .site-nav[data-drawer-open="true"] .nav-collapse {
    max-height: calc(100vh - 64px);
    overflow-y: auto;
  }
  .site-nav .nav-links {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 6px 0;
  }
  .site-nav .nav-link {
    padding: 14px 24px;
    font-size: 16px;
    border-radius: 0;
    border-top: 1px solid #FBF1E2;
    color: #1A1F25;
  }
  .site-nav .nav-link:first-child { border-top: none; }
  .site-nav .nav-link.active::after { display: none; }
  .site-nav .nav-link.active {
    background: #FFF1DC;
    border-left: 3px solid #F4A261;
    padding-left: 21px;
  }
  .nav-utility {
    padding: 18px 24px 22px;
    justify-content: space-between;
    border-top: 1px solid #FBF1E2;
    flex-wrap: wrap;
    gap: 14px;
  }
}

/* ===== Skip link (a11y) ===== */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: #1A1F25;
  color: #fff;
  padding: 12px 18px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
}
.skip-link:focus {
  left: 16px;
  top: 12px;
}

/* ===== Reduce-motion ===== */
@media (prefers-reduced-motion: reduce) {
  .nav-hamburger .bar,
  .nav-collapse,
  .nav-link {
    transition: none !important;
  }
}
