/* Shared navigation (see nav.mjs): the left rail on wide screens, the menu button and bottom sheet on
   phones, the rail popovers and the OP login card. Self-contained, because the editor does not load
   the map's stylesheet; the colours follow the shared light/dark theme (html.dark). */

:root {
  --rail: 68px;
  --nav-accent: #12a150;
  --nav-accent-soft: rgba(18, 161, 80, .12);
  --nav-ink: #1f2328;
  --nav-muted: #6b7280;
  --nav-line: #e5e7eb;
  --nav-card: #ffffff;
  --nav-hover: #f2f3f5;
  --nav-shadow: 0 2px 6px rgba(0, 0, 0, .12), 0 8px 24px rgba(0, 0, 0, .08);
}
html.dark {
  --nav-accent-soft: rgba(18, 161, 80, .22);
  --nav-ink: #e8eaed;
  --nav-muted: #9aa0a6;
  --nav-line: #3a3f47;
  --nav-card: #23272e;
  --nav-hover: #2f343c;
  --nav-shadow: 0 2px 6px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
}
@media (max-width: 640px) { :root { --rail: 0px; } }
html:not(.has-rail) { --rail: 0px; }

.nav-rail, .nav-pop, .nav-scrim, .nav-gate, .nav-menu-btn {
  font-family: "Pretendard Variable", Pretendard, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
.nav-rail *, .nav-pop *, .nav-scrim *, .nav-gate * { box-sizing: border-box; }
.nav-rail .ms, .nav-pop .ms, .nav-scrim .ms, .nav-gate .ms, .nav-menu-btn .ms {
  font-family: "Material Symbols Rounded"; font-weight: 500; font-style: normal; font-size: 22px; line-height: 1;
  display: inline-block; vertical-align: middle; user-select: none; font-feature-settings: "liga"; letter-spacing: 0;
}
:where(.nav-rail, .nav-pop, .nav-scrim, .nav-gate) :where(button, input) { font: inherit; color: inherit; }

/* ------------------------------------------------------------------ rail */
.nav-rail {
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 9000; width: var(--rail);
  display: flex; flex-direction: column; align-items: stretch; padding: 10px 0 12px;
  background: var(--nav-card); color: var(--nav-ink); box-shadow: 1px 0 0 var(--nav-line), 2px 0 10px rgba(0, 0, 0, .06);
}
@media (max-width: 640px) { .nav-rail { display: none; } }
.nav-brand { display: grid; place-items: center; height: 44px; margin: 0 10px 10px; border-radius: 12px; }
.nav-brand img { width: 34px; height: 34px; display: block; }
.nav-items { display: grid; gap: 2px; }
.nav-foot { margin-top: auto; display: grid; gap: 2px; }
.nav-item {
  display: grid; justify-items: center; gap: 3px; margin: 0 6px; padding: 7px 0 8px; min-width: 0;
  border: 0; border-radius: 12px; background: transparent; color: var(--nav-muted); text-decoration: none; cursor: pointer;
  font-size: 11.5px; font-weight: 600; letter-spacing: -.01em;
}
.nav-item > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.nav-item:hover { color: var(--nav-ink); }
/* Pages: a pill behind the icon (hover: grey, current page: green). Rail buttons: the whole item. */
.nav-ind { display: grid; place-items: center; width: 44px; height: 30px; border-radius: 15px; transition: background-color .15s; }
.nav-items .nav-item:hover .nav-ind { background: var(--nav-hover); }
.nav-foot .nav-item:hover { background: var(--nav-hover); }
.nav-item[aria-current="page"] { color: var(--nav-accent); font-weight: 700; cursor: default; }
.nav-item[aria-current="page"] .nav-ind { background: var(--nav-accent-soft); }
.nav-item[aria-expanded="true"] { background: var(--nav-hover); color: var(--nav-ink); }
.nav-item:focus-visible, .nav-brand:focus-visible { outline: 2px solid var(--nav-accent); outline-offset: -2px; }
.nav-avatar {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: var(--nav-accent); color: #fff; font-size: 14px; font-weight: 800; line-height: 1;
}
.nav-avatar.off { background: var(--nav-hover); color: var(--nav-muted); }
.nav-me .nav-avatar { width: 28px; height: 28px; font-size: 13px; margin-bottom: 1px; }

/* Popovers that open beside the rail (theme, account). */
.nav-pop {
  position: fixed; z-index: 9500; width: 244px; padding: 12px; border-radius: 14px;
  background: var(--nav-card); color: var(--nav-ink); box-shadow: var(--nav-shadow), 0 0 0 1px var(--nav-line);
  font-size: 13px;
}
.nav-pop h3 { margin: 2px 2px 10px; font-size: 12px; font-weight: 700; color: var(--nav-muted); }
.nav-note { margin: 10px 2px 0; font-size: 12px; line-height: 1.5; color: var(--nav-muted); word-break: keep-all; }
.nav-theme { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.nav-theme button {
  display: grid; justify-items: center; gap: 4px; padding: 10px 0 9px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--nav-line); background: var(--nav-card); color: var(--nav-muted); font-size: 12.5px; font-weight: 600;
}
.nav-theme button:hover { background: var(--nav-hover); color: var(--nav-ink); }
.nav-theme button[aria-checked="true"] { border-color: var(--nav-accent); background: var(--nav-accent-soft); color: var(--nav-accent); }
.nav-theme button:focus-visible { outline: 2px solid var(--nav-accent); outline-offset: 1px; }
.nav-account { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 2px 2px 12px; }
.nav-account .nav-avatar { width: 40px; height: 40px; font-size: 17px; }
.nav-account-text { display: grid; gap: 2px; min-width: 0; }
.nav-account-text b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-account-text small { font-size: 12px; color: var(--nav-muted); word-break: keep-all; }
.nav-pop-row {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border: 0; border-top: 1px solid var(--nav-line);
  border-radius: 0 0 8px 8px; background: transparent; cursor: pointer; font-size: 14px; font-weight: 600; text-align: left;
}
.nav-pop-row .ms { font-size: 20px; color: var(--nav-muted); }
.nav-pop-row:hover { background: var(--nav-hover); }

/* ------------------------------------------------------------------ phones: menu button + sheet */
.nav-menu-btn {
  display: none; flex: none; width: 48px; height: 48px; border: 0; border-radius: 12px; cursor: pointer; place-items: center;
  background: var(--nav-card); color: var(--nav-ink); box-shadow: var(--nav-shadow);
}
.nav-menu-btn .ms { font-size: 24px; }
.nav-menu-btn:active { background: var(--nav-hover); }
.nav-menu-btn.signed-in { position: relative; }
/* A green dot: someone is logged in on this browser. */
.nav-menu-btn.signed-in::after {
  content: ""; position: absolute; top: 10px; right: 10px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--nav-accent); box-shadow: 0 0 0 2px var(--nav-card);
}
@media (max-width: 640px) { .nav-menu-btn { display: grid; } }

