/* ============================================
   DOOM Easter Egg — CRT Terminal Styles
   ============================================ */

.doom-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Courier New', Courier, monospace;
  color: #0f0;
  overflow: hidden;
  padding: calc(var(--spacing-md, 1.5rem) + env(safe-area-inset-top))
    calc(var(--spacing-md, 1.5rem) + env(safe-area-inset-right))
    calc(var(--spacing-md, 1.5rem) + env(safe-area-inset-bottom))
    calc(var(--spacing-md, 1.5rem) + env(safe-area-inset-left));
}

/* Scanline overlay */
.doom-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgb(0 0 0 / 15%) 0,
    rgb(0 0 0 / 15%) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 1;
}

/* CRT vignette */
.doom-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 60%, rgb(0 0 0 / 60%) 100%);
  pointer-events: none;
  z-index: 1;
}

.doom-terminal {
  position: relative;
  z-index: 2;
  max-width: 700px;
  width: 90%;
  padding: 2rem;
}

.doom-terminal-line {
  margin: 0;
  padding: 2px 0;
  font-size: clamp(0.75rem, 2vw, 1rem);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  opacity: 0;
  animation: doom-fade-in 0.1s forwards;
}

.doom-terminal-line.status-ok {
  color: #0f0;
}

.doom-terminal-line.status-ready {
  color: #ff0;
  font-weight: bold;
}

.doom-terminal-line.prompt {
  color: #0cf;
  animation: doom-pulse 1.2s infinite;
}

.doom-cursor {
  display: inline-block;
  width: 0.6em;
  height: 1em;
  background: #0f0;
  vertical-align: text-bottom;
  animation: doom-blink 0.7s step-end infinite;
}

.doom-start-btn {
  display: inline-block;
  margin-top: 1.5rem;
  padding: 0.75rem 2rem;
  background: transparent;
  border: 2px solid #0f0;
  color: #0f0;
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.1rem;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 2px;
  position: relative;
  z-index: 2;
  transition:
    background var(--duration-fast) var(--ease-default),
    color var(--duration-fast) var(--ease-default);
}

.doom-start-btn:hover,
.doom-start-btn:focus-visible {
  background: #0f0;
  color: #000;
  outline: none;
}

.doom-close-btn {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  z-index: 3;
  background: none;
  border: 1px solid #555;
  color: #888;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.85rem;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  transition:
    color var(--duration-fast) var(--ease-default),
    border-color var(--duration-fast) var(--ease-default);
}

.doom-close-btn:hover,
.doom-close-btn:focus-visible {
  color: #f44;
  border-color: #f44;
}

/* Touch comfort target (WCAG 2.5.5) on coarse pointers */
@media (pointer: coarse) {
  .doom-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
  }
}

.doom-game-container {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 800px;
  aspect-ratio: 4 / 3;
}

.doom-game-container iframe {
  width: 100%;
  height: 100%;
  border: 2px solid #0f0;
}

.doom-fps {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 3;
  color: #ff0;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.75rem;
  background: rgb(0 0 0 / 70%);
  padding: 2px 6px;
  pointer-events: none;
}

.doom-disclaimer {
  position: relative;
  z-index: 2;
  max-width: 700px;
  width: 90%;
  margin-top: 1rem;
  font-size: 0.6rem;
  color: #363;
  text-align: center;
  line-height: 1.4;
}

.doom-hint {
  color: rgb(255 255 255 / 4%);
  font-size: 0.6rem;
  text-align: center;
  margin-top: 3rem;
  user-select: none;
  pointer-events: none;
}

/* Glitch effect on activation */
.doom-glitch {
  animation: crt-glitch var(--duration-slow) linear;
}

/* Keyframes */
@keyframes doom-fade-in {
  to {
    opacity: 1;
  }
}

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

  50% {
    opacity: 0;
  }
}

@keyframes doom-pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

@keyframes crt-glitch {
  0% {
    filter: hue-rotate(0deg) brightness(1);
    transform: translate(0);
  }

  20% {
    filter: hue-rotate(90deg) brightness(1.5);
    transform: translate(-2px, 1px);
  }

  40% {
    filter: hue-rotate(180deg) brightness(0.8);
    transform: translate(2px, -1px);
  }

  60% {
    filter: hue-rotate(270deg) brightness(1.3);
    transform: translate(-1px, 2px);
  }

  80% {
    filter: hue-rotate(360deg) brightness(1);
    transform: translate(1px, -2px);
  }

  100% {
    filter: hue-rotate(0deg) brightness(1);
    transform: translate(0);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .doom-terminal-line {
    animation: none;
    opacity: 1;
  }

  .doom-cursor {
    animation: none;
    opacity: 1;
  }

  .doom-terminal-line.prompt {
    animation: none;
  }

  .doom-glitch {
    animation: none;
  }
}
