/* ============================================================
   dresner.me — CRT Terminal Stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

/* --- Variables -------------------------------------------- */
:root {
  --purple:        #c200f5;
  --purple-bright: #dc6fff;
  --purple-dim:    #7a008f;
  --glow-sm:       0 0 6px #c200f5, 0 0 14px rgba(194, 0, 245, 0.5);
  --glow-lg:       0 0 12px #c200f5, 0 0 30px rgba(194, 0, 245, 0.4), 0 0 60px rgba(194, 0, 245, 0.15);
  --screen-bg:     #030009;
  --terminal-font: 'VT323', 'Courier New', Courier, monospace;
}

/* --- Reset ------------------------------------------------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  width: 100%;
  height: 100%;
  /* Prevent iOS Safari from auto-inflating font sizes */
  -webkit-text-size-adjust: 100%;
}

body {
  width: 100%;
  height: 100%;
}

/* --- Page background: dark room with faint purple ambient -- */
body {
  background: #000008;
  background: radial-gradient(
    ellipse at 50% 42%,
    #0e0020 0%,
    #04000f 45%,
    #000004 100%
  );
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  font-family: var(--terminal-font);
}

/* --- Scene container --------------------------------------- */
.scene {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}

/* ============================================================
   MONITOR
   ============================================================ */

.monitor {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Whole monitor casts a large soft shadow on the "desk" */
  filter: drop-shadow(0 30px 80px rgba(0, 0, 0, 0.95));
}

/* --- Main bezel body --------------------------------------- */
.monitor-body {
  width: 700px;
  background: linear-gradient(155deg, #2c2c2c 0%, #1c1c1c 40%, #131313 100%);
  border-radius: 14px 14px 5px 5px;
  padding: 22px 24px 0;

  box-shadow:
    /* Top-edge highlight */
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    /* Left-edge highlight */
    inset 1px 0 0 rgba(255, 255, 255, 0.03),
    /* Inner depth */
    inset 3px 3px 10px rgba(0, 0, 0, 0.6),
    inset -3px -3px 10px rgba(0, 0, 0, 0.4),
    /* Purple ambient light from screen spilling onto bezel */
    0 0 60px rgba(194, 0, 245, 0.10),
    0 0 120px rgba(194, 0, 245, 0.05);
}

/* --- Screen area (fixed 4:3 ratio) ------------------------- */
.screen-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 4px;
  overflow: hidden;

  /* Recessed frame shadow around screen edge */
  box-shadow:
    inset 0 0 0 2px #080808,
    inset 0 0 24px rgba(0, 0, 0, 0.9);
}

.screen {
  position: absolute;
  inset: 0;
  background-color: var(--screen-bg);
  border-radius: 3px;
  overflow: hidden;

  /* The screen glows outward into the bezel */
  box-shadow: var(--glow-lg);
}

/* --- Scanline overlay -------------------------------------- */
/* Creates that iconic CRT horizontal line texture */
.scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent       0px,
    transparent       3px,
    rgba(0, 0, 0, 0.13) 3px,
    rgba(0, 0, 0, 0.13) 4px
  );
  pointer-events: none;
  z-index: 20;
}

/* --- Vignette: simulates CRT screen curvature / falloff --- */
.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 50%,
    rgba(0, 0, 0, 0.55) 100%
  );
  pointer-events: none;
  z-index: 21;
}

/* ============================================================
   TERMINAL
   ============================================================ */

#terminal {
  position: absolute;
  inset: 0;
  padding: 18px 20px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;              /* Firefox */
  -ms-overflow-style: none;          /* IE/Edge */
  -webkit-overflow-scrolling: touch; /* iOS momentum scrolling */
  z-index: 10;

  /* Very subtle screen flicker — fires a few times per cycle */
  animation: crt-flicker 11s ease-in-out infinite;
}

#terminal::-webkit-scrollbar {
  display: none;
}

/* Flicker: barely perceptible opacity dips */
@keyframes crt-flicker {
  0%,   19%,  21%,  49%,  51%,  100% { opacity: 1; }
  20%                                  { opacity: 0.94; }
  50%                                  { opacity: 0.97; }
}

/* --- Output area ------------------------------------------ */
#output {
  color: var(--purple-bright);
  font-size: 18px;
  line-height: 1.45;
  white-space: pre;           /* preserves spaces and newlines (important for ASCII art) */
  text-shadow: var(--glow-sm);
}

