/* =========================================================
   MARVEL — Navigation Bar
   ─────────────────────────────────────────────────────────
   All selectors prefixed with `.mnav-` so this block cannot
   collide with any pre-existing .navbar or .nav-links rules.

   Works from 320px → 1920px+ with smooth animations on every
   breakpoint. Mobile uses a bottom-anchored sheet for one-hand
   reach. Active page is highlighted at every size.

   Expected CSS variables (already in your styles.css):
     --primary-blue   e.g. #1F9ED8
     --light-blue     e.g. #4BB5E8
     --red            e.g. #D62828
     --dark-text      e.g. #0A2638
     --light-gray     e.g. #8a96a3
     --white          #ffffff
     --grad           linear-gradient(...) brand gradient
   Fallbacks are baked in so the bar still looks right if
   any variable is missing.
   ========================================================= */

/* ---------------------------------------------------------
   0. SCOPED RESET — only inside the nav
   --------------------------------------------------------- */
.mnav-bar,
.mnav-bar *,
.mnav-bar *::before,
.mnav-bar *::after {
  box-sizing: border-box;
}

/* ---------------------------------------------------------
   1. BAR SHELL
   --------------------------------------------------------- */
.mnav-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.85);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
          backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid rgba(10, 38, 56, 0.06);
  transition:
    background      0.35s ease,
    border-color    0.35s ease,
    box-shadow      0.35s ease,
    transform       0.35s ease;
  will-change: transform;
}
.mnav-bar.is-scrolled {
  background: rgba(255, 255, 255, 0.97);
  border-bottom-color: rgba(10, 38, 56, 0.1);
  box-shadow: 0 6px 24px rgba(10, 38, 56, 0.08);
}

