/* ==========================================================================
   Header 2026 — Navigation redesign overrides
   Two-class selectors (0-2-0) to beat application.css (0-1-1)
   ========================================================================== */

/* --------------------------------------------------------------------------
   Shadcn-inspired slide-in animations
   -------------------------------------------------------------------------- */

@keyframes megamenuSlideIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes megamenuSimpleSlideIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* --------------------------------------------------------------------------
   Sticky header — clean sticky at top: 0 (override application.css top: -1px)
   -------------------------------------------------------------------------- */

.header {
  top: 0;
}

/* --------------------------------------------------------------------------
   Two-row layout — override application.css single-row flex
   -------------------------------------------------------------------------- */

/* Neutralise the old single-container flex row */
.nav > .container {
  display: none;
}

/* Row 1: Top bar — logo + login */
.nav-topbar {
  border-bottom: 1px solid #f0ecf2;
}

.nav-topbar > .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.nav-topbar__right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Row 2: Nav bar — menu items + CTA buttons */
.nav-navbar {
  border-bottom: 1px solid #f0ecf2;
}

.nav-navbar > .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.375rem;
  padding-bottom: 0.375rem;
}

/* --------------------------------------------------------------------------
   Ghost button — Login
   -------------------------------------------------------------------------- */

.btn.btn--ghost {
  background: transparent;
  border: 1px solid #e0e0e0;
  color: #341c4c;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.3rem 1rem;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn.btn--ghost svg {
  vertical-align: -0.15em;
  margin-right: 0.25rem;
}

.btn.btn--ghost:hover {
  background-color: #f5f0f7;
  border-color: #d0c8d8;
}

/* --------------------------------------------------------------------------
   Login container — now in normal flow (no absolute positioning)
   -------------------------------------------------------------------------- */

.nav-loginContainer {
  position: static;
}

.nav-login {
  margin: 0;
}

/* --------------------------------------------------------------------------
   Logo — accommodate wider landscape PNG
   -------------------------------------------------------------------------- */

.nav .nav-logo img,
.nav .nav-logo svg {
  height: 2.5rem;
  width: auto;
}

@media (max-width: 1023px) {
  .nav .nav-logo img,
  .nav .nav-logo svg {
    height: 2rem;
  }
}

/* --------------------------------------------------------------------------
   Top-level menu text — lighter weight, smaller size
   -------------------------------------------------------------------------- */

.nav-primary > .nav-item > a {
  font-size: 0.875rem;
  font-weight: 500;
  color: #341c4c;
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-primary > .nav-item > a:hover {
  background-color: #f3f4f6;
}

/* Compact vertical padding for second-row nav items */
@media (min-width: 1024px) {
  .nav-primary > .nav-item {
    padding: 0.75rem 0;
  }
}

@media (max-width: 1023px) {
  .nav-primary > .nav-item > a {
    font-size: 1.66667rem;
    font-weight: 500;
  }
}

/* --------------------------------------------------------------------------
   Arrow indicator — smaller to match lighter nav text
   -------------------------------------------------------------------------- */

.nav-primary .arrow {
  width: 0.7rem;
  height: 0.7rem;
  margin-left: 0.35rem;
  transition: transform 200ms ease;
}

/* --------------------------------------------------------------------------
   Megamenu — base (replaces old li > ul dropdown)
   -------------------------------------------------------------------------- */

.nav-megamenu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background: #fff;
  padding: 2.25rem 0;
  z-index: 100;
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 0 0 8px 8px;
  border: 1px solid #e5e7eb;
  border-top: none;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.07),
    0 2px 4px -2px rgba(0, 0, 0, 0.05);
  opacity: 0;
}

/* Show megamenu when parent has .show class */
@media (min-width: 1024px) {
  .nav-item--has-children.show > .nav-megamenu {
    display: flex;
    flex-direction: row;
    opacity: 1;
    animation: megamenuSlideIn 200ms ease-out both;
  }
}

@media (max-width: 1023px) {
  .nav-item--has-children.show > .nav-megamenu {
    display: flex;
    flex-direction: column;
    opacity: 1;
  }
}

/* Extend background to viewport edges */
.nav-megamenu::before,
.nav-megamenu::after {
  content: "";
  position: absolute;
  top: 0;
  height: 100%;
  width: 100vw;
  background: #fff;
  z-index: -1;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.07),
    0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

.nav-megamenu::before {
  right: 100%;
  border-radius: 0 0 0 8px;
}

.nav-megamenu::after {
  left: 100%;
  border-radius: 0 0 8px 0;
}

/* Hide the old ul-based dropdown when megamenu is present */
.nav-item--has-children.show > .nav-megamenu ~ ul {
  display: none !important;
}

/* --------------------------------------------------------------------------
   Megamenu — Product (multi-column)
   -------------------------------------------------------------------------- */

.nav-megamenu--product {
  gap: 0;
  width: 64rem;
  max-width: 64rem;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  margin-top: 0.375rem;
  padding: 1.5rem 0;
}

/* Product menu doesn't need full-bleed pseudo-elements */
.nav-megamenu--product::before,
.nav-megamenu--product::after {
  display: none;
}

.nav-megamenu--product > .nav-megamenu__column {
  padding: 0 1.25rem;
}

/* Three equal columns */
.nav-megamenu--product > .nav-megamenu__column {
  flex: 1;
}

.nav-megamenu--product > .nav-megamenu__column:first-child {
  flex: 1;
  max-width: none;
}

/* Second column (Products) — wider, splits into 2 sub-columns */
.nav-megamenu--product > .nav-megamenu__column--split {
  flex: 1;
}

