/* THE DIRECTOR — ARCHIVE-9 terminal */

@font-face { font-family: 'term'; src: local('Courier New'); }

:root {
  --green: #3aff6e;
  --green-dim: #1e8f42;
  --green-dark: #0c3a1d;
  --amber: #ffb000;
  --red: #ff3b30;
  --bg: #020604;
  --glow-soft: rgba(58, 255, 110, 0.7);
  --glow-wide: rgba(58, 255, 110, 0.25);
  --glow-faint: rgba(58, 255, 110, 0.045);
  --tint: rgba(20, 60, 30, 0.22);
}

/* PRISM phosphor themes */
body[data-theme="amber"] {
  --green: #ffb642;
  --green-dim: #9a6d1f;
  --green-dark: #3a2c0c;
  --amber: #6ee7ff;
  --glow-soft: rgba(255, 182, 66, 0.7);
  --glow-wide: rgba(255, 182, 66, 0.25);
  --glow-faint: rgba(255, 182, 66, 0.05);
  --tint: rgba(70, 48, 12, 0.25);
  --bg: #070402;
}
body[data-theme="blue"] {
  --green: #57c8ff;
  --green-dim: #2a6f96;
  --green-dark: #0c2a3a;
  --glow-soft: rgba(87, 200, 255, 0.7);
  --glow-wide: rgba(87, 200, 255, 0.25);
  --glow-faint: rgba(87, 200, 255, 0.05);
  --tint: rgba(15, 40, 70, 0.25);
  --bg: #020507;
}
body[data-theme="red"] {
  --green: #ff5b4d;
  --green-dim: #96352c;
  --green-dark: #3a0f0c;
  --amber: #ffb000;
  --glow-soft: rgba(255, 91, 77, 0.7);
  --glow-wide: rgba(255, 91, 77, 0.25);
  --glow-faint: rgba(255, 91, 77, 0.05);
  --tint: rgba(70, 15, 12, 0.25);
  --bg: #070202;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: #000;
  color: var(--green);
  font-family: 'VT323', 'term', 'Courier New', monospace;
  font-size: 20px;
  line-height: 1.45;
  overflow: hidden;
  text-transform: uppercase;
  cursor: default;
}

#screen {
  position: relative;
  height: 100%;
  background:
    radial-gradient(ellipse at center, var(--tint) 0%, rgba(0,0,0,0) 65%),
    var(--bg);
  overflow: hidden;
  animation: powerOn 0.9s ease-out 1;
  transition: background 0.6s;
}

@keyframes powerOn {
  0%   { transform: scale(1, 0.005); filter: brightness(6); }
  35%  { transform: scale(1, 0.005); filter: brightness(6); }
  60%  { transform: scale(1, 1);     filter: brightness(2.4); }
  100% { transform: scale(1, 1);     filter: brightness(1); }
}

/* CRT power-off collapse */
#screen.off {
  animation: powerOff 0.55s ease-in forwards;
}
@keyframes powerOff {
  0%   { transform: scale(1, 1);       filter: brightness(1); }
  55%  { transform: scale(1, 0.006);   filter: brightness(4); }
  80%  { transform: scale(0.4, 0.004); filter: brightness(6); }
  100% { transform: scale(0, 0.002);   filter: brightness(0); }
}

/* blinking power prompt on dead screen */
#powerPrompt {
  position: fixed;
  top: 20px; left: 26px;
  z-index: 80;
  display: none;
  color: var(--green);
  font-family: 'VT323', 'Courier New', monospace;
  font-size: 20px;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 0 8px var(--glow-soft);
  animation: blink 1.3s steps(1) infinite;
  cursor: pointer;
}
#powerPrompt.on { display: block; }

/* scanlines */
#screen::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0)   0px,
    rgba(0,0,0,0)   2px,
    rgba(0,0,0,0.28) 3px,
    rgba(0,0,0,0)   4px
  );
  pointer-events: none;
  z-index: 30;
}

/* vignette + slow moving scan bar */
#screen::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,0.55) 100%);
  pointer-events: none;
  z-index: 31;
}

#scanbar {
  position: absolute; left: 0; right: 0; height: 90px;
  background: linear-gradient(to bottom, transparent 0%, var(--glow-faint) 50%, transparent 100%);
  animation: scanMove 7s linear infinite;
  pointer-events: none;
  z-index: 29;
}
@keyframes scanMove { 0% { top: -90px; } 100% { top: 100%; } }

/* subtle flicker */
#flicker {
  position: absolute; inset: 0;
  background: var(--glow-faint);
  animation: flick 0.12s steps(2) infinite;
  pointer-events: none;
  z-index: 28;
}
@keyframes flick { 0% { opacity: 0.35; } 50% { opacity: 0.12; } 100% { opacity: 0.3; } }

body.glitch #screen { animation: glitchJump 0.15s steps(2) 1; }
@keyframes glitchJump {
  0%   { transform: translate(0,0) skewX(0deg); filter: none; }
  30%  { transform: translate(-6px, 2px) skewX(2deg); filter: hue-rotate(30deg) brightness(1.6); }
  60%  { transform: translate(4px, -2px) skewX(-1.5deg); }
  100% { transform: translate(0,0); }
}

#term {
  position: absolute; inset: 0;
  padding: 34px 44px 110px 44px;
  overflow-y: auto;
  z-index: 10;
  text-shadow: 0 0 6px var(--glow-soft), 0 0 24px var(--glow-wide);
  scrollbar-width: none;
}
#term::-webkit-scrollbar { display: none; }

