/* ============================================================
   Dynamic Pricing AI — nav.css
   Primary navigation: desktop dropdown + mobile slide-in
   ============================================================ */

/* ── Base nav list ─────────────────────────────────────────── */
.nav-menu {
  display: flex;
  align-items: center;
  gap: 0;
  list-style: none;
}

.nav-menu > li {
  position: relative;
  align-self: center;
  height: fit-content;
}

.nav-menu > li > a {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--c-dark-alt);
  border-radius: var(--r-sm);
  transition: color var(--ease), background var(--ease);
  white-space: nowrap;
}

.nav-menu > li > a:hover,
.nav-menu > li.current-menu-item > a,
.nav-menu > li.current-menu-ancestor > a {
  color: var(--c-primary);
  background: rgba(0, 0, 0, 0.05);
}

/* Dropdown arrow */
.nav-arrow {
  transition: transform var(--ease);
  color: var(--c-muted);
  flex-shrink: 0;
}
.nav-menu > li:hover > a .nav-arrow,
.nav-menu > li[aria-expanded="true"] > a .nav-arrow {
  transform: rotate(180deg);
}

/* ── Sub-menu (dropdown) ────────────────────────────────────── */
.sub-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 240px;
  background: #ffffff;
  border: none;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.04), 0 12px 40px rgba(0,0,0,0.10);
  list-style: none;
  padding: var(--sp-2) var(--sp-2);
  padding-top: 10px;
  z-index: 200;

  /* Hidden by default */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}

/* Show on hover (desktop) */
.nav-menu > li:hover > .sub-menu,
.nav-menu > li:focus-within > .sub-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

/* Restore sub-sub-menu when parent dropdown is open */
.nav-menu > li:hover > .sub-menu .sub-menu,
.nav-menu > li:focus-within > .sub-menu .sub-menu {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

/* Sub-menu items */
.sub-menu a {
  display: block;
  padding: 0.5rem 0.875rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--c-dark-alt);
  border-radius: 6px;
  transition: color 0.12s ease, background 0.12s ease;
  line-height: 1.4;
}
.sub-menu a:hover {
  color: var(--c-dark);
  background: rgba(0, 0, 0, 0.05);
}
.sub-menu .current-menu-item a { color: var(--c-primary); font-weight: 600; }

/* ── Third-level sub-menu (depth 2) ────────────────────────── */
/* Shown inline and indented beneath the parent item */
.sub-menu .sub-menu {
  position: static;
  opacity: 1;
  /* Do NOT set visibility/pointer-events here —
     let them inherit from the parent .sub-menu so the
     child stays hidden when the parent is hidden. */
  transform: none;
  box-shadow: none;
  border: none;
  border-radius: 0;
  min-width: 0;
  padding: 0;
  background: transparent;
  border-left: 1px solid var(--c-border);
  margin: 0.25rem 0 0.5rem 1.25rem;
  transition: none;
}

.sub-menu .sub-menu a {
  padding: 0.4rem 0.875rem;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--c-muted);
}
.sub-menu .sub-menu a:hover {
  color: var(--c-primary);
  background: var(--c-primary-light);
}

/* Hide the toggle arrow on depth-1 items that have a depth-2 child */
.sub-menu .menu-item-has-children > a .nav-arrow { display: none; }
.sub-menu .menu-item-has-children > .sub-menu-toggle { display: none; }

/* Sub-menu toggle button — hidden on desktop */
.sub-menu-toggle { display: none; }

/* ── Mobile-only Log In block (inside slide-in nav) ─────────── */
.mobile-login {
  display: none;
}

/* ── Mobile hamburger button ────────────────────────────────── */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 8px;
  border-radius: var(--r-sm);
  transition: background var(--ease);
  flex-shrink: 0;
  margin-left: auto;
}
.nav-toggle:hover { background: var(--c-primary-light); }

.nav-toggle__bar {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--c-dark-alt);
  border-radius: var(--r-full);
  transform-origin: center;
  transition: transform var(--ease), opacity var(--ease);
}

/* Hamburger → X animation */
.nav-is-open .nav-toggle__bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-is-open .nav-toggle__bar:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-is-open .nav-toggle__bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Mobile breakpoint ──────────────────────────────────────── */
@media (max-width: 1024px) {

  /* Fixed header — always on top, never scrolls away */
  .site-header {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    transform: none !important;
    background: var(--c-white) !important;
    border-bottom: 1px solid var(--c-border) !important;
    box-shadow: var(--shadow-sm) !important;
  }

  /* Compensate for fixed header height */
  body {
    padding-top: 72px;
  }

  /* WordPress admin bar on tablet (783px+) adds 32px — account for it */
  .admin-bar .site-header {
    top: 32px;
  }
  .admin-bar body {
    padding-top: 104px;
  }

  .nav-toggle { display: flex; }

  .site-nav {
    position: fixed;
    inset: 72px 0 0 0;
    background: var(--c-white);
    overflow-y: auto;
    padding: var(--sp-6) var(--container-pad) var(--sp-12);
    z-index: 999;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    border-top: 1px solid var(--c-border);
  }

  .nav-is-open .site-nav {
    transform: translateX(0);
  }

  /* Log In button at top of mobile nav */
  .mobile-login {
    display: block;
    padding-bottom: var(--sp-6);
    border-bottom: 1px solid var(--c-border);
    margin-bottom: var(--sp-2);
  }

  .mobile-login .btn {
    width: 100%;
    justify-content: center;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
  }

  /* Stack menu vertically on mobile */
  .nav-menu {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .nav-menu > li > a {
    padding: 0.875rem 0;
    font-size: var(--text-base);
    border-radius: 0;
    border-bottom: 1px solid var(--c-border);
    justify-content: space-between;
  }

  /* Sub-menu: static on mobile */
  .sub-menu {
    position: static;
    opacity: 1;
    visibility: hidden;
    max-height: 0;
    overflow: hidden;
    transform: none;
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 0;
    margin: 0;
    transition: max-height 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
    background: var(--c-bg);
  }

  .sub-menu.is-open {
    visibility: visible;
    max-height: 800px;
    pointer-events: auto;
  }

  /* Third-level on mobile: always visible inside an open depth-1 */
  .sub-menu.is-open .sub-menu {
    visibility: visible;
    max-height: none;
    pointer-events: auto;
    border-left: 1px solid var(--c-border);
    margin: 0 0 0 1rem;
    background: transparent;
  }

  .sub-menu .menu-item-has-children > .sub-menu-toggle { display: none; }

  .sub-menu a {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--c-border);
    font-size: var(--text-sm);
  }

  /* Mobile sub-menu toggle button */
  .sub-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    right: 0;
    top: 0;
    height: 52px;
    width: 52px;
    color: var(--c-primary);
    z-index: 1;
  }

  .nav-arrow { display: none; }

  /* Hide header Log In button — shown inside mobile nav instead */
  .site-header__actions { display: none; }
}
