/* ==========================================================================
   The sidebar — the menu inside the app (every members-only page).

   Written into each page by tools/sync-nav.mjs, like the top bar, which the
   public pages keep. <html data-shell="side"> (also written by the script)
   makes room for it. Carries its own tokens, scoped to .sidenav, so a page's
   own :root variables or dark mode never repaint it.

   Wide screens: a fixed column on the left. Narrow (< 900px): a 62px bar
   across the top with a Menu button that opens the same list as a panel —
   the same height as the old top bar, so sticky toolbars keep their offset.
   ========================================================================== */

.sidenav {
  --sn-w: 232px;
  --sn-ink: #0C2040; --sn-ink-2: #2A3E5C; --sn-muted: #4A6180; --sn-faint: #7A8CA6;
  --sn-line: #DCE5ED; --sn-bg: #FBFBF9; --sn-panel: #FFFFFF; --sn-sunk: #EDF2F7;
  --sn-accent: #0070C0; --sn-accent-ink: #005A9A; --sn-accent-soft: #E6F1FA;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--sn-ink); color-scheme: light;
  background: var(--sn-bg); z-index: 60; box-sizing: border-box;
}
.sidenav *, .sidenav *::before, .sidenav *::after { box-sizing: border-box; }

.sidenav .sn-top { height: 62px; display: flex; align-items: center; gap: 12px; padding: 0 20px; flex: none; }
.sidenav .sn-brand {
  font-family: Montserrat, Inter, system-ui, sans-serif;
  font-weight: 700; font-size: 16px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--sn-ink); text-decoration: none; white-space: nowrap;
  display: flex; align-items: center; gap: 10px;
}
.sidenav .brand-mark {
  width: 24px; height: 28px; flex: none; display: inline-block;
  background: url("../img/kove-mark.png") center/contain no-repeat;
}
.sidenav .sn-toggle {
  display: none; margin-left: auto; align-items: center; gap: 8px;
  font: inherit; font-size: 13.5px; color: var(--sn-ink-2);
  background: var(--sn-panel); border: 1px solid var(--sn-line); border-radius: 6px;
  padding: 7px 12px; cursor: pointer;
}
.sidenav .sn-bars, .sidenav .sn-bars::before, .sidenav .sn-bars::after {
  display: block; width: 14px; height: 1.5px; background: currentColor; border-radius: 1px; position: relative;
}
.sidenav .sn-bars::before, .sidenav .sn-bars::after { content: ""; position: absolute; left: 0; }
.sidenav .sn-bars::before { top: -4.5px; }
.sidenav .sn-bars::after { top: 4.5px; }

.sidenav .sn-panel { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.sidenav .sn-nav { flex: 1; overflow-y: auto; padding: 6px 12px 20px; }
.sidenav .sn-link {
  display: block; padding: 6px 10px; border-radius: 6px;
  font-size: 13.5px; line-height: 1.35; color: var(--sn-ink-2); text-decoration: none;
}
.sidenav .sn-link:hover { background: var(--sn-sunk); color: var(--sn-ink); }
.sidenav .sn-link:focus-visible, .sidenav .sn-toggle:focus-visible { outline: 2px solid var(--sn-accent); outline-offset: 1px; }
.sidenav .sn-link.active { background: var(--sn-accent-soft); color: var(--sn-accent-ink); font-weight: 600; }
.sidenav .sn-label {
  margin: 16px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--sn-faint);
}
.sidenav .sn-sep { height: 1px; background: var(--sn-line); margin: 6px 10px; }

/* Links only one role can use (tools/sync-nav.mjs, data-for): hidden until
   auth.js has set <html data-role>, then shown to that role and to the admin.
   Presentation only: the page itself checks the role. */
.sidenav .sn-link[data-for] { display: none; }
html[data-role="admin"] .sidenav .sn-link[data-for],
html[data-role="originator"] .sidenav .sn-link[data-for="originator"] { display: block; }

/* Admin group: only for the admin. auth.js sets <html data-role> after sign-in.
   Presentation only — each admin page checks the role itself. */
.sidenav .sn-admin { display: none; }
html[data-role="admin"] .sidenav .sn-admin { display: block; }

