/* MintCues — Mobile Navigation Overlay
 * Loaded AFTER /assets/css/style.css.
 * Authoritative mobile nav rules — overrides everything in the older
 * hotfix blocks (4 conflicting @media blocks were fighting each other).
 *
 * Works with existing markup:
 *   <nav class="nav">
 *     <div class="nav-inner">
 *       <a class="nav-logo">...</a>
 *       <div class="nav-links" id="navLinks">...</div>
 *       <button class="nav-toggle" onclick="toggleMobileNav()">...</button>
 *       <div class="nav-actions">...</div>
 *     </div>
 *   </nav>
 *
 * Piggybacks on the existing `#navLinks.open` class set by toggleMobileNav().
 */

/* ============ Backdrop element we inject from JS ============ */
.mc-nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 190;
  background: rgba(25, 28, 30, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.mc-nav-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* ============ Lock body scroll when drawer is open ============ */
body.mc-nav-open {
  overflow: hidden;
}

/* ============ MOBILE LAYOUT (≤ 960px) ============ */
@media (max-width: 960px) {

  /* --- Header layout: logo left, hamburger right, CTA hidden (lives in drawer) --- */
  .nav {
    position: sticky !important;
    top: 0 !important;
    z-index: 200 !important;
    background: rgba(247, 249, 251, 0.96) !important;
  }
  .nav-inner {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 0.6rem !important;
    padding: 0.55rem 1rem !important;
    height: auto !important;
  }
  .nav-logo {
    flex: 0 1 auto !important;
    max-width: 60vw !important;
    min-width: 0 !important;
  }
  .nav-logo img {
    height: 30px !important;
    max-height: 34px !important;
    width: auto !important;
    max-width: 55vw !important;
    object-fit: contain !important;
    display: block !important;
  }

  /* Hide desktop nav-actions on mobile; they move into the drawer footer */
  .nav-actions {
    display: none !important;
  }

  /* --- Hamburger: clean icon, always rightmost, sensible size --- */
  .nav-toggle {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 0 auto !important;
    order: 99 !important;             /* always last */
    margin-left: auto !important;     /* push right when sibling order gets weird */
    width: 42px !important;
    height: 42px !important;
    padding: 0 !important;
    font-size: 0 !important;          /* hide any text/emoji inside */
    color: var(--primary) !important;
    background: var(--white) !important;
    border: 1px solid rgba(196, 198, 207, 0.35) !important;
    border-radius: 0.5rem !important;
    cursor: pointer !important;
  }
  /* Inline SVG hamburger, drawn with the border-color pseudo-elements
     so we don't need to touch the PHP header to change the icon. */
  .nav-toggle::before,
  .nav-toggle::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform 0.2s ease, top 0.2s ease, opacity 0.2s ease;
  }
  .nav-toggle { position: relative !important; }
  .nav-toggle::before { top: 14px; }
  .nav-toggle::after  { top: 24px; }
  .nav-toggle::before,
  .nav-toggle::after { left: 12px; }
  /* middle line */
  .nav-toggle > * { display: none !important; }  /* hide the "☰" emoji */

  /* Cross animation when drawer is open (we toggle .is-open on the button) */
  .nav-toggle.is-open::before {
    top: 19px;
    transform: rotate(45deg);
  }
  .nav-toggle.is-open::after {
    top: 19px;
    transform: rotate(-45deg);
  }

  /* --- Drawer: slide-in panel from the right --- */
  .nav-links {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: min(340px, 86vw) !important;
    height: 100vh !important;
    max-height: 100vh !important;
    margin: 0 !important;
    padding: 1.5rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom)) !important;
    background: var(--white) !important;
    box-shadow: -24px 0 60px rgba(25, 28, 30, 0.22) !important;
    border-radius: 0 !important;
    display: flex !important;            /* always flex; animate via transform */
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 0.1rem !important;
    z-index: 200 !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    transform: translateX(100%) !important;
    transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
    visibility: visible !important;
  }
  .nav-links.open {
    transform: translateX(0) !important;
  }

  /* Space at top of drawer for visual breathing room */
  .nav-links::before {
    content: "Menu";
    display: block;
    font-family: var(--font-h, serif);
    font-style: italic;
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--outline);
    padding: 0.25rem 0.65rem 1rem;
    border-bottom: 1px solid rgba(196, 198, 207, 0.2);
    margin-bottom: 0.5rem;
  }

  /* Drawer links */
  .nav-links .nav-link {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0.95rem 0.75rem !important;
    font-size: 0.98rem !important;
    font-weight: 500 !important;
    color: var(--on-surface) !important;
    background: transparent !important;
    border: none !important;
    border-bottom: 1px solid rgba(196, 198, 207, 0.18) !important;
    border-radius: 0 !important;
    white-space: normal !important;
  }
  .nav-links .nav-link:last-child {
    border-bottom: none !important;
  }
  .nav-links .nav-link::after {
    content: "→";
    opacity: 0.35;
    font-size: 0.85rem;
    transition: transform 0.18s ease, opacity 0.18s ease;
  }
  .nav-links .nav-link:hover,
  .nav-links .nav-link:focus {
    color: var(--primary) !important;
    background: rgba(0, 32, 70, 0.04) !important;
  }
  .nav-links .nav-link:hover::after {
    opacity: 1;
    transform: translateX(3px);
  }
  .nav-links .nav-link.active {
    color: var(--primary) !important;
    background: rgba(0, 32, 70, 0.06) !important;
    font-weight: 700 !important;
    border-bottom-color: rgba(196, 198, 207, 0.18) !important;
  }

  /* CTA block pushed to bottom of drawer via ::after helper.
     We style the Subscribe / search from .nav-actions… but we hid
     .nav-actions on mobile. So we inject them into drawer via JS
     (mintcues-mobile-nav.js) as .mc-drawer-cta. */
  .mc-drawer-cta {
    margin-top: auto !important;
    padding: 1rem 0.25rem calc(0.5rem + env(safe-area-inset-bottom)) !important;
    border-top: 1px solid rgba(196, 198, 207, 0.22) !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.6rem !important;
  }
  .mc-drawer-cta .btn,
  .mc-drawer-cta button {
    width: 100% !important;
    justify-content: center !important;
    padding: 0.85rem 1rem !important;
    font-size: 0.78rem !important;
  }
  .mc-drawer-cta .mc-search-btn {
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    width: 100% !important;
    padding: 0.85rem 1rem !important;
    background: var(--surface-mid, #eceef0) !important;
    color: var(--on-surface-var, #44474e) !important;
    border-radius: 0.5rem !important;
    font-size: 0.8rem !important;
    font-weight: 500 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    cursor: pointer !important;
  }
  .mc-drawer-cta .mc-search-btn:hover {
    background: var(--white) !important;
    color: var(--on-surface) !important;
  }
  .mc-drawer-cta .mc-search-btn svg {
    flex: 0 0 auto;
  }

  /* Kill the old hotfix grid + conflicting rules */
  .nav-inner {
    grid-template-columns: none !important;
  }

  /* Ticker: the existing hotfix hides it on mobile. Keep hidden — it's
     too wide. Easy to re-enable here if you want: remove this block. */
  .ticker {
    display: none !important;
  }

  /* Hero / layout — keep existing hotfix intact, but tighten nav-top padding */
  .hero {
    padding-top: 3rem !important;
  }
}

/* ============ SMALL PHONES (≤ 480px) ============ */
@media (max-width: 480px) {
  .nav-logo img {
    height: 28px !important;
    max-width: 48vw !important;
  }
  .nav-toggle {
    width: 40px !important;
    height: 40px !important;
  }
  .nav-links {
    width: min(320px, 92vw) !important;
    padding: 1.25rem 1rem calc(1.25rem + env(safe-area-inset-bottom)) !important;
  }
}

/* ============ Desktop: ensure backdrop hidden ============ */
@media (min-width: 961px) {
  .mc-nav-backdrop {
    display: none !important;
  }
  /* Make sure nav-links never gets stuck in translateX from mobile state */
  .nav-links {
    transform: none !important;
  }
  /* Hide any mobile-only drawer footer on desktop */
  .mc-drawer-cta {
    display: none !important;
  }
}
