/* ========================================
   RSA Automatic Driving Lessons - Navigation
   Client: rsa-auto
   Phase 7A: Universal header & navigation overhaul

   Mobile-first responsive navigation with:
   - Sticky header with scroll shadow + backdrop blur
   - Desktop mega-menu dropdowns
   - Mobile hamburger slide-out drawer
   - Active page highlighting
   - Smooth transitions throughout

   Uses brand.css custom properties exclusively.
   Wrapped in @layer brand for cascade ordering.

   Authored: 2026-04-10 (Phase 7A, Pixel)
   ======================================== */

@layer brand {

/* ────────────────────────────────────────
   1. STICKY HEADER
   ──────────────────────────────────────── */

.auto-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border-subtle);
  transition: box-shadow 0.3s ease, background-color 0.3s ease;
}

.auto-nav.scrolled {
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
  background: rgba(12, 12, 13, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
  height: 64px;
}

/* ────────────────────────────────────────
   2. BRAND / LOGO
   ──────────────────────────────────────── */

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  flex-shrink: 0;
}

.nav-brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.nav-brand-title .brand-accent {
  color: var(--accent-primary);
}

/* ────────────────────────────────────────
   3. DESKTOP NAVIGATION (hidden mobile)
   ──────────────────────────────────────── */

.nav-primary {
  display: none;
}

.nav-links {
  display: flex;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 0;
}

.nav-links > li {
  position: relative;
}

/* Top-level nav items */
.nav-links > li > a,
.nav-links > li > button {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.85rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.2s ease;
  white-space: nowrap;
  height: 64px;
  line-height: 64px;
  padding-top: 0;
  padding-bottom: 0;
}

.nav-links > li > a:hover,
.nav-links > li > a:focus-visible,
.nav-links > li > button:hover,
.nav-links > li > button:focus-visible {
  color: var(--text-primary);
}

.nav-links > li > a[aria-current="page"],
.nav-links > li.active > a,
.nav-links > li.active > button {
  color: var(--accent-primary);
}