.mnav-inner {
  position: relative;
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

/* ---------------------------------------------------------
   2. LOGO
   --------------------------------------------------------- */
.mnav-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  text-decoration: none;
  color: var(--dark-text, #0A2638);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 1px;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.mnav-logo:hover { transform: translateY(-1px) scale(1.02); }
.mnav-logo:active { transform: translateY(0) scale(0.98); }
.mnav-logo-img {
  width: 32px; height: 32px;
  object-fit: contain;
  transition: transform 0.4s ease;
}
.mnav-logo:hover .mnav-logo-img { transform: rotate(-6deg); }
.mnav-logo-text {
  background: var(--grad, linear-gradient(135deg, #D62828, #1F9ED8));
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
          color: transparent;
}

/* ---------------------------------------------------------
   3. LINKS — DESKTOP DEFAULT
   --------------------------------------------------------- */
.mnav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0;
  padding: 0;
}
.mnav-item { margin: 0; }

.mnav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--dark-text, #0A2638);
  text-decoration: none;
  white-space: nowrap;
  outline: none;
  transition:
    color 0.25s ease,
    background 0.25s ease,
    transform 0.2s ease;
}

/* Icons only visible on mobile sheet — hidden on desktop */
.mnav-icon { display: none; }

/* Underline that grows from centre */
.mnav-link::after {
  content: '';
  position: absolute;
  left: 15px; right: 15px;
  bottom: 3px;
  height: 2px;
  border-radius: 2px;
  background: var(--grad, linear-gradient(135deg, #D62828, #1F9ED8));
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mnav-link:hover,
.mnav-link:focus-visible {
  color: var(--primary-blue, #1F9ED8);
}
.mnav-link:hover::after,
.mnav-link:focus-visible::after {
  transform: scaleX(1);
}

/* ----- ACTIVE PAGE — desktop ----- */
.mnav-link.is-active {
  color: var(--primary-blue, #1F9ED8);
}
.mnav-link.is-active::after {
  transform: scaleX(1);
}

/* ----- CTA pill ----- */
.mnav-cta {
  margin-left: 10px;
  padding: 9px 20px;
  background: var(--grad, linear-gradient(135deg, #D62828, #1F9ED8));
  color: var(--white, #fff) !important;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(31, 158, 216, 0.3);
  transition:
    transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.25s ease,
    filter 0.25s ease;
}
.mnav-cta i { font-size: 0.85rem; }
.mnav-cta::after { display: none !important; }
.mnav-cta:hover,
.mnav-cta:focus-visible {
  transform: translateY(-2px);
  filter: brightness(1.07);
  box-shadow: 0 10px 22px rgba(31, 158, 216, 0.45);
}
.mnav-cta:active { transform: translateY(0); }
.mnav-cta.is-active { color: var(--white, #fff) !important; }

/* ---------------------------------------------------------
   4. HAMBURGER TOGGLE
   --------------------------------------------------------- */
.mnav-toggle {
  display: none;                  /* hidden on desktop, shown on mobile */
  width: 44px; height: 44px;
  border-radius: 12px;
  background: transparent;
  border: 1.5px solid rgba(10, 38, 56, 0.12);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  transition:
    background 0.25s ease,
    border-color 0.25s ease,
    transform 0.18s ease,
    box-shadow 0.25s ease;
}
.mnav-toggle:hover {
  background: rgba(31, 158, 216, 0.08);
  border-color: var(--light-blue, #4BB5E8);
  box-shadow: 0 4px 12px rgba(31, 158, 216, 0.15);
}
.mnav-toggle:active { transform: scale(0.93); }
.mnav-toggle.is-open {
  background: rgba(31, 158, 216, 0.1);
  border-color: var(--primary-blue, #1F9ED8);
}

.mnav-toggle-bars {
  position: relative;
  display: block;
  width: 20px; height: 14px;
  pointer-events: none;
}
.mnav-toggle-bars span {
  position: absolute;
  left: 0; width: 100%;
  height: 2px;
  background: var(--dark-text, #0A2638);
  border-radius: 2px;
  transition:
    top       0.35s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    opacity   0.2s  ease,
    background 0.25s ease;
}
.mnav-toggle-bars span:nth-child(1) { top: 0; }
.mnav-toggle-bars span:nth-child(2) { top: 6px; }
.mnav-toggle-bars span:nth-child(3) { top: 12px; }

/* Open: bars morph to an X */
.mnav-toggle.is-open .mnav-toggle-bars span:nth-child(1) {
  top: 6px;
  transform: rotate(45deg);
  background: var(--primary-blue, #1F9ED8);
}
.mnav-toggle.is-open .mnav-toggle-bars span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.mnav-toggle.is-open .mnav-toggle-bars span:nth-child(3) {
  top: 6px;
  transform: rotate(-45deg);
  background: var(--primary-blue, #1F9ED8);
}

/* ---------------------------------------------------------
   5. BACKDROP (mobile only)
   --------------------------------------------------------- */
.mnav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 38, 56, 0.5);
  -webkit-backdrop-filter: blur(5px);
          backdrop-filter: blur(5px);
  z-index: 998;
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.3s ease;
}
.mnav-backdrop.is-active { opacity: 1; }

body.mnav-locked { overflow: hidden; }

/* ---------------------------------------------------------
   6. MOBILE BOTTOM-SHEET (≤ 900px)
   The sheet slides up from the bottom for one-hand reach.
   --------------------------------------------------------- */
@media (max-width: 900px) {

  .mnav-toggle { display: inline-flex; }
  .mnav-backdrop { display: block; }

  /* Show icons in the sheet */
  .mnav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border-radius: 10px;
    background: rgba(31, 158, 216, 0.08);
    color: var(--primary-blue, #1F9ED8);
    font-size: 0.95rem;
    flex-shrink: 0;
    transition:
      background 0.22s ease,
      color 0.22s ease,
      transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  /* ── THE SHEET ── */
  .mnav-links {
    position: fixed;
    left: 12px; right: 12px;
    bottom: 12px; top: auto;

    flex-direction: column;
    align-items: stretch;
    gap: 2px;

    background: var(--white, #fff);
    border-radius: 22px;
    border: 1.5px solid rgba(10, 38, 56, 0.08);
    box-shadow:
      0 28px 60px rgba(10, 38, 56, 0.32),
      0  8px 22px rgba(10, 38, 56, 0.16);

    padding: 26px 10px 14px;          /* top room for the gradient strip + drag pill */

    /* Off-screen rest state */
    transform: translateY(calc(100% + 28px));
    opacity: 0;
    pointer-events: none;

    transition:
      transform 0.45s cubic-bezier(0.34, 1.46, 0.64, 1),
      opacity   0.28s ease;
    z-index: 999;

    max-height: 82dvh;
    max-height: 82vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .mnav-links::-webkit-scrollbar { display: none; }

  /* Gradient top strip — sits flush at the top of the sheet */
  .mnav-links::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--grad, linear-gradient(90deg, #D62828, #1F9ED8));
    border-radius: 22px 22px 0 0;
    pointer-events: none;
  }

  /* Drag-handle pill */
  .mnav-links::after {
    content: '';
    position: absolute;
    top: 9px;
    left: 50%;
    transform: translateX(-50%);
    width: 38px; height: 4px;
    background: rgba(10, 38, 56, 0.16);
    border-radius: 2px;
    pointer-events: none;
  }

  /* Open state */
  .mnav-links.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  /* ── LIST ITEMS — staggered entrance ── */
  .mnav-item {
    width: 100%;
    opacity: 0;
    transform: translateY(12px);
    transition:
      opacity   0.32s ease,
      transform 0.32s cubic-bezier(0.34, 1.46, 0.64, 1);
  }
  .mnav-links.is-open .mnav-item        { opacity: 1; transform: translateY(0); }
  .mnav-links.is-open .mnav-item:nth-child(1) { transition-delay: 0.06s; }
  .mnav-links.is-open .mnav-item:nth-child(2) { transition-delay: 0.10s; }
  .mnav-links.is-open .mnav-item:nth-child(3) { transition-delay: 0.14s; }
  .mnav-links.is-open .mnav-item:nth-child(4) { transition-delay: 0.18s; }
  .mnav-links.is-open .mnav-item:nth-child(5) { transition-delay: 0.22s; }
  .mnav-links.is-open .mnav-item:nth-child(6) { transition-delay: 0.26s; }
  .mnav-links.is-open .mnav-item:nth-child(7) { transition-delay: 0.30s; }
  .mnav-links.is-open .mnav-item:nth-child(8) { transition-delay: 0.34s; }

  /* ── MOBILE LINK ROW ── */
  .mnav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 13px 16px 13px 22px;    /* 22px left → room for the active bar */
    border-radius: 14px;
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--dark-text, #0A2638);
    background: transparent;
    transition:
      background 0.2s ease,
      color 0.2s ease,
      transform 0.18s ease;
  }

  /* Kill the desktop underline */
  .mnav-link::after { display: none; }

  /* Chevron on the right — using a real element-like content slot */
  .mnav-link:not(.mnav-cta) .mnav-label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .mnav-link:not(.mnav-cta) .mnav-label::after {
    content: '\f054';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.7rem;
    color: rgba(10, 38, 56, 0.22);
    margin-left: 12px;
    transition: transform 0.22s ease, color 0.22s ease;
  }

  .mnav-link:hover,
  .mnav-link:active {
    background: rgba(31, 158, 216, 0.07);
    color: var(--primary-blue, #1F9ED8);
  }
  .mnav-link:hover .mnav-icon,
  .mnav-link:active .mnav-icon {
    background: rgba(31, 158, 216, 0.15);
    transform: scale(1.05);
  }
  .mnav-link:hover:not(.mnav-cta) .mnav-label::after,
  .mnav-link:active:not(.mnav-cta) .mnav-label::after {
    transform: translateX(4px);
    color: var(--primary-blue, #1F9ED8);
  }

  /* ── ACTIVE PAGE — mobile ── */
  .mnav-link.is-active {
    background: linear-gradient(to right,
      rgba(31, 158, 216, 0.14) 0%,
      rgba(31, 158, 216, 0.03) 100%);
    color: var(--primary-blue, #1F9ED8);
  }
  /* Left accent bar (re-uses ::before since the desktop underline used ::after) */
  .mnav-link.is-active::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 50%;
    width: 3px;
    height: 22px;
    background: var(--grad, linear-gradient(180deg, #D62828, #1F9ED8));
    border-radius: 2px;
    transform: translateY(-50%);
    pointer-events: none;
  }
  .mnav-link.is-active .mnav-icon {
    background: var(--grad, linear-gradient(135deg, #D62828, #1F9ED8));
    color: var(--white, #fff);
  }
  .mnav-link.is-active:not(.mnav-cta) .mnav-label::after {
    color: var(--primary-blue, #1F9ED8);
  }

  /* ── CTA inside the sheet ── */
  .mnav-item-cta {
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px solid rgba(10, 38, 56, 0.06);
  }
  .mnav-cta {
    margin: 0;
    padding: 15px 20px;
    justify-content: center;
    gap: 10px;
    border-radius: 14px;
    font-size: 1rem;
    box-shadow: 0 6px 18px rgba(31, 158, 216, 0.32);
  }
  .mnav-cta::before,
  .mnav-cta::after { display: none !important; }
  .mnav-cta:hover,
  .mnav-cta:active {
    filter: brightness(1.07);
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(31, 158, 216, 0.42);
  }
}

/* ---------------------------------------------------------
   7. SMALL PHONES (≤ 380 px)
   --------------------------------------------------------- */
@media (max-width: 380px) {
  .mnav-inner { padding: 12px 16px; }
  .mnav-logo { font-size: 1.1rem; }
  .mnav-logo-img { width: 28px; height: 28px; }
  .mnav-links {
    left: 8px; right: 8px; bottom: 8px;
    padding: 24px 8px 12px;
    border-radius: 18px;
  }
  .mnav-link {
    padding: 12px 14px 12px 20px;
    gap: 12px;
    font-size: 0.94rem;
  }
  .mnav-icon { width: 32px; height: 32px; font-size: 0.85rem; }
}

/* ---------------------------------------------------------
   8. WIDE DESKTOPS (≥ 1400 px)
   --------------------------------------------------------- */
@media (min-width: 1400px) {
  .mnav-inner { padding: 18px 32px; }
  .mnav-link { padding: 10px 18px; font-size: 0.95rem; }
  .mnav-cta { padding: 10px 24px; }
}

/* ---------------------------------------------------------
   9. REDUCED MOTION
   --------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .mnav-bar,
  .mnav-link,
  .mnav-link::after,
  .mnav-item,
  .mnav-icon,
  .mnav-logo,
  .mnav-logo-img,
  .mnav-toggle,
  .mnav-toggle-bars span,
  .mnav-backdrop,
  .mnav-links {
    transition: none !important;
    animation: none !important;
  }
  /* Still want the sheet to APPEAR when open, just without animation */
  .mnav-links.is-open {
    transform: translateY(0) !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }
  .mnav-links.is-open .mnav-item {
    opacity: 1 !important;
    transform: none !important;
  }
}