/* adminrail — the admin console's section navigation.
 *
 * WHY THIS EXISTS. Every owner's /admin grew the same way: one horizontal row
 * of tabs, one tab per feature wave, `overflow-x:auto` so it never visibly
 * broke. The first console to reach twelve sections fitted nine — the last
 * three sat off the right edge of a scroller with nothing on screen saying
 * they existed, and the owner found them by accident. A row that silently
 * hides its own tail is not navigation.
 *
 * The rail runs the sections down the left in labelled groups: all of them on
 * screen at once, and still on screen while the page scrolls. Under
 * --adminrail-break it becomes a grouped grid above the content instead.
 *
 * CONTRACT WITH THE PAGE
 *   - the tab bar is `#admin-root > .admin-tabs` holding `.admin-tab` buttons
 *   - `adminrail.js` wraps them into `.atg > .atg-label + .atg-list`
 *   - panels are DIRECT children `#admin-root > .panel[data-tab]`; this sheet
 *     never reparents them, because every owner's tab CSS and collapse layer
 *     select them with the child combinator
 *   - zero colour literals: role tokens only, per webcore's stylesheet law
 */

#admin-root {
  display: grid;
  grid-template-columns: var(--adminrail-w, 236px) minmax(0, 1fr);
  column-gap: var(--adminrail-gap, 30px);
  align-items: start;
}
#admin-root > .section-title,
#admin-root > .admin-head { grid-column: 1 / -1; }
#admin-root > .panel { grid-column: 2; }

/* The rail spans every content row so `position:sticky` has a track to travel
   down. A rail placed in one grid row is only as tall as that row, and sticky
   inside it looks broken rather than absent — which is worse. */
#admin-root > .admin-tabs {
  grid-column: 1;
  grid-row: 2 / span 80;
  display: block;
  overflow: visible;
  margin: 0;
  padding: 14px 10px 16px;
  position: sticky;
  top: var(--adminrail-top, 76px);
  align-self: start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.atg { padding: 0; }
.atg + .atg {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
/* Owner-only sections ship hidden. A group whose every tab is hidden must not
   leave its heading standing over nothing. */
.atg[hidden] { display: none; }

.atg-label {
  padding: 0 12px 8px;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg-mute);
}
.atg-list { display: block; }

#admin-root > .admin-tabs .admin-tab {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 14px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-dim);
  transition: color 0.15s ease, background 0.15s ease;
}
#admin-root > .admin-tabs .admin-tab + .admin-tab { margin-top: 1px; }
#admin-root > .admin-tabs .admin-tab:hover {
  color: var(--fg);
  background: var(--surface-hover);
}
#admin-root > .admin-tabs .admin-tab.active {
  color: var(--fg);
  background: var(--surface-hover);
}
/* Selection is a lit left edge. Owners whose flat bar drew a gradient
   underline keep their ramp by overriding --adminrail-mark. */
#admin-root > .admin-tabs .admin-tab.active::after {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 0 2px 2px 0;
  background: var(--adminrail-mark, var(--accent));
}
/* Flat bars shipped with no focus ring at all: a keyboard user could reach the
   tabs and not see which one they were on. */
#admin-root > .admin-tabs .admin-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
#admin-root > .admin-tabs .admin-tab[hidden] { display: none; }

/* Below the rail's width budget: a grouped grid above the content, and no
   longer sticky. A rail this tall pinned to a short viewport covers the thing
   it was used to reach. */
@media (max-width: 1180px) {
  #admin-root { display: block; }
  #admin-root > .admin-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 18px;
    padding: 12px 12px 14px;
    margin: 0 0 24px;
    position: static;
  }
  .atg { flex: 1 1 150px; min-width: 150px; }
  .atg + .atg { margin-top: 0; padding-top: 0; border-top: 0; }
}

/* Phone. The groups narrow rather than stack — single file put roughly 650px
   of navigation above the first panel. Labels WRAP here: a flat bar could set
   `white-space:nowrap` because it scrolled sideways, and a fixed-width column
   cannot. Wrapping makes the overflow impossible at every width instead of at
   the widths that happened to get measured. */
@media (max-width: 720px) {
  #admin-root > .admin-tabs { gap: 6px 12px; padding: 12px 10px 14px; }
  .atg { flex: 1 1 132px; min-width: 132px; }
  .atg-label { padding: 0 12px 6px; }
  #admin-root > .admin-tabs .admin-tab {
    padding: 8px 12px 9px;
    letter-spacing: 0.08em;
    white-space: normal;
    line-height: 1.35;
  }
}
