/* Intro Animation Styles */
.intro-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  opacity: 1;
  transition: opacity 0.5s ease-out;
}

.intro-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.intro-content {
  position: relative;
  width: 600px;
  height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 30px auto;
  padding: 20px;
  text-align: center;
}

.intro-logo {
  max-width: 300px;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

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

/* Subtle logo jitter & channel skew */
@keyframes logoJitter {
  0% { transform: translate(0,0) scale(1) skewX(0deg); filter: saturate(1); }
  12% { transform: translate(-2px,1px) scale(1.01) skewX(1deg); }
  25% { transform: translate(3px,-2px) scale(0.995) skewX(-1deg); }
  37% { transform: translate(-1px,2px) scale(1.008); }
  50% { transform: translate(2px,0) scale(1.002) skewX(0.5deg); filter: saturate(1.15); }
  63% { transform: translate(-3px,-1px) scale(1.01); }
  75% { transform: translate(1px,2px) scale(0.998); }
  87% { transform: translate(-2px,1px) scale(1.004); }
  100% { transform: translate(0,0) scale(1) skewX(0deg); filter: saturate(1); }
}

/* Logo wobble for analog distortion feel */
@keyframes logoWobble {
  0% { transform: perspective(1000px) rotateX(0deg) rotateY(0deg); }
  25% { transform: perspective(1000px) rotateX(3deg) rotateY(-2deg); }
  50% { transform: perspective(1000px) rotateX(-2deg) rotateY(3deg); }
  75% { transform: perspective(1000px) rotateX(2deg) rotateY(-3deg); }
  100% { transform: perspective(1000px) rotateX(0deg) rotateY(0deg); }
}

/* Scanline effect */
.intro-overlay::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15),
    rgba(0, 0, 0, 0.15) 1px,
    transparent 1px,
    transparent 2px
  );
  pointer-events: none;
  z-index: 1;
  animation: scanlines 8.3s steps(20) infinite, scanlinesPulse 3.7s ease-in-out infinite;
}

@keyframes scanlines {
  0% {
    transform: translateY(0);
  }
  33% {
    transform: translateY(15px);
  }
  67% {
    transform: translateY(8px);
  }
  100% {
    transform: translateY(20px);
  }
}

@keyframes scanlinesPulse {
  0%, 100% {
    opacity: 1;
  }
  23% {
    opacity: 0.7;
  }
  58% {
    opacity: 0.9;
  }
}

/* RGB Split Distortion */
.intro-overlay::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    ellipse at center,
    rgba(139, 0, 0, 0.15) 0%,
    transparent 50%
  );
  pointer-events: none;
  z-index: 2;
  animation: vignette 4.1s cubic-bezier(0.42, 0, 0.58, 1) infinite alternate, vignetteShift 7.3s ease-in-out infinite;
}

@keyframes vignette {
  0% {
    opacity: 0.3;
  }
  23% {
    opacity: 0.6;
  }
  47% {
    opacity: 0.4;
  }
  71% {
    opacity: 0.8;
  }
  100% {
    opacity: 0.5;
  }
}

@keyframes vignetteShift {
  0%, 100% {
    transform: scale(1);
  }
  31% {
    transform: scale(1.05);
  }
  62% {
    transform: scale(0.97);
  }
}

/* Distortion lines (transmission disruption) */
.distortion-line {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 10px rgba(139, 0, 0, 0.5);
  animation: distortionMove 2.1s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite;
}

@keyframes distortionMove {
  0% {
    top: -10%;
    opacity: 0;
  }
  17% {
    top: 5%;
    opacity: 0.8;
  }
  43% {
    top: 35%;
    opacity: 1;
  }
  68% {
    top: 60%;
    opacity: 0.9;
  }
  84% {
    top: 85%;
    opacity: 0.6;
  }
  100% {
    top: 110%;
    opacity: 0;
  }
}

.distortion-line:nth-child(2) {
  animation-delay: 0.53s;
  animation-duration: 3.2s;
  animation-timing-function: cubic-bezier(0.22, 0.61, 0.36, 1);
}

.distortion-line:nth-child(3) {
  animation-delay: 1.27s;
  animation-duration: 1.6s;
  background: rgba(139, 0, 0, 0.2);
  animation-timing-function: cubic-bezier(0.85, 0, 0.15, 1);
}

/* Glitch blocks */
.glitch-block {
  position: absolute;
  width: 100%;
  height: 40px;
  background: rgba(139, 0, 0, 0.15);
  mix-blend-mode: overlay;
  animation: glitchBlock 5.85s steps(10) infinite;
}

