/* Splash Screen */
#splash {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #0d0d0d;
  color: #00f0ff;
  font-family: 'Fira Code', monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  text-align: center;
  padding: 2rem;
}

#splash .ascii-logo {
  margin-bottom: 2rem;
  font-size: 14px;
  line-height: 1.2;
}

.cursor {
  display: inline-block;
  animation: blink 1s steps(2, start) infinite;
  font-size: 1.1rem;
}

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

#skip-button {
  background: none;
  color: #00f0ff;
  border: 1px solid #00f0ff;
  padding: 0.5rem 1rem;
  font-family: 'Fira Code', monospace;
  cursor: pointer;
  margin-top: 1rem;
}

/* Light/Dark Theme Variables */
:root[data-theme="light"] {
  --bg-color: #f9f9f9;
  --text-color: #222;
  --header-footer-bg: #e0e0e0;
  --header-footer-text: #222;
  --link-color: #007acc;
}

:root[data-theme="dark"] {
  --bg-color: #0d0d0d;
  --text-color: #e0f7ff;
  --header-footer-bg: #111;
  --header-footer-text: #00f0ff;
  --link-color: #00ccff;
}

/* Apply Theme */
body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: 'Fira Code', monospace;
  font-size: clamp(16px, 2vw, 22px);
  line-height: 1.6;
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header and Footer */
header, footer {
  background-color: var(--header-footer-bg);
  color: var(--header-footer-text);
  font-size: clamp(14px, 1.8vw, 20px);
  padding: 1rem 2rem;
  text-align: center;
  width: 100%;
}

/* Navigation */
nav {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

nav a {
  position: relative;
  padding: 0 0.5rem;
}

nav a + a::before {
  content: '|';
  color: #00f0ff;
  position: absolute;
  left: -0.6rem;
}

/* Links */
a {
  color: var(--link-color);
  text-decoration: none;
}

/* Footer Theme Toggle Button */
footer #theme-toggle {
  background: none;
  color: inherit;
  border: none;
  font-family: 'Fira Code', monospace;
  font-size: inherit;
  cursor: pointer;
  padding: 0 0.5rem;
  margin-left: 0.5rem;
}

footer #theme-toggle:hover {
  text-decoration: underline;
}

/* Responsive Font */
@media screen and (min-width: 1024px) {
  body {
    font-size: clamp(20px, 2vw, 24px);
  }
}

/* Flicker Overlay for Page Transitions */
#flicker-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 99998;
  transition: opacity 0.2s ease-in-out;
}

#flicker-overlay.flicker-in {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.1s ease-in;
}

/* Glitch Flicker Overlay */
#flicker-overlay.glitch {
  animation: glitchFade 0.4s ease-out;
  background: 
    repeating-linear-gradient(
      to bottom,
      rgba(255,255,255,0.03) 0px,
      rgba(255,255,255,0.03) 2px,
      transparent 2px,
      transparent 4px
    ),
    repeating-linear-gradient(
      to bottom,
      rgba(0,255,255,0.05) 0px,
      transparent 3px,
      rgba(255,0,255,0.05) 3px,
      transparent 6px
    );
  background-size: 100% 4px;
  mix-blend-mode: screen;
  opacity: 0.5;
  pointer-events: none; /* Prevent staying clickable */
}

@keyframes glitchFade {
  0% {
    opacity: 0.2;
    transform: translate(0, 0);
    filter: hue-rotate(0deg);
  }
  20% {
    opacity: 0.4;
    transform: translate(-2px, 1px);
    filter: hue-rotate(10deg);
  }
  40% {
    opacity: 0.6;
    transform: translate(2px, -1px);
    filter: hue-rotate(-10deg);
  }
  60% {
    opacity: 0.3;
    transform: translate(-1px, 2px);
    filter: hue-rotate(5deg);
  }
  80% {
    opacity: 0.1;
    transform: translate(1px, -1px);
    filter: hue-rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(0, 0);
  }
}

/* Glitch Line Overlays for CRT effect */
.glitch-line {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: rgba(0, 255, 255, 0.12);
  opacity: 0.9;
  z-index: 99999;
  pointer-events: none;
  animation: glitch-line-move 0.25s ease-out forwards;
  transform: translateX(0) scaleX(1);
}

@keyframes glitch-line-move {
  0% {
    transform: translateX(-2px) scaleX(1.1);
    opacity: 0.8;
  }
  25% {
    transform: translateX(2px) scaleX(1.3);
    opacity: 1;
  }
  50% {
    transform: translateX(-1px) scaleX(1.05);
    opacity: 0.7;
  }
  100% {
    transform: translateX(0) scaleX(1);
    opacity: 0;
  }
}

/* Brief overlay for CRT-style fade */
.crt-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 255, 255, 0.05);
  pointer-events: none;
  z-index: 99997;
  animation: crt-fade 0.25s ease-out forwards;
}

@keyframes crt-fade {
  from {
    opacity: 0.2;
    backdrop-filter: blur(0.2px);
  }
  to {
    opacity: 0;
    backdrop-filter: blur(0);
  }
}

/* Optional RGB split effect for brief glitching */
body.glitch-color {
  animation: glitch-color-fx 0.25s ease-in-out;
}

@keyframes glitch-color-fx {
  0% {
    filter: drop-shadow(-1px 0 red) drop-shadow(1px 0 cyan);
  }
  100% {
    filter: none;
  }
}
