/* Edgar — Electric Dreams (1984) interactive tribute.
   Retro CRT terminal aesthetic. */

:root {
  --phos: #33ff33;      /* green phosphor          */
  --phos-dim: #1a4d1a;  /* green, dimmed           */
  --amber: #ffbf00;     /* amber for accents       */
  --bg: #000408;         /* near-black desk         */
  --glass: #051014;     /* CRT glass tint          */
  --bezel: #101820;     /* dark grey bezel         */
  --scan: rgba(0,255,51,0.035);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--phos);
  font: 12px/1.4 "Courier New", Courier, monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow-x: hidden;          /* allow CRT glow to show; clip x-overflow only */
}

.desk {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  max-width: 620px;
}

/* ---- CRT monitor ---- */
.crt-frame {
  position: relative;
  width: 100%;                 /* responsive by default */
  max-width: 512px;
  height: auto;                /* let aspect-ratio control height */
  aspect-ratio: 512 / 384;
  display: flex;
  align-items: center;
  justify-content: center;
}

.crt-frame::before {
  content: "";
  position: absolute;
  inset: -18px;
  border-radius: 10px;
  background: radial-gradient(ellipse at center, #1a1a1a 0%, #000 70%);
  box-shadow:
    inset 0 0 0 2px #222,
    inset 0 0 0 4px #0d141d,
    0 0 30px 8px rgba(51,255,51,0.12),
    0 0 60px 16px rgba(51,255,51,0.06);
  z-index: 2;
  pointer-events: none;
}

.crt-frame::after {
  content: "";
  position: absolute;
  inset: -18px;
  border-radius: 10px;
  background: linear-gradient(
    135deg,
    transparent 45%,
    rgba(51,255,51,0.04) 50%,
    transparent 55%
  );
  z-index: 3;
  pointer-events: none;
  animation: glare 6s infinite;
}

@keyframes glare {
  0%, 70%, 100% { opacity: 0; }
  75%, 85%       { opacity: 0.6; }
}

.crt-bezel {
  position: absolute;
  inset: 0;
  border: 14px solid var(--bezel);
  border-radius: 10px;
  background: linear-gradient(145deg, #0c1016 0%, #121823 100%);
  box-shadow: inset 0 0 0 2px #000;
  z-index: 1;
}

.crt-bezel::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  border: 2px solid var(--phos);
  border-radius: 50%;
  box-shadow: 0 0 0 4px var(--bg), 0 0 20px rgba(51,255,51,0.3);
}

.crt-screen {
  position: relative;
  z-index: 2;               /* above bezel (z-index:1) */
  width: 100%;                 /* follow responsive frame */
  height: 100%;
  align-self: stretch;         /* force fill in flex container */
  background: var(--glass);
  overflow: hidden;
  border: 2px solid var(--phos-dim);
  box-shadow: inset 0 0 20px rgba(0,0,0,0.6);
}

.crt-screen canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* scanline overlay */
.scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    var(--scan) 3px,
    var(--scan) 4px
  );
  pointer-events: none;
  z-index: 4;
}

/* ---- Terminal (inside CRT screen) ---- */
.terminal {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  max-width: calc(100% - 24px);
  background: rgba(0, 8, 16, 0.75);
  border: 1px solid var(--phos-dim);
  border-radius: 4px;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 0 15px rgba(51,255,51,0.08);
  overflow-wrap: break-word;
  z-index: 5;   /* above scanlines (z-index:4) */
}

.terminal pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--phos);
  text-shadow: 0 0 3px var(--phos);
}

.terminal .dir { color: var(--amber); }
.terminal .file { color: #77ff99; }
.terminal .comment { color: #559955; opacity: 0.7; }
.terminal .error { color: #ff6666; }

.prompt {
  margin-top: 4px;
  color: var(--phos);
  display: flex;
  align-items: center;
  gap: 6px;
}

.prompt .prefix { opacity: 0.6; }

.cursor {
  display: inline-block;
  width: 10px;
  height: 14px;
  background: var(--phos);
  animation: blink 1s steps(2) infinite;
  box-shadow: 0 0 6px var(--phos), inset 0 0 3px #000;
}

.music-btn {
  background: none;
  border: 1px solid var(--phos-dim);
  color: var(--phos);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 8px;
  margin-left: auto;
  opacity: 0.5;
  transition: opacity 0.2s, color 0.2s;
  border-radius: 3px;
}
.music-btn:hover,
.music-btn.on { opacity: 1; color: var(--amber); }
.music-btn.on { border-color: var(--amber); }

@keyframes blink {
  to { opacity: 0; }
}

@media (prefers-color-scheme: light) {
  :root {
    --phos: #006600;
    --phos-dim: #003300;
    --amber: #cc8800;
    --bg: #d0e0d0;
    --glass: #d8f0d8;
    --bezel: #c0c0c0;
    --scan: rgba(0,102,0,0.08);
  }
  .terminal { background: rgba(0,102,0,0.04); }
}

/* ---- Mobile: scale down CRT + terminal ---- */
@media (max-width: 480px) {
  .terminal { font-size: 11px; padding: 10px 12px; }
  .desk { gap: 1rem; }
}
