/*
  The application shell: rail, drawer, scrim, tmux-style status bar, main column.

  Structure is study_desk's (study_agent/assets/css/shell.css) — a 44px icon rail
  plus a slide-over drawer — which is itself the DOM rendition of the wonder HUD
  chrome. Kept intact. Re-skinned to addapa-phosphor, and TUI'd up: the status bar
  is a tmux line with the title inside the border rule, the rail is box-drawing
  glyphs, drawer rows carry ▸ markers.

  What changed from study_desk, and why:
    - study_desk pins .app-shell to 100vh because it is a pywebview window.
      A website scrolls, so the shell is min-height and the rail is sticky.
    - the drawer becomes a full-width sheet under 720px instead of a 288px slide.
    - every interactive target is >=32px and keyboard reachable.
    - focus-visible rings are real, because this one ships to strangers.

  Only shell selectors belong in this file.
*/

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  /* transparent so the body's dot-grid wallpaper shows through — an opaque
     fill here was silently covering it */
  background: transparent;
  position: relative;
  z-index: 1;
}

/* The rail is 100vh and sticky, so on a long page its own background runs out
   partway down. This paints the rail column for the full height of the document
   behind it, so the stripe never ends mid-scroll. */
.app-shell::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--rail-w);
  background: var(--pane);
  border-right: 1px solid var(--border2);
  z-index: 0;
}

/* ============================ rail ============================ */

.rail {
  grid-column: 1;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  z-index: 40;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 5px;
}

.rail-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--accent-dim);
  background: transparent;
  border: 1px solid transparent;
  font-family: var(--mono-family);
  font-size: 15px;
  line-height: 1;
  display: grid;
  place-items: center;
  text-decoration: none;
}
.rail-btn:hover {
  color: var(--accent);
  background: var(--raised);
  border-color: var(--border2);
}
/* "You are here": the shortcut whose section owns the current page. Set at
   build time; one step dimmer than a focused control (alpha ladder). */
.rail-btn.view-active {
  color: var(--accent);
  box-shadow: inset 2px 0 0 var(--accent-dim);
}
.rail-btn.menu-btn { color: var(--ink2); border-color: var(--border2); }
.rail-btn.menu-btn:hover { color: var(--accent); }
.rail-fill { flex: 1; min-height: 4px; }

/* The rail seal — a vertical wordmark at the foot of the rail. Pure ornament,
   and the only thing down there, so it can afford to be. */
.rail-seal {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-family: var(--mono-family);
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--accent-dim);
  user-select: none;
  padding: 8px 0;
}
.rail-mark { width: 20px; height: 20px; color: var(--accent); margin: 2px 0 6px; }

/* ============================ drawer ============================ */

.drawer {
  position: fixed;
  left: var(--rail-w);
  top: 0;
  bottom: 0;
  width: var(--drawer-w);
  max-width: calc(100vw - var(--rail-w));
  z-index: 30;
  background: var(--pane);
  border-right: 2px solid var(--border);
  box-shadow: 6px 0 22px rgba(0, 0, 0, 0.7);
  transform: translateX(-340px);
  /* visibility flips only after the slide has finished, so the exit animates */
  transition: transform 0.18s ease-out, visibility 0s linear 0.18s;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  visibility: hidden;
}
.drawer-open .drawer { transform: translateX(0); visibility: visible; transition: transform 0.18s ease-out; }
body.drawer-open { overflow: hidden; }

.scrim {
  position: fixed;
  left: var(--rail-w);
  top: 0; right: 0; bottom: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.66);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease-out;
  border: 0;
  padding: 0;
}
.drawer-open .scrim { opacity: 1; pointer-events: auto; }

