/* Shared top navigation bar (built by src/nav.js, loaded on every page).
   Self-contained so it looks identical whether the page is the light batch
   finder (style.css) or a dark console page (compose.css). It leans on the
   shared theme tokens both stylesheets define, with hard fallbacks. */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--asphalt, #1b1e24);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.site-nav-inner {
  position: relative;
  max-width: 1040px;
  margin-inline: auto;
  padding: 0.5rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* brand lockup */
.site-nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  flex: none;
}
.site-nav-logo {
  width: 30px;
  height: 30px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}
.site-nav-word {
  font: 700 0.8rem/1 var(--mono, "Space Mono", monospace);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--headlight, #ffcf3f);
}
.site-nav-word span { color: var(--accent, #f2334d); }

/* tabs */
.site-nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
}
.site-nav-link {
  position: relative;
  text-decoration: none;
  color: #c9cbc4;
  font: 700 0.84rem/1 var(--body, "Inter", system-ui, sans-serif);
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  transition: color 0.15s ease, background 0.15s ease;
}
.site-nav-link:hover { color: #fff; background: rgba(255, 255, 255, 0.07); }
.site-nav-link:focus-visible {
  outline: 2px solid var(--accent, #f2334d);
  outline-offset: 2px;
}
.site-nav-link.active { color: #fff; }

/* install-as-app button */
.site-nav-install {
  border: 1px solid var(--headlight, #ffcf3f);
  background: transparent;
  color: var(--headlight, #ffcf3f);
  cursor: pointer;
  margin-left: 0.4rem;
}
.site-nav-install:hover { background: rgba(255, 207, 63, 0.14); color: var(--headlight, #ffcf3f); }
.site-nav-install.active::after { display: none; }
.site-nav-link.active::after {
  content: "";
  position: absolute;
  left: 0.9rem;
  right: 0.9rem;
  bottom: 0.28rem;
  height: 2px;
  border-radius: 2px;
  background: var(--accent, #f2334d);
}

/* hamburger (mobile) */
.site-nav-toggle {
  display: none;
  width: 42px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.site-nav-toggle:focus-visible {
  outline: 2px solid var(--accent, #f2334d);
  outline-offset: 2px;
}
.site-nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: #e8e8e2;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.site-nav-toggle.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.site-nav-toggle.open span:nth-child(2) { opacity: 0; }
.site-nav-toggle.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 820px) {
  .site-nav-toggle { display: flex; }
  .site-nav-links {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin-left: 0;
    padding: 0.4rem 1rem 0.8rem;
    background: var(--asphalt, #1b1e24);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }
  .site-nav-links.open { display: flex; }
  .site-nav-link { padding: 0.75rem 0.7rem; }
  .site-nav-link.active::after { left: 0.7rem; right: auto; width: 16px; bottom: 0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .site-nav-link, .site-nav-toggle span { transition: none; }
}

/* Leaflet gives its controls and popups very high z-indexes (up to ~1000), which
   would otherwise render above the sticky nav (and modals) as a map scrolls past.
   Isolating the map into its own stacking context keeps all of that below page
   chrome, so the map tucks neatly under the menu bar. */
.leaflet-container {
  position: relative;
  z-index: 0;
  isolation: isolate;
}

/* right-side auxiliary cluster: connection badge + help */
.site-nav-aux { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }

.conn-badge { display: inline-flex; align-items: center; font: 600 0.74rem/1 var(--mono, "Space Mono", monospace); white-space: nowrap; }
.conn-badge .dot { width: 8px; height: 8px; border-radius: 50%; margin-right: 0.4rem; background: currentColor; }
.conn-badge.ok { color: #6fd39b; }
.conn-badge.warn { color: #ffcf3f; }
.conn-badge.warn button { display: inline-flex; align-items: center; border: 1px solid rgba(255, 207, 63, 0.5); background: rgba(255, 207, 63, 0.12); color: #ffcf3f; font: inherit; padding: 0.35rem 0.6rem; border-radius: 999px; cursor: pointer; }
.conn-badge.warn button:hover { background: rgba(255, 207, 63, 0.22); }

.site-nav-help { width: 26px; height: 26px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.22); background: transparent; color: #c9cbc4; font: 700 0.9rem/1 var(--body, sans-serif); cursor: pointer; flex: none; }
.site-nav-help:hover { color: #fff; border-color: #fff; }

.nav-help-pop { position: fixed; z-index: 400; width: min(320px, calc(100vw - 2rem)); background: #211f2a; color: #ece9f3; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 14px; padding: 0.9rem 1rem; box-shadow: 0 20px 50px -18px rgba(0, 0, 0, 0.8); }
.nav-help-pop p { margin: 0; font: 400 0.88rem/1.5 var(--body, system-ui, sans-serif); }
.nav-help-pop[hidden] { display: none; }

@media (max-width: 720px) {
  .conn-badge { display: none; }
}

/* global place search — a compact magnifier that expands into an input on focus,
   so it doesn't crowd the nav. */
.nav-search { position: relative; }
.nav-search input {
  width: 2.4rem;
  padding: 0.4rem 0.6rem 0.4rem 1.95rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%239a9c95' stroke-width='1.6'%3E%3Ccircle cx='7' cy='7' r='4.5'/%3E%3Cpath d='M10.5 10.5l3.5 3.5'/%3E%3C/svg%3E")
    no-repeat 0.6rem center;
  background-size: 15px;
  color: #ece9f3;
  font: 500 0.82rem/1 var(--body, system-ui, sans-serif);
  transition: width 0.18s ease, border-color 0.15s ease;
  cursor: pointer;
}
.nav-search input::placeholder { color: #9a9c95; }
.nav-search input:focus { outline: none; width: 210px; border-color: var(--accent, #f2334d); cursor: text; }
.nav-search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: min(320px, 80vw);
  background: #211f2a;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  box-shadow: 0 20px 50px -18px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  z-index: 400;
}
.nav-search-results[hidden] { display: none; }
.nav-search-results a {
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.nav-search-results a:last-child { border-bottom: 0; }
.nav-search-results a:hover { background: rgba(255, 255, 255, 0.07); }
.nav-search-results .nsr-name { color: #fff; font: 600 0.86rem/1.3 var(--body, system-ui, sans-serif); }
.nav-search-results .nsr-sub { color: #9a95a8; font: 400 0.74rem/1.3 var(--mono, monospace); }
.nav-search-empty { margin: 0; padding: 0.7rem 0.75rem; color: #9a95a8; font: 400 0.82rem/1.4 var(--body, system-ui, sans-serif); }

.nav-help-keys { margin: 0.5rem 0 0 !important; padding-top: 0.5rem; border-top: 1px solid rgba(255, 255, 255, 0.12); color: #b7b2c4 !important; font: 500 0.78rem/1.4 var(--mono, monospace) !important; }

@media (max-width: 520px) { .nav-search { display: none; } }
