/* ==========================================================================
   nav.css — the desktop rail (the sections as cascading tabs down the left
   side), the mobile pill, and its menu (a native dialog)
   ========================================================================== */

/* Rail (≥1200px): fixed in a column of its own; the page sits to its right. */
.rail { display: none; }
@media (min-width: 1200px) {
  body { padding-left: var(--rail); }
  .rail {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: var(--z-nav);
    width: var(--rail); display: flex; flex-direction: column; gap: var(--s8);
    padding: var(--s6) var(--s5) var(--s6) var(--s6);
    border-right: 1px solid var(--line);
    overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
  }
  .rail::-webkit-scrollbar { display: none; }
}
.rail__brand {
  align-self: flex-start; display: inline-flex; align-items: center; min-height: 44px;
  margin-left: -10px; padding: 0 10px; border-radius: 10px;
  font-family: var(--font-display); font-weight: 600; font-size: var(--fs-title); letter-spacing: -0.01em; color: var(--text);
}
.rail__tabs, .rail__sub { display: flex; flex-direction: column; gap: 2px; }
.rail__tab {
  position: relative; z-index: 1; display: flex; align-items: center; min-height: 36px;
  padding: 0 12px; border-radius: 10px;
  font-size: 0.9375rem; font-weight: 600; color: var(--text-3);
  transition: color 120ms ease-out;
}
.rail__tab:hover, .rail__tab.is-active, .rail__tab.is-open { color: var(--text); }
/* The cascade: the work sits one step in, on a thread hanging from its tab. */
.rail__sub { margin: 2px 0 6px 18px; padding-left: 8px; border-left: 1px solid var(--line); }
.rail__sub .rail__tab { min-height: 32px; font-size: 0.875rem; font-weight: 500; }
/* The active tab sits on a soft pill that glides between tabs (a CSS transition). */
.rail__indicator {
  position: absolute; left: 0; top: 0; width: 1px; height: 1px;
  border-radius: 10px; background: var(--mat-thin-bg); border: 1px solid var(--line);
  opacity: 0; pointer-events: none;
}
.rail__indicator.is-on { opacity: 1; }
.rail__indicator.is-placed { transition: transform 300ms var(--ease-out), width 300ms var(--ease-out), height 300ms var(--ease-out), opacity 200ms ease; }
html[data-motion="reduced"] .rail__indicator.is-placed { transition: opacity 200ms ease; }

/* Mobile pill (<1200px) ---------------------------------------------------- */
.pill {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: var(--z-nav);
  width: min(92vw, 420px); height: 56px; border-radius: var(--r-round);
  display: grid; grid-template-columns: minmax(0, 1fr) 20px; align-items: center; gap: 12px;
  padding: 0 18px 0 22px; color: var(--text); text-align: left;
  background: var(--mat-chrome-bg);
  -webkit-backdrop-filter: var(--mat-chrome-blur); backdrop-filter: var(--mat-chrome-blur);
  border-top: 1px solid var(--mat-chrome-edge); box-shadow: var(--mat-chrome-shadow);
  transform: translateX(-50%);
  transition: opacity 160ms ease, transform 160ms var(--ease-out);
}
.pill.pressed { transform: translateX(-50%) scale(0.98); }
.pill.is-under { opacity: 0; pointer-events: none; }
.pill__label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill__chev { color: var(--text-2); width: 20px; height: 20px; }
@media (min-width: 1200px) { .pill, .sheet { display: none !important; } }
html.no-js .pill, html.no-js .sheet { display: none !important; }

/* Menu: a native modal <dialog>, docked to the bottom ---------------------- */
/* The browser gives it the top layer, focus containment, an inert page and Escape. */
html.has-sheet { overflow: hidden; }
.sheet {
  inset: 0; margin: auto auto 0; padding: 0; border: 0;
  width: min(100vw, 480px); max-width: 100vw; max-height: 100%;
  background: transparent; color: var(--text); overflow: visible;
}
.sheet::backdrop { background: var(--scrim); opacity: 0; transition: opacity 240ms ease; }
.sheet.is-open::backdrop { opacity: 1; }
.sheet__panel {
  padding: 8px 8px calc(16px + env(safe-area-inset-bottom));
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  background: var(--mat-thick-solid);
  border-top: 1px solid var(--mat-thick-edge); box-shadow: var(--mat-thick-shadow);
  max-height: 100vh; max-height: 100dvh; overflow-y: auto; overscroll-behavior: contain;   /* phones held sideways */
  transform: translateY(100%);
  transition: transform 320ms var(--ease-out);
}
.sheet.is-open .sheet__panel { transform: none; }
html[data-motion="reduced"] .sheet__panel, html[data-motion="reduced"] .sheet::backdrop { transition: none; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 4px 8px 16px; }
.sheet__title { color: var(--text-2); }
.sheet__nav { display: flex; flex-direction: column; }
.sheet__row {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 16px;
  border-radius: 14px; color: var(--text-2); font-weight: 600;
}
.sheet__row::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: transparent; flex: none; }
.sheet__row.is-active { color: var(--text); }
.sheet__row.is-active::before { background: var(--brand); }
.sheet__row.pressed, .sheet__row:active { background: var(--surface-3); transform: none; }
.sheet__tools { display: flex; justify-content: center; gap: 4px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
html[data-contrast="more"] .sheet__panel, html[data-contrast="more"] .pill { border: 1px solid var(--line-strong); }
