/* ==========================================================================
   SUBJECT OBSERVATION — visual identity
   Palette:
     --void        #050607   (rack background)
     --steel       #16181a   (terminal chassis)
     --steel-hi    #23262a   (chassis highlight edge)
     --crt-black   #030402   (feed background)
     --phosphor    #cdeee2   (cold cyan-white readout text)
     --phosphor-dim#5f7d76
     --alert-amber #ffb84d
     --alert-red   #ff3b3b
     --paper       #0d0f10   (report panel — cold, not warm)
   Type: monospace terminal face throughout — this is institutional
   equipment, not a consumer gadget, so there is no second "friendly" face.
   ========================================================================== */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: #050607;
  color: #cdeee2;
  font-family: "SF Mono", "Space Mono", Consolas, monospace;
  -webkit-font-smoothing: antialiased;
}

.rack {
  max-width: 420px;
  margin: 0 auto;
  padding: 16px 12px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #0a0c0d 0%, #050607 60%);
}

/* ---------------- TERMINAL CHASSIS ---------------- */

.terminal {
  width: 100%;
  max-width: 360px;
  background: linear-gradient(180deg, #1d2023 0%, #16181a 10%, #101214 90%, #0a0b0c 100%);
  border-radius: 10px;
  padding: 10px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.04) inset,
    0 -2px 12px rgba(0,0,0,0.6) inset,
    0 20px 44px rgba(0,0,0,0.6);
  position: relative;
  border: 1px solid #000;
}

/* corner mounting screws — sells the "physical rack unit" read */
.terminal::before, .terminal::after {
  content: "";
  position: absolute;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #4a4e54, #101214 70%);
  box-shadow: 0 0 0 1px #000;
  top: 6px;
  z-index: 2;
}
.terminal::before { left: 6px; }
.terminal::after { right: 6px; }
.terminal__footer { position: relative; }
.terminal__footer::before, .terminal__footer::after {
  content: "";
  position: absolute;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #4a4e54, #101214 70%);
  box-shadow: 0 0 0 1px #000;
  bottom: 2px;
}
.terminal__footer::before { left: 2px; }
.terminal__footer::after { right: 2px; }

.terminal__header, .terminal__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  letter-spacing: 1.4px;
  color: #6c7a76;
  padding: 2px 4px;
}
.terminal__header { padding-bottom: 8px; }
.terminal__footer { padding-top: 8px; }

.hdr-left { display: flex; flex-direction: column; gap: 1px; }
.hdr-title { color: #9fb8b0; font-size: 10.5px; letter-spacing: 1.4px; }
.hdr-sub { color: #4d635c; font-size: 8.5px; letter-spacing: 1.2px; }

.hdr-right { display: flex; align-items: center; gap: 5px; }
.link-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #4f8a78;
  box-shadow: 0 0 5px #4f8a78;
  animation: breathe 3s ease-in-out infinite;
}
.link-dot.lost { background: #ff3b3b; box-shadow: 0 0 5px #ff3b3b; animation: blink 0.5s steps(1) infinite; }
@keyframes breathe { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }

.led-strip { display: flex; gap: 6px; }
.led {
  width: 5px; height: 5px; border-radius: 50%;
  background: #1c1f22;
  box-shadow: 0 0 0 1px #000 inset;
}
.led.on { background: #4f8a78; box-shadow: 0 0 4px #4f8a78; }
.led--hdd.blink { background: #ffb84d; box-shadow: 0 0 4px #ffb84d; }

/* ---------------- FEED / CRT ---------------- */

.feed {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #030402;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 0 0 2px #000, inset 0 0 40px rgba(0,0,0,0.9);
}

#scene {
  width: 100%;
  height: 100%;
  display: block;
  filter: grayscale(0.4) brightness(1.05) contrast(1.15) sepia(0.08) hue-rotate(140deg);
}

.osd {
  position: absolute;
  font-size: 10.5px;
  color: #cdeee2;
  text-shadow: 0 0 4px rgba(205,238,226,0.6);
  letter-spacing: 0.6px;
  z-index: 5;
  pointer-events: none;
  user-select: none;
  line-height: 1.5;
}
.osd--top-left { top: 8px; left: 10px; }
.osd--top-right { top: 8px; right: 10px; text-align: right; }
.osd--bottom-left { bottom: 8px; left: 10px; }
.osd--bottom-right { bottom: 8px; right: 10px; }

.osd-line { font-variant-numeric: tabular-nums; margin-top: 2px; opacity: 0.9; }

.osd-rec { display: flex; align-items: center; gap: 5px; }
.osd-rec .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #ff3b3b;
  box-shadow: 0 0 5px #ff3b3b;
  animation: blink 1.4s steps(1) infinite;
}
@keyframes blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0.15; } }

.osd--center-flash {
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.5s ease;
  background: rgba(3,4,2,0.6);
  padding: 4px 10px;
  border: 1px solid rgba(205,238,226,0.3);
}
.osd--center-flash.show { opacity: 1; }

.osd--alert {
  top: 34px; left: 50%;
  transform: translateX(-50%);
  color: #ffb84d;
  text-shadow: 0 0 6px rgba(255,184,77,0.7);
  font-weight: bold;
  opacity: 0;
  transition: opacity 0.3s ease;
  white-space: nowrap;
}
.osd--alert.show { opacity: 1; animation: alert-flicker 0.6s steps(3) infinite; }
@keyframes alert-flicker { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* texture layers */
.scanlines {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    to bottom, rgba(0,0,0,0.22) 0px, rgba(0,0,0,0.22) 1px, transparent 2px, transparent 3px
  );
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 4;
}
.vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.65) 100%);
  pointer-events: none;
  z-index: 3;
}
.noise {
  position: absolute; inset: 0;
  opacity: 0.045;
  pointer-events: none;
  z-index: 6;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: noise-shift 0.4s steps(2) infinite;
}
@keyframes noise-shift { 0% { transform: translate(0,0); } 100% { transform: translate(-4px, 3px); } }

