/* Jarvis HUD. The reactor is the one loud element; rails and panels stay quiet glass. */

:root {
  --void: #04090F;
  --deep: #071522;
  --glass: rgba(12, 38, 56, .42);
  --glass-edge: rgba(82, 224, 255, .16);
  --cyan: #52E0FF;
  --cyan-2: #2BA8C9;
  --cyan-dim: #15546A;
  --ice: #DDF6FF;
  --ice-dim: #86A9B8;
  --amber: #FFB02E;
  --red: #FF4757;
  --green: #36F1A2;

  --f-hud: 'Chakra Petch', 'Arial Narrow', sans-serif;
  --f-text: 'Barlow Semi Condensed', 'Helvetica Neue', sans-serif;
  --gutter: clamp(16px, 2.4vw, 32px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; overflow-x: clip;
  color: var(--ice);
  font: 400 16px/1.45 var(--f-text);
  font-variant-numeric: tabular-nums;
  background:
    radial-gradient(60% 55% at 50% 46%, rgba(43,168,201,.16) 0%, transparent 70%),
    linear-gradient(rgba(82,224,255,.035) 1px, transparent 1px) 0 0 / 100% 32px,
    linear-gradient(90deg, rgba(82,224,255,.035) 1px, transparent 1px) 0 0 / 32px 100%,
    radial-gradient(120% 90% at 50% 40%, var(--deep) 0%, var(--void) 70%);
  background-color: var(--void);
  padding-bottom: 40px;
}
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
button { font: inherit; color: inherit; }

/* a single slow scanline, the HUD's pulse */
.scan {
  position: fixed; inset: 0; pointer-events: none; z-index: 5;
  background: linear-gradient(180deg, transparent 0%, rgba(82,224,255,.05) 50%, transparent 100%) 0 -30vh / 100% 30vh no-repeat;
  animation: scan 9s linear infinite;
}
@keyframes scan { to { background-position: 0 130vh; } }

/* ---------- top ---------- */
.top {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 24px;
  padding: 16px var(--gutter);
  border-bottom: 1px solid var(--glass-edge);
  background: linear-gradient(180deg, rgba(4,9,15,.9), rgba(4,9,15,.4));
}
.id { display: flex; align-items: center; gap: 12px; }
.id-core {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--cyan);
  background: radial-gradient(circle, var(--ice) 0 18%, var(--cyan) 30%, transparent 62%);
  box-shadow: 0 0 14px var(--cyan), inset 0 0 6px var(--cyan);
}
.id-name { font: 600 22px/1 var(--f-hud); letter-spacing: .32em; color: var(--ice); }
.greet { margin: 0; font: 500 17px/1.3 var(--f-hud); color: var(--cyan); min-height: 1.3em; }
.greet::after { content: '▍'; margin-left: 2px; animation: blink 1s steps(1) infinite; color: var(--cyan); }
@keyframes blink { 50% { opacity: 0; } }
.top-right { display: flex; align-items: center; gap: 14px; }
.feed { font-size: 14px; color: var(--ice-dim); display: flex; align-items: center; gap: 8px; }
.feed::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.feed.stale::before { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.feed.dead::before { background: var(--red); box-shadow: 0 0 8px var(--red); }
.clock { font: 500 22px/1 var(--f-hud); letter-spacing: .06em; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 6px; cursor: pointer; text-decoration: none;
  font: 600 14px/1 var(--f-hud); letter-spacing: .06em; color: var(--void);
  background: var(--cyan); border: 1px solid var(--cyan);
  box-shadow: 0 0 18px rgba(82,224,255,.35);
}
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.ghost { background: transparent; color: var(--cyan); box-shadow: none; border-color: var(--glass-edge); }
.btn.speaking { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 32px rgba(82,224,255,.8); } }

/* ---------- deck ---------- */
.deck {
  display: grid; grid-template-columns: minmax(260px, 330px) 1fr minmax(300px, 380px);
  gap: 22px; padding: 22px var(--gutter) 0; max-width: 1680px; margin: 0 auto; align-items: start;
}
.rail { display: grid; gap: 12px; align-content: start; }
.rail-h { margin: 6px 0 0; font: 600 13px/1 var(--f-hud); letter-spacing: .18em; color: var(--ice-dim); }