.nav-scrim {
  position: fixed; inset: 0; z-index: 9800; display: flex; align-items: flex-end;
  background: rgba(17, 20, 24, .4); animation: nav-fade .15s ease-out;
}
.nav-sheet {
  width: 100%; max-height: 88vh; overflow: auto; padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--nav-card); color: var(--nav-ink); border-radius: 18px 18px 0 0; box-shadow: 0 -4px 24px rgba(0, 0, 0, .2);
  animation: nav-up .2s cubic-bezier(.2, .8, .2, 1);
}
.nav-sheet::before { content: ""; display: block; width: 36px; height: 4px; margin: 0 auto 10px; border-radius: 2px; background: var(--nav-line); }
@keyframes nav-fade { from { opacity: 0; } }
@keyframes nav-up { from { transform: translateY(40px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .nav-scrim, .nav-sheet { animation: none; } }
.nav-sheet-head { display: flex; align-items: center; gap: 8px; padding: 4px 0 14px; border-bottom: 1px solid var(--nav-line); }
.nav-sheet-head .nav-account { flex: 1; padding: 0; }
.nav-pill {
  flex: none; height: 34px; padding: 0 14px; border-radius: 17px; border: 1px solid var(--nav-line); background: var(--nav-card);
  font-size: 13.5px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.nav-pill.primary { border-color: var(--nav-accent); background: var(--nav-accent); color: #fff; }
.nav-icon-btn { flex: none; display: grid; place-items: center; padding: 6px; border: 0; border-radius: 8px; background: transparent; color: var(--nav-muted); cursor: pointer; }
.nav-icon-btn:hover { background: var(--nav-hover); color: var(--nav-ink); }
.nav-sheet-pages { list-style: none; margin: 6px -16px 0; padding: 0; }
.nav-sheet-pages a { display: flex; align-items: center; gap: 14px; padding: 12px 16px; color: inherit; text-decoration: none; }
.nav-sheet-pages a:active { background: var(--nav-hover); }
.nav-sheet-ico { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; flex: none; background: var(--nav-hover); color: var(--nav-muted); }
.nav-sheet-pages a[aria-current="page"] .nav-sheet-ico { background: var(--nav-accent-soft); color: var(--nav-accent); }
.nav-sheet-pages a[aria-current="page"] b { color: var(--nav-accent); }
.nav-sheet-txt { flex: 1; display: grid; gap: 2px; min-width: 0; }
.nav-sheet-txt b { font-size: 15.5px; }
.nav-sheet-txt small { font-size: 12.5px; color: var(--nav-muted); }
.nav-sheet-pages a > .ms { color: var(--nav-muted); font-size: 20px; }
.nav-here { flex: none; font-size: 12px; font-weight: 700; color: var(--nav-accent); }
.nav-sheet-theme { display: grid; gap: 8px; padding: 14px 0 2px; border-top: 1px solid var(--nav-line); margin-top: 6px; }
.nav-sheet-theme > span { font-size: 12px; font-weight: 700; color: var(--nav-muted); }

/* ------------------------------------------------------------------ login card */
.nav-gate {
  position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; padding: 16px;
  background: rgba(17, 20, 24, .45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.nav-login {
  position: relative; width: min(360px, 100%); display: grid; gap: 12px; padding: 24px;
  background: var(--nav-card); color: var(--nav-ink); border-radius: 16px; box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}
.nav-login-close { position: absolute; top: 10px; right: 10px; }
.nav-login-mark img { width: 40px; height: 40px; display: block; }
.nav-login h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.nav-login p { margin: 0; font-size: 13px; line-height: 1.55; color: var(--nav-muted); word-break: keep-all; }
.nav-login label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
.nav-login input {
  width: 100%; border: 1px solid var(--nav-line); border-radius: 10px; padding: 10px 12px; font-size: 15px;
  background: var(--nav-card); color: var(--nav-ink);
}
.nav-login input:focus { outline: 2px solid var(--nav-accent); outline-offset: -1px; border-color: var(--nav-accent); }
.nav-login .nav-login-error { color: #c62828; }
html.dark .nav-login .nav-login-error { color: #ff8a80; }
.nav-login-submit {
  border: 0; border-radius: 10px; padding: 12px; margin-top: 2px; background: var(--nav-accent); color: #fff !important;
  font-size: 15px; font-weight: 700; cursor: pointer;
}
.nav-login-submit:hover { background: #0f8a44; }
.nav-login-submit:disabled { opacity: .7; cursor: default; }
.nav-login-back { display: inline-flex; align-items: center; justify-content: center; gap: 4px; font-size: 13px; color: var(--nav-muted); text-decoration: none; }
.nav-login-back .ms { font-size: 16px; }
.nav-login-back:hover { color: var(--nav-ink); text-decoration: underline; }
