/* =========================================================
   ROOT VARIABLES
   ========================================================= */
:root { 
  --red: #ff0000; 
  --black: #050505; 
  --dark-grey: #121212; 
  --white: #ffffff; 
}

/* =========================================================
   GLOBAL RESETS & BASE
   ========================================================= */
* { 
  -webkit-tap-highlight-color: transparent; 
  box-sizing: border-box; 
}

body { 
  background: var(--black); 
  color: var(--white); 
  font-family: 'Nova Mono', monospace; 
  margin: 0; 
  overflow: hidden; 
  height: 100vh;
}

/* =========================================================
   CRT SCANLINE OVERLAY
   ========================================================= */
body::after {
  content: " "; 
  display: block; 
  position: fixed; 
  top: 0; 
  left: 0; 
  width: 100%; 
  height: 100%;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%);
  z-index: 999; 
  background-size: 100% 3px; 
  pointer-events: none; 
  opacity: 0.3;
}


/* --- SPLASH SCREEN BASE --- */
.splash-screen {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh;
    background: var(--black);
    z-index: 1000; /* Stays above your CRT overlay */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease;
}

.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    width: 90%;
    position: relative;
}

/* --- THE GLITCH EFFECTS --- */

/* 1. Typewriter Reveal */
.logo-text, .logo-x, .logo-dot {
    opacity: 0;
    animation: typewriterReveal 1.2s steps(30) 0.5s forwards;
}

/* 2. RGB Glitch (Targets the Red X specifically) */
.logo-x {
    fill: var(--red);
    animation: typewriterReveal 1.2s steps(30) 0.5s forwards, 
               rgbGlitch 0.3s ease-in-out 1.2s 3;
}

/* 3. Neon Pulse (Whole Logo) */
.splash-logo {
    width: 100%;
    max-width: 800px;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.2));
    animation: neonPulse 3s ease-in-out 2s infinite;
}

/* 4. Scanline Sweep (Splash-only overlay) */
.splash-content::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, transparent 0%, rgba(255, 255, 255, 0.1) 50%, transparent 100%);
    background-size: 100% 8px;
    pointer-events: none;
    animation: scanlinesSweep 1.5s linear infinite;
}

/* --- ANIMATION KEYFRAMES --- */
@keyframes typewriterReveal {
    0% { opacity: 0; clip-path: inset(0 100% 0 0); }
    1% { opacity: 1; }
    100% { opacity: 1; clip-path: inset(0 0 0 0); }
}

@keyframes rgbGlitch {
    0%, 100% { transform: translate(0, 0); filter: drop-shadow(0 0 5px var(--red)); }
    25% { transform: translate(-4px, 1px); filter: drop-shadow(-2px 0 red) drop-shadow(2px 0 cyan); }
    50% { transform: translate(4px, -1px); filter: drop-shadow(2px 0 red) drop-shadow(-2px 0 cyan); }
    75% { transform: translate(-2px, -1px); filter: drop-shadow(-1px 0 red) drop-shadow(1px 0 cyan); }
}

@keyframes neonPulse {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.2)); }
    50% { filter: drop-shadow(0 0 25px rgba(255, 0, 0, 0.5)); }
}

@keyframes scanlinesSweep {
    from { transform: translateY(-100%); }
    to { transform: translateY(100%); }
}

/* Cleanup */
.splash-screen.fade-out { opacity: 0; pointer-events: none; }

/* =========================================================
   APP GRID LAYOUT
   ========================================================= */
.app-grid { 
  display: grid; 
  grid-template-columns: 200px 1fr; 
  grid-template-rows: 50px 1fr 350px 30px;
  height: 100vh;
}

header { 
  grid-column: span 2; 
  border-bottom: 1px solid var(--red); 
  background: #000; 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  padding: 0 20px;
}

/* =========================================================
   UTILITY CLASSES
   ========================================================= */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-4 { gap: 1rem; }