@keyframes glitchBlock {
  0% {
    top: 0%;
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  20% {
    top: 20%;
  }
  30% {
    opacity: 0.5;
  }
  40% {
    top: 40%;
  }
  50% {
    opacity: 1;
    top: 60%;
  }
  60% {
    opacity: 0.3;
  }
  70% {
    top: 80%;
  }
  80% {
    opacity: 0.8;
  }
  90% {
    top: 95%;
  }
  100% {
    top: 100%;
    opacity: 0;
  }
}

.glitch-block:nth-child(4) {
  animation-delay: 0.585s;
  animation-duration: 3.9s;
}

.glitch-block:nth-child(5) {
  animation-delay: 1.56s;
  animation-duration: 4.875s;
  height: 60px;
}

/* Noise overlay */
.noise-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='2' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  opacity: 0.15;
  animation: noise 0.6s steps(6) infinite, noisePulse 2.3s steps(11) infinite;
  pointer-events: none;
  z-index: 8; /* above logo */
}

@keyframes noise {
  0%, 100% {
    transform: translate(0, 0);
  }
  8% {
    transform: translate(-7%, -3%);
  }
  23% {
    transform: translate(-12%, 8%);
  }
  31% {
    transform: translate(6%, -13%);
  }
  47% {
    transform: translate(-8%, 11%);
  }
  54% {
    transform: translate(-14%, 2%);
  }
  68% {
    transform: translate(13%, -5%);
  }
  77% {
    transform: translate(-3%, 14%);
  }
  85% {
    transform: translate(-11%, -7%);
  }
  92% {
    transform: translate(9%, 4%);
  }
}

@keyframes noisePulse {
  0%, 100% {
    opacity: 0.15;
  }
  18% {
    opacity: 0.25;
  }
  41% {
    opacity: 0.1;
  }
  63% {
    opacity: 0.3;
  }
  82% {
    opacity: 0.12;
  }
}

/* Chromatic Aberration on logo */
.intro-content {
  animation: chromatic 1.3s steps(3) infinite, chromaticShift 2.7s steps(5) infinite;
}

@keyframes chromatic {
  0% {
    filter: drop-shadow(2px 0 0 rgba(255, 0, 0, 0.5)) 
            drop-shadow(-2px 0 0 rgba(0, 255, 255, 0.5));
  }
  33% {
    filter: drop-shadow(-3px 0 0 rgba(255, 0, 0, 0.7)) 
            drop-shadow(3px 0 0 rgba(0, 255, 255, 0.6));
  }
  67% {
    filter: drop-shadow(1px 0 0 rgba(255, 0, 0, 0.3)) 
            drop-shadow(-1px 0 0 rgba(0, 255, 255, 0.4));
  }
  100% {
    filter: drop-shadow(2px 0 0 rgba(255, 0, 0, 0.5)) 
            drop-shadow(-2px 0 0 rgba(0, 255, 255, 0.5));
  }
}

@keyframes chromaticShift {
  0%, 100% {
    transform: translateX(0);
  }
  29% {
    transform: translateX(-1px);
  }
  57% {
    transform: translateX(2px);
  }
  86% {
    transform: translateX(-0.5px);
  }
}

/* Static flicker - only brightness, not opacity */
@keyframes flickerIntense {
  0%, 100% {
    filter: brightness(1);
  }
  11% {
    filter: brightness(0.9);
  }
  19% {
    filter: brightness(1.05);
  }
  34% {
    filter: brightness(0.85);
  }
  51% {
    filter: brightness(1);
  }
  68% {
    filter: brightness(0.95);
  }
  83% {
    filter: brightness(1.02);
  }
}

.intro-overlay {
  animation: flickerIntense 1.8s steps(8) infinite;
}

/* ================= Additional Diversified Distortion Layers ================= */
/* Channel split overlay: animated horizontal slices shifting RGB channels */
.channel-split-layer {
  position: absolute;
  inset: 0;
  z-index: 9; /* very top distortion */
  pointer-events: none;
  mix-blend-mode: screen;
  background:
    repeating-linear-gradient(
      180deg,
      rgba(255,0,0,0.08) 0px,
      rgba(255,0,0,0.08) 2px,
      rgba(0,255,255,0.08) 2px,
      rgba(0,255,255,0.08) 4px,
      transparent 4px,
      transparent 6px
    );
  animation: channelSplitDrift 11s linear infinite;
}