/* glitch bar: a thin horizontal tear that intensifies with subject awareness */
.glitch-bar {
  position: absolute;
  left: 0; right: 0;
  height: 0;
  background: rgba(205,238,226,0.08);
  z-index: 7;
  pointer-events: none;
  mix-blend-mode: screen;
}
.glitch-bar.active {
  height: 14px;
  animation: glitch-jump 0.15s steps(2) infinite;
}
@keyframes glitch-jump { 0% { transform: translateX(0); } 50% { transform: translateX(-6px); } 100% { transform: translateX(4px); } }

.signal-loss {
  position: absolute; inset: 0;
  background: #000;
  color: #cdeee2;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; letter-spacing: 3px;
  opacity: 0;
  z-index: 8;
  pointer-events: none;
}
.signal-loss.show { opacity: 1; }

/* boot / reconnect sequence, shown briefly whenever the feed connects */
.boot-overlay {
  position: absolute; inset: 0;
  background: #000;
  z-index: 9;
  display: flex;
  align-items: center;
  padding: 20px;
  opacity: 1;
  transition: opacity 0.6s ease;
}
.boot-overlay.hidden { opacity: 0; pointer-events: none; }
.boot-lines {
  color: #6fdc9a;
  font-size: 11px;
  line-height: 1.9;
  text-shadow: 0 0 4px rgba(111,220,154,0.6);
  white-space: pre-wrap;
}
.boot-lines .ok { color: #6fdc9a; }
.boot-lines .warn { color: #ffb84d; }

/* ---------------- CONTROLS ---------------- */

.controls {
  width: 100%;
  max-width: 360px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 16px;
}
.btn {
  background: linear-gradient(180deg, #1c1f22, #121416);
  border: 1px solid #000;
  border-radius: 3px;
  padding: 10px 4px;
  color: #a9c4bc;
  font-size: 9.5px;
  letter-spacing: 0.6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 0 rgba(0,0,0,0.5), 0 1px 0 rgba(255,255,255,0.03) inset;
  transition: transform 0.08s ease, color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.btn__icon { font-size: 13px; color: #5f7d76; }
.btn:hover { color: #cdeee2; }
.btn:hover .btn__icon { color: #7fd8b8; }
.btn:active {
  transform: translateY(2px);
  color: #cdeee2;
  background: linear-gradient(180deg, #121416, #0b0d0e);
}
.btn:focus-visible {
  outline: 1px solid #ffb84d;
  outline-offset: 2px;
}

/* terminal command echo — immediate feedback for every input, independent
   of how the subject eventually reacts (which arrives later, in the log) */
.command-line {
  width: 100%;
  max-width: 360px;
  margin-top: 8px;
  padding: 7px 10px;
  background: #06070a;
  border: 1px solid #1c1f22;
  border-radius: 3px;
  font-size: 10.5px;
  color: #7fd8b8;
  letter-spacing: 0.4px;
}
.command-line .prompt { color: #4f8a78; margin-right: 4px; }
.command-line .cursor { animation: blink 1s steps(1) infinite; margin-left: 2px; }

/* ---------------- REPORT PANEL ---------------- */

.panel-toggle {
  width: 100%;
  max-width: 360px;
  display: flex;
  gap: 6px;
  margin-top: 22px;
}
.tab {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid #23262a;
  color: #5f7d76;
  padding: 8px 4px;
  font-size: 11px;
  letter-spacing: 0.4px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.tab__icon { margin-right: 5px; opacity: 0.8; }
.tab:hover { color: #9fb8b0; }
.tab.active { color: #cdeee2; border-bottom: 2px solid #ffb84d; }
.tab:focus-visible { outline: 1px solid #ffb84d; outline-offset: -2px; }

.panel {
  width: 100%;
  max-width: 360px;
  background: #0d0f10;
  border: 1px solid #1c1f22;
  border-radius: 4px;
  margin-top: 10px;
  padding: 16px 16px 20px;
  color: #cdeee2;
  min-height: 180px;
}
.panel__page { display: none; }
.panel__page.active { display: block; }

.panel h2 { margin: 0 0 4px; font-size: 15px; letter-spacing: 0.6px; }
.muted { color: #5f7d76; font-size: 11px; margin: 2px 0 10px; }
.muted.small { font-size: 10.5px; }

.stat-list { display: flex; flex-direction: column; gap: 10px; }
.stat-row { display: flex; flex-direction: column; gap: 3px; }
.stat-row__label { display: flex; justify-content: space-between; font-size: 11px; color: #9fb8b0; }
.stat-row__bar { height: 5px; background: #1c1f22; overflow: hidden; }
.stat-row__fill { height: 100%; background: #4f8a78; transition: width 0.4s ease; }
.stat-row__fill.warn { background: #ffb84d; }
.stat-row__fill.danger { background: #ff3b3b; }

.log-list, .notes-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.log-list li, .notes-list li {
  background: #0a0c0d;
  border: 1px solid #1c1f22;
  border-radius: 3px;
  padding: 9px 10px;
  font-size: 11.5px;
}
.log-list .l-time, .notes-list .n-time { font-size: 10px; color: #5f7d76; margin-top: 3px; }
.log-list .l-empty, .notes-list .n-empty { color: #5f7d76; text-align: center; padding: 18px 0; font-size: 11px; }

@media (max-width: 380px) {
  .btn { font-size: 8px; padding: 8px 2px; }
  .btn__icon { font-size: 12px; }
  .hdr-sub { display: none; }
}
