/* ============================================================
   THE PROCEDURE — CRT Stylesheet
   Fixed 800×600 terminal. One font size. No compromise.
   ============================================================ */

@font-face {
  font-family: 'VT323';
  src: url('assets/fonts/VT323.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: block;
}

:root {
  --green:       #39ff14;
  --green-dim:   #2ab80e;
  --green-faint: #1a7a0a;
  --green-glow:  rgba(57, 255, 20, 0.16);
  --bg:          #080e08;
  --bezel:       #1c1c1c;
  --font:        'VT323', 'Courier New', Courier, monospace;
  --font-size:   20px;
  --line-height: 1.42;
  --screen-w: 800px;
  --screen-h: 600px;
}

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

/* ── Text selection: inverted like an 80s monochrome CRT ── */
::selection {
  background: var(--green);
  color: var(--bg);
  text-shadow: none;
}

::-moz-selection {
  background: var(--green);
  color: var(--bg);
  text-shadow: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #111;
  overflow: hidden;
}

/* ── Outer bezel ── */
#crt-bezel {
  background: var(--bezel);
  border-radius: 14px;
  padding: 24px 28px 32px;
  box-shadow:
    0 0 0 2px #0a0a0a,
    0 8px 48px rgba(0,0,0,0.95),
    inset 0 1px 4px rgba(255,255,255,0.03);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: calc(var(--screen-w) + 56px);
  /* Positioned at viewport center; scale.js applies translate(-50%,-50%) + scale() */
  position: fixed;
  top: 50%;
  left: 50%;
  transform-origin: center center;
}

/* ── Screen ── */
#crt-screen {
  width: var(--screen-w);
  height: var(--screen-h);
  background: var(--bg);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow:
    inset 0 0 80px rgba(0,0,0,0.65),
    inset 0 0 16px rgba(0,0,0,0.4),
    0 0 24px rgba(57,255,20,0.06);
  animation: flicker 11s infinite;
}

/* ── Scanlines (with slow vertical drift) ── */
#crt-screen::before {
  content: '';
  position: absolute;
  /* Extend beyond the screen so drift doesn't reveal blank edges */
  top: -8px;
  left: 0;
  right: 0;
  bottom: -8px;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 3px,
    rgba(0,0,0,0.28) 3px,
    rgba(0,0,0,0.28) 4px
  );
  pointer-events: none;
  z-index: 10;
  animation: scanline-drift 8s linear infinite;
}

@keyframes scanline-drift {
  0%   { transform: translateY(0); }
  100% { transform: translateY(4px); }
}

/* ── Rolling brightness bar (CRT refresh artifact) ── */
#crt-roll {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  overflow: hidden;
}

#crt-roll::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(57, 255, 20, 0.018) 30%,
    rgba(57, 255, 20, 0.03) 50%,
    rgba(57, 255, 20, 0.018) 70%,
    transparent 100%
  );
  animation: roll-bar 6s linear infinite;
}

@keyframes roll-bar {
  0%   { top: -120px; }
  100% { top: 100%; }
}

/* ── Vignette ── */
#crt-screen::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 50%,
    rgba(0,0,0,0.75) 100%
  );
  pointer-events: none;
  z-index: 11;
}

@keyframes flicker {
  0%, 91%, 93%, 95.5%, 97%, 100% { opacity: 1; }
  92%   { opacity: 0.94; }
  95%   { opacity: 0.97; }
  96.5% { opacity: 0.95; }
}

/* ── Inner content ── */
#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px 18px 8px;
  overflow: hidden;
  color: var(--green);
  font-family: var(--font);
  font-size: var(--font-size);
  line-height: var(--line-height);
}

/* ── Status bar ── */
#status-bar {
  display: flex;
  justify-content: space-between;
  padding: 0 0 5px;
  border-bottom: 1px solid var(--green-faint);
  color: var(--green-faint);
  text-shadow: none;
  flex-shrink: 0;
}

/* ── Terminal (scrollable text zone) ── */
#terminal {
  flex: 1;
  padding: 8px 0 4px;
  overflow-y: auto;
  scrollbar-width: none;
  min-height: 0; /* flex child: allow shrinking */
}
#terminal::-webkit-scrollbar { display: none; }

/* ── Lines — no size variation ── */
.line {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: calc(var(--font-size) * var(--line-height));
  text-shadow: 0 0 7px var(--green-glow), 0 0 14px rgba(57,255,20,0.25);
}