@keyframes channelSplitDrift {
  0% { transform: translateY(0); filter: hue-rotate(0deg) brightness(1); }
  25% { transform: translateY(-10px); filter: hue-rotate(10deg) brightness(1.05); }
  50% { transform: translateY(6px); filter: hue-rotate(-10deg) brightness(0.95); }
  75% { transform: translateY(-4px); filter: hue-rotate(5deg) brightness(1.08); }
  100% { transform: translateY(0); filter: hue-rotate(0deg) brightness(1); }
}

/* Warp grid: subtle perspective grid flicker */
.warp-grid-layer {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  background:
    repeating-linear-gradient(90deg, rgba(200,0,0,0.05) 0 1px, transparent 1px 120px),
    repeating-linear-gradient(0deg, rgba(200,0,0,0.05) 0 1px, transparent 1px 90px);
  transform-origin: center;
  animation: warpPulse 6.5s ease-in-out infinite;
  mix-blend-mode: overlay;
}

@keyframes warpPulse {
  0% { transform: perspective(800px) translateZ(0) scale(1); opacity: 0.15; }
  45% { transform: perspective(800px) translateZ(40px) scale(1.04) skewX(1deg); opacity: 0.3; }
  55% { transform: perspective(800px) translateZ(55px) scale(1.06) skewX(-1deg); opacity: 0.35; }
  100% { transform: perspective(800px) translateZ(0) scale(1); opacity: 0.15; }
}

/* Glitch shards: random angular fragments over the logo */
.glitch-shards {
  position: absolute; inset: 0; z-index: 8; pointer-events: none;
}
.glitch-shards span {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: url('../img/kraken_only.webp') center/contain no-repeat;
  mix-blend-mode: lighten;
  opacity: 0.08;
  animation: shardAnim 3.8s steps(15,end) infinite;
  clip-path: polygon(
    10% 5%, 35% 0%, 60% 4%, 70% 15%, 80% 35%, 65% 55%, 40% 65%, 25% 55%, 15% 40%
  );
}
.glitch-shards span:nth-child(2) { animation-delay: .6s; opacity: .06; clip-path: polygon(20% 20%, 55% 10%, 85% 25%, 90% 55%, 70% 80%, 40% 85%, 15% 70%, 10% 40%); }
.glitch-shards span:nth-child(3) { animation-delay: 1.3s; opacity: .03; clip-path: polygon(5% 35%, 30% 15%, 60% 12%, 78% 30%, 90% 55%, 72% 75%, 45% 82%, 18% 70%); }
.glitch-shards span:nth-child(4) { animation-delay: 2.1s; opacity: .07; clip-path: polygon(12% 10%, 42% 5%, 68% 18%, 82% 42%, 74% 66%, 52% 78%, 26% 70%, 16% 50%); }

@keyframes shardAnim {
  0% { transform: translate(0,0) scale(1); filter: hue-rotate(0deg); }
  25% { transform: translate(-4px,2px) scale(1.01); filter: hue-rotate(25deg); }
  50% { transform: translate(3px,-3px) scale(0.99); filter: hue-rotate(-15deg); }
  75% { transform: translate(-2px,1px) scale(1.02); filter: hue-rotate(10deg); }
  100% { transform: translate(0,0) scale(1); filter: hue-rotate(0deg); }
}

/* Heavy static artifacts for bad transmission effect */
.static-artifacts {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.12) 0%, transparent 15%),
    radial-gradient(circle at 80% 70%, rgba(255,255,255,0.08) 0%, transparent 20%),
    radial-gradient(circle at 50% 50%, rgba(255,255,255,0.06) 0%, transparent 25%);
  animation: staticArtifacts 7s ease-in-out infinite;
  mix-blend-mode: screen;
}

@keyframes staticArtifacts {
  0% { opacity: 0.3; transform: scale(1) translateY(0); }
  15% { opacity: 0.6; transform: scale(1.02) translateY(-5px); }
  30% { opacity: 0.2; transform: scale(0.98) translateY(3px); }
  45% { opacity: 0.5; transform: scale(1.01) translateY(-2px); }
  60% { opacity: 0.35; transform: scale(0.99) translateY(4px); }
  75% { opacity: 0.55; transform: scale(1.015) translateY(-3px); }
  90% { opacity: 0.25; transform: scale(0.985) translateY(2px); }
  100% { opacity: 0.3; transform: scale(1) translateY(0); }
}

/* White noise bars sweeping across */
.noise-bars {
  position: absolute;
  inset: 0;
  z-index: 11;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      45deg,
      rgba(255,255,255,0.08) 0px,
      rgba(255,255,255,0.08) 3px,
      transparent 3px,
      transparent 12px
    );
  animation: noiseBars 9s linear infinite;
  mix-blend-mode: overlay;
}

