/*
 * Mobile navigation — hamburger menu for viewports <= 768px.
 * Included on every page that has a <nav>. Works with both static
 * nav links and dynamically-injected content from auth-nav.js.
 * Does NOT own desktop nav styles — each page keeps its own.
 */

/* ---- HAMBURGER BUTTON (hidden on desktop) ---- */
.hamburger-btn {
  display: none; /* shown via media query */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 110;
  -webkit-tap-highlight-color: transparent;
}

.hamburger-btn span {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Default (light theme) bar color */
.hamburger-btn span {
  background: #0a0a0a;
}

/* Dark theme (landing page) bar color */
nav.nav-dark .hamburger-btn span {
  background: #ffffff;
}

/* X state when menu is open */
.hamburger-btn.is-open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.hamburger-btn.is-open span:nth-child(2) {
  opacity: 0;
}
.hamburger-btn.is-open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}


/* ---- MOBILE MENU OVERLAY (backdrop) ---- */
.mobile-menu-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.mobile-menu-backdrop.is-visible {
  opacity: 1;
}


/* ---- MOBILE BREAKPOINT ---- */
@media (max-width: 768px) {

  /* Show hamburger */
  .hamburger-btn {
    display: flex;
  }

  /* Hide the nav-links container on mobile by default */
  .nav-links,
  .nav-right {
    display: none !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 101;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0 !important;
    padding: 1rem 1.5rem 1.5rem !important;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    transform: translateY(-10px);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }

  /* Light theme mobile menu */
  .nav-links,
  .nav-right {
    background: #fafaf8 !important;
  }

  /* Dark theme mobile menu */
  nav.nav-dark .nav-links {
    background: #1a1a2e !important;
  }

  /* When menu is open */
  .nav-links.mobile-menu-open,
  .nav-right.mobile-menu-open {
    display: flex !important;
    transform: translateY(0);
    opacity: 1;
  }

  /* Show the backdrop when menu is open */
  .mobile-menu-backdrop.is-visible {
    display: block;
    opacity: 1;
  }

  /* Style all links inside the mobile menu */
  .nav-links.mobile-menu-open > a,
  .nav-links.mobile-menu-open > button,
  .nav-right.mobile-menu-open > a,
  .nav-right.mobile-menu-open > button,
  .nav-right.mobile-menu-open > .nav-link {
    display: block !important;
    width: 100% !important;
    padding: 0.85rem 0.5rem !important;
    font-size: 0.95rem !important;
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    text-align: left;
  }

  /* Last link has no border */
  .nav-links.mobile-menu-open > a:last-child,
  .nav-links.mobile-menu-open > button:last-child,
  .nav-links.mobile-menu-open > *:last-child,
  .nav-right.mobile-menu-open > a:last-child,
  .nav-right.mobile-menu-open > *:last-child {
    border-bottom: none;
  }

  /* Light theme link colors — blue to match nav-link class */
  .nav-links.mobile-menu-open > a,
  .nav-right.mobile-menu-open > a,
  .nav-right.mobile-menu-open > .nav-link {
    color: #3591E5 !important;
  }

  /* Dark theme link colors */
  nav.nav-dark .nav-links.mobile-menu-open > a {
    color: #ffffff !important;
    border-bottom-color: rgba(255, 255, 255, 0.1);
  }

  /* CTA button gets special treatment in mobile menu */
  .nav-links.mobile-menu-open > .nav-cta,
  .nav-links.mobile-menu-open > a[style*="background:#4f46e5"],
  .nav-links.mobile-menu-open > a[style*="background: #4f46e5"] {
    display: inline-block !important;
    width: auto !important;
    text-align: center;
    margin-top: 0.5rem;
    border-bottom: none;
    border-radius: 10px;
    padding: 0.65rem 1.5rem !important;
  }

  /* User info section in logged-in nav (the div with border-left) */
  .nav-links.mobile-menu-open > div,
  .nav-right.mobile-menu-open > div {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.75rem !important;
    padding: 0.85rem 0.5rem !important;
    border-left: none !important;
    border-top: 1px solid rgba(0, 0, 0, 0.06) !important;
    margin-left: 0 !important;
    margin-top: 0.25rem;
  }

  /* Dark theme user info */
  nav.nav-dark .nav-links.mobile-menu-open > div {
    border-top-color: rgba(255, 255, 255, 0.1) !important;
  }

  /* Logout button in mobile menu */
  .nav-links.mobile-menu-open button,
  .nav-right.mobile-menu-open button {
    text-align: left;
  }

  /* Admin badge in mobile menu */
  .nav-right.mobile-menu-open > .admin-badge {
    display: inline-block !important;
    margin-bottom: 0.25rem;
  }

  /* terms/privacy pages use .nav-inner wrapper */
  .nav-inner {
    flex-wrap: nowrap !important;
  }
}
