/* ==========================================================================
   menu-nav.css — mobile category navigator for menu.php
   The "Browse by Category" sidebar is hidden below 720px, so this provides
   the same jump-to-section navigation as a sticky rail + a bottom sheet.
   Everything is prefixed .mmn-* / .menu-mobile-nav and is display:none above
   720px, so the desktop menu page is completely untouched.
   ========================================================================== */

.menu-mobile-nav,
.mmn-sheet,
.mmn-top {
  display: none;
}

@media (max-width: 720px) {

  /* Anchors must land below the fixed header AND the sticky rail */
  .menu-category-section,
  #menu-top {
    scroll-margin-top: calc(var(--mmn-top, 92px) + 74px);
  }

  /* ── Sticky category rail ─────────────────────────────────────────── */
  .menu-mobile-nav {
    display: block;
    position: fixed;
    top: var(--mmn-top, 92px);
    left: 0;
    right: 0;
    z-index: 900;
    padding: 0.55rem 0.75rem;
    background: linear-gradient(180deg, rgba(250, 247, 242, 0.97) 0%, rgba(243, 236, 224, 0.95) 100%);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 12px 28px rgba(30, 27, 24, 0.08);
    transform: translateY(-130%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease, visibility 0.35s ease;
  }

  .menu-mobile-nav.is-visible {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }

  /* Stay out of the way while the nav drawer is open */
  body.nav-open .menu-mobile-nav {
    opacity: 0;
    visibility: hidden;
  }

  .mmn-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
  }

  /* "All" trigger — opens the full category sheet */
  .mmn-all {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid var(--accent-gold);
    background: var(--text-dark);
    color: var(--bg-primary);
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 0.6rem 0.85rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.3s ease, color 0.3s ease, transform 0.3s ease;
  }

  .mmn-all:active {
    transform: scale(0.95);
  }

  .mmn-all svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
  }

  /* The horizontally scrolling chip rail */
  .mmn-rail {
    flex: 1 1 auto;
    display: flex;
    gap: 0.45rem;
    overflow-x: auto;
    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0.15rem 0.25rem;
    /* Fade the chips out at the right edge so it reads as scrollable */
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 90%, transparent 100%);
    mask-image: linear-gradient(90deg, #000 0, #000 90%, transparent 100%);
  }

  .mmn-rail::-webkit-scrollbar {
    display: none;
  }

  .mmn-chip {
    flex: 0 0 auto;
    scroll-snap-align: start;
    white-space: nowrap;
    padding: 0.55rem 0.95rem;
    border-radius: 999px;
    border: 1px solid rgba(140, 114, 68, 0.22);
    background: #fff;
    color: var(--text-dark);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
  }

  .mmn-chip.is-active {
    background: linear-gradient(120deg, var(--accent-gold), var(--accent-gold-hover));
    border-color: var(--accent-gold-hover);
    color: #fff;
    box-shadow: 0 8px 18px rgba(197, 168, 128, 0.4);
  }

  /* ── Bottom sheet with every category ─────────────────────────────── */
  .mmn-sheet {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1200;
    visibility: hidden;
  }

  .mmn-sheet.is-open {
    visibility: visible;
  }

  .mmn-sheet__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(24, 20, 17, 0.55);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.4s ease;
  }

  .mmn-sheet.is-open .mmn-sheet__backdrop {
    opacity: 1;
  }

  .mmn-sheet__panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 82dvh;
    display: flex;
    flex-direction: column;
    border-radius: 26px 26px 0 0;
    padding: 0.75rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
    background:
      radial-gradient(120% 45% at 100% 0%, rgba(197, 168, 128, 0.3), transparent 60%),
      linear-gradient(180deg, #FFFDF9 0%, var(--bg-secondary) 100%);
    border-top: 1px solid var(--border-medium);
    box-shadow: 0 -24px 60px rgba(30, 27, 24, 0.3);
    transform: translateY(100%);
    transition: transform 0.55s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .mmn-sheet.is-open .mmn-sheet__panel {
    transform: translateY(0);
  }

  .mmn-sheet__handle {
    width: 44px;
    height: 4px;
    border-radius: 999px;
    background: rgba(140, 114, 68, 0.35);
    margin: 0.25rem auto 0.9rem;
    flex: 0 0 auto;
  }

  .mmn-sheet__head {
    position: relative;
    flex: 0 0 auto;
    padding-right: 3rem;
    margin-bottom: 1rem;
  }

  .mmn-sheet__head .section-tag {
    font-size: 1.05rem;
    margin-bottom: 0.15rem;
  }

  .mmn-sheet__head h3 {
    font-family: var(--font-serif);
    font-size: 1.45rem;
    color: var(--text-dark);
    line-height: 1.2;
  }

  .mmn-sheet__close {
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-medium);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.75);
    color: var(--text-dark);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.3s ease, background 0.3s ease;
  }

  .mmn-sheet__close:active {
    transform: rotate(90deg);
  }

  .mmn-search {
    flex: 0 0 auto;
    position: relative;
    margin-bottom: 1rem;
  }

  .mmn-search input {
    width: 100%;
    font-family: var(--font-sans);
    font-size: 16px; /* keeps iOS from auto-zooming on focus */
    color: var(--text-dark);
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 0.8rem 1rem 0.8rem 2.6rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
  }

  .mmn-search input:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 4px rgba(197, 168, 128, 0.18);
  }

  .mmn-search svg {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    width: 17px;
    height: 17px;
    stroke: var(--accent-gold-hover);
    fill: none;
    stroke-width: 2;
    pointer-events: none;
  }

  .mmn-grid {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.7rem;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-gold) transparent;
  }

  .mmn-grid::-webkit-scrollbar {
    width: 4px;
  }

  .mmn-grid::-webkit-scrollbar-thumb {
    background: var(--accent-gold);
    border-radius: 999px;
  }

  .mmn-tile {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.85rem 0.9rem;
    border: 1px solid rgba(140, 114, 68, 0.18);
    border-radius: 14px;
    background: #fff;
    text-decoration: none;
    /* Staggered entrance, delay set by menu-nav.js */
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.4s ease, transform 0.45s cubic-bezier(0.16, 1, 0.3, 1),
                background 0.3s ease, border-color 0.3s ease;
  }

  .mmn-sheet.is-open .mmn-tile {
    opacity: 1;
    transform: translateY(0);
  }

  .mmn-tile.is-hidden {
    display: none;
  }

  .mmn-tile.is-active {
    background: linear-gradient(120deg, rgba(197, 168, 128, 0.28), rgba(197, 168, 128, 0.08));
    border-color: var(--accent-gold);
  }

  .mmn-tile__name {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-dark);
    line-height: 1.25;
  }

  .mmn-tile__count {
    font-family: var(--font-accent);
    font-style: italic;
    font-size: 0.85rem;
    color: var(--accent-gold-hover);
  }

  .mmn-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 1.5rem 0;
  }

  /* Floating back-to-top pill */
  .mmn-top {
    position: fixed;
    right: 1rem;
    bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    z-index: 890;
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--accent-gold);
    border-radius: 50%;
    background: rgba(30, 27, 24, 0.9);
    color: var(--bg-primary);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px);
    transition: opacity 0.35s ease, visibility 0.35s ease, transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .mmn-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .mmn-top svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
}

@media (prefers-reduced-motion: reduce) {
  .menu-mobile-nav,
  .mmn-sheet__panel,
  .mmn-tile,
  .mmn-top {
    transition-duration: 0.01ms !important;
  }

  .mmn-rail {
    scroll-behavior: auto;
  }
}
