/* ==========================================================================
   WebArcade Retro Visual Effects & CLI Terminal Stylesheet
   ========================================================================== */

/* --- CRT Screen Overlay Effects --- */
body.crt-active {
  position: relative;
  animation: crt-flicker 0.18s infinite;
}

/* Base CRT Container */
.crt-overlay-container {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 999999; /* Higher than everything except console interactions */
  width: 100vw;
  height: 100vh;
}

/* Horizontal scanlines pattern */
body.crt-active .crt-scanlines {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%,
    rgba(0, 0, 0, 0.25) 50%
  ), linear-gradient(
    90deg,
    rgba(255, 0, 0, 0.04),
    rgba(0, 255, 0, 0.01),
    rgba(0, 0, 255, 0.04)
  );
  background-size: 100% 4px, 6px 100%;
}

/* Curvature Vignette (VCR screen glass curve simulation) */
body.crt-active .crt-curvature {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.7);
  background: radial-gradient(circle at center, transparent 60%, rgba(0, 0, 0, 0.4) 100%);
}

/* Chromatic Aberration & Phosphor Glow on text and items */
body.crt-active p,
body.crt-active span,
body.crt-active h1,
body.crt-active h2,
body.crt-active h3,
body.crt-active h4,
body.crt-active a,
body.crt-active button,
body.crt-active td,
body.crt-active th {
  text-shadow: 1px 0px 1px rgba(255, 0, 0, 0.6), -1px 0px 1px rgba(0, 0, 255, 0.6), 0 0 2px rgba(255, 255, 255, 0.2);
}

/* CRT Screen Flicker animation */
@keyframes crt-flicker {
  0% { opacity: 0.993; }
  50% { opacity: 1; }
  100% { opacity: 0.995; }
}

/* --- Developer CLI Cheat Terminal --- */
#retro-cheat-console {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 350px;
  background: rgba(5, 7, 18, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 2px solid var(--accent, #00ff66);
  z-index: 1000000; /* Stays above scanlines overlay */
  font-family: 'Space Grotesk', 'Courier New', monospace;
  color: var(--accent, #00ff66);
  display: flex;
  flex-direction: column;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8), 0 0 15px var(--accent-glow, rgba(0, 255, 100, 0.15));
  transform: translateY(-100%);
  transition: transform 0.35s cubic-bezier(0.19, 1, 0.22, 1);
  padding: 16px;
  box-sizing: border-box;
}

#retro-cheat-console.open {
  transform: translateY(0);
}

/* Header section of Terminal */
.retro-console-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border, rgba(0, 255, 102, 0.15));
  padding-bottom: 8px;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
}

.retro-console-header span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.retro-console-header .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent, #00ff66);
  box-shadow: 0 0 8px var(--accent, #00ff66);
  animation: led-blink 1s infinite alternate;
}

@keyframes led-blink {
  0% { opacity: 0.3; }
  100% { opacity: 1; }
}

/* Log output area */
.retro-console-logs {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.6;
  padding-right: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border, rgba(255, 255, 255, 0.15)) transparent;
}

.retro-console-logs::-webkit-scrollbar {
  width: 6px;
}
.retro-console-logs::-webkit-scrollbar-thumb {
  background: var(--border, rgba(0, 255, 102, 0.15));
  border-radius: 3px;
}

.retro-console-logs div {
  margin-bottom: 4px;
  word-break: break-all;
}

.retro-console-logs .cmd-input-line {
  color: #ffffff;
}

.retro-console-logs .cmd-error {
  color: #ff4466;
}

.retro-console-logs .cmd-success {
  color: #ffd700;
}

/* Input area */
.retro-console-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border, rgba(0, 255, 102, 0.15));
  border-radius: 6px;
  padding: 8px 12px;
}

.retro-console-prompt {
  font-weight: 700;
  user-select: none;
}

.retro-console-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  color: #ffffff;
  padding: 0;
  caret-color: var(--accent, #00ff66);
}

/* --- Live FPS Tracker Overlay --- */
#fps-counter {
  position: fixed;
  top: 15px;
  right: 15px;
  background: rgba(5, 7, 18, 0.85);
  border: 1px solid var(--accent, #00ff66);
  border-radius: 6px;
  padding: 6px 12px;
  font-family: 'Space Grotesk', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent, #00ff66);
  z-index: 99999;
  pointer-events: none;
  box-shadow: 0 0 10px var(--accent-glow, rgba(0, 255, 100, 0.15));
  display: none;
}

#fps-counter.visible {
  display: block;
}

/* --- Matrix Canvas Background --- */
#matrix-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999997; /* Behind console and scanlines */
  pointer-events: none;
  opacity: 0.15;
  display: none;
}

#matrix-canvas.visible {
  display: block;
}

/* --- Theme Visual Overrides --- */

/* 1. Synthwave Theme: Neon Pinks & Purples */
body.theme-synthwave {
  --bg-primary: #120621 !important;
  --bg-secondary: #1d0936 !important;
  --bg-card: rgba(45, 10, 80, 0.45) !important;
  --bg-glass: rgba(29, 9, 54, 0.75) !important;
  --accent: #ff007f !important;
  --accent-glow: rgba(255, 0, 127, 0.3) !important;
  --border: rgba(255, 0, 127, 0.2) !important;
  --text-secondary: #d9a5ff !important;
}
body.theme-synthwave #bg-solid {
  background: #120621 !important;
}

/* 2. Gameboy Retro Theme: Monochromatic Pixel Green shades */
body.theme-gameboy {
  --bg-primary: #8bac0f !important;
  --bg-secondary: #9bbc0f !important;
  --bg-card: rgba(48, 98, 48, 0.15) !important;
  --bg-glass: rgba(139, 172, 15, 0.9) !important;
  --accent: #0f380f !important;
  --accent-glow: rgba(15, 56, 15, 0.2) !important;
  --border: rgba(15, 56, 15, 0.25) !important;
  --text-primary: #0f380f !important;
  --text-secondary: #306230 !important;
  --text-muted: #306230 !important;
}
body.theme-gameboy #bg-solid {
  background: #8bac0f !important;
}
body.theme-gameboy * {
  box-shadow: none !important;
  text-shadow: none !important;
}

/* 3. Cyberpunk Theme: Amber Orange & Carbon Charcoal */
body.theme-cyberpunk {
  --bg-primary: #0a0805 !important;
  --bg-secondary: #14100a !important;
  --bg-card: rgba(35, 28, 15, 0.5) !important;
  --bg-glass: rgba(20, 16, 10, 0.8) !important;
  --accent: #ff7700 !important;
  --accent-glow: rgba(255, 119, 0, 0.3) !important;
  --border: rgba(255, 119, 0, 0.2) !important;
  --text-secondary: #ffd37a !important;
}
body.theme-cyberpunk #bg-solid {
  background: #0a0805 !important;
}

