/* ================= ESCAPEMENTS — engineering-lab dark theme ================= */

:root {
  --bg: #14171b;
  --panel: #1a1f25;
  --panel2: #171c21;
  --line: #2a323c;
  --txt: #d7dee7;
  --dim: #8b98a8;
  --recoil: #ff8a5c;
  --deadbeat: #4da3ff;
  --gravity: #35d0a0;
  --lock: #ffb648;
  --warn: #ff6259;
  --mono: Consolas, "Cascadia Mono", "Courier New", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--txt);
  font: 13px/1.55 "Segoe UI", system-ui, -apple-system, sans-serif;
  display: grid;
  grid-template-columns: 214px 1fr 350px;
  grid-template-rows: 52px 1fr;
  grid-template-areas: "top top top" "left stage right";
}

/* ------------------------------- fatal ---------------------------------- */
#fatal {
  display: none; position: fixed; inset: 0; z-index: 99;
  background: var(--bg); color: var(--txt);
  align-items: center; justify-content: center; text-align: center; padding: 40px;
}
#fatal.show { display: flex; }
#fatal code { color: var(--lock); font-family: var(--mono); }

/* ------------------------------- topbar --------------------------------- */
#topbar {
  grid-area: top; display: flex; align-items: center; gap: 18px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 0 14px; z-index: 20;
}
#brand h1 { font-size: 15px; letter-spacing: 3px; font-weight: 600; white-space: nowrap; }
#brand span {
  font-size: 10px; color: var(--dim); letter-spacing: 0.8px;
  text-transform: uppercase; white-space: nowrap;
}
#chaptabs { flex: 1; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
#chaptabs::-webkit-scrollbar { display: none; }
#chaptabs button {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--dim); font: 600 10.5px/1 inherit; letter-spacing: 1px;
  padding: 10px 9px 8px; cursor: pointer; white-space: nowrap;
}
#chaptabs button:hover { color: var(--txt); }
#chaptabs button.on { color: var(--txt); border-bottom-color: var(--deadbeat); }
#chaptabs button .n { color: var(--deadbeat); margin-right: 5px; font-family: var(--mono); }
#topright button {
  width: 28px; height: 28px; border-radius: 50%;
  background: none; border: 1px solid var(--line); color: var(--dim);
  cursor: pointer; font-size: 13px;
}
#topright button:hover { color: var(--txt); border-color: var(--dim); }

/* -------------------------------- rails --------------------------------- */
aside {
  background: var(--panel); overflow-y: auto; scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
aside::-webkit-scrollbar { width: 8px; }
aside::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

#leftrail { grid-area: left; border-right: 1px solid var(--line); }
#rightrail { grid-area: right; border-left: 1px solid var(--line); }

aside section { padding: 12px 12px 14px; border-bottom: 1px solid var(--line); }

aside h3 {
  font: 600 10px/1 inherit; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--dim); margin-bottom: 9px;
  display: flex; justify-content: space-between; align-items: baseline;
}
aside h3.sub { margin-top: 14px; }
aside h3 em {
  font-style: normal; color: var(--txt); font-family: var(--mono);
  font-size: 11px; letter-spacing: 0;
}
p.note { font-size: 10.5px; color: var(--dim); line-height: 1.45; margin-top: 6px; }

/* buttons */
.btncol, .btnrow { display: flex; gap: 4px; }
.btncol { flex-direction: column; }
.btnrow { flex-wrap: wrap; margin-top: 5px; }
.btnrow.tight { margin-top: 0; }

aside button, #chNav button {
  flex: 1; background: var(--panel2); border: 1px solid var(--line);
  color: var(--dim); font: 600 10px/1 inherit; letter-spacing: 0.9px;
  padding: 8px 6px; cursor: pointer; border-radius: 3px; white-space: nowrap;
}
aside button:hover, #chNav button:hover { color: var(--txt); border-color: #3b4753; }
aside button.on { color: #0e1116; background: var(--deadbeat); border-color: var(--deadbeat); }
aside button:disabled { opacity: 0.35; cursor: default; }
aside button em {
  font-style: normal; font-family: var(--mono); opacity: 0.55; margin-left: 5px;
}

#mechbtns button[data-mech="recoil"].on { background: var(--recoil); border-color: var(--recoil); }
#mechbtns button[data-mech="deadbeat"].on { background: var(--deadbeat); border-color: var(--deadbeat); }
#mechbtns button[data-mech="gravity"].on { background: var(--gravity); border-color: var(--gravity); }

.figline {
  display: flex; justify-content: space-between; gap: 8px;
  margin-top: 8px; font-size: 10.5px; color: var(--dim);
}
.figline em { font-style: normal; font-family: var(--mono); color: var(--lock); }

input[type=range] {
  width: 100%; height: 3px; -webkit-appearance: none; appearance: none;
  background: var(--line); border-radius: 2px; outline: none; margin: 3px 0 2px;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%;
  background: var(--txt); cursor: pointer; border: 2px solid var(--panel);
}
input[type=range]::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%; background: var(--txt);
  cursor: pointer; border: 2px solid var(--panel);
}