/* Dropdown chevron */
.nav-chevron {
  width: 10px;
  height: 10px;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.nav-links > li.dropdown-open > button .nav-chevron {
  transform: rotate(180deg);
}

/* ────────────────────────────────────────
   4. DROPDOWN PANELS
   ──────────────────────────────────────── */

.nav-dropdown {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  min-width: 200px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.nav-links > li.dropdown-open > .nav-dropdown {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.nav-dropdown a {
  display: block;
  padding: 0.6rem 1.1rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.nav-dropdown a:hover,
.nav-dropdown a:focus-visible {
  color: var(--text-primary);
  background: var(--bg-subtle);
}

.nav-dropdown a[aria-current="page"] {
  color: var(--accent-primary);
}

/* Dropdown subheading (for "Areas" mega-menu) */
.nav-dropdown-heading {
  display: block;
  padding: 0.5rem 1.1rem 0.25rem;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.nav-dropdown-heading:not(:first-child) {
  border-top: 1px solid var(--border-subtle);
  margin-top: 0.25rem;
  padding-top: 0.65rem;
}

/* Areas dropdown wider layout */
.nav-dropdown.dropdown-areas {
  min-width: 180px;
}

/* ────────────────────────────────────────
   5. RIGHT-SIDE ACTIONS (phone + CTA)
   ──────────────────────────────────────── */

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.nav-phone {
  display: none;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s ease;
  white-space: nowrap;
}

.nav-phone:hover,
.nav-phone:focus-visible {
  color: var(--text-primary);
}

.nav-phone-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-cta {
  display: none;
  align-items: center;
  padding: 0.5rem 1.1rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-on-accent);
  background: var(--accent-primary);
  border: none;
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
  white-space: nowrap;
}

.nav-cta:hover,
.nav-cta:focus-visible {
  background: var(--accent-primary-hover);
}

.nav-cta:active {
  transform: scale(0.97);
}

/* ────────────────────────────────────────
   6. HAMBURGER BUTTON (mobile only)
   ──────────────────────────────────────── */

.nav-hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 8px;
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
  z-index: 1010;
}

.nav-hamburger-bar {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Hamburger open state (X) */
.nav-hamburger[aria-expanded="true"] .nav-hamburger-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-hamburger[aria-expanded="true"] .nav-hamburger-bar:nth-child(2) {
  opacity: 0;
}

.nav-hamburger[aria-expanded="true"] .nav-hamburger-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ────────────────────────────────────────
   7. MOBILE DRAWER
   ──────────────────────────────────────── */

.mobile-drawer {
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999;
  background: var(--bg-deep);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-drawer.open {
  transform: translateX(0);
}

/* Overlay behind drawer */
.mobile-drawer-overlay {
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 998;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.mobile-drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.mobile-drawer-content {
  padding: 1rem 0 6rem;
}

/* Mobile nav groups */
.mobile-nav-group {
  border-bottom: 1px solid var(--border-subtle);
}

.mobile-nav-group:last-child {
  border-bottom: none;
}

.mobile-nav-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 1rem 1.25rem;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: none;
  border: none;
  cursor: pointer;
}

.mobile-nav-heading .mobile-chevron {
  width: 12px;
  height: 12px;
  transition: transform 0.2s ease;
  color: var(--text-muted);
}

.mobile-nav-group.open > .mobile-nav-heading .mobile-chevron {
  transform: rotate(180deg);
}

.mobile-nav-links {
  list-style: none;
  margin: 0;
  padding: 0 0 0.5rem;
  display: none;
}

.mobile-nav-group.open > .mobile-nav-links {
  display: block;
}

.mobile-nav-links a {
  display: block;
  padding: 0.65rem 1.25rem 0.65rem 2rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.mobile-nav-links a:hover,
.mobile-nav-links a:focus-visible {
  color: var(--text-primary);
  background: var(--bg-subtle);
}

.mobile-nav-links a[aria-current="page"] {
  color: var(--accent-primary);
}

/* Standalone mobile links (not grouped) */
.mobile-nav-standalone {
  border-bottom: 1px solid var(--border-subtle);
}

.mobile-nav-standalone a {
  display: block;
  padding: 1rem 1.25rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.mobile-nav-standalone a:hover,
.mobile-nav-standalone a:focus-visible {
  color: var(--text-primary);
  background: var(--bg-subtle);
}

.mobile-nav-standalone a[aria-current="page"] {
  color: var(--accent-primary);
}

/* Mobile CTA area */
.mobile-nav-cta {
  padding: 1.5rem 1.25rem;
}

.mobile-nav-cta .mobile-cta-btn {
  display: block;
  width: 100%;
  padding: 0.85rem 1.25rem;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-on-accent);
  background: var(--accent-primary);
  border: none;
  border-radius: var(--radius-md);
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.mobile-nav-cta .mobile-cta-btn:hover,
.mobile-nav-cta .mobile-cta-btn:focus-visible {
  background: var(--accent-primary-hover);
}

.mobile-nav-phone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  margin-top: 0.75rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  text-align: center;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.mobile-nav-phone:hover,
.mobile-nav-phone:focus-visible {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.mobile-nav-phone svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ────────────────────────────────────────
   8. FOOTER UPDATES
   ──────────────────────────────────────── */

.footer-cta-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  margin-top: 1rem;
}

.footer-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.5rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-on-accent);
  background: var(--accent-primary);
  border: none;
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.footer-cta-btn:hover,
.footer-cta-btn:focus-visible {
  background: var(--accent-primary-hover);
}

.footer-cta-btn:active {
  transform: scale(0.97);
}

.footer-cta-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ────────────────────────────────────────
   9. FOCUS STYLES (accessibility)
   ──────────────────────────────────────── */

.nav-links > li > a:focus-visible,
.nav-links > li > button:focus-visible,
.nav-dropdown a:focus-visible,
.nav-phone:focus-visible,
.nav-cta:focus-visible,
.nav-hamburger:focus-visible,
.mobile-nav-links a:focus-visible,
.mobile-nav-standalone a:focus-visible,
.mobile-cta-btn:focus-visible,
.mobile-nav-phone:focus-visible,
.footer-cta-btn:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* ────────────────────────────────────────
   10. BODY SCROLL LOCK (when mobile menu open)
   ──────────────────────────────────────── */

body.nav-open {
  overflow: hidden;
}

/* ────────────────────────────────────────
   11. DESKTOP BREAKPOINT (>= 768px)
   ──────────────────────────────────────── */

@media (min-width: 768px) {
  .nav-container {
    height: 72px;
    padding: 0 1.5rem;
  }

  .mobile-drawer,
  .mobile-drawer-overlay {
    top: 72px;
  }

  .nav-brand-title {
    font-size: 1.25rem;
  }

  .nav-phone {
    display: flex;
  }

  .nav-cta {
    display: inline-flex;
  }

  /* Hide hamburger on tablets that have enough width for phone + CTA */
}

/* Large desktop: show full navigation */
@media (min-width: 1024px) {
  .nav-container {
    gap: 1rem;
  }

  .nav-primary {
    display: block;
    flex: 1;
    margin: 0 0.5rem;
  }

  .nav-links {
    justify-content: center;
  }

  /* Hide hamburger on desktop */
  .nav-hamburger {
    display: none;
  }

  .mobile-drawer,
  .mobile-drawer-overlay {
    display: none;
  }
}

/* Extra large: more generous spacing */
@media (min-width: 1280px) {
  .nav-links > li > a,
  .nav-links > li > button {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

  .nav-phone {
    font-size: 0.9rem;
  }
}

} /* end @layer brand */