.drawer-top {
  flex: none;
  height: 44px;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 0 12px;
  border-bottom: 1px solid var(--border2);
  background: #050505;
}
.drawer-mark { width: 24px; height: 24px; flex: 0 0 24px; color: var(--accent); }
.drawer-title { min-width: 0; line-height: 1.2; font-family: var(--mono-family); }
.drawer-title b { display: block; color: var(--accent); letter-spacing: 1px; font-size: 12px; font-weight: 600; }
.drawer-title span {
  display: block;
  color: var(--dim);
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-close {
  margin-left: auto;
  color: var(--dim);
  border: 1px solid transparent;
  padding: 3px 6px;
  font-size: 11px;
}
.drawer-close:hover { color: var(--accent); background: var(--raised); border-color: var(--border2); }

.drawer-body { overflow-y: auto; flex: 1 1 auto; min-height: 0; padding-bottom: 12px; }

.drawer-section { flex: none; padding: 10px 12px; border-bottom: 1px solid var(--border3); }
.drawer-section:last-child { border-bottom: 0; }

.section-title {
  font-family: var(--mono-family);
  color: var(--accent);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin: 0 0 8px;
  user-select: none;
}
/* study_desk brackets its drawer sections ┤ LIKE THIS ├ — same move here. */
.section-title::before { content: "┤ "; color: var(--border2); letter-spacing: 0; }
.section-title::after  { content: " ├"; color: var(--border2); letter-spacing: 0; }

/* The section a rail shortcut jumped to stays lit until the drawer closes. */
.drawer-section.lit { background: #060d04; box-shadow: inset 2px 0 0 var(--accent-dim); }

.navrow {
  display: block;
  width: 100%;
  text-align: left;
  padding: 5px 8px 5px 6px;
  margin: 1px 0;
  border: 1px solid transparent;
  color: var(--ink2);
  background: transparent;
  text-decoration: none;
  font-family: var(--mono-family);
}
.navrow::before {
  content: "▸ ";
  color: var(--accent-dim);
}
.navrow:hover { background: var(--raised); border-color: var(--border2); color: var(--ink); }
.navrow:hover::before { color: var(--accent); }
.navrow[aria-current="page"] {
  border-color: var(--accent-dim);
  background: #060d04;
  box-shadow: inset 2px 0 0 var(--accent);
}
.navrow[aria-current="page"]::before { content: "▾ "; color: var(--accent); }
.navrow b { display: inline; font-size: 12px; font-weight: 600; }
.navrow span { display: block; font-size: 10px; color: var(--dim); padding-left: 14px; }
.navrow[aria-current="page"] b { color: var(--accent); }

/* ============================ desk + status bar ============================ */

.desk {
  grid-column: 2;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/*
  tmux status line. The title sits inside the rule, the way every pane title in
  the wonder HUD does (brief §1: "titles live inside the top border line,
  tmux-style: ╭─┤ wonder@mind:~/trace ├───╮"). The ─ runs are real glyphs, flexed
  to fill, so the line closes at any width without measuring anything.
*/
.statusbar {
  position: sticky;
  top: 0;
  z-index: 15;
  flex: none;
  display: flex;
  align-items: center;
  background: var(--bg);
  border-bottom: 1px solid var(--border3);
  font-family: var(--mono-family);
  font-size: 11px;
  line-height: 1;
  padding: 7px 10px;
  gap: 0;
  white-space: nowrap;
  overflow: hidden;
  color: var(--accent-dim);
}
.statusbar .dash {
  flex: 1 1 auto;
  min-width: 8px;
  overflow: hidden;
  color: var(--border2);
  user-select: none;
}
.statusbar .seg {
  flex: none;
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 62vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.statusbar .bracket { color: var(--border2); user-select: none; }
/* The statusbar hamburger — hidden until the rail leaves (≤520px). */
.sb-menu, .sb-menu-sep { display: none; }
.sb-menu {
  color: var(--accent);
  background: transparent;
  border: 0;
  padding: 0 4px;
  font: inherit;
  line-height: inherit;
}
.statusbar .host { color: var(--accent); }
.statusbar .path { color: var(--ink2); overflow: hidden; text-overflow: ellipsis; }
.statusbar .path a { color: var(--accent-dim); border: 0; }
.statusbar .path a:hover { color: var(--accent); }
/* The parked block cursor. Static on purpose — blink is wall-clock motion,
   and the site has already spent its one exception (decode.js). */
.statusbar .caret { color: var(--accent); flex: none; }
.statusbar .clearance { color: var(--dim); }

/* ============================ main ============================ */

.view {
  flex: 1 1 auto;
  min-width: 0;
  padding: var(--gap-out) 0 0;
}

/* ============================ keys: ribbon · palette · help ============================ */

/*
  The k9s/fzf layer (palette.js). All three surfaces render from the one KEYS
  table in that file, so nothing here can advertise a key that does not work.
  Ribbon and overlays are JS-injected: a page without JS never shows them.
*/
.keyribbon {
  position: fixed;
  left: var(--rail-w);
  right: 0;
  bottom: 0;
  z-index: 25;
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 4px 14px;
  background: var(--bar);
  border-top: 1px solid var(--border2);
  font-family: var(--mono-family);
  font-size: 11px;
  color: var(--dim);
  user-select: none;
}
.kchip { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.kchip kbd,
.keyrow kbd {
  font-family: var(--mono-family);
  background: var(--accent-dim);
  color: #000;
  padding: 0 5px;
  font-size: 11px;
  line-height: 16px;
}
body.has-keys .site-footer { padding-bottom: 44px; }
@media (max-width: 860px) { .keyribbon { display: none; } body.has-keys .site-footer { padding-bottom: 0; } }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.72);
  display: grid;
  place-items: start center;
  padding-top: 14vh;
}
/* display:grid would silently defeat the hidden attribute */
.overlay[hidden] { display: none; }
.palette-box {
  width: min(560px, calc(100vw - 32px));
  padding: 22px 18px 14px;
}
.palette-prompt {
  display: flex;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid var(--border3);
  padding-bottom: 8px;
}
.palette-prompt .pp { color: var(--accent); }
.palette-prompt input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--ink);
  font: var(--mono);
  caret-color: var(--accent);
}
.palette-prompt .pcount { color: var(--dim); font-size: 11px; }
.palette-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 46vh; overflow-y: auto; }
.prow {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 5px 8px;
  border: 1px solid transparent;
  font-family: var(--mono-family);
  cursor: pointer;
}
.prow .plabel { color: var(--ink2); font-size: 13px; white-space: nowrap; }
.prow .pdesc { color: var(--dim); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .m { color: var(--accent-hi); font-weight: 600; }
.prow:hover { background: var(--raised); border-color: var(--border2); }
.prow.sel {
  background: #060d04;
  border-color: var(--accent-dim);
  box-shadow: inset 2px 0 0 var(--accent);
}
.prow.sel .plabel { color: var(--accent); }

.keyrows { padding-top: 10px; display: grid; gap: 6px; }
.keyrow { display: flex; gap: 12px; align-items: center; font-family: var(--mono-family); font-size: 12px; color: var(--ink2); }

/* ============================ pager ============================ */

/*
  Record-to-record paging, less-style. The dossier is a stack of files; ◀ and ▶
  walk it in the one global order build() computes. Quiet chrome — it sits
  between the record and the footer, and never competes with either.
*/
.pager {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: var(--gap-in);
  padding: 0 clamp(10px, 2.2vw, 24px);
  font-family: var(--mono-family);
  font-size: 12px;
}
.pager a {
  color: var(--accent-dim);
  text-decoration: none;
  border: 1px solid transparent;
  padding: 8px 10px;
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pager a:hover { color: var(--accent); background: var(--raised); border-color: var(--border2); }
.pager .pager-pos { color: var(--dim); font-size: 10.5px; letter-spacing: 1px; }
.pager .pager-null { color: var(--faint); padding: 5px 9px; user-select: none; }

/* ============================ footer ============================ */

.site-footer {
  flex: none;
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: clamp(22px, 3vw, 36px) clamp(10px, 2.2vw, 24px) clamp(30px, 4vw, 52px);
  color: var(--dim);
  font-family: var(--mono-family);
  font-size: 10.5px;
  line-height: 1.85;
}
.site-footer a { color: var(--dim); border-bottom-color: var(--border3); }
.site-footer a:hover { color: var(--accent); border-bottom-color: var(--accent-dim); }
.site-footer .rule { margin: 0 0 14px; }

/* The disclaimer. Addapa Industries is fiction; this line says so in plain text,
   outside the terminal conceit, because a reader who lands mid-site should never
   have to guess which parts are real. */
.site-footer .disclaimer { max-width: var(--measure); margin: 0 0 10px; color: #b0b0b0; }
.site-footer .colophon { max-width: var(--measure); margin: 0; }

/* ---- statusbar fact modules ---- */
.statusbar .mods { flex: none; display: inline-flex; gap: 8px; align-items: center; padding: 0 8px; }
.statusbar .mod { color: var(--dim); white-space: nowrap; }
.statusbar .modsep { color: var(--border2); }
.statusbar .dash.short { flex: 0 0 16px; }
@media (max-width: 860px) { .statusbar .mods, .statusbar .mods + .bracket, .statusbar .mods + .bracket + .dash.short, .statusbar .mods + .bracket + .dash.short + .bracket { display: none; } }