#term .line { white-space: pre-wrap; word-break: break-word; min-height: 1.45em; }
#term .dim    { color: var(--green-dim); text-shadow: 0 0 4px rgba(30,143,66,0.6); }
#term .amber  { color: var(--amber); text-shadow: 0 0 6px rgba(255,176,0,0.6); }
#term .red    { color: var(--red); text-shadow: 0 0 8px rgba(255,59,48,0.7); }
#term .bright { color: #baffce; }
#term .sys    { color: var(--green-dim); }
#term .big    { font-size: 26px; letter-spacing: 2px; }

#term a { color: var(--amber); text-decoration: none; border-bottom: 1px dotted var(--amber); }
#term a:hover { background: rgba(255,176,0,0.15); }

.clicky {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--green-dark);
  text-underline-offset: 4px;
}
.clicky:hover {
  background: rgba(58,255,110,0.09);
  text-decoration-color: var(--green-dim);
}

/* prompt / input */
#promptRow {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 14px 44px 26px 44px;
  display: none;
  align-items: baseline;
  gap: 10px;
  z-index: 12;
  background: linear-gradient(to top, rgba(2,6,4,0.95) 70%, rgba(2,6,4,0));
  text-shadow: 0 0 6px rgba(58,255,110,0.7);
}
#promptRow.on { display: flex; }
#promptRow { text-shadow: 0 0 6px var(--glow-soft); }
#promptChar { color: var(--green); flex: 0 0 auto; }
#cli {
  flex: 0 1 auto;
  width: 2ch;
  min-width: 2ch;
  max-width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--green);
  font: inherit;
  text-transform: uppercase;
  letter-spacing: 1px;
  caret-color: transparent;
  text-shadow: inherit;
}
#fakeCaret {
  display: inline-block;
  width: 11px; height: 20px;
  background: var(--green);
  animation: blink 1.05s steps(1) infinite;
  vertical-align: text-bottom;
  box-shadow: 0 0 8px var(--glow-soft);
}
@keyframes blink { 50% { opacity: 0; } }

/* cursor while typing output */
.cursor::after {
  content: '█';
  animation: blink 0.9s steps(1) infinite;
}

/* transmission overlay */
#tx {
  position: absolute; inset: 0;
  background: #000;
  z-index: 40;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 60px 30px 60px;
  text-align: center;
  overflow: hidden;
}
#tx.on { display: flex; }
#txInner {
  max-width: 900px;
  width: 100%;
  font-size: clamp(18px, 3.4vh, 30px);
  line-height: 1.6;
  letter-spacing: 2px;
  text-shadow: 0 0 10px var(--glow-soft), 0 0 40px var(--glow-wide);
  flex: 0 1 auto;
  max-height: calc(100vh - 170px);
  overflow-y: auto;
  scrollbar-width: none;
}
#txInner::-webkit-scrollbar { display: none; }
#txInner .line { min-height: 1.6em; }
#txFooter { margin-top: 34px; font-size: 18px; color: var(--green-dim); flex: 0 0 auto; }
#txFooter .btn, #vidFooter .btn {
  display: inline-block; margin: 8px 14px; padding: 4px 14px;
  border: 1px solid var(--green-dim); color: var(--green);
  cursor: pointer; text-decoration: none;
}
#txFooter .btn:hover, #vidFooter .btn:hover { background: rgba(58,255,110,0.12); }

/* video render overlay */
#vid {
  position: absolute; inset: 0;
  background: #000;
  z-index: 45;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 30px;
}
#vid.on { display: flex; }
#vidStatus { color: var(--green-dim); font-size: 16px; letter-spacing: 2px; }
#vidCanvas {
  max-width: 92%;
  max-height: 70vh;
  border: 1px solid var(--green-dark);
  box-shadow: 0 0 40px rgba(58,255,110,0.15);
}
#vidFooter { font-size: 18px; }

/* OPTIC MODULE attachments — phosphor-tinted */
.optic-img {
  display: block;
  margin: 6px 0 6px 16px;
  max-width: 280px;
  max-height: 180px;
  filter: grayscale(1) sepia(1) hue-rotate(70deg) saturate(2.4) brightness(0.92) contrast(1.15);
  border: 1px solid var(--green-dim);
  box-shadow: 0 0 18px rgba(58,255,110,0.25);
}

/* boot splash */
#splash {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 26px;
  z-index: 50;
  background: #000;
}
#splash .blink { animation: blink 1.2s steps(1) infinite; }
#splash .tiny { color: var(--green-dim); font-size: 15px; letter-spacing: 3px; }

/* RED ALERT (konami) */
body.redalert #screen {
  animation: alertFlash 0.55s steps(2) infinite;
}
@keyframes alertFlash {
  0%   { background: radial-gradient(ellipse at center, rgba(120,10,5,0.5) 0%, rgba(0,0,0,0) 65%), #180302; }
  50%  { background: radial-gradient(ellipse at center, var(--tint) 0%, rgba(0,0,0,0) 65%), var(--bg); }
  100% { background: radial-gradient(ellipse at center, rgba(120,10,5,0.5) 0%, rgba(0,0,0,0) 65%), #180302; }
}
body.redalert #term { text-shadow: 0 0 8px rgba(255,59,48,0.8), 0 0 30px rgba(255,59,48,0.3); }

@media (max-width: 700px) {
  body { font-size: 16px; }
  #term { padding: 20px 16px 100px 16px; }
  #term .big { font-size: 20px; letter-spacing: 1px; }
  #promptRow { padding: 10px 16px 18px 16px; }
  #txInner { font-size: 20px; }
  #tx { padding: 24px; }
}