.nav-megamenu__column--split > .nav-megamenu__list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}

/* --------------------------------------------------------------------------
   Megamenu — Simple (single column for Learn, About)
   -------------------------------------------------------------------------- */

/* Position dropdowns under their parent nav item */
@media (min-width: 1024px) {
  .nav-item--has-children:has(.nav-megamenu--simple),
  .nav-item--has-children:has(.nav-megamenu--product) {
    position: relative;
  }
}

.nav-megamenu--simple {
  max-width: 24rem;
  width: 24rem;
  left: 0;
  flex-direction: column;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.07),
    0 2px 4px -2px rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  margin-top: 0.375rem;
  padding: 0.5rem 0;
}

/* Override animation for simple dropdowns */
@media (min-width: 1024px) {
  .nav-item--has-children.show > .nav-megamenu--simple {
    animation: megamenuSimpleSlideIn 200ms ease-out both;
  }
}

/* Simple menus don't need edge-extending pseudo-elements */
.nav-megamenu--simple::before,
.nav-megamenu--simple::after {
  display: none;
}

.nav-megamenu--simple > .nav-megamenu__column {
  padding: 0 0.75rem;
}

/* --------------------------------------------------------------------------
   Category headers — hidden for clean, simple style
   -------------------------------------------------------------------------- */

.nav-category-header {
  display: none;
}

/* --------------------------------------------------------------------------
   Menu items inside dropdown
   -------------------------------------------------------------------------- */

.nav-megamenu__list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-megamenu__item {
  margin-bottom: 0.125rem;
}

.nav-megamenu__item a {
  display: block;
  padding: 0.625rem 0.75rem;
  border-radius: 8px;
  text-decoration: none;
  color: #341c4c;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-megamenu__item a:hover {
  background-color: #f5f0f7;
  color: #341c4c;
}

.nav-megamenu__item a:focus-visible {
  outline: 2px solid #95569e;
  outline-offset: -2px;
  border-radius: 8px;
}

/* --------------------------------------------------------------------------
   Subtitles
   -------------------------------------------------------------------------- */

.nav-subtitle {
  display: block;
  color: #6b7280;
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.45;
  margin-top: 0.125rem;
  white-space: nowrap;
}

.nav-megamenu__item a:hover .nav-subtitle {
  color: #5b4a6e;
}

/* --------------------------------------------------------------------------
   Backdrop overlay — dims the page when a dropdown is open
   -------------------------------------------------------------------------- */

.nav-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 200ms ease;
  pointer-events: none;
  z-index: 99;
}

.nav-backdrop.is-visible {
  opacity: 1;
  visibility: visible;
}

/* --------------------------------------------------------------------------
   CTA buttons — match Login button size
   -------------------------------------------------------------------------- */

.nav-buttons .btn {
  font-size: 0.8125rem;
  padding: 0.3rem 1rem;
  border-radius: 6px;
}

.nav-buttons .btn--lilacOutline {
  background-color: #fff;
  color: #95569e;
  border: 1px solid #95569e;
}

.nav-buttons .btn--lilacOutline:hover,
.nav-buttons .btn--lilacOutline:focus {
  background-color: #95569e;
  color: #fff;
}

/* --------------------------------------------------------------------------
   Mobile overrides
   -------------------------------------------------------------------------- */

@media (max-width: 1023px) {
  /* Collapse nav bar row on mobile — but keep it in DOM so the
     position:fixed .nav-primaryContainer overlay can still render */
  .nav-navbar {
    height: 0;
    overflow: visible;
    border-bottom: none;
    padding: 0;
  }

  .nav-navbar > .container {
    height: 0;
    overflow: visible;
    padding: 0;
  }

  /* Hide the CTA buttons row on mobile (they're not in the overlay) */
  .nav-navbar .nav-buttons {
    display: none;
  }

  .nav-topbar {
    border-bottom: none;
  }

  /* Login hidden on mobile */
  .nav-loginContainer {
    display: none;
  }

  .nav-megamenu {
    position: static;
    border: none;
    padding: 0.5rem 0;
    max-height: none;
    box-shadow: none;
    border-radius: 0;
    opacity: 1;
    margin-top: 0;
  }

  /* Match 0-3-0 specificity to override desktop .show rule */
  .nav-item--has-children.show > .nav-megamenu {
    flex-direction: column;
  }

  .nav-megamenu::before,
  .nav-megamenu::after {
    display: none;
  }

  /* Reset simple-dropdown desktop styles so Learn/About match Product */
  .nav-megamenu--simple {
    max-width: none;
    width: auto;
    box-shadow: none;
    border-radius: 0;
    border: none;
    margin-top: 0;
    padding: 0.5rem 0;
  }

  .nav-megamenu--product > .nav-megamenu__column,
  .nav-megamenu--product > .nav-megamenu__column:first-child,
  .nav-megamenu--simple > .nav-megamenu__column {
    flex: none;
    max-width: 100%;
    padding: 0;
    border-right: none;
    margin-bottom: 0.25rem;
  }

  .nav-megamenu__column--split > .nav-megamenu__list {
    grid-template-columns: 1fr;
  }

  /* Hide category headers — not useful in single-column mobile list */
  .nav-category-header {
    display: none;
  }

  /* Full-width hover highlight with generous touch targets */
  .nav-megamenu__item a {
    font-size: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 0;
  }

  /* Hide subtitles — keeps mobile nav scannable */
  .nav-subtitle {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .nav-megamenu__item a {
    transition: none;
  }

  .nav-item--has-children.show > .nav-megamenu {
    animation: none !important;
    opacity: 1;
  }
}
