/* Shared side navigation — the sidenav shell that used to be copy-pasted into
   index.html, campus.html, appearance.html and admin.html. Colour tokens come
   from each page's own :root block; markup comes from /assets/sidebar.js. */

.sidenav {
  flex: 0 0 auto; width: var(--nav-w);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
  transition: width .18s ease;
  overflow: hidden; z-index: 20;
}
body[data-nav="rail"] .sidenav { width: var(--nav-w-rail); }

.nav-head { display: flex; align-items: center; gap: 10px; padding: 16px 14px; min-height: 62px; }
.nav-brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.nav-brand h1 { font-size: 16.5px; font-weight: 650; letter-spacing: -.01em; margin: 0; white-space: nowrap; }
.nav-toggle {
  margin-left: auto; flex: 0 0 auto; display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
  background: transparent; border: 1px solid transparent; color: var(--muted);
}
.nav-toggle:hover { color: var(--text); background: var(--surface-2); border-color: var(--border); }
body[data-nav="rail"] .nav-brand { display: none; }
body[data-nav="rail"] .nav-toggle { margin: 0 auto; }

.nav-list { flex: 1 1 auto; overflow-y: auto; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-sec {
  font-size: 10px; letter-spacing: .13em; text-transform: uppercase; color: var(--muted);
  font-weight: 700; padding: 14px 10px 6px; white-space: nowrap;
}
body[data-nav="rail"] .nav-sec { padding: 12px 0 4px; text-align: center; overflow: hidden; }
body[data-nav="rail"] .nav-sec span { display: none; }
body[data-nav="rail"] .nav-sec::before { content: "···"; letter-spacing: 0; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 9px; cursor: pointer;
  background: transparent; border: 1px solid transparent;
  color: var(--muted); font: inherit; font-size: 14px; font-weight: 550;
  text-align: left; text-decoration: none; width: 100%; white-space: nowrap;
  transition: background .13s, color .13s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current="page"] {
  background: var(--accent-soft); color: var(--text); font-weight: 650;
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.nav-item[aria-current="page"] svg.i { color: var(--accent); }
.nav-item .lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
body[data-nav="rail"] .nav-item { justify-content: center; padding: 10px 0; }
body[data-nav="rail"] .nav-item .lbl,
body[data-nav="rail"] .nav-item .nav-badge { display: none; }
.nav-badge {
  margin-left: auto; font-size: 10.5px; font-weight: 700; font-family: var(--mono);
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 0 6px;
}

/* Nested items (Map/List under Rooms, folders under Link groups, page sections
   under the active Administration entry). On the rail the indent shrinks but
   must not vanish — a connector line keeps them reading as children of the
   item above rather than peers of it. */
.nav-sub {
  display: flex; flex-direction: column; gap: 2px;
  margin: 2px 0 2px 26px; padding-left: 0; border-left: 0;
}
body[data-nav="rail"] .nav-sub {
  margin: 2px 6px 2px 20px; padding-left: 2px;
  border-left: 1px solid var(--border);
}
body[data-nav="rail"] .nav-sub .nav-item { padding: 7px 0; }
.nav-sub .nav-item { font-size: 13px; padding: 6px 11px; }
.nav-sub .nav-item svg.i { width: 15px; height: 15px; }
/* folder anchors carry a colour swatch, which doubles as their rail icon */
.nav-dot {
  width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto;
  background: var(--dot, var(--muted)); box-shadow: 0 0 0 1px rgba(0, 0, 0, .22) inset;
}
/* collections: a square emblem, their member folders indented beneath */
.nav-sq {
  width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto;
  background: var(--dot, var(--muted)); box-shadow: 0 0 0 1px rgba(0, 0, 0, .22) inset;
}
.nav-sub .nav-item.member { padding-left: 26px; }
body[data-nav="rail"] .nav-sub .nav-item.member { padding-left: 0; }
.nav-sub .nav-item .cnt { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
body[data-nav="rail"] .nav-sub .nav-item .cnt { display: none; }
.nav-sub .empty-sub { font-size: 12px; color: var(--muted); padding: 4px 11px; white-space: nowrap; }
body[data-nav="rail"] .nav-sub .empty-sub { display: none; }

.nav-foot { flex: 0 0 auto; border-top: 1px solid var(--border); padding: 12px 12px 14px; }
.nav-who { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; min-width: 0; }
.nav-avatar {
  width: 30px; height: 30px; border-radius: 9px; flex: 0 0 auto; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}
.nav-who .meta { min-width: 0; display: flex; flex-direction: column; }
.nav-who .nm { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-who .rl { font-size: 10px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
body[data-nav="rail"] .nav-who .meta { display: none; }
body[data-nav="rail"] .nav-who { justify-content: center; }

.looks { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; margin-bottom: 8px; }
.looks button {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 11px; font-weight: 650; letter-spacing: .02em;
  padding: 5px 4px; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.looks button[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); }
.looks button:hover { color: var(--text); }
body[data-nav="rail"] .looks { display: none; }
/* The theme-cycle button stands in for the segmented switcher on the rail.
   Needs to out-specify `.nav-foot .signout`, which sets display:flex. */
body:not([data-nav="rail"]) .nav-foot .rail-look { display: none; }

.nav-foot .signout {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  background: transparent; border: 1px solid var(--border); border-radius: 9px;
  color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600;
  padding: 7px 10px; cursor: pointer;
}
.nav-foot .signout:hover { color: var(--text); border-color: var(--accent); }
body[data-nav="rail"] .signout .lbl { display: none; }

/* A section arrived at from the sidenav flashes once so the eye lands on it —
   the same idea as the Link-groups folder .flash on the dashboard. */
.sec-flash { animation: sec-flash 1.2s ease-out; }
@keyframes sec-flash {
  0% { outline: 2px solid var(--accent); outline-offset: 10px; }
  100% { outline: 2px solid transparent; outline-offset: 10px; }
}

@media (max-width: 900px) {
  .sidenav { width: var(--nav-w-rail) !important; }
  .sidenav .nav-brand, .sidenav .nav-item .lbl, .sidenav .nav-item .nav-badge,
  .sidenav .nav-who .meta, .sidenav .looks, .sidenav .nav-sec span { display: none; }
  .sidenav .nav-item { justify-content: center; padding: 10px 0; }
  /* the rail is forced here regardless of data-nav, so repeat the nesting cues */
  .sidenav .nav-sub { margin: 2px 6px 2px 20px; padding-left: 2px; border-left: 1px solid var(--border); }
  .sidenav .nav-sub .nav-item { padding: 7px 0; }
  .sidenav .nav-sub .nav-item .cnt, .sidenav .nav-sub .empty-sub { display: none; }
  .sidenav .nav-toggle { display: none; }
  .sidenav .signout .lbl { display: none; }
  body .sidenav .nav-foot .rail-look { display: flex; }
  .sidenav .nav-sec { padding: 12px 0 4px; text-align: center; }
}