.needs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.need {
  position: relative; padding: 11px 12px 11px 16px;
  background: var(--glass); border: 1px solid var(--glass-edge); border-radius: 8px;
  backdrop-filter: blur(6px);
}
.need::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.need[data-level="red"]::before { background: var(--red); box-shadow: 0 0 10px var(--red); }
.need-biz { font: 600 13px/1 var(--f-hud); color: var(--ice-dim); letter-spacing: .05em; }
.need-text { margin-top: 5px; font-size: 15px; line-height: 1.35; }
.need.clear { color: var(--ice-dim); }
.need.clear::before { background: var(--green); box-shadow: 0 0 10px var(--green); }

.feeds { list-style: none; margin: 0; padding: 12px; display: grid; gap: 6px; background: var(--glass); border: 1px solid var(--glass-edge); border-radius: 8px; font-size: 14px; }
.feeds li { display: flex; justify-content: space-between; gap: 10px; }
.feeds li span:last-child { color: var(--ice-dim); font: 500 13px var(--f-hud); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 8px; background: var(--green); box-shadow: 0 0 6px var(--green); vertical-align: 1px; }
.dot.amber { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.dot.red { background: var(--red); box-shadow: 0 0 6px var(--red); }
.dot.idle { background: var(--cyan-dim); box-shadow: none; }

/* ---------- reactor ---------- */
.reactor-wrap { display: grid; place-items: center; }
.reactor { position: relative; width: min(100%, 680px); aspect-ratio: 1; }
.dial { position: absolute; inset: 0; }
.rings { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.rings .spin-slow { transform-origin: 300px 300px; animation: spin 80s linear infinite; }
.rings .spin-rev  { transform-origin: 300px 300px; animation: spin 40s linear infinite reverse; }
.rings .spin-mid  { transform-origin: 300px 300px; animation: spin 24s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.rings .faint { fill: none; stroke: var(--cyan-dim); }
.rings .bright { fill: none; stroke: var(--cyan); }
.rings .seg { fill: none; stroke-width: 10; stroke-linecap: butt; filter: drop-shadow(0 0 6px currentColor); transition: stroke .4s; }

.core {
  position: absolute; left: 50%; top: 50%; width: 34%; aspect-ratio: 1; transform: translate(-50%, -50%);
  border-radius: 50%; display: grid; place-items: center; text-align: center;
  background: radial-gradient(circle, rgba(221,246,255,.22) 0%, rgba(82,224,255,.12) 38%, rgba(4,9,15,.0) 70%);
}
.core-n { font: 700 clamp(44px, 7vw, 86px)/.9 var(--f-hud); color: var(--ice); text-shadow: 0 0 22px var(--cyan); }
.core-l { font: 500 15px/1.2 var(--f-hud); color: var(--cyan); letter-spacing: .08em; margin-top: 6px; }
.core[data-level="red"] .core-n { text-shadow: 0 0 22px var(--red); }
.core[data-level="amber"] .core-n { text-shadow: 0 0 22px var(--amber); }

.orbit { position: absolute; inset: 0; }
.node {
  position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%);
  width: 138px; padding: 8px 8px 7px; cursor: pointer; text-align: center;
  background: rgba(7, 21, 34, .82); border: 1px solid var(--glass-edge); border-radius: 8px;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.node:hover { border-color: var(--cyan); }
.node[aria-pressed="true"] { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan), 0 0 22px rgba(82,224,255,.35); }
.node-name { display: block; font: 600 14px/1.1 var(--f-hud); letter-spacing: .03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node-metric { display: block; font-size: 13px; color: var(--ice-dim); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node .dot { margin-right: 6px; }

/* ---------- detail ---------- */
.detail {
  background: var(--glass); border: 1px solid var(--glass-edge); border-radius: 10px;
  padding: 18px; backdrop-filter: blur(6px); display: grid; gap: 14px;
}
.detail-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.detail-name { margin: 0; font: 600 26px/1 var(--f-hud); letter-spacing: .02em; }
.detail-state { font: 500 13px var(--f-hud); color: var(--ice-dim); }
.detail-big { font: 600 44px/1 var(--f-hud); text-shadow: 0 0 16px rgba(82,224,255,.45); }
.detail-big small { font: 500 15px var(--f-text); color: var(--ice-dim); margin-left: 8px; text-shadow: none; }
.detail-notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 15px; }
.detail-notes li { padding-left: 14px; position: relative; }
.detail-notes li::before { content: ''; position: absolute; left: 0; top: .55em; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.detail-notes li.red::before { background: var(--red); }
.rows { display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; margin: 0; font-size: 15px; }
.rows dt { color: var(--ice-dim); }
.rows dd { margin: 0; font: 600 16px/1.25 var(--f-hud); text-align: right; }
.bars { display: grid; gap: 7px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 14px; }
.bar-row b { font: 600 15px var(--f-hud); }
.bar { grid-column: 1 / -1; height: 5px; background: rgba(82,224,255,.1); border-radius: 3px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.spark { width: 100%; height: 48px; display: block; }
.spark path { fill: none; stroke: var(--cyan); stroke-width: 1.6; filter: drop-shadow(0 0 4px var(--cyan)); }
.spark .area { fill: rgba(82,224,255,.12); stroke: none; filter: none; }
.empty { border: 1px dashed var(--cyan-dim); border-radius: 8px; padding: 12px; color: var(--ice-dim); font-size: 14px; }
.empty strong { display: block; color: var(--ice); font-weight: 600; margin-bottom: 3px; }
.sub-h { font: 600 12px/1 var(--f-hud); letter-spacing: .16em; color: var(--ice-dim); margin: 4px 0 -4px; }

/* ---------- ask ---------- */
.reactor-wrap { gap: 18px; }
.ask {
  position: relative; z-index: 10;
  width: min(680px, 100%);
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 12px;
  background: rgba(4, 12, 20, .92); border: 1px solid var(--glass-edge);
  box-shadow: 0 0 0 1px rgba(82,224,255,.05), 0 18px 50px rgba(0,0,0,.6);
}
.ask:focus-within { border-color: var(--cyan); box-shadow: 0 0 26px rgba(82,224,255,.25); }
.ask-label { font: 600 14px/1 var(--f-hud); color: var(--cyan); letter-spacing: .06em; white-space: nowrap; }
.ask input { background: transparent; border: 0; outline: 0; color: var(--ice); font: 500 17px var(--f-text); min-width: 0; }
.ask input::placeholder { color: #4F7384; }
.ask kbd { font: 500 12px var(--f-hud); color: var(--ice-dim); border: 1px solid var(--glass-edge); border-radius: 4px; padding: 2px 7px; }
.ask-out { grid-column: 1 / -1; font-size: 15px; color: var(--ice); line-height: 1.4; }
.ask-out:empty { display: none; }

/* ---------- boot sequence: the one orchestrated moment ---------- */
body.booting .rings > * { opacity: 0; }
.rings > * { transition: opacity .6s ease; }
body.booting .node, body.booting .core { opacity: 0; }
.node, .core { transition: opacity .5s ease, border-color .2s, box-shadow .2s; }

/* ---------- responsive ---------- */
@media (max-width: 1250px) {
  .deck { grid-template-columns: 1fr 1fr; }
  .reactor-wrap { grid-column: 1 / -1; order: -1; }
}
@media (max-width: 760px) {
  body { padding-bottom: 150px; }
  .top { grid-template-columns: 1fr auto; gap: 10px 14px; }
  .greet { grid-column: 1 / -1; order: 3; font-size: 15px; }
  .top-right .feed, .top-right .ghost { display: none; }
  .deck { grid-template-columns: 1fr; }
  /* the orbit becomes a grid under a smaller reactor */
  .reactor { width: 100%; aspect-ratio: auto; }
  .dial { position: relative; width: 100%; aspect-ratio: 1; }
  .orbit { position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
  .node { position: static; transform: none; width: auto; text-align: left; }
  .ask { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); width: calc(100% - 2 * var(--gutter)); grid-template-columns: 1fr; gap: 6px; }
  .ask kbd { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .scan, .rings .spin-slow, .rings .spin-rev, .rings .spin-mid, .greet::after, .btn.speaking { animation: none; }
}
.btn, .clock { white-space: nowrap; }
@media (max-width: 760px) {
  .clock { font-size: 18px; }
  .btn { padding: 8px 10px; }
  .ask-out { cursor: pointer; max-height: 30vh; overflow-y: auto; }
}

/* demo label, so nobody mistakes invented numbers for a real business */
.demo-tag { font: 600 12px/1 var(--f-hud); letter-spacing: .08em; color: var(--amber);
  border: 1px solid rgba(255,176,46,.45); border-radius: 4px; padding: 5px 8px; white-space: nowrap; }