/* --- account, at the foot ------------------------------------------------ */
.sidenav .sn-who { flex: none; border-top: 1px solid var(--sn-line); padding: 12px; display: flex; }
.sidenav .sn-who .nav-group.account { position: relative; width: 100%; }
.sidenav .nav-group.account .nav-trigger {
  width: 100%; display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  font: inherit; font-size: 13px; color: var(--sn-ink-2); text-align: left;
  background: none; border: 1px solid transparent; border-radius: 8px; padding: 8px 10px; cursor: pointer;
}
.sidenav .nav-group.account .nav-trigger:hover,
.sidenav .nav-group.account.open .nav-trigger { background: var(--sn-sunk); }
.sidenav .nav-trigger .caret { margin-left: auto; font-size: 9px; opacity: .55; }
.sidenav .ident-org { color: var(--sn-ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.sidenav .ident-role {
  font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--sn-accent-ink); background: var(--sn-accent-soft); padding: 2px 7px; border-radius: 4px;
}
.sidenav .ident-acting {
  font-size: 11px; font-weight: 600; color: #7A4B00; background: #FFE8B3; padding: 2px 7px; border-radius: 4px; white-space: nowrap;
}
.sidenav .nav-menu {
  /* Opens upward. top:auto matters: styles.css gives .nav-menu a top, and a
     menu with both top and bottom set collapses and spills below the screen. */
  position: absolute; top: auto; left: 0; right: 0; bottom: calc(100% + 6px);
  background: var(--sn-panel); border: 1px solid var(--sn-line); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(12,32,64,.14); padding: 6px; display: none; z-index: 100;
}
.sidenav .nav-group.open > .nav-menu { display: block; }
.sidenav .nav-menu a, .sidenav .nav-menu button {
  display: block; width: 100%; text-align: left; padding: 8px 11px; border-radius: 6px;
  font: inherit; font-size: 13.5px; color: var(--sn-ink-2); text-decoration: none;
  background: none; border: 0; cursor: pointer;
}
.sidenav .nav-menu a:hover, .sidenav .nav-menu button:hover { background: var(--sn-sunk); color: var(--sn-ink); }
.sidenav .nav-menu .nav-hint { color: var(--sn-faint); }
.sidenav .nav-menu .nav-sep { height: 1px; background: var(--sn-line); margin: 6px 4px; }
.sidenav .nav-menu .nav-note { padding: 6px 11px 2px; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--sn-faint); }
.sidenav .tb-cta {
  width: 100%; text-align: center; background: var(--sn-accent); color: #fff; text-decoration: none;
  font-size: 13px; font-weight: 500; padding: 8px 13px; border-radius: 6px;
}
.sidenav .tb-cta:hover { background: var(--sn-accent-ink); }

/* build stamp and DEV badge (nav.js) */
.sidenav .sn-version { flex: none; margin: 0; padding: 0 22px 12px; font-size: 11px; color: var(--sn-faint); font-variant-numeric: tabular-nums; }
.sidenav .sn-version[hidden], .sidenav .sn-env[hidden] { display: none; }
.sidenav .sn-env {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: #7A4B00; background: #FFE8B3; padding: 2px 7px; border-radius: 4px;
}
html[data-env="dev"] .sidenav { --sn-bg: #FFFBF0; }

/* --- wide: a fixed column ------------------------------------------------ */
@media (min-width: 900px) {
  html[data-shell="side"] body { padding-left: 232px; }
  .sidenav {
    position: fixed; top: 0; left: 0; bottom: 0; width: var(--sn-w);
    display: flex; flex-direction: column; border-right: 1px solid var(--sn-line);
  }
  /* sticky page toolbars sat under a 62px top bar; there is none now */
  html[data-shell="side"] .toolbar,
  html[data-shell="side"] .timeline { top: 0; }
}

/* --- narrow: a bar with a Menu button ------------------------------------ */
@media (max-width: 899.98px) {
  .sidenav { position: sticky; top: 0; border-bottom: 1px solid var(--sn-line); }
  .sidenav .sn-top { padding: 0 16px; }
  .sidenav .sn-toggle { display: inline-flex; }
  .sidenav .sn-panel {
    display: none; position: absolute; top: 62px; left: 0; right: 0;
    max-height: calc(100vh - 62px); overflow-y: auto;
    background: var(--sn-bg); border-bottom: 1px solid var(--sn-line);
    box-shadow: 0 12px 28px rgba(12,32,64,.12);
  }
  .sidenav.is-open .sn-panel { display: flex; }
  .sidenav .sn-nav { overflow: visible; }
}

@media print {
  .sidenav { display: none !important; }
  html[data-shell="side"] body { padding-left: 0 !important; }
}
