/* smw.org - hamburger menu (assets/nav.js), loaded on every public page.

   The button is position:fixed in the top-right corner, so it stays in view
   while you scroll and takes no space in any page's layout. It is hidden
   whenever the browser is in full-screen mode (Marble's full-screen button,
   the home page's full-screen map).

   Two looks, chosen automatically by nav.js:
   - .is-sky   the home page: uses its sky tokens (--ink*, --plank*, ...)
               from base.css, exactly as before.
   - default   every other page: a self-contained dark-glass palette that
               reads on any background, and does not borrow the page's own
               --ink/--accent tokens (they mean different things per page). */

.site-nav {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 900;
  font-family: var(--sans, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif);

  --nv-ink: #ffffff;
  --nv-ink-soft: rgba(255, 255, 255, 0.92);
  --nv-ink-dim: rgba(255, 255, 255, 0.75);
  --nv-plank: rgba(12, 28, 50, 0.74);
  --nv-plank-brd: rgba(255, 255, 255, 0.32);
  --nv-accent: #ffd27a;
  --nv-focus: #cfe8ff;
  --nv-menu-bg: #14294a;
  --nv-menu-brd: rgba(255, 255, 255, 0.28);
  --nv-shadow: rgba(4, 10, 20, 0.6);
}
.site-nav.is-sky {
  --nv-ink: var(--ink);
  --nv-ink-soft: var(--ink-soft);
  --nv-ink-dim: var(--ink-dim);
  --nv-plank: var(--plank);
  --nv-plank-brd: var(--plank-brd);
  --nv-accent: var(--accent);
  --nv-focus: var(--accent-2);
  --nv-menu-bg: color-mix(in srgb, var(--sky-top) 78%, #050b14 22%);
  --nv-menu-brd: var(--panel-brd);
  --nv-shadow: var(--shadow);
}
.site-nav[hidden], .site-nav.is-fullscreen { display: none; }

/* invisible in any full-screen mode (Fullscreen API, or the home page's
   full-screen map overlay). Separate rules: an unknown prefixed selector
   would otherwise invalidate the whole list. */
:fullscreen .site-nav { display: none !important; }
:-webkit-full-screen .site-nav { display: none !important; }
html.wm-fs-lock .site-nav { display: none; }
@media print { .site-nav { display: none; } }

.site-nav-btn {
  display: grid;
  place-items: center;
  width: 44px;            /* 44px minimum tap target */
  height: 44px;
  padding: 0;
  color: var(--nv-ink-soft);
  background: var(--nv-plank);
  border: 1px solid var(--nv-plank-brd);
  border-radius: 14px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px -12px var(--nv-shadow);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.site-nav-btn svg { width: 20px; height: 20px; display: block; }
.site-nav-btn:hover,
.site-nav-btn[aria-expanded="true"] { color: var(--nv-ink); border-color: var(--nv-accent); }
.site-nav-btn:focus-visible { outline: 2px solid var(--nv-focus); outline-offset: 2px; }

.site-nav-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1;
  list-style: none;
  margin: 0;
  padding: 6px;
  min-width: 200px;
  max-width: min(300px, calc(100vw - 20px));
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  /* mostly opaque so whatever is behind never makes the links hard to read */
  background: var(--nv-menu-bg);
  border: 1px solid var(--nv-menu-brd);
  border-radius: 16px;
  box-shadow: 0 16px 40px -14px var(--nv-shadow);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  backdrop-filter: blur(14px) saturate(130%);
}
.site-nav-menu[hidden] { display: none; }

.site-nav-menu a {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 14px;
  color: var(--nv-ink);
  font-size: 0.95rem;
  line-height: 1.2;
  text-decoration: none;
  border: 0;
  border-radius: 10px;
}
.site-nav-menu a:hover { background: rgba(255, 255, 255, 0.12); color: var(--nv-ink); }
.site-nav-menu a:focus-visible { outline: 2px solid var(--nv-focus); outline-offset: -2px; background: rgba(255, 255, 255, 0.12); }

.site-nav-ext { color: var(--nv-ink-dim); font-size: 0.8em; }

/* visually hidden, still read by screen readers */
.site-nav-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .site-nav-btn { transition: color 0.15s, border-color 0.15s; }
  .site-nav-menu:not([hidden]) { animation: siteNavIn 0.14s ease-out; }
  @keyframes siteNavIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}

@media (max-width: 560px) {
  .site-nav { top: 8px; right: 8px; }
}
