/* ============ U-JOINT vs CV JOINT — engineering-lab dark theme ============ */

:root {
  --bg: #14171b;
  --panel: #1a1f25;
  --panel2: #171c21;
  --line: #2a323c;
  --txt: #d7dee7;
  --dim: #8b98a8;
  --in: #4da3ff;      /* input accent (blue)   */
  --out: #ff9e42;     /* U-joint output (orange) */
  --cv: #35d0a0;      /* CV output (green)     */
  --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.5 "Segoe UI", system-ui, -apple-system, sans-serif;
  display: grid;
  grid-template-columns: 224px 1fr 340px;
  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;
}
#fatal.show { display: flex; }
#fatal code { color: var(--out); }

/* ------------------------------- 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: 2px; font-weight: 600; white-space: nowrap; }
#brand span { font-size: 10px; color: var(--dim); letter-spacing: 1px; 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; text-transform: uppercase;
}
#chaptabs button:hover { color: var(--txt); }
#chaptabs button.on { color: var(--txt); border-bottom-color: var(--in); }
#chaptabs button .n { color: var(--in); margin-right: 4px; font-family: var(--mono); }
#topright button {
  width: 28px; height: 28px; border-radius: 50%;
  background: none; border: 1px solid var(--line); color: var(--dim);
  font-weight: 700; cursor: pointer;
}
#topright button:hover { color: var(--txt); border-color: var(--dim); }

/* -------------------------------- rails --------------------------------- */
aside {
  background: var(--panel); z-index: 10;
  overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
#leftrail  { grid-area: left;  border-right: 1px solid var(--line); padding: 10px 12px 30px; }
#rightrail { grid-area: right; border-left: 1px solid var(--line); padding: 10px 14px 30px; }

aside section { margin-bottom: 16px; }
aside h3 {
  font-size: 10px; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--dim); margin-bottom: 7px; display: flex; justify-content: space-between;
}
aside h3 em { font-style: normal; color: var(--txt); font-family: var(--mono); font-size: 11px; }

.btncol { display: flex; flex-direction: column; gap: 4px; }
.btnrow { display: flex; gap: 4px; flex-wrap: wrap; }
aside button {
  background: var(--panel2); border: 1px solid var(--line); color: var(--dim);
  font: 600 10.5px/1 inherit; letter-spacing: 1px; padding: 7px 8px;
  cursor: pointer; border-radius: 3px; flex: 1; text-align: center; white-space: nowrap;
}
aside button:hover { color: var(--txt); border-color: #3a4450; }
aside button.on { color: #fff; background: #24466b; border-color: var(--in); }
#phasebtns button.on[data-ph="0"] { background: #6b2a24; border-color: var(--warn); }

input[type=range] { width: 100%; accent-color: var(--in); height: 22px; cursor: pointer; }
#explodewrap { display: block; margin-top: 8px; font-size: 11px; color: var(--dim); }

.checks { display: flex; flex-direction: column; gap: 3px; }
.checks label { font-size: 12px; color: var(--txt); cursor: pointer; display: flex; gap: 7px; align-items: center; }
.checks input { accent-color: var(--in); }

#viewsec.hidden, #phasesec.hidden, #ctxsec.hidden { display: none; }

/* ------------------------------- readouts -------------------------------- */
#readouts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 4px;
  padding: 10px 12px;
}
.rolabel { font-size: 10px; letter-spacing: 2px; }
.rolabel.in { color: var(--in); } .rolabel.out { color: var(--out); }
body.cvout .rolabel.out, body.cvout .roval.out { color: var(--cv); }
.roval { font-family: var(--mono); font-size: 26px; font-weight: 600; line-height: 1.1; }
.roval.in { color: var(--in); } .roval.out { color: var(--out); }
.roval small { font-size: 11px; color: var(--dim); font-weight: 400; }
.rosub { font-size: 10px; color: var(--dim); }
.rosub .mono { font-family: var(--mono); color: var(--txt); }
.rowide {
  grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--dim); border-top: 1px solid var(--line); padding-top: 6px;
}
.rowide b { font-family: var(--mono); color: var(--txt); font-weight: 600; margin-left: 4px; }
.rowide.dim { border-top: none; padding-top: 0; }
#btnZero { flex: 0 0 auto; padding: 3px 8px; font-size: 9px; }

