/* The tools shell: a graphite index rail beside one full-height view.
   The rail is quiet chrome; each tool brings its own colour as --accent, which lights its
   glyph and the active bar. Collapsed (wide screens) it becomes a strip of glyphs; on
   narrow screens it is a drawer over the view. */

@import url("fonts/fonts.css");

:root {
  --bg: #0e1012;
  --rail: #121417;
  --line: #22262b;
  --text: #e6e8eb;
  --muted: #9aa1aa;
  --faint: #878f99;
  --hover: #1a1d21;
  --active: #1e2227;
  --focus: #f2f4f6;
  --rail-w: 252px;
  --strip-w: 56px;
  --here: #f2f4f6;
  --sans: "Instrument Sans", system-ui, sans-serif;
  --mono: "Martian Mono", ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font: 14px/1.4 var(--sans); overflow: hidden; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.skip {
  position: absolute; left: 8px; top: -48px; z-index: 50; padding: 8px 12px;
  background: var(--focus); color: #000; border-radius: 4px; text-decoration: none; font-weight: 600;
}
.skip:focus { top: 8px; }

.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  height: 100vh; height: 100dvh;
}
.collapsed .shell { grid-template-columns: var(--strip-w) minmax(0, 1fr); }

/* ── rail ─────────────────────────────────────────────────────────────────── */
.rail {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--rail); border-right: 1px solid var(--line);
}
.rail-head { display: flex; align-items: center; gap: 6px; padding: 12px 10px 8px 14px; }
.brand {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
  color: var(--text); text-decoration: none; border-radius: 6px; padding: 4px 4px 4px 0;
}
.brand .mark { flex: none; display: grid; grid-template-columns: repeat(4, 6px); gap: 2px; padding: 2px; }
.brand .mark i { width: 6px; height: 6px; border-radius: 1.5px; background: var(--c); }
.brand b { font: 650 17px/1 var(--sans); letter-spacing: -0.01em; }
.brand small { display: block; font: 400 10px/1.3 var(--mono); color: var(--faint); letter-spacing: 0; margin-top: 3px; white-space: nowrap; }
.brand[aria-current="page"] b { text-decoration: underline 2px; text-underline-offset: 4px; text-decoration-color: var(--line); }

.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.collapsed .collapse svg { transform: rotate(180deg); }

.filter {
  display: flex; align-items: center; gap: 8px; margin: 2px 10px 8px; padding: 0 8px;
  height: 32px; border: 1px solid var(--line); border-radius: 6px; color: var(--faint);
  background: #0f1114;
}
.filter:focus-within { border-color: #3a4048; color: var(--muted); }
.filter input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text);
  font: 13.5px var(--sans); outline: none;
}
.filter input::placeholder { color: var(--faint); }
.filter input::-webkit-search-cancel-button { display: none; }
.filter kbd {
  font: 10px/1 var(--mono); color: var(--faint); border: 1px solid var(--line);
  border-radius: 3px; padding: 3px 5px;
}

.toc { flex: 1; overflow-y: auto; padding: 2px 6px 12px; scrollbar-width: thin; scrollbar-color: #2a2f35 transparent; }
.group { margin: 0; padding: 0; }
.group + .group { margin-top: 6px; }
.group h2 {
  margin: 0; padding: 8px 10px 4px; font: 500 10px/1.2 var(--mono);
  text-transform: uppercase; letter-spacing: 0.12em; color: var(--faint);
}
.group ul { list-style: none; margin: 0; padding: 0; }
.tool a {
  position: relative; display: flex; align-items: center; gap: 10px;
  min-height: 30px; padding: 4px 10px; border-radius: 6px;
  color: var(--muted); text-decoration: none;
}
.tool a:hover { background: var(--hover); color: var(--text); }
.tool .glyph { flex: none; color: var(--accent); opacity: 0.85; }
.tool .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.tool a[aria-current="page"] { background: var(--active); color: var(--text); }
.tool a[aria-current="page"] .glyph { opacity: 1; }
.tool a[aria-current="page"]::before {
  content: ""; position: absolute; left: -6px; top: 7px; bottom: 7px; width: 3px;
  border-radius: 0 2px 2px 0; background: var(--accent);
}
.tool .sub { min-height: 26px; padding-left: 36px; font-size: 13px; }
.tool .sub::after {
  content: ""; position: absolute; left: 17px; top: 0; bottom: 50%; width: 10px;
  border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); border-bottom-left-radius: 4px;
}
.tool .sub .live {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.tool .sub .path { margin-left: auto; font: 10.5px var(--mono); color: var(--faint); }

.empty { margin: 4px 16px; color: var(--faint); font-size: 13px; }

.rail-foot { border-top: 1px solid var(--line); padding: 8px 10px; }
.alone {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px;
  color: var(--faint); text-decoration: none; font-size: 12.5px;
}
.alone:hover { background: var(--hover); color: var(--text); }

/* Collapsed: a strip of glyphs (wide screens only). */
@media (min-width: 821px) {
  .collapsed .rail-head { flex-direction: column; padding: 12px 0 6px; gap: 8px; }
  .collapsed .brand { flex: none; padding: 0; }
  .collapsed .brand > span:not(.mark) { display: none; }
  .collapsed .filter, .collapsed .group h2, .collapsed .tool .name, .collapsed .tool .path,
  .collapsed .alone span, .collapsed .empty { display: none; }
  .collapsed .toc { padding: 2px 8px; }
  .collapsed .group + .group { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
  .collapsed .tool a { justify-content: center; padding: 6px 0; }
  .collapsed .tool .sub { min-height: 22px; padding: 2px 0 6px; }
  .collapsed .tool .sub::after { display: none; }
  .collapsed .tool a[aria-current="page"]::before { left: -8px; }
  .collapsed .rail-foot { padding: 8px; }
  .collapsed .alone { justify-content: center; }
}

/* ── stage ────────────────────────────────────────────────────────────────── */
.stage { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: none; }
.stage iframe { flex: 1; width: 100%; min-height: 0; border: 0; display: block; background: var(--bg); }
.progress {
  position: absolute; left: 0; right: 0; top: 0; height: 2px; z-index: 5; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--here), transparent) 0 0 / 40% 100% no-repeat;
  opacity: 0; transition: opacity 0.2s;
}
.progress.on { opacity: 1; animation: sweep 1s linear infinite; }
@keyframes sweep { from { background-position: -40% 0; } to { background-position: 140% 0; } }

/* ── narrow: a top bar and a drawer ───────────────────────────────────────── */
@media (max-width: 820px) {
  .shell, .collapsed .shell { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: fixed; z-index: 30; left: 0; top: 0; bottom: 0; width: min(86vw, 300px);
    transform: translateX(-102%); transition: transform 0.18s ease-out; box-shadow: 8px 0 32px #0009;
  }
  .drawer .rail { transform: none; }
  .collapse { display: none; }
  .scrim { position: fixed; inset: 0; z-index: 20; background: #0008; }
  .topbar {
    display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 8px;
    background: var(--rail); border-bottom: 1px solid var(--line);
  }
  .here { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .progress { top: 48px; }
  .tool a { min-height: 40px; }
  .tool .sub { min-height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .rail, .progress { transition: none; }
  .progress.on { animation: none; }
}
