/* ===== CSS Custom Properties ===== */
:root {
  --void-black: #0D0D0D;
  --charcoal-shell: #1A1A1F;
  --phosphor-white: #E8E8EC;
  --terminal-cyan: #3AEFB4;
  --amber-signal: #F5A623;
  --revert-green: #4ADE80;
  --delete-red: #EF4444;
  --dim-gray: #6B6B76;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-snap-type: y proximity;
}

body {
  font-family: 'IBM Plex Mono', monospace;
  background: var(--void-black);
  color: var(--phosphor-white);
  overflow-x: hidden;
  line-height: 1.7;
}

/* ===== Noise Overlay ===== */
.noise-overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.04;
  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.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
  transition: opacity 0.5s;
}

/* ===== Terminal Frame ===== */
.terminal-frame {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  border: 1px solid var(--terminal-cyan);
  opacity: 0;
  transition: opacity 1.5s ease, border-color 1s ease;
}
.terminal-frame.visible { opacity: 1; }
.terminal-frame.dissolving {
  border-color: transparent;
  opacity: 0;
}

.title-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: rgba(13, 13, 13, 0.95);
  border-bottom: 1px solid var(--terminal-cyan);
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  color: var(--dim-gray);
  letter-spacing: 0.04em;
}

/* ===== Rewind Column ===== */
.rewind-column {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}
.tick {
  width: 8px;
  height: 8px;
  border: 1px solid var(--terminal-cyan);
  border-radius: 50%;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}
.tick.filled {
  background: var(--terminal-cyan);
  box-shadow: 0 0 6px var(--terminal-cyan);
}

/* ===== Floating Layer ===== */
.floating-layer {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}
.floating-el {
  position: absolute;
  font-family: 'IBM Plex Mono', monospace;
  white-space: nowrap;
  will-change: transform;
}
.floating-el.cursor-block {
  width: 12px;
  height: 20px;
  background: var(--terminal-cyan);
  opacity: 0.15;
  animation: cursorPulse 1.2s step-end infinite;
}
.floating-el.command-ghost {
  color: var(--amber-signal);
  opacity: 0.08;
  font-size: 0.75rem;
  font-weight: 400;
  transition: opacity 1s ease;
}
.floating-el.revert-arrow {
  color: var(--revert-green);
  opacity: 0;
  font-size: 1.2rem;
  transition: opacity 1s ease;
  animation: arrowPulse 3s ease-in-out infinite;
}
.floating-el.spinner {
  color: var(--dim-gray);
  opacity: 0.2;
  font-size: 0.9rem;
}

@keyframes cursorPulse {
  0%, 100% { opacity: 0.15; }
  50% { opacity: 0.04; }
}
@keyframes arrowPulse {
  0%, 100% { transform: scale(0.8); }
  50% { transform: scale(1.2); }
}

/* ===== Scenes ===== */
.scene {
  min-height: 100vh;
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 80px 60px 60px 60px;
}
.scene-content {
  max-width: 780px;
  width: 100%;
}

/* Scene 1: Boot */
.scene-boot {
  min-height: 100vh;
  justify-content: center;
  padding-left: 80px;
}
.hero-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(3.5rem, 9vw, 8rem);
  letter-spacing: -0.04em;
  color: var(--phosphor-white);
  line-height: 1.05;
  min-height: 1.1em;
}
.hero-title .char {
  display: inline-block;
  opacity: 0;
  transform: scale(1.3);
  transition: opacity 0.15s, transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.hero-title .char.visible {
  opacity: 1;
  transform: scale(1);
}
.hero-tagline {
  margin-top: 1.5rem;
  font-size: 0.95rem;
  color: var(--dim-gray);
}
.prompt-symbol { color: var(--terminal-cyan); }
.cursor-blink {
  color: var(--terminal-cyan);
  animation: blink 1s step-end infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Scene 2: Mistake */
.scene-mistake { background: var(--charcoal-shell); }
.command-block {
  position: relative;
  background: rgba(13, 13, 13, 0.6);
  border: 1px solid rgba(107, 107, 118, 0.2);
  border-radius: 4px;
  padding: 1.5rem;
  margin: 1.5rem 0;
}
.prompt-line {
  font-weight: 600;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}
.command-text.danger { color: var(--amber-signal); }
.command-text.revert { color: var(--revert-green); }
.command-text { color: var(--phosphor-white); }

.output-line {
  font-size: 0.85rem;
  color: var(--dim-gray);
  padding: 2px 0;
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.output-line.visible {
  opacity: 1;
  transform: translateX(0);
}
.output-line.restore { color: var(--revert-green); }
.error-text { color: var(--delete-red); font-weight: 600; }
.success-text { color: var(--revert-green); font-weight: 600; }

.ascii-warning {
  text-align: center;
  color: var(--delete-red);
  opacity: 0;
  transition: opacity 1s ease;
  font-size: 0.85rem;
}
.ascii-warning.visible { opacity: 0.3; }

.ascii-divider {
  font-family: 'IBM Plex Mono', monospace;
  color: var(--dim-gray);
  text-align: center;
  margin-bottom: 2rem;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

/* Scene 3: Undo */
.scene-undo { background: var(--void-black); }
.ripple-overlay {
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background: radial-gradient(circle at 50% 0%, var(--revert-green), transparent 70%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.ripple-overlay.active {
  animation: rippleFlash 0.8s ease-out forwards;
}
@keyframes rippleFlash {
  0% { opacity: 0.15; }
  100% { opacity: 0; }
}

/* Scene 4: Philosophy */
.scene-philosophy {
  background: var(--charcoal-shell);
  align-items: flex-start;
  padding-top: 100px;
}
.philosophy-block {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease-out, transform 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  margin-bottom: 2rem;
}
.philosophy-block.visible {
  opacity: 1;
  transform: translateY(0);
}
.philosophy-text {
  padding: 0.5rem 0;
}
.philosophy-text h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  letter-spacing: -0.02em;
  color: var(--phosphor-white);
  margin-bottom: 0.75rem;
}
.philosophy-text p {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 300;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--dim-gray);
}
.philosophy-text code {
  color: var(--terminal-cyan);
  background: rgba(58, 239, 180, 0.08);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.9em;
}
.version-output {
  color: var(--terminal-cyan) !important;
  font-family: 'IBM Plex Mono', monospace !important;
}

/* Scene 5: Exit */
.scene-exit {
  background: var(--void-black);
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 100vh;
}
.scene-exit .scene-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.exit-prompt {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 2rem;
}
.exit-message {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 300;
  font-size: 1.2rem;
  color: var(--dim-gray);
  opacity: 0;
  transition: opacity 1.5s ease;
}
.exit-message.visible { opacity: 1; }
.domain-label {
  margin-top: 3rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 4rem);
  color: var(--terminal-cyan);
  opacity: 0;
  transition: opacity 2s ease 0.5s;
}
.domain-label.visible { opacity: 0.15; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .scene {
    padding: 60px 24px 40px 24px;
  }
  .scene-boot { padding-left: 24px; }
  .rewind-column { right: 4px; }
  .title-bar { font-size: 0.7rem; padding: 0 10px; height: 32px; }
  .hero-title { font-size: clamp(2.5rem, 12vw, 5rem); }
}

@media (max-width: 480px) {
  .scene { padding: 50px 16px 30px 16px; }
  .command-block { padding: 1rem; }
  .philosophy-text h2 { font-size: 1.3rem; }
}