/* -------------------------------- graph ---------------------------------- */
#graphsec { margin-top: 14px; }
#graphsec h3 { justify-content: flex-start; }
#graph {
  width: 100%; height: auto; display: block;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 4px;
}

/* ------------------------------- article ---------------------------------- */
#article { margin-top: 14px; }
#article h2 { font-size: 14px; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 8px; }
#chBody p { margin-bottom: 9px; color: #c3ccd7; }
#chBody b { color: #fff; }
#chBody .in  { color: var(--in);  font-weight: 600; }
#chBody .out { color: var(--out); font-weight: 600; }
#chBody .cv  { color: var(--cv);  font-weight: 600; }
#chBody .eq {
  font-family: var(--mono); font-size: 13px; color: #e8eef5;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 3px;
  padding: 7px 10px; margin: 9px 0; text-align: center;
}
#chBody .note { font-size: 11.5px; color: var(--dim); border-left: 2px solid var(--line); padding-left: 9px; }
#chNav { display: flex; justify-content: space-between; margin-top: 12px; }
#chNav button { flex: 0 0 auto; padding: 7px 14px; }

/* -------------------------------- stage ----------------------------------- */
#stage { grid-area: stage; position: relative; overflow: hidden; background: radial-gradient(120% 90% at 50% 30%, #1d232b 0%, #14171b 62%, #0e1114 100%); }
#stage canvas.gl { position: absolute; inset: 0; display: block; }
#vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background: radial-gradient(120% 100% at 50% 42%, transparent 55%, rgba(5,7,9,.55) 100%);
}
#leaders { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; }
#labels { position: absolute; inset: 0; pointer-events: none; z-index: 5; }

.lbl {
  position: absolute; transform: translate(-50%, -50%);
  font: 600 10.5px/1.25 "Segoe UI", sans-serif; letter-spacing: 1.2px; text-transform: uppercase;
  color: #e6edf4; background: rgba(16,20,25,.82); border: 1px solid #37414d;
  padding: 3px 8px; border-radius: 2px; white-space: nowrap; pointer-events: none;
}
.lbl small { display: block; font-weight: 400; font-size: 9px; color: var(--dim); letter-spacing: .6px; text-transform: none; }
.lbl.acc-in  { border-color: var(--in);  color: #bcdcff; }
.lbl.acc-out { border-color: var(--out); color: #ffd9ae; }
.lbl.acc-cv  { border-color: var(--cv);  color: #b8f2df; }
.lbl.acc-plane { border-color: #24b6c9; color: #aef1fa; background: rgba(10,36,40,.82); }
.lbl.big { font-size: 13px; padding: 5px 12px; }
.lbl.math { text-transform: none; font-size: 12px; }

#dialwrap { position: absolute; left: 14px; bottom: 12px; z-index: 6; pointer-events: none; }
#dial { display: block; }

#bigmsg {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 6; pointer-events: none; text-align: center;
  font: 600 13px/1.5 "Segoe UI", sans-serif; letter-spacing: 1.5px; text-transform: uppercase;
  color: #e6edf4; text-shadow: 0 1px 6px #000;
  opacity: 0; transition: opacity .5s;
}
#bigmsg.show { opacity: 1; }
#bigmsg em { font-style: normal; color: var(--out); }
#bigmsg .sub { font-size: 10.5px; color: var(--dim); letter-spacing: 1px; }

/* -------------------------------- help ------------------------------------ */
#helpmodal {
  position: fixed; inset: 0; z-index: 50; background: rgba(8,10,13,.72);
  display: flex; align-items: center; justify-content: center;
}
#helpmodal.hidden { display: none; }
#helpcard {
  width: 520px; max-width: 92vw; max-height: 86vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 22px 26px;
}
#helpcard h2 { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--dim); margin: 14px 0 8px; }
#helpcard h2:first-child { margin-top: 0; }
#helpcard table { border-collapse: collapse; width: 100%; }
#helpcard td { padding: 3px 0; font-size: 12.5px; }
#helpcard td:last-child { color: var(--dim); font-family: var(--mono); text-align: right; }
#helpcard p { font-size: 12px; color: #b6c0cc; margin-bottom: 6px; }
#helpcard button { margin-top: 14px; background: var(--panel2); border: 1px solid var(--line); color: var(--txt); padding: 8px 18px; cursor: pointer; border-radius: 3px; letter-spacing: 1px; font-size: 10.5px; font-weight: 600; }

/* 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); }