/* --- Current input line ------------------------------------ */
#input-line {
  display: flex;
  align-items: center;
  color: var(--purple-bright);
  font-size: 18px;
  text-shadow: var(--glow-sm);
  margin-top: 1px;
}

#input-line.hidden {
  visibility: hidden;
}

.prompt {
  white-space: nowrap;
  flex-shrink: 0;
}

#input-text {
  /* the text the user is currently typing */
}

/* --- Blinking block cursor --------------------------------- */
.cursor {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  background: var(--purple-bright);
  vertical-align: text-bottom;
  margin-left: 1px;
  animation: blink 1.1s step-end infinite;

  box-shadow:
    0 0 6px var(--purple),
    0 0 18px rgba(194, 0, 245, 0.7);
}

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

/* ============================================================
   MONITOR CHIN (bottom bezel strip)
   ============================================================ */

.chin {
  height: 54px;
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.brand-label {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 4px;
  color: #2e2e2e;
  text-transform: uppercase;
  user-select: none;
}

/* Power LED: tiny glowing purple dot */
.power-led {
  position: absolute;
  right: 16px;
  bottom: 14px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--purple);
  box-shadow:
    0 0 4px var(--purple),
    0 0 10px var(--purple),
    0 0 20px rgba(194, 0, 245, 0.9);
  animation: led-pulse 3.5s ease-in-out infinite;
}

@keyframes led-pulse {
  0%, 100% { opacity: 1;   box-shadow: 0 0 4px var(--purple), 0 0 10px var(--purple), 0 0 20px rgba(194,0,245,0.9); }
  50%       { opacity: 0.55; box-shadow: 0 0 2px var(--purple), 0 0 6px var(--purple);  }
}

/* ============================================================
   MONITOR STAND
   ============================================================ */

.stand {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Neck: trapezoid shape — narrower at top, wider at bottom */
.neck {
  width: 110px;
  height: 42px;
  background: linear-gradient(180deg, #181818 0%, #202020 100%);
  clip-path: polygon(22% 0%, 78% 0%, 100% 100%, 0% 100%);
}

/* Base: flat oval-ish foot */
.base {
  width: 230px;
  height: 16px;
  background: linear-gradient(180deg, #202020 0%, #151515 100%);
  border-radius: 0 0 8px 8px;
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.7),
    0 2px 4px rgba(0, 0, 0, 0.5);
}

/* ============================================================
   MOBILE INPUT (visually hidden, used for mobile keyboard)
   ============================================================ */

#mobile-input {
  position: fixed;
  top: -200px;
  left: -200px;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: none;
  outline: none;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font-size: 16px; /* prevents iOS zoom on focus */
}

/* ============================================================
   RESPONSIVE: shrink the monitor on smaller viewports
   ============================================================ */

/* Tablet / small desktop */
@media (max-width: 780px) {
  .monitor-body {
    width: 94vw;
  }
  #output,
  #input-line {
    font-size: 3.2vw;
  }
}

/* Phone portrait — override the 4:3 ratio and go full-width */
@media (max-width: 540px) {
  body {
    align-items: flex-start;
    overflow-y: auto;
    /* Respect iPhone notch / home indicator */
    padding-top:    env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left:   env(safe-area-inset-left);
    padding-right:  env(safe-area-inset-right);
  }

  .scene {
    align-items: flex-start;
    padding: 12px 0 20px;
    min-height: 100%;
  }

  .monitor {
    width: 100%;
  }

  .monitor-body {
    width: 100%;
    border-radius: 0;
    padding: 10px 10px 0;
  }

  /* Use dvh so Safari's chrome doesn't clip the screen */
  .screen-wrapper {
    aspect-ratio: unset;
    height: 72dvh;
    border-radius: 2px;
  }

  #terminal {
    padding: 12px 14px;
  }

  #output,
  #input-line {
    font-size: 16px;
    line-height: 1.5;
  }

  /* Slim the chin */
  .chin {
    height: 36px;
    margin-top: 8px;
  }

  /* Hide the stand — wastes space on phone */
  .stand {
    display: none;
  }

  /* Remove iOS blue tap flash when touching the screen */
  .screen,
  .screen-wrapper,
  #terminal {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
}