.line.dim    { color: var(--green-dim);   text-shadow: 0 0 5px rgba(42,184,14,0.18); }
.line.faint  { color: var(--green-faint); text-shadow: none; }
.line.bright { color: #d0ffcc;            text-shadow: 0 0 10px rgba(57,255,20,0.35), 0 0 20px rgba(57,255,20,0.15); }
.line.system { color: var(--green-faint); text-shadow: none; }
.line.sep    { color: var(--green-faint); text-shadow: none; }
.line.empty  { min-height: calc(var(--font-size) * var(--line-height)); }

/* ── Bottom panel (options + input) — fixed at bottom ── */
#bottom-panel {
  flex-shrink: 0;
  border-top: 1px solid var(--green-faint);
  padding: 6px 0 0;
}

/* ── Options ── */
#options-panel {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#options-panel:empty { display: none; }

.option-btn {
  background: transparent;
  border: 1px solid var(--green-faint);
  color: var(--green-dim);
  font-family: var(--font);
  font-size: var(--font-size);
  text-align: left;
  padding: 2px 10px;
  cursor: pointer;
  transition: border-color 0.07s, color 0.07s, background 0.07s;
  line-height: var(--line-height);
}

.option-btn:hover {
  border-color: var(--green);
  color: var(--green);
  background: rgba(57, 255, 20, 0.04);
  text-shadow: 0 0 8px var(--green-glow);
}

.option-btn:focus  { outline: 1px solid var(--green); outline-offset: 2px; }
.option-btn:disabled { opacity: 0.28; cursor: default; }

/* Highlight selected option */
.option-btn.selected {
  border-color: var(--green);
  color: var(--green);
  background: rgba(57, 255, 20, 0.06);
  text-shadow: 0 0 8px var(--green-glow);
}

/* ── Input line ── */
#input-line {
  display: flex;
  align-items: center;
  padding: 4px 0 2px;
  color: var(--green);
}

#input-line .prompt {
  color: var(--green-dim);
  margin-right: 4px;
}

#input-line .input-text {
  color: var(--green);
  text-shadow: 0 0 8px var(--green-glow);
}

#input-line .cursor {
  display: inline-block;
  animation: blink 1.1s step-end infinite;
  color: var(--green);
  text-shadow: 0 0 8px var(--green-glow);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Start message (hidden until JS shows it) ── */
#start-msg {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 5;
  background: #000;
  color: var(--green-faint);
  font-family: var(--font);
  font-size: var(--font-size);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  animation: blink 1.1s step-end infinite;
}
#start-msg.visible {
  display: flex;
}

/* ── Bezel bottom row ── */
#bezel-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  position: relative;
}

#bezel-label {
  text-align: center;
  color: #2a2a2a;
  font-family: var(--font);
  font-size: var(--font-size);
  letter-spacing: 0.18em;
  user-select: none;
}

/* ── Power button ── */
#power-btn {
  position: absolute;
  right: 4px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background:
    radial-gradient(circle at 40% 35%, #3a3a3a 0%, #222 60%, #151515 100%);
  box-shadow:
    0 2px 4px rgba(0,0,0,0.8),
    0 4px 8px rgba(0,0,0,0.5),
    inset 0 1px 1px rgba(255,255,255,0.06),
    inset 0 -1px 2px rgba(0,0,0,0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.06s, box-shadow 0.06s;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

#power-btn .power-icon {
  font-size: 14px;
  color: #444;
  line-height: 1;
  transition: color 0.3s, text-shadow 0.3s;
  pointer-events: none;
}

#power-btn:hover .power-icon {
  color: #555;
}

#power-btn:active {
  transform: translateY(1px);
  box-shadow:
    0 1px 2px rgba(0,0,0,0.8),
    0 2px 4px rgba(0,0,0,0.5),
    inset 0 1px 1px rgba(255,255,255,0.04),
    inset 0 -1px 2px rgba(0,0,0,0.6);
}

/* Power button ON state */
#power-btn.on .power-icon {
  color: var(--green);
  text-shadow: 0 0 6px var(--green-glow), 0 0 12px rgba(57,255,20,0.12);
}

/* ── Power button DEAD state — after final case, machine is done ── */
#power-btn.dead {
  cursor: default;
  pointer-events: none;
}

#power-btn.dead .power-icon {
  color: #222;
  text-shadow: none;
}

/* ── CRT off state ── */
#crt-screen.off {
  animation: none;
  box-shadow:
    inset 0 0 80px rgba(0,0,0,0.9),
    inset 0 0 16px rgba(0,0,0,0.6);
}

#crt-screen.off::before,
#crt-screen.off::after {
  opacity: 0;
}

#crt-screen.off #crt-roll {
  display: none;
}

#crt-screen.off #app {
  visibility: hidden;
}
