/* ==========================================================================
   VARIABLES Y SISTEMA DE DISEÑO (DESIGN TOKENS)
   ========================================================================== */
:root {
  /* Paleta cromática nocturna y romántica */
  --bg-space: #07090e;
  --bg-deep: #0d111a;
  --bg-card: rgba(18, 24, 38, 0.75);
  --bg-card-border: rgba(255, 255, 255, 0.1);
  --bg-card-glow: rgba(224, 108, 117, 0.12);

  /* Acentos de luz */
  --accent-gold: #f6d89b;
  --accent-gold-glow: rgba(246, 216, 155, 0.35);
  --accent-pink: #e06c75;
  --accent-pink-soft: #d15886;
  --accent-rose-glow: rgba(224, 108, 117, 0.4);
  --accent-cyan: #56b6c2;
  --accent-blue-deep: #16243b;

  /* Papel de la Carta */
  --paper-bg: #faf6ee;
  --paper-text: #2c241e;
  --paper-line: rgba(180, 160, 140, 0.25);
  --paper-shadow: rgba(0, 0, 0, 0.45);

  /* Tipografías */
  --font-pixel: 'Pixelify Sans', 'VT323', monospace, sans-serif;
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-letter: 'Cormorant Garamond', 'Plus Jakarta Sans', Georgia, serif;

  /* Textos */
  --text-main: #f0f3f8;
  --text-muted: #9aa5b8;
  --text-dim: #647087;

  /* Bordes y Sombras */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-full: 9999px;
  --shadow-subtle: 0 4px 20px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 25px rgba(224, 108, 117, 0.25);
  --shadow-gold: 0 0 20px rgba(246, 216, 155, 0.25);

  /* Transiciones */
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.45s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   RESET Y BASE
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  min-height: 100%;
  min-height: 100dvh;
  background-color: var(--bg-space);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   CANVAS AMBIENTAL Y PARTÍCULAS
   ========================================================================== */
.ambient-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 0;
  pointer-events: none;
  display: block;
}

.particle-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

/* ==========================================================================
   BARRA / DOCK FLOTANTE DE RECUERDOS (ACCESO PERMANENTE TRAS DESBLOQUEO)
   ========================================================================== */
.floating-memory-dock {
  position: fixed;
  top: max(0.85rem, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  background: rgba(14, 20, 32, 0.82);
  border: 1px solid rgba(246, 216, 155, 0.3);
  border-radius: var(--radius-full);
  padding: 0.35rem 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5), 0 0 15px rgba(246, 216, 155, 0.15);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: fadeInDown 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.dock-nav-item {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-pixel);
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}

.dock-nav-item:active {
  transform: scale(0.94);
}

.dock-nav-item.active {
  color: var(--accent-gold);
  background: rgba(246, 216, 155, 0.16);
  border: 1px solid rgba(246, 216, 155, 0.3);
  box-shadow: 0 0 10px rgba(246, 216, 155, 0.2);
}

.dock-icon {
  font-size: 0.95rem;
}

.dock-divider {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.12);
}

/* ==========================================================================
   CONTENEDOR PRINCIPAL Y ESCENAS
   ========================================================================== */
.app-container {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(max(1.5rem, env(safe-area-inset-top)) + 2.5rem) env(safe-area-inset-right, 1rem) env(safe-area-inset-bottom, 1.5rem) env(safe-area-inset-left, 1rem);
}

.scene {
  width: 100%;
  max-width: 680px;
  display: none;
  opacity: 0;
  transform: translateY(18px) scale(0.98);
  transition: opacity var(--transition-slow), transform var(--transition-slow);
  margin: 0 auto;
}

.scene.scene-active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.scene.scene-exit {
  opacity: 0;
  transform: translateY(-24px) scale(0.97);
  pointer-events: none;
}

/* ==========================================================================
   PANELES GLASSMORPHISM Y ESTILOS COMUNES
   ========================================================================== */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-subtle), var(--shadow-glow);
  padding: 1.75rem 1.5rem;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.pixel-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-pixel);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-gold);
  background: rgba(246, 216, 155, 0.12);
  border: 1px solid rgba(246, 216, 155, 0.25);
  border-radius: var(--radius-full);
  padding: 0.3rem 0.85rem;
  margin-bottom: 0.75rem;
}

.scene-header {
  text-align: center;
  margin-bottom: 2rem;
  width: 100%;
}

.scene-title {
  font-family: var(--font-pixel);
  font-size: clamp(1.4rem, 5vw, 1.9rem);
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
  margin-bottom: 0.5rem;
  text-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

.scene-description {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto;
}

/* ==========================================================================
   BOTONES PIXEL Y LLAMADAS A LA ACCIÓN
   ========================================================================== */
.pixel-btn {
  font-family: var(--font-pixel);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.85rem 1.6rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  text-decoration: none;
  outline: none;
  position: relative;
}

.primary-btn {
  background: linear-gradient(135deg, #e06c75, #c94c65);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(224, 108, 117, 0.35);
  border-bottom: 3px solid #9b2c40;
}

.primary-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 8px rgba(224, 108, 117, 0.25);
  border-bottom-width: 1px;
}

.next-scene-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--accent-gold);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.next-scene-btn:active {
  transform: translateY(2px);
  background: rgba(255, 255, 255, 0.14);
}

.btn-pixel-icon {
  width: 18px;
  height: 18px;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.4));
}

.btn-arrow {
  font-size: 1.1rem;
  transition: transform var(--transition-fast);
}

.next-scene-btn:active .btn-arrow {
  transform: translateX(4px);
}

/* ==========================================================================
   AUDIO TOGGLE FLOTANTE
   ========================================================================== */
.audio-toggle {
  position: fixed;
  top: max(0.85rem, env(safe-area-inset-top));
  right: max(0.85rem, env(safe-area-inset-right));
  z-index: 100;
  background: rgba(13, 17, 26, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
  padding: 0.4rem 0.75rem;
  color: var(--text-main);
  font-family: var(--font-pixel);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.audio-toggle:active {
  transform: scale(0.95);
}

/* ==========================================================================
   UTILIDADES
   ========================================================================== */
.hidden {
  display: none !important;
}

@keyframes fadeInDown {
  0% { opacity: 0; transform: translate(-50%, -15px); }
  100% { opacity: 1; transform: translate(-50%, 0); }
}

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

@keyframes gentlePulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.04); filter: brightness(1.15); }
}

@keyframes starGlow {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.2); filter: drop-shadow(0 0 8px #ffeaa7); }
}

/* Accesibilidad: Reducción de movimiento */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