@keyframes noiseBars {
  0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); opacity: 0.4; }
  50% { transform: translateX(50%) translateY(50%) rotate(45deg); opacity: 0.7; }
  100% { transform: translateX(200%) translateY(200%) rotate(45deg); opacity: 0.4; }
}

/* Analog tracking errors (horizontal displacement bands) */
.tracking-errors {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  background:
    linear-gradient(180deg,
      transparent 0%,
      transparent 15%,
      rgba(255,255,255,0.05) 15.5%,
      rgba(255,255,255,0.05) 18%,
      transparent 18.5%,
      transparent 35%,
      rgba(255,255,255,0.08) 35.5%,
      rgba(255,255,255,0.08) 39%,
      transparent 39.5%,
      transparent 62%,
      rgba(255,255,255,0.06) 62.5%,
      rgba(255,255,255,0.06) 66%,
      transparent 66.5%,
      transparent 82%,
      rgba(255,255,255,0.07) 82.5%,
      rgba(255,255,255,0.07) 85%,
      transparent 85.5%
    );
  animation: trackingDrift 12s ease-in-out infinite;
}

@keyframes trackingDrift {
  0% { transform: translateX(0); opacity: 0.5; }
  20% { transform: translateX(-8px); opacity: 0.8; }
  40% { transform: translateX(6px); opacity: 0.6; }
  60% { transform: translateX(-4px); opacity: 0.7; }
  80% { transform: translateX(5px); opacity: 0.55; }
  100% { transform: translateX(0); opacity: 0.5; }
}

/* Layer ordering helper comment:
   logo z-index:6, noise 8, shards 8, grid 7, channel split 9, tracking 9, static 10, noise-bars 11
*/

/* ================= Sci-Fi Login Window ================= */
.scifi-login {
    position: relative;
    width: 90%;
    max-width: 550px;
    z-index: 12;
    pointer-events: none;
    font-family: 'Courier New', monospace;
    color: #00ff41;
    text-shadow: 0 0 5px rgba(0, 255, 65, 0.5);
    background: transparent;
    border: none;
    border-radius: 4px;
    padding: 30px;
    opacity: 0;
    animation: loginFadeIn 0.5s ease-in forwards 0.5s;
}

@keyframes loginFadeIn {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-header {
  text-align: center;
  font-size: 1.1rem;
  font-weight: bold;
  letter-spacing: 3px;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 1px solid rgba(0, 255, 65, 0.3);
  color: #00ff41;
}

.login-form {
  margin-bottom: 15px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 2px;
  margin-bottom: 8px;
  opacity: 0.8;
}

.input-field {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(0, 255, 65, 0.3);
  padding: 12px;
  min-height: 20px;
  font-size: 0.95rem;
  position: relative;
}

.input-text {
  display: inline;
}

.input-cursor {
  display: inline;
  animation: cursorBlink 0.8s step-end infinite;
  margin-left: 2px;
}

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

.input-field.typing .input-cursor {
  animation: none;
  opacity: 1;
}

.input-field.complete .input-cursor {
  display: none;
}

.login-button {
  width: 100%;
  background: rgba(0, 255, 65, 0.1);
  border: 2px solid rgba(0, 255, 65, 0.5);
  color: #00ff41;
  padding: 15px;
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  opacity: 0.5;
  pointer-events: none;
}

.login-button.active {
  opacity: 1;
  pointer-events: auto;
}

.login-button.active:hover {
  background: rgba(0, 255, 65, 0.2);
  border-color: #00ff41;
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.3);
}

.login-button.pressed {
  background: rgba(0, 255, 65, 0.3);
  transform: scale(0.98);
}

.button-arrow {
  font-size: 1.2rem;
  transition: transform 0.3s ease;
}

.login-button.active:hover .button-arrow {
  transform: translateX(5px);
}

.login-status {
  text-align: center;
  font-size: 0.85rem;
  min-height: 20px;
  margin-top: 15px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.login-status.show {
  opacity: 1;
}

.login-status.success {
  color: #00ff41;
}

.login-status.error {
  color: #ff4444;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .scifi-login {
    font-size: 0.85rem;
    padding: 20px;
    width: 95%;
    max-width: 95%;
  }
  
  .login-logo-container {
    padding: 10px;
    margin-bottom: 20px;
  }
  
  .intro-logo {
    max-width: 200px;
  }
  
  .login-header {
    font-size: 0.9rem;
    letter-spacing: 2px;
  }
}
