/* ============================================================
   GIT YARD — app.css
   Rail-yard clarity: signal lamps on branching tracks,
   monospace badges, playful infrastructure.
   ============================================================ */

:root {
  --bg: #0c1015;
  --bg2: #10151c;
  --panel: #131922;
  --panel2: #0f141b;
  --edge: #232e3b;
  --edge2: #2c3948;
  --text: #d5e0ea;
  --dim: #77879a;
  --faint: #4b5a6d;
  --amber: #f5b942;
  --green: #43d17c;
  --cyan: #4cc9f0;
  --violet: #b48cff;
  --red: #ff6b6b;
  --err: #ff7b72;
  --ok: #56d364;
  --hintc: #e3b341;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --hdr-h: 52px;
  --bot-h: 272px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- header ---------------- */
.topbar {
  height: var(--hdr-h);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 14px;
  background: linear-gradient(180deg, #141b25, #10151d);
  border-bottom: 1px solid var(--edge);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.lamps { display: inline-flex; gap: 4px; padding: 5px 7px; background: #0a0d12; border: 1px solid var(--edge); border-radius: 9px; }
.lamps i { width: 8px; height: 8px; border-radius: 50%; display: block; }
.lamps .l1 { background: var(--amber); box-shadow: 0 0 6px var(--amber); animation: blink 3.4s infinite; }
.lamps .l2 { background: var(--green); box-shadow: 0 0 6px var(--green); animation: blink 3.4s .9s infinite; }
.lamps .l3 { background: var(--cyan); box-shadow: 0 0 6px var(--cyan); animation: blink 3.4s 1.8s infinite; }
@keyframes blink { 0%, 88%, 100% { opacity: 1; } 92% { opacity: .35; } }
.title { font-weight: 700; letter-spacing: 3px; font-size: 15px; }
.subtitle { color: var(--dim); font-size: 11px; letter-spacing: .6px; }

.scen-row {
  display: flex; align-items: center; gap: 7px;
  overflow-x: auto; scrollbar-width: none;
  flex: 1; min-width: 0;
  mask-image: linear-gradient(90deg, #000 92%, transparent);
}
.scen-row::-webkit-scrollbar { display: none; }
.scen-label { color: var(--faint); font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase; margin-right: 2px; }

.hctl { display: flex; gap: 7px; }
.hbtn {
  font-family: var(--mono); font-size: 11.5px;
  background: #17202b; color: var(--text);
  border: 1px solid var(--edge2); border-radius: 7px;
  padding: 7px 11px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.hbtn:hover { background: #1e2a38; border-color: #3d4f66; }
.hbtn:disabled { opacity: .38; cursor: default; }
.hbtn.icon { padding: 7px 9px; min-width: 34px; }
.hbtn.scen { color: var(--cyan); }
.hbtn.stop { color: var(--err); }
#soundBtn.off { color: var(--faint); text-decoration: line-through; }
#resetBtn:hover, #resetBtn.armed { border-color: var(--err); color: var(--err); }

/* ---------------- main layout ---------------- */
.main {
  height: calc(100vh - var(--hdr-h));
  height: calc(100dvh - var(--hdr-h));
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.graph-pane {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background:
    radial-gradient(circle at 1px 1px, #1a2230 1.1px, transparent 1.2px) 0 0 / 26px 26px,
    linear-gradient(180deg, #0c1015, #0b0e13);
  border-bottom: 1px solid var(--edge);
}
.scroller {
  position: absolute; inset: 0;
  overflow: auto;
  cursor: grab;
  overscroll-behavior: contain;
}
.scroller.panning { cursor: grabbing; }
#stage { display: block; }

.graph-tools {
  position: absolute; right: 12px; bottom: 12px;
  display: flex; gap: 6px; z-index: 3;
}
.gbtn {
  font-family: var(--mono); font-size: 12px;
  background: rgba(19, 25, 34, .88); color: var(--text);
  border: 1px solid var(--edge2); border-radius: 7px;
  min-width: 34px; height: 32px; padding: 0 9px;
  cursor: pointer; backdrop-filter: blur(3px);
}
.gbtn:hover { background: #223041; border-color: #43587a; }

/* ---------------- bottom pane ---------------- */
.bottom-pane {
  flex: 0 0 var(--bot-h);
  display: flex;
  min-height: 0;
  background: var(--panel2);
}
.tabs { display: none; }
.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.console-pane {
  flex: 1.35;
  border-right: 1px solid var(--edge);
}
.board-pane { flex: 1; }

/* chips */
.chips {
  display: flex; gap: 6px; padding: 7px 10px;
  border-bottom: 1px solid var(--edge);
  overflow-x: auto; scrollbar-width: none; flex-shrink: 0;
}
.chips::-webkit-scrollbar { display: none; }
.chip-run {
  font-family: var(--mono); font-size: 10.5px;
  background: #161e29; color: var(--dim);
  border: 1px solid var(--edge); border-radius: 20px;
  padding: 4px 10px; cursor: pointer; white-space: nowrap;
}
.chip-run:hover { color: var(--text); border-color: var(--edge2); background: #1b2534; }

/* ---------------- terminal ---------------- */
.terminal {
  flex: 1; display: flex; flex-direction: column;
  min-height: 0; background: var(--panel2);
}
.term-out {
  flex: 1; overflow-y: auto;
  padding: 10px 12px 6px;
  font-size: 12.5px; line-height: 1.5;
}
.tl { white-space: pre-wrap; word-break: break-word; }
.tl.echo { color: var(--faint); margin-top: 4px; }
.tl.echo .echo-text { color: #9fb2c8; }
.tl.out { color: var(--text); }
.tl.dim { color: var(--dim); }
.tl.err { color: var(--err); }
.tl.hint { color: var(--hintc); }
.tl.ok { color: var(--ok); }
.tl.warn { color: var(--amber); }
.tl.log { color: #b8c7d8; }
.tl.head { color: var(--green); }
.tl.note { color: var(--violet); font-style: italic; }
.prompt {
  color: var(--green);
  font-weight: 700;
  user-select: none;
}
.term-row {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  border-top: 1px solid var(--edge);
  background: #0d1218;
  flex-shrink: 0;
}
.term-input {
  flex: 1; min-width: 0;
  background: transparent; border: none; outline: none;
  color: #e8f1fa; font-family: var(--mono); font-size: 13.5px;
  caret-color: var(--green);
}
.term-input::placeholder { color: #3f4f63; }
.term-input:disabled { opacity: .5; }
.terminal.locked .prompt { color: var(--violet); }

/* ---------------- board ---------------- */
.board {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: 8px 10px 12px;
}
.board-strip {
  display: flex; align-items: baseline; gap: 7px;
  padding: 8px 10px; margin-bottom: 8px;
  background: #131a24; border: 1px solid var(--edge); border-radius: 8px;
  font-size: 12px; position: sticky; top: 0; z-index: 2;
}
.bs-label { color: var(--faint); font-size: 10px; letter-spacing: 1.5px; }
.bs-label.det { color: var(--err); }
.bs-arrow { color: var(--faint); }
.bs-branch { color: var(--c, var(--amber)); font-weight: 700; }
.bs-at { color: var(--faint); }
.bs-hash { color: #9fb2c8; }
.bs-counts { margin-left: auto; color: var(--faint); font-size: 10.5px; }

.commit-list { display: flex; flex-direction: column; gap: 2px; }
.crow {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left;
  background: transparent; border: 1px solid transparent;
  border-radius: 6px; padding: 5px 8px;
  color: var(--text); font-family: var(--mono); font-size: 11.5px;
  cursor: pointer; min-height: 30px;
}
.crow:hover { background: #17202c; }
.crow.sel { background: #1a2636; border-color: var(--edge2); }
.crow.ghost { opacity: .45; }
.c-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 5px currentColor; }
.c-hash { color: #8fa3ba; font-size: 10.5px; flex-shrink: 0; }
.c-msg { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-refs { color: var(--amber); font-size: 9.5px; flex-shrink: 0; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-merge { color: var(--violet); flex-shrink: 0; }
.mono { font-family: var(--mono); }
.dim { color: var(--dim); }

/* detail card */
.detail-card {
  background: #141c28; border: 1px solid var(--edge2);
  border-radius: 9px; padding: 10px 12px; margin-bottom: 8px;
  font-size: 12px;
}
.dc-head { display: flex; align-items: center; gap: 8px; }
.dc-dot { width: 10px; height: 10px; border-radius: 50%; }
.dc-hash { color: #a8bdd4; font-size: 11px; }
.dc-merge { color: var(--violet); font-size: 10px; border: 1px solid var(--violet); border-radius: 10px; padding: 1px 7px; }
.dc-x {
  margin-left: auto; background: none; border: none; color: var(--dim);
  font-size: 16px; cursor: pointer; padding: 0 4px; font-family: var(--mono);
}
.dc-x:hover { color: var(--text); }
.dc-msg { margin: 8px 0 6px; color: #e6eef7; font-size: 12.5px; }
.dc-meta { color: var(--dim); font-size: 11px; margin-top: 3px; }
.plink {
  background: #1a2433; border: 1px solid var(--edge2); color: #a8bdd4;
  font-family: var(--mono); font-size: 10.5px; border-radius: 5px;
  padding: 2px 7px; cursor: pointer;
}
.plink:hover { border-color: #4a617f; color: var(--text); }

/* ---------------- svg scene ---------------- */
.guide { stroke-width: 8; opacity: .07; stroke-linecap: round; }
.guideg { transition: opacity .4s; }
.guideg.enter { opacity: 0; }
.guideg.ghost { opacity: .5; }
.tracknum { font-family: var(--mono); font-size: 9px; opacity: .4; letter-spacing: 1px; }
.edge { transition: opacity .3s; }
.edge.ghost { opacity: .22; stroke-dasharray: 5 5; }

.cnode { transition: transform .48s cubic-bezier(.22, 1.2, .3, 1), opacity .3s; cursor: pointer; outline: none; }
.cnode .tie { fill: #242f3d; opacity: .8; }
.cnode .halo { opacity: .16; transition: opacity .3s; }
.cnode:hover .halo, .cnode:focus-visible .halo { opacity: .42; }
.cnode.sel .halo { opacity: .5; }
.cnode.sel .ring { stroke-width: 3.4; }
.cnode .pulse { opacity: 0; }
.cnode.head .pulse { animation: pulse 1.9s ease-out infinite; }
@keyframes pulse {
  0% { transform: scale(1); opacity: .85; }
  70%, 100% { transform: scale(2.1); opacity: 0; }
}
.cnode .hash {
  fill: #6e7f93; font-size: 10px; font-family: var(--mono);
  letter-spacing: .5px; transition: fill .2s;
}
.cnode:hover .hash, .cnode.sel .hash { fill: #c4d3e4; }
.cnode.ghost { opacity: .34; }
.cnode.ghost .ring { stroke-dasharray: 3 3; }
.cnode.ghost .hash { fill: #4e5b6a; }
.cnode.detached .ring { stroke-dasharray: 4 2.4; }

.placard { transition: transform .48s cubic-bezier(.3, 1.15, .35, 1), opacity .28s; }
.placard .post { opacity: .9; }
.placard .post.dashed { stroke-dasharray: 2.5 2.5; }
.placard .chip-txt { font-family: var(--mono); fill: var(--text); font-weight: 600; }
.placard .tag-txt { fill: #e8cd8f; }
.placard .head-txt { font-weight: 800; letter-spacing: .5px; }

/* ---------------- help modal ---------------- */
.help-modal {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(5, 8, 12, .66);
  display: none; align-items: center; justify-content: center;
  padding: 18px;
}
.help-modal.open { display: flex; }
.hm-card {
  position: relative;
  background: var(--panel); border: 1px solid var(--edge2);
  border-radius: 12px; padding: 20px 24px;
  max-width: 640px; width: 100%; max-height: 84vh; overflow-y: auto;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .55);
}
.hm-card h2 { margin: 0 0 10px; font-size: 15px; letter-spacing: 2px; }
.hm-card h3 { margin: 14px 0 4px; font-size: 10.5px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--amber); }
.hm-card p { margin: 0; font-size: 12px; line-height: 1.9; color: #b9c7d6; }
.hm-card code { background: #0d1218; border: 1px solid var(--edge); border-radius: 4px; padding: 1px 5px; font-size: 11px; color: #cfe0f2; }
.hm-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 26px; }
.hm-x {
  position: absolute; top: 10px; right: 12px;
  background: none; border: none; color: var(--dim);
  font-size: 20px; cursor: pointer; font-family: var(--mono);
}
.hm-x:hover { color: var(--text); }

/* ---------------- scrollbars ---------------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #232e3b; border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #2f3d4f; }

/* ---------------- mobile ---------------- */
@media (max-width: 920px) {
  :root { --hdr-h: 92px; --bot-h: 42dvh; }
  body { font-size: 13px; }
  .topbar { gap: 8px 10px; padding: 0 10px; flex-wrap: wrap; align-content: center; }
  .subtitle { display: none; }
  .title { font-size: 13px; letter-spacing: 2px; }
  .scen-row {
    order: 3; flex-basis: 100%;
    padding-bottom: 2px;
    mask-image: linear-gradient(90deg, #000 88%, transparent);
  }
  .hctl { margin-left: auto; }
  .hbtn { padding: 6px 9px; font-size: 10.5px; min-height: 34px; }
  .scen-label { display: none; }
  .hbtn.scen { padding: 6px 10px; }

  .bottom-pane { flex-direction: column; position: relative; }
  .tabs {
    display: flex; gap: 0; flex-shrink: 0;
    border-bottom: 1px solid var(--edge);
    background: #0e1319;
  }
  .tab-btn {
    flex: 1; font-family: var(--mono); font-size: 11.5px;
    letter-spacing: 1px; text-transform: uppercase;
    background: none; border: none; color: var(--faint);
    padding: 12px 0; min-height: 44px; cursor: pointer;
    border-bottom: 2px solid transparent;
  }
  .tab-btn.active { color: var(--text); border-bottom-color: var(--amber); }
  .pane { display: none; flex: 1; }
  .bottom-pane[data-tab="console"] .console-pane { display: flex; }
  .bottom-pane[data-tab="board"] .board-pane { display: flex; }
  .console-pane { border-right: none; }
  .chip-run { min-height: 34px; font-size: 11px; padding: 4px 13px; }
  .term-out { font-size: 12px; padding: 8px 10px 4px; }
  .hm-cols { grid-template-columns: 1fr; }
  .graph-tools { bottom: 8px; right: 8px; }
  .gbtn { height: 36px; min-width: 36px; }
}

/* ---------------- reduced motion ---------------- */
@media (prefers-reduced-motion: reduce) {
  .cnode, .placard, .edge, .guide { transition: none !important; }
  .cnode.head .pulse { animation: none; opacity: .45; transform: scale(1.4); }
  .lamps i { animation: none; }
}