.w-2 { width: 0.5rem; }
.h-2 { height: 0.5rem; }
.bg-zinc-900 { background-color: #18181b; }
.rounded-full { border-radius: 9999px; }
.bg-red-600 { background-color: #dc2626; }

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

.text-white { color: #ffffff; }
.font-bold { font-weight: 700; }
.tracking-tighter { letter-spacing: -0.05em; }
.text-sm { font-size: 0.875rem; }
.uppercase { text-transform: uppercase; }
.text-red-700 { color: #b91c1c; }
.text-\[10px\] { font-size: 10px; }

.border { border-width: 1px; }
.border-zinc-800 { border-color: #27272a; }

.px-3 {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

.py-1 {
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}

.hover\:border-red-600:hover { border-color: #dc2626; }
.hover\:text-red-600:hover { color: #dc2626; }

.cursor-pointer { cursor: pointer; }
.mt-6 { margin-top: 1.5rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }

.text-\[8px\] { font-size: 8px; }
.text-\[9px\] { font-size: 9px; }
.text-zinc-700 { color: #3f3f46; }
.text-zinc-600 { color: #52525b; }
.text-red-900 { color: #7f1d1d; }
.tracking-widest { letter-spacing: 0.1em; }

.absolute { position: absolute; }
.top-2 { top: 0.5rem; }
.left-4 { left: 1rem; }

.italic { font-style: italic; }

/* =========================================================
   SIDEBAR
   ========================================================= */
.menu-trigger {
  background: #000;
  cursor: pointer;
}

.sidebar { 
  background: #0a0a0a; 
  border-right: 1px solid #222; 
  overflow-y: auto; 
  padding: 20px; 
}

.section-label {
  color: #666;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

/* =========================================================
   VIEWPORT SPLIT
   ========================================================= */
#viewport { 
  display: grid; 
  grid-template-columns: 1fr 320px; 
  background: #000; 
  border-bottom: 1px solid var(--red); 
  overflow: hidden;
}

.story-panel {
  padding: 30px; 
  overflow-y: auto; 
  border-right: 1px solid #222;
  font-family: 'Special Elite', serif; 
  font-size: 14px; 
  line-height: 1.7; 
  background: #080808;
}

.log-panel {
  padding: 20px; 
  overflow-y: hidden;
  font-family: 'VT323', monospace; 
  font-size: 13px; 
  color: #555; 
  background: #050505;
}

/* =========================================================
   BOTTOM SECTION
   ========================================================= */
.bottom-container {
  display: grid; 
  grid-template-columns: 350px 1fr; 
  grid-column: span 2;
  border-top: 1px solid var(--red); 
  height: 350px; 
  background: #000;
}

/* =========================================================
   SIGIL FORGE
   ========================================================= */
.sigil-forge {
  background: #000; 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  justify-content: center;
  border-left: 1px solid #222; 
  position: relative; 
  overflow: hidden;
}

#sigil-canvas { 
  cursor: crosshair; 
  filter: drop-shadow(0 0 10px var(--red)); 
}

/* =========================================================
   CHAT / EDITOR
   ========================================================= */
.chat-section { 
  background: var(--red); 
  display: flex; 
  flex-direction: column; 
  overflow: hidden; 
  border-right: 1px solid #000;
}

.editor-header { 
  background: #111; 
  color: white; 
  padding: 8px 15px; 
  font-family: 'Special Elite', serif; 
  font-size: 10px; 
  text-transform: uppercase; 
  letter-spacing: 2px; 
  border-bottom: 1px solid #000;
}

.chat-control-btn {
  background: #000;
  color: #444;
  border: 1px solid #222;
  padding: 4px 12px;
  font-size: 9px;
  cursor: pointer;
  font-family: 'Nova Mono', monospace;
  transition: all 0.2s;
  margin: 5px;
}

.chat-control-btn:hover {
  color: var(--red);
  border-color: var(--red);
}

#chat-container { 
  flex: 1; 
  padding: 15px; 
  overflow-y: auto; 
  background: #000; 
  font-family: 'VT323', monospace; 
}

.chat-bubble { 
  margin-bottom: 10px; 
  padding: 10px; 
  border: 1px solid #222; 
  font-size: 1.1rem; 
}

.user-message { 
  border-left: 4px solid #444; 
  color: #888; 
}

.bot-message { 
  border-left: 4px solid var(--red); 
  color: var(--white); 
  background: #0a0000; 
}

.chat-input-area { 
  background: #111; 
  padding: 10px; 
  display: flex; 
  gap: 8px; 
}

#chat-input { 
  background: #000; 
  color: var(--red); 
  border: 1px solid #333; 
  flex: 1; 
  padding: 8px; 
  font-family: 'VT323'; 
  font-size: 18px; 
  outline: none; 
}

/* =========================================================
   FOOTER & POWER
   ========================================================= */
footer { 
  grid-column: span 2; 
  background: #000; 
  border-top: 1px solid #222; 
  font-size: 9px; 
  color: #444; 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  padding: 0 20px; 
}

.power-btn { 
  font-size: 9px; 
  padding: 2px 8px; 
  border: 1px solid #333; 
  color: #444; 
  cursor: pointer; 
  background: #000;
}

.power-on { 
  color: var(--red); 
  border-color: var(--red); 
  box-shadow: 0 0 5px var(--red); 
}

/* =========================================================
   QR CODE
   ========================================================= */
#ton-qr {
  width: 66px;
  border: 1px solid var(--white);
  padding: 2px;
  background: #000;
  cursor: zoom-in;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
  position: relative;
  z-index: 10001;
}

#ton-qr:hover,
#to-qr:active {
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.6);
  border-color: var(--red);
}

#ton-qr.expanded {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(3.5);
  z-index: 999999;
  border-color: var(--white);
  box-shadow: 0 0 100px rgba(0, 0, 0, 0.9), 0 0 50px rgba(255, 255, 255, 0.8);
  cursor: zoom-out;
}

#toq-qr {
  width: 66px;
  border: 1px solid var(--white);
  padding: 2px;
  background: #000;
  cursor: zoom-in;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
  position: relative;
  z-index: 10001;
}

#toq-qr:hover,
#toq-qr:active {  /* ← Fixed: changed #to-qr to #toq-qr */
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.6);
  border-color: var(--red);
}

#toq-qr.expanded {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(3.5);
  z-index: 999999;
  border-color: var(--white);
  box-shadow: 0 0 100px rgba(0, 0, 0, 0.9), 0 0 50px rgba(255, 255, 255, 0.8);
  cursor: zoom-out;
}
  

