/* ============================================
   BASE STYLES - Layout y efectos generales
   ============================================ */

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-cv);
  color: var(--text-main);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  transition: background var(--transition-smooth);
  position: relative;
  overflow-x: hidden;
}

/* Fondo animado con gradiente + grain */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: 
    radial-gradient(
      700px 520px at calc(50% + (var(--px) * 0.6)) calc(62% + (var(--py) * 0.6)),
      rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.08),
      rgba(255, 255, 255, 0) 60%
    ),
    radial-gradient(
      900px 700px at calc(40% + (var(--px) * 0.35)) calc(20% + (var(--py) * 0.35)),
      rgba(0, 0, 0, 0.05),
      rgba(255, 255, 255, 0) 55%
    );
  transition: background 0.6s ease;
}

/* Textura grain sutil */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.22'/%3E%3C/svg%3E");
  opacity: 0.08;
  mix-blend-mode: multiply;
}

/* Scanlines (solo en Lado B) */
.scanlines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0),
    rgba(255, 255, 255, 0) 50%,
    rgba(0, 0, 0, 0.1) 50%,
    rgba(0, 0, 0, 0.1)
  );
  background-size: 100% 4px;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 1s;
}

/* Light leak ambiental (solo Lado B) */
.lightleak {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  transition: opacity 1s ease;
  background: 
    radial-gradient(
      900px 700px at 15% 15%,
      rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.13),
      rgba(0, 0, 0, 0) 60%
    ),
    radial-gradient(
      700px 540px at 85% 75%,
      rgba(var(--accent-r), var(--accent-g), var(--accent-b), 0.10),
      rgba(0, 0, 0, 0) 62%
    );
  filter: blur(0.2px);
  animation: leakDrift 18s ease-in-out infinite alternate;
}

@keyframes leakDrift {
  from { transform: translate(calc(var(--px) * 0.25), calc(var(--py) * 0.25)); }
  to { transform: translate(calc(var(--px) * -0.25), calc(var(--py) * -0.25)); }
}

/* Estado alternativo (Lado B) */
body.alt-active {
  background: var(--bg-alt);
  align-items: flex-start;
  padding-top: 60px;
  animation: pulseBg 5s infinite alternate;
}

@keyframes pulseBg {
  from { background: #050505; }
  to { background: #0f0000; }
}

body.alt-active .scanlines {
  opacity: 0.4;
}

body.alt-active .lightleak {
  opacity: 0.85;
}

body.alt-active .window {
  display: none;
}

body.alt-active .alt-view {
  display: block;
  animation: appearIn 0.5s ease-out;
}

@keyframes appearIn {
  0% {
    opacity: 0;
    transform: translateY(20px);
    filter: blur(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

/* Responsivo */
@media (max-width: 768px) {
  body {
    padding: 16px;
  }
  
  body.alt-active {
    padding-top: 30px;
  }
}