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

:root {
  --green: #33ff33;
  --dim-green: #1a7a1a;
  --dark-green: #0a2a0a;
  --bg: #050f05;
  --amber: #ffb000;
}

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

html, body {
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Share Tech Mono', 'Courier New', monospace;
  overflow: hidden;
}

/* Electricity veins canvas — behind the monitor */
.veins-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* CRT outer shell */
.crt-shell {
  position: relative;
  z-index: 1;
  width: min(90vw, 860px);
  aspect-ratio: 4/3;
  background: #111;
  border-radius: 24px / 18px;
  box-shadow:
    0 0 0 4px #1a1a1a,
    0 0 0 8px #222,
    0 0 40px 8px rgba(0,0,0,0.9),
    inset 0 0 60px rgba(0,0,0,0.6);
  padding: 28px 32px 36px;
  display: flex;
  flex-direction: column;
}

/* Bezel label */
.crt-shell::before {
  content: "P9C-372 ∞ GATE NETWORK TERMINAL";
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  color: #333;
  font-size: 0.55rem;
  letter-spacing: 0.25em;
  white-space: nowrap;
}

/* The screen itself */
.screen {
  flex: 1;
  background: var(--bg);
  border-radius: 10px / 8px;
  position: relative;
  overflow: hidden;
  cursor: default;
  box-shadow:
    inset 0 0 80px rgba(0, 0, 0, 0.7),
    inset 0 0 20px rgba(51, 255, 51, 0.04),
    0 0 20px rgba(51, 255, 51, 0.08);
}

/* Phosphor glow behind text layer */
.screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 40%, rgba(51,255,51,0.06) 0%, transparent 70%);
  pointer-events: none;
  z-index: 1;
}

/* Scanlines */
.screen::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 3px,
    rgba(0, 0, 0, 0.18) 3px,
    rgba(0, 0, 0, 0.18) 4px
  );
  pointer-events: none;
  z-index: 10;
  border-radius: inherit;
}

/* CRT curvature overlay */
.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.75) 100%);
  pointer-events: none;
  z-index: 11;
  border-radius: inherit;
}

/* Horizontal flicker band — animates slowly downward */
.flicker-band {
  position: absolute;
  left: 0; right: 0;
  height: 3px;
  background: rgba(51,255,51,0.07);
  animation: scanband 9s linear infinite;
  pointer-events: none;
  z-index: 12;
}

@keyframes scanband {
  0%   { top: -3px; }
  100% { top: 100%; }
}

/* Content area */
.terminal {
  position: relative;
  z-index: 5;
  padding: 22px 26px;
  height: 100%;
  display: flex;
  flex-direction: column;
  color: var(--green);
  font-size: clamp(0.6rem, 1.5vw, 0.82rem);
  line-height: 1.55;
  text-shadow: 0 0 6px rgba(51,255,51,0.8), 0 0 14px rgba(51,255,51,0.35);
}

.header {
  border-bottom: 1px solid var(--dim-green);
  padding-bottom: 8px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  opacity: 0.85;
}

.header-left { line-height: 1.4; }
.header-right { text-align: right; line-height: 1.4; }

.dim { color: var(--dim-green); text-shadow: 0 0 4px rgba(51,255,51,0.2); }
.bright { color: #80ff80; text-shadow: 0 0 8px rgba(51,255,51,1), 0 0 20px rgba(51,255,51,0.5); }

/* Main log area */
.log {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.log-line {
  display: block;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.1s, transform 0.1s;
  white-space: pre;
}

.log-line.visible {
  opacity: 1;
  transform: none;
}

.log-line.warn  { color: var(--amber); text-shadow: 0 0 6px rgba(255,176,0,0.8); }
.log-line.error { color: #ff4444;      text-shadow: 0 0 6px rgba(255,68,68,0.8); }
.log-line.muted { color: var(--dim-green); }
.log-line.blank { height: 0.6em; }

/* Prompt / input line */
.prompt-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.prompt-symbol { color: var(--dim-green); }

.typed-text { color: var(--green); letter-spacing: 0.04em; }

.cursor {
  display: inline-block;
  width: 0.55em;
  height: 1.1em;
  background: var(--green);
  vertical-align: middle;
  margin-left: 1px;
  animation: blink 1.1s step-end infinite;
  box-shadow: 0 0 6px rgba(51,255,51,0.9);
}

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

/* Status bar */
.statusbar {
  border-top: 1px solid var(--dim-green);
  margin-top: 10px;
  padding-top: 6px;
  display: flex;
  justify-content: space-between;
  font-size: 0.75em;
  opacity: 0.7;
  flex-shrink: 0;
}

.status-dot {
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  border-radius: 50%;
  background: var(--green);
  margin-right: 5px;
  animation: pulse 2.2s ease-in-out infinite;
  box-shadow: 0 0 6px rgba(51,255,51,0.8);
  vertical-align: middle;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}

/* Glitch flicker on the whole screen occasionally */
.screen.glitch { animation: glitch 0.12s steps(2) forwards; }

@keyframes glitch {
  0%   { filter: brightness(1.8) hue-rotate(20deg); transform: skewX(-0.3deg); }
  50%  { filter: brightness(0.6); transform: skewX(0.2deg) translateX(1px); }
  100% { filter: brightness(1); transform: none; }
}

/* Noise texture via SVG data URI */
.noise {
  position: absolute;
  inset: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9;
  animation: noiseshift 0.18s steps(1) infinite;
}

@keyframes noiseshift {
  0%   { background-position: 0 0; }
  25%  { background-position: 40px -30px; }
  50%  { background-position: -20px 50px; }
  75%  { background-position: 60px 20px; }
  100% { background-position: 0 0; }
}

/* ── Portrait phones ── */
@media (max-width: 600px) {
  .crt-shell {
    width: 95vw;
    height: 88vh;
    /* explicit height overrides aspect-ratio */
    aspect-ratio: unset;
    padding: 12px 12px 22px;
    border-radius: 14px / 10px;
  }

  .crt-shell::before {
    font-size: 0.42rem;
  }

  .terminal {
    padding: 10px 10px;
    font-size: clamp(0.68rem, 3.5vw, 0.82rem);
  }

  .header {
    flex-direction: column;
    gap: 2px;
  }

  .header-right {
    text-align: left;
  }

  /* long log lines wrap instead of overflowing */
  .log-line {
    white-space: pre-wrap;
    word-break: break-word;
  }

  .statusbar {
    font-size: 0.66em;
  }
}

/* ── Landscape phones (short viewport) ── */
@media (max-height: 480px) and (orientation: landscape) {
  .crt-shell {
    width: min(98vw, 860px);
    height: 92vh;
    aspect-ratio: unset;
    padding: 8px 14px 14px;
    border-radius: 10px / 8px;
  }

  .terminal {
    padding: 6px 10px;
    font-size: clamp(0.6rem, 1.8vw, 0.78rem);
    line-height: 1.4;
  }

  .header {
    margin-bottom: 6px;
    padding-bottom: 4px;
  }

  .log-line {
    white-space: pre-wrap;
    word-break: break-word;
  }
}
