/* ☰ The section menu (navmenu.js): BuckBoy's ☰ panel (ported from ChoreBoy's) with DressBoy's drawer. The ☰ at the left
   of the top bar, then the logo (with its Beta pill); the panel is a drawer down the left side, under the top bar, on a
   computer and drops down across the screen under the bar on a phone. Its motion follows ✨ Animations (html[data-fx]). */

.nav-menu-btn { display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; width: 2.3rem; height: 2.3rem; padding: 0; margin-right: -.25rem; border: 0; border-radius: 999px; background: none; color: var(--text-2); cursor: pointer; }
.nav-menu-btn svg { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.nav-menu-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-menu-btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.nav-menu-btn[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent-text); }

/* The chips sit at the right (no screen name in the bar since 2026-11-11). */
.topbar .top-tools { margin-left: auto; }

body.logged-out .nav-menu-btn, body.logged-out .nav-menu, body.in-setup .nav-menu-btn { display: none !important; }

/* (Open: the bar and its panel over the 💬 Help chat (61), under popups (300).) */
body.nav-open .topbar { z-index: 62; }

/* ---------- the panel ---------- */

.nav-menu {
  position: absolute; z-index: 45; top: calc(100% + 6px); left: 1rem;
  min-width: 220px; max-width: calc(100vw - 16px); max-height: calc(100vh - 5rem); overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 2px; padding: .35rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  transform-origin: top left;
  animation: nav-menu-in .18s cubic-bezier(.2, .8, .3, 1);
}
.nav-menu[hidden] { display: none !important; }
.nav-menu.closing { animation: nav-menu-out .14s ease-in forwards; pointer-events: none; }
.nav-menu-item { display: flex; align-items: center; gap: .7rem; width: 100%; padding: .6rem .75rem; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); font: 600 .95rem var(--font); text-align: left; cursor: pointer; }
.nav-menu-item:hover, .nav-menu-item:focus-visible { background: var(--surface-2); }
.nav-menu-item:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.nav-menu-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }
.nav-menu-item[aria-current="page"]::after { content: '✓'; margin-left: auto; padding-left: .75rem; font-weight: 700; }
.nav-menu-ico { width: 1.4rem; flex-shrink: 0; text-align: center; font-size: 1.05rem; line-height: 1; }
.nav-menu-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@keyframes nav-menu-in { from { opacity: 0; transform: translateY(-6px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes nav-menu-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-4px) scale(.98); } }
@keyframes nav-drawer-in { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes nav-menu-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes nav-menu-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes nav-drawer-out { from { transform: none; } to { transform: translateX(-100%); } }

/* ---------- phones: across the screen, under the bar ---------- */

@media (max-width: 600px) {
  .nav-menu {
    top: 100%; left: 0; right: 0; min-width: 0; max-width: none; max-height: calc(100dvh - 4rem);
    border-width: 0 0 1px; border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    padding: .4rem max(.6rem, env(safe-area-inset-right)) .6rem max(.6rem, env(safe-area-inset-left));
    box-shadow: var(--shadow-lg), 0 0 0 100vmax rgb(0 0 0 / .25); /* (the dim: a press on it is outside, so it closes) */
    transform-origin: top center;
  }
  .nav-menu-btn { width: 2.1rem; height: 2.1rem; margin-right: -.15rem; }
  .nav-menu-item { padding: .75rem .8rem; font-size: 1rem; }
}

/* ---------- wider: a drawer down the left side, under the top bar, over a dimmed page ---------- */

/* Under the bar, not over it (Jared, 2026-11-23: "slide in below the top nav/under it instead of overlay. it
   can overlay on the current page, but not the topnav"). The drawer hangs from the bar: it's absolute in the
   bar's <header> (sticky, so the bar is its frame), its top just under the bar's 1px bottom border
   (calc(100% + 1px)). So it moves with the bar in the same frame, whatever moves the bar: the page scrolling
   the ↩ Return band (returnbar.js) away or back (the browser scrolls the sticky bar by itself, a
   frame or more before a 'scroll' handler runs), the band arriving, sliding open or going (✕), or the bar
   wrapping to two lines. (A fixed drawer at a measured top trailed the bar mid-scroll: an undimmed strip
   flickered between them, or the drawer slid over the bar's bottom edge.)
   Only its height is measured: the window less --nav-top, where the bar ends on screen (navmenu.js keeps it
   right while it's open), so it runs to the bottom of the window, scrolling inside itself. A height a frame
   out of date only moves its bottom edge, below the window or over the dim, never its top.
   z-index -1: the panel lives in the bar's <header>, so this puts it under the bar's ☰, logo and chips, while
   the bar itself (62 when open) stays over the page and 💬 Help. The clip-path cuts the dim (the box-shadow)
   off at the drawer's top edge, so the bar and the band above it are never dimmed and stay clickable. */
@media (min-width: 601px) {
  /* (The bar keeps its blur while the drawer's open. Only the fixed drawer needed it off: a blurred bar was its
     frame and squashed it into the bar. The sticky bar is this drawer's frame either way: checked in headless
     Chrome, the drawer draws the same with the bar blurred or not.) */
  .nav-menu {
    position: absolute; z-index: -1; top: calc(100% + 1px); bottom: auto; left: 0; right: auto;
    height: calc(100vh - var(--nav-top, 3.6rem)); height: calc(100dvh - var(--nav-top, 3.6rem));
    width: max-content; min-width: 0; max-width: min(300px, 85vw); max-height: none; gap: 4px; /* (as wide as the longest screen's name: Jared, 2026-11-23) */
    padding: .6rem .6rem 1rem max(.6rem, env(safe-area-inset-left));
    border-width: 0 1px 0 0; border-radius: 0 0 var(--radius-lg) 0; /* (square at the top, flush with the bar) */
    box-shadow: var(--shadow-lg), 0 0 0 100vmax rgb(0 0 0 / .32);
    clip-path: inset(0 -100vmax -100vmax -100vmax);
    transform-origin: left center;
    animation: nav-drawer-in .22s cubic-bezier(.2, .8, .3, 1);
  }
  .nav-menu.closing { animation: nav-drawer-out .16s ease-in forwards; }
  .nav-menu-item { padding: .75rem .85rem; font-size: 1rem; }
}

/* ✨ Animations: Subtle fades, Off (and reduced motion) doesn't move. */
html[data-fx="subtle"] .nav-menu { animation: nav-menu-fade-in .12s ease-out; }
html[data-fx="subtle"] .nav-menu.closing { animation: nav-menu-fade-out .1s ease-in forwards; }
html[data-fx="off"] .nav-menu, html[data-fx="off"] .nav-menu.closing { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .nav-menu, .nav-menu.closing { animation: none; }
}
@media print {
  .nav-menu-btn, .nav-menu { display: none !important; }
}