/* =========================================================
   SLIDE MENU
   ========================================================= */
.menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.menu-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.slide-menu {
  position: fixed;
  bottom: -100%;
  left: 0;
  width: 100%;
  height: 70%;
  background: #000;
  border-top: 2px solid var(--red);
  z-index: 9999;
  transition: bottom 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  overflow-y: auto;
  padding: 40px 30px;
}

.slide-menu.active { bottom: 0; }

.menu-content {
  max-width: 600px;
  margin: 0 auto;
}

.menu-title {
  color: var(--red);
  font-size: 1.8rem;
  margin-bottom: 30px;
  text-transform: uppercase;
}

.menu-section { margin-bottom: 25px; }

.menu-section-title {
  color: #666;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 10px;
}

.menu-link {
  display: block;
  color: var(--white);
  text-decoration: none;
  padding: 12px 0;
  border-bottom: 1px solid #222;
  transition: all 0.2s;
  font-size: 13px;
}

.menu-link:hover {
  color: var(--red);
  padding-left: 10px;
  border-color: var(--red);
}

/* =========================================================
   WITCH SYMBOL ANIMATIONS
   ========================================================= */
.witch-symbol {
  animation: witch-glow 3s ease-in-out infinite;
}

@keyframes witch-glow {
  0%, 100% {
    opacity: 0.6;
    filter: drop-shadow(0 0 2px var(--red));
  }
  50% {
    opacity: 1;
    filter: drop-shadow(0 0 8px var(--red));
  }
}

/* =========================================================
   CUBE NAVIGATION
   ========================================================= */
.cube-menu-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin: 20px 0 30px 0;
}

.cube-container {
  position: relative;
  width: 120px;
  height: 120px;
  perspective: 600px;
}

.cube {
  position: relative;
  width: 90px;
  height: 90px;
  margin: 15px auto;
  transform-style: preserve-3d;
  transform: rotateX(-20deg) rotateY(30deg);
}

.cube-face {
  position: absolute;
  width: 90px;
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border: 2px solid #666;
  background: rgba(0, 0, 0, 0.9);
  transition: all 0.4s ease;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
  padding: 8px;
  box-sizing: border-box;
  line-height: 1.2;
}

.cube-face:hover {
  border-color: #ff0000;
  background: rgba(255, 0, 0, 0.1);
  transform: translateZ(10px);
}

.cube-front {
  color: #ff0000;
  transform: translateZ(45px);
}

.cube-right {
  color: #ccc;
  transform: rotateY(90deg) translateZ(45px);
}

.cube-left {
  color: #aaa;
  transform: rotateY(-90deg) translateZ(45px);
}