/* -------------------------------- stage --------------------------------- */
#stage {
  grid-area: stage; position: relative; overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 18%, #212832 0%, #12151a 62%, #0d1014 100%);
}
#stage canvas { display: block; width: 100%; height: 100%; }

#bigmsg {
  position: absolute; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: rgba(20,23,27,0.9); border: 1px solid var(--warn);
  color: var(--warn); padding: 8px 16px; border-radius: 3px;
  font: 600 11px/1 var(--mono); letter-spacing: 0.6px;
  opacity: 0; transition: opacity 0.25s; pointer-events: none; white-space: nowrap;
}
#bigmsg.show { opacity: 1; }

/* ------------------------------ read-outs ------------------------------- */
.rogrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ro { background: var(--panel2); border: 1px solid var(--line); border-radius: 3px; padding: 7px 9px; }
.rolabel {
  font: 600 9px/1 inherit; letter-spacing: 1.2px; color: var(--dim); margin-bottom: 4px;
}
.roval { font: 600 17px/1 var(--mono); color: var(--txt); }
.roval small { font-size: 10px; color: var(--dim); margin-left: 3px; font-weight: 400; }
.roval.accent { color: var(--lock); }
.roval.mode { font-size: 13px; letter-spacing: 1px; padding-top: 3px; }
.roval.mode.locked { color: var(--lock); }
.roval.mode.impulse { color: var(--gravity); }
.roval.mode.recoil { color: var(--warn); }
.roval.mode.drop { color: var(--dim); }
.roval.mode.stopped { color: var(--warn); }

.rowide {
  display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px;
  font-size: 10.5px; align-items: center;
}
.rowide.dim { color: var(--dim); }
.rowide b { color: var(--txt); font-weight: 600; }
.mono { font-family: var(--mono); }

canvas.trace {
  width: 100%; height: 58px; margin-top: 9px; display: block;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 3px;
}
canvas.chart {
  width: 100%; height: 172px; display: block; margin-top: 8px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 3px;
}
canvas.chart.short { height: 116px; }

/* ------------------------------- article -------------------------------- */
#article h2 { font-size: 14.5px; font-weight: 600; margin-bottom: 8px; line-height: 1.35; }
#chBody p { margin-bottom: 9px; font-size: 12.5px; color: #c2cbd6; }
#chBody ol, #chBody ul { margin: 0 0 9px 17px; font-size: 12.5px; color: #c2cbd6; }
#chBody li { margin-bottom: 5px; }
#chBody b { color: var(--txt); }
#chBody code { font-family: var(--mono); font-size: 11.5px; color: var(--lock); }
#chBody p.hint {
  border-left: 2px solid var(--deadbeat); padding-left: 9px;
  color: var(--dim); font-size: 11.5px;
}
#chNav { display: flex; gap: 5px; margin-top: 10px; }

/* -------------------------------- modal --------------------------------- */
#helpmodal {
  position: fixed; inset: 0; z-index: 40; display: flex;
  align-items: center; justify-content: center; background: rgba(8,10,13,0.78);
  padding: 30px;
}
#helpmodal.hidden { display: none; }
#helpcard {
  background: var(--panel); border: 1px solid var(--line); border-radius: 5px;
  padding: 22px 24px; max-width: 640px; max-height: 86vh; overflow-y: auto;
}
#helpcard h2 {
  font: 600 11px/1 inherit; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--dim); margin: 16px 0 8px;
}
#helpcard h2:first-child { margin-top: 0; }
#helpcard table { width: 100%; border-collapse: collapse; font-size: 12px; }
#helpcard td { padding: 3px 0; }
#helpcard td:last-child { text-align: right; font-family: var(--mono); color: var(--dim); }
#helpcard p { font-size: 12px; color: #b9c3cf; margin-bottom: 8px; }
#helpcard code { font-family: var(--mono); font-size: 11.5px; color: var(--lock); }
#helpcard em { color: var(--txt); font-style: italic; }
#btnCloseHelp {
  margin-top: 16px; background: var(--panel2); border: 1px solid var(--line);
  color: var(--dim); font: 600 10px/1 inherit; letter-spacing: 1px;
  padding: 9px 18px; cursor: pointer; border-radius: 3px;
}
#btnCloseHelp:hover { color: var(--txt); }

@media (max-width: 1180px) {
  body { grid-template-columns: 190px 1fr 300px; }
}

/* Back to the Parastrate dashboard (parastrate.com hosts these lessons). */
#homelink {
  pointer-events: auto; flex: none; white-space: nowrap;
  font-size: 10.5px; letter-spacing: 0.06em; text-decoration: none;
  color: #9aa7b4; padding: 4px 9px; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 3px;
}
#homelink:hover { color: #fff; border-color: rgba(255, 255, 255, 0.4); }