.cube-top {
  color: #999;
  transform: rotateX(90deg) translateZ(45px);
}

.cube-container:hover .cube {
  transform: rotateX(-25deg) rotateY(35deg);
}

.cube-geo-label {
  text-align: center;
  color: #666;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 8px;
}

/* =========================================================
   SVG DRAW ANIMATION
   ========================================================= */
.witch-symbol {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: draw 5s ease-in-out infinite;
}

@keyframes draw {
  0% { stroke-dashoffset: 1000; }
  50% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: 1000; }
}

/* =========================================================
   ANASTASIA IMAGE
   ========================================================= */
#anastasia-img:hover,
#anastasia-img:active {
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.6);
  border-color: var(--red);
}

#anastasia-img.expanded {
  transform: scale(3.5);
  z-index: 999999;
  border-color: var(--white);
  box-shadow: 0 0 100px rgba(0, 0, 0, 0.9), 0 0 50px rgba(255, 255, 255, 0.8);
  cursor: zoom-out;
  filter: grayscale(0%);
}

/* =========================================================
   TEXT TO SPEECH
   ========================================================= */
.tts-trigger {
  color: #ff0000;
  cursor: pointer;
  font-size: 16px;
  display: inline-block;
  margin-left: 10px;
  transition: all 0.2s;
  user-select: none;
}

.tts-trigger:hover {
  color: #fff;
  text-shadow: 0 0 8px #ff0000;
}

.tts-trigger.speaking {
  animation: pulse 1s infinite;
}

/* =========================================================
   RESPONSIVE – TABLET
   ========================================================= */
@media (max-width: 768px) {
  body {
    overflow: visible !important;
    height: auto !important;
  }

  .app-grid {
    grid-template-columns: 1fr;
    grid-template-rows: 50px auto 400px 300px 250px 30px;
    height: auto;
    overflow-y: visible;
  }

  .sidebar {
    grid-row: 2;
    height: 150px;
    border-right: none;
    border-bottom: 1px solid #222;
    z-index: 1;
  }

  #ton-qr { z-index: 1 !important; }
  #ton-qr.expanded { z-index: 10000 !important; }

  #anastasia-img { z-index: 1 !important; }
  #anastasia-img.expanded { z-index: 10000 !important; }

  #viewport {
    grid-row: 3;
    grid-template-columns: 1fr;
    height: 400px;
  }

  .story-panel {
    border-right: none;
    border-bottom: 1px solid #222;
  }

  .bottom-container {
    grid-row: 4 / 6;
    grid-template-columns: 1fr;
    height: auto;
  }

  .chat-section {
    height: 300px;
    border-right: none;
    border-bottom: 1px solid #222;
  }

  .sigil-forge {
    height: 250px;
    border-left: none;
  }

  .slide-menu {
    height: 90%;
    padding: 30px 20px;
  }

  .menu-title {
    font-size: 1.5rem;
    margin-bottom: 20px;
  }

  .menu-section-title { font-size: 0.65rem; }

  .menu-link {
    font-size: 12px;
    padding: 8px 0;
  }
}

/* =========================================================
   RESPONSIVE – MOBILE
   ========================================================= */
@media (max-width: 480px) {
  #viewport { min-height: 40vh; }

  .slide-menu { height: 95%; }

  header { padding: 0 10px; }

  .text-sm { font-size: 0.75rem; }
}

/* =========================================================
   RESPONSIVE – CUBE
   ========================================================= */
@media (max-width: 600px) {
  .cube-menu-container { gap: 15px; }

  .cube-container {
    width: 100px;
    height: 100px;
  }

  .cube {
    width: 75px;
    height: 75px;
  }

  .cube-face {
    width: 75px;
    height: 75px;
    font-size: 8px;
  }

  .cube-front { transform: translateZ(37.5px); }
  .cube-right { transform: rotateY(90deg) translateZ(37.5px); }
  .cube-left { transform: rotateY(-90deg) translateZ(37.5px); }
  .cube-top { transform: rotateX(90deg) translateZ(37.5px); }
}

#power-light {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: redWhiteAlternate 1s infinite;
}

@keyframes redWhiteAlternate {
  0%, 50% { 
    background-color: #ef4444;
    box-shadow: 0 0 10px #ef4444;
  }
  51%, 100% { 
    background-color: white;
    box-shadow: 0 0 10px white;
  }
}
