/* =========================================
   STYLE.CSS - VERSIÓN FINAL (OPTIMIZADA)
   Arquitectura: App Shell (Scroll Interno) + Diseño Móvil Expandido
   ========================================= */

/* 1. FUENTES */
@import url('https://fonts.googleapis.com/css2?family=Courgette&family=Montserrat:wght@300;400;500;600&display=swap');

/* 2. VARIABLES */
:root {
  /* Tipografía */
  --title-font: 'Courgette', cursive;
  --body-font: 'Montserrat', sans-serif;

  /* Colores Base */
  --text-light: #CDD8D5;
  --text-medium: #AEA5A5;
  --text-dark: #E0CFC1;
  --header-color: #BCBDB9;
  
  /* Fondos y Capas */
  --background-overlay: rgba(20, 18, 28, 0.75);
  --container-bg: rgba(32, 30, 43, 0.75);
  --content-bg: rgba(30, 32, 33, 0.85);
  --input-bg: rgba(107, 93, 116, 0.5);
  --modal-bg: rgba(30, 30, 30, 0.95);
  --modal-overlay-bg: rgba(0, 0, 0, 0.85);
  
  /* Interacción */
  --border-color-input: #8E7383;
  --button-bg-initial: #9A8C8B;
  --button-bg-hover: #3F3938;
  
  /* Acentos */
  --progress-color: #A3C3BD;
  --highlight-pink: #ff7aa8;
  --highlight-pink-light: #ffaed0;
  --highlight-green: #7B9D8F;
  --highlight-red: #E74C3C;
  --highlight-gold: #FFD700;
  
  /* Componentes Específicos */
  --achievement-bg: #4A4A6A;
  --achievement-text: #E0CFC1;
  --favorite-icon-default: #888;
  --favorite-icon-active: #FFD700;

  /* Z-Index (Arquitectura Estricta) */
  --z-bg: -10;
  --z-particles: -5;
  --z-overlay: -1;
  --z-content: 10;
  --z-fab: 1500;
  --z-menu: 1499;
  --z-toast: 2000;
  --z-modal: 9999;
}

body.dark-mode {
  --text-light: #f2e6df;
  --text-medium: #d8ccc3;
  --background-overlay: rgba(5, 5, 5, 0.85);
  --container-bg: rgba(20, 20, 20, 0.8);
  --content-bg: rgba(17, 17, 17, 0.95);
  --button-bg-initial: #4A4A4A;
  --highlight-pink: #A860A8;
}

/* 3. ESTRUCTURA BASE (BLOQUEO DE SCROLL EN BODY) 
   Esto soluciona el Background Jumping en Chrome Android */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%;
  height: 100%; 
  overflow: hidden; /* Bloqueamos scroll nativo */
  position: fixed; /* Fijamos el viewport */
}

body {
  font-family: var(--body-font);
  color: var(--text-light);
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* 4. CAPAS FIJAS (FONDO Y PARTICULAS) */
#fixed-bg {
  position: fixed;
  inset: 0;
  background: url('assets/images/fondo-romantico.webp') center / cover no-repeat;
  z-index: var(--z-bg);
  pointer-events: none;
  transform: translateZ(0); /* Fuerza GPU */
}

#tsparticles {
  position: fixed;
  inset: 0;
  z-index: var(--z-particles);
  pointer-events: none;
}

.background-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--background-overlay);
  backdrop-filter: blur(4px);
  z-index: var(--z-overlay);
  pointer-events: none;
}

/* 5. CONTENEDOR DE SCROLL INTERNO (EL NUEVO BODY) */
#app-scroll {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  overflow-y: auto; 
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch; 
  overscroll-behavior: none; 
  z-index: var(--z-content);
  display: flex; flex-direction: column; align-items: center;
}

/* Scrollbar personalizado */
/* Eliminado */

/* 6. COMPONENTES UI PRINCIPALES */
.container {
  background-color: var(--container-bg);
  padding: 2.5rem; border-radius: 16px;
  text-align: center; max-width: 900px; width: 90%;
  margin: 4rem auto 8rem auto; 
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 15px 35px 0 rgba(0, 0, 0, 0.4);
}

/* Tipografía */
h1 { font-family: var(--title-font); color: var(--header-color); font-weight: 400; text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4); margin-bottom: 1.5rem; font-size: 3em; letter-spacing: 1px; }
h2, .section-title { font-family: var(--title-font); color: var(--header-color); font-weight: 400; margin-bottom: 1rem; }
.intro-text { font-size: 1.1em; margin-bottom: 2rem; color: var(--text-medium); }

.header-img { 
  width: 140px; height: auto; margin-bottom: 1.5rem; 
  filter: drop-shadow(0 5px 15px rgba(0,0,0,0.3));
  animation: float 6s ease-in-out infinite; 
}

/* Inputs y Botones */
.input-container { display: flex; gap: 12px; margin-bottom: 2rem; justify-content: center; }

#codeInput {
  flex-grow: 1; max-width: 350px; padding: 15px 20px;
  border: 2px solid var(--border-color-input); border-radius: 12px;
  background-color: var(--input-bg); color: var(--text-light);
  font-family: var(--body-font); font-size: 1.1em; text-align: center;
  transition: all 0.3s ease;
}
#codeInput:focus { border-color: var(--highlight-pink); outline: none; box-shadow: 0 0 15px rgba(255, 122, 168, 0.3); }
#codeInput.success { border-color: var(--highlight-green); box-shadow: 0 0 15px rgba(39, 174, 96, 0.3); }
#codeInput.error { border-color: var(--highlight-red); box-shadow: 0 0 15px rgba(231, 76, 60, 0.3); }

.button {
  background-color: var(--button-bg-initial); color: var(--text-light);
  border: none; border-radius: 12px; padding: 15px 25px;
  font-family: var(--body-font); font-weight: 600; font-size: 1em;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; position: relative; overflow: hidden;
  transition: transform 0.2s;
}
.button:active { transform: scale(0.96); }
.button.small-button { padding: 10px 18px; font-size: 0.9em; }

#hintBtn { background-color: var(--highlight-gold); color: #333; width: 50px; padding: 0; font-size: 1.2rem; }
#hintBtn:hover { background-color: #f39c12; color: #fff; box-shadow: 0 0 15px rgba(255,215,0,0.5); }

/* 7. CONTENIDO DINÁMICO (Cartas) */
.contenido-container {
  background-color: var(--content-bg); padding: 2.5rem; border-radius: 16px;
  margin-top: 2rem; text-align: left; line-height: 1.8; color: var(--text-medium);
  border: 1px solid rgba(255, 255, 255, 0.05);
  animation: slideUp 0.5s ease-out;
}
.contenido-container img { max-width: 100%; border-radius: 12px; margin: 1.5em auto; display: block; box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
.mensaje-texto { font-size: 1.2em; white-space: pre-wrap; color: var(--text-light); }

/* 8. VIDEOS, LOADERS & IFRAMES (Restaurado) */
.video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9; /* Forzar 16:9 siempre */
  border-radius: 12px;
  overflow: hidden;
  margin: 1.5em 0;
  background: #000; /* Fondo negro inicial */
  box-shadow: 0 8px 20px rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
}

/* Spinner de carga */
.video-loader {
  position: absolute;
  width: 40px; height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--highlight-pink);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 1;
}

/* Iframe de video (oculto hasta cargar) */
.video-frame {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  border: none; opacity: 0; transition: opacity 0.6s ease-in;
  z-index: 2;
}

/* Contenedor Iframe Externo */
.internal-wrapper { width: 100%; display: flex; flex-direction: column; align-items: center; margin-top: 15px; }
.internal-frame {
  width: 100%; height: 600px;
  border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 20px;
  background: white;
}

/* 9. PROGRESO Y LOGROS (Multicolor Restaurado) */
.achievements-section { margin-top: 3rem; padding-top: 2rem; border-top: 1px dashed rgba(255,255,255,0.2); }
.progress-bar-container {
  width: 100%; max-width: 400px; background-color: rgba(255,255,255,0.1);
  border-radius: 20px; height: 16px; margin: 0 auto; overflow: hidden;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.2);
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--progress-color), var(--highlight-pink-light), var(--highlight-pink));
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(255, 122, 168, 0.5);
}

/* 10. LISTAS Y COLECCIÓN */

/* --- CONTENEDOR PRINCIPAL --- */
.unlocked-codes-section[hidden] { display: none !important; }

.unlocked-codes-panel, .unlocked-codes-section { 
  /* CAMBIO: Quitamos backdrop-filter y usamos un fondo más sólido */
  background: var(--content-bg); /* Usa el color sólido definido en tus variables */
  padding: 1.5rem; 
  border-radius: 16px; /* Bajamos un poco el radio para suavizar bordes de píxeles */
  margin-top: 1.5rem; 
  border: 1px solid rgba(255, 255, 255, 0.1); /* Borde simple */
  /* Sin box-shadow pesado */
  display: flex; flex-direction: column;
  max-height: 85vh; 
}

/* --- FILTROS --- */
.filter-controls { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 1.5rem; justify-content: center; }
.filter-controls input, .filter-controls select { 
  padding: 12px 15px; 
  border-radius: 10px; 
  border: 1px solid rgba(255, 255, 255, 0.15); 
  background: rgba(0, 0, 0, 0.2); 
  color: var(--text-light); 
  outline: none;
}

/* --- LISTA --- */
.lista-codigos { 
  display: flex; flex-direction: column; gap: 10px; 
  list-style: none; overflow-y: auto; padding: 2px;
  /* Rendimiento: will-change avisa al navegador que esto se moverá */
  will-change: scroll-position;
}

/* --- TARJETA DE CÓDIGO (OPTIMIZADA) --- */
.lista-codigo-item {
  position: relative; 
  /* CAMBIO: Color plano en vez de degradado complejo */
  background: rgba(255,255,255,0.05); 
  padding: 12px 15px; 
  border-radius: 12px; 
  border: 1px solid rgba(255,255,255,0.05);
  
  /* Flexbox eficiente */
  display: flex; 
  align-items: center; 
  justify-content: space-between;
  gap: 15px;
  
  cursor: pointer; 
  /* Solo animamos opacidad y transform, que son baratos para la GPU */
  transition: background 0.2s, transform 0.1s; 
}

.lista-codigo-item:hover { 
  background: rgba(255,255,255,0.1); /* Cambio simple de color al hover */
  transform: translateY(-1px); /* Movimiento mínimo */
}

.lista-codigo-item:active { transform: scale(0.98); }

.lista-codigo-item.locked { 
  background: rgba(0,0,0,0.2); 
  border: 1px dashed rgba(255,255,255,0.1); 
  opacity: 0.6; 
}

/* --- TEXTO (Mantiene la corrección de desbordamiento) --- */
.lista-codigo-item > div {
  min-width: 0;         
  overflow: hidden;     
  display: flex;        
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.codigo-text { 
  font-family: var(--body-font);
  font-weight: 600; 
  font-size: 1.1em;
  color: var(--text-light); 
  text-transform: capitalize;
  display: block;
  white-space: nowrap;      
  overflow: hidden;         
  text-overflow: ellipsis; 
}

/* --- ETIQUETA --- */
.category { 
  font-size: 0.75em; 
  /* Fondo semitransparente simple */
  background: rgba(163, 195, 189, 0.1); 
  color: var(--progress-color);
  padding: 2px 8px; 
  border-radius: 6px; /* Menos radio es más fácil de dibujar */
  align-self: flex-start; 
  max-width: 100%; 
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* --- BOTÓN FAVORITOS --- */
.favorite-toggle-btn { 
  flex: 0 0 auto; 
  width: 40px; height: 40px; 
  /* Quitamos el borde y fondo complejo, dejamos solo área táctil */
  background: transparent; 
  border-radius: 50%;
  border: none;
  display: flex; align-items: center; justify-content: center;
  
  font-size: 1.2em; 
  color: var(--favorite-icon-default); 
  cursor: pointer;
  z-index: 5;
}

/* Feedback visual simple al tocar */
.favorite-toggle-btn:active { background: rgba(255,255,255,0.1); }

.favorite-toggle-btn.active { color: var(--favorite-icon-active); }
#filterFavBtn.active { background-color: var(--highlight-pink); color: white; }

/* 11. MENÚ FAB */
.menu-button {
  position: fixed; bottom: 25px; right: 25px; z-index: var(--z-fab);
  background: var(--highlight-pink); color: white; border: none; border-radius: 50%;
  width: 60px; height: 60px; font-size: 1.5em; cursor: pointer; 
  box-shadow: 0 4px 20px rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center;
}
.menu-button:active { transform: scale(0.9); }

.dropdown-menu {
  position: fixed; bottom: 95px; right: 25px; 
  background: var(--modal-bg);
  border-radius: 16px; padding: 15px; min-width: 220px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6); 
  opacity: 0; visibility: hidden; transform: translateY(20px) scale(0.9);
  transform-origin: bottom right; transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
  z-index: var(--z-menu); border: 1px solid rgba(255,255,255,0.1);
}
.dropdown-menu.show { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }

.dropdown-menu button, .menu-link-button {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px;
  color: var(--text-light); background: none; border: none; text-align: left;
  cursor: pointer; border-radius: 8px; font-family: var(--body-font); font-size: 1em; text-decoration: none;
}
.dropdown-menu button:hover, .menu-link-button:hover { background: rgba(255,255,255,0.1); color: var(--highlight-pink); }
.menu-divider { height: 1px; background: rgba(255,255,255,0.1); margin: 8px 0; }
.danger-text { color: var(--highlight-red) !important; }

/* 12. PANELES LATERALES (Tools/Audio) */
.side-panel {
  position: fixed; top: 0; right: 0; width: 320px; height: 100%;
  background: var(--modal-bg); 
  box-shadow: -10px 0 30px rgba(0,0,0,0.6); padding: 30px;
  transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2500; display: flex; flex-direction: column;
}
.side-panel.show { transform: translateX(0); }
.panel-header { display: flex; justify-content: space-between; margin-bottom: 20px; align-items: center; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 10px; }
.close-panel-btn { background: none; border: none; color: white; font-size: 1.5em; cursor: pointer; }

/* Herramientas */
.tools-container { overflow-y: auto; flex-grow: 1; }
.tool-card { background: rgba(255,255,255,0.05); border-radius: 12px; padding: 15px; margin-bottom: 15px; border: 1px solid rgba(255,255,255,0.05); }
.tool-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; color: var(--highlight-pink); font-weight: 600; }
.tool-desc { font-size: 0.9em; color: var(--text-medium); margin-bottom: 12px; }
.tool-btn { display: block; text-align: center; background: var(--button-bg-initial); color: white; padding: 10px; border-radius: 8px; text-decoration: none; font-size: 0.9em; }

/* Audio */
.audio-controls { display: flex; justify-content: center; gap: 20px; margin: 20px 0; }
.audio-btn { background: rgba(255,255,255,0.1); border: none; color: white; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1.2em; }
.audio-btn.small { width: 30px; height: 30px; font-size: 0.9em; }

/* 13. TOASTS Y MODALES (Centrados) */
#achievement-toast-container { 
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%); 
  z-index: var(--z-toast); pointer-events: none; width: 90%; max-width: 400px; 
  display: flex; flex-direction: column; align-items: center; 
}
.achievement-toast {
  background: var(--achievement-bg); color: var(--achievement-text); padding: 12px 24px;
  border-radius: 50px; margin-bottom: 10px; font-weight: 600; box-shadow: 0 5px 20px rgba(0,0,0,0.4);
  animation: slideDown 0.5s ease-out, fadeOut 0.5s ease-in 3.5s forwards;
  border: 1px solid rgba(255,255,255,0.1);
}

.glass-overlay, .media-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--modal-overlay-bg);
    z-index: var(--z-modal);
    display: flex; justify-content: center; align-items: center; flex-direction: column;
    padding: 20px; animation: fadeIn 0.3s ease;
}
.glass-card {
    background: var(--content-bg); border: 1px solid rgba(255, 255, 255, 0.2); 
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5); border-radius: 20px; padding: 30px; 
    width: 100%; max-width: 340px; text-align: center; color: var(--text-light);
}
.media-content-container { max-width: 95%; max-height: 80vh; display: flex; justify-content: center; align-items: center; margin-bottom: 20px; }
.secure-media { max-width: 100%; max-height: 70vh; border-radius: 12px; box-shadow: 0 0 20px rgba(0,0,0,0.5); }
.media-controls { display: flex; gap: 15px; }
.media-btn { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.3); color: white; padding: 10px 20px; border-radius: 30px; cursor: pointer; display: flex; align-items: center; gap: 5px; }

/* 14. ANIMACIONES */
@keyframes slideDown { from {transform:translateY(-100%); opacity:0;} to {transform:translateY(0); opacity:1;} }
@keyframes fadeOut { to {opacity:0;} }
@keyframes fadeIn { from {opacity:0;} to {opacity:1;} }
@keyframes float { 0%,100% {transform:translateY(0);} 50% {transform:translateY(-10px);} }
@keyframes slideUp { from {opacity:0; transform:translateY(20px);} to {opacity:1; transform:translateY(0);} }
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================
   15. OPTIMIZACIÓN MÓVIL CRÍTICA
   Maximizar espacio, eliminar tubos, mostrar videos grandes
   ========================================= */
@media (max-width: 768px) {
  /* LAYOUT ANTI-TUBO: Expandir al 98% del ancho */
  .container { 
    width: 98%; 
    margin-top: 3rem; 
    padding: 1.5rem 0.3rem; /* Padding mínimo lateral */
    padding-bottom: 8rem; 
  }
  
  h1 { font-size: 1.8em; margin-bottom: 10px; }
  .intro-text { padding: 0 5px; font-size: 1em; }

  /* CONTENIDO EXPANDIDO */
  .contenido-container { 
    padding: 1rem 0.5rem; /* Menos padding interno */
    font-size: 16px; 
    margin-top: 1.5rem;
  }
  
  /* VIDEOS FULL WIDTH */
  .video-wrapper, .contenido-container img {
    width: 100%; 
    margin: 1em 0; 
    border-radius: 8px;
  }
  
  /* IFRAMES GRANDES */
  .internal-frame { height: 75vh; border-radius: 12px; }

  /* GRID TÁCTIL */
  .input-container { 
    display: grid; 
    grid-template-columns: 1fr 50px; 
    grid-template-rows: auto auto; 
    gap: 8px; 
    padding: 0 5px;
  }
  #codeInput { grid-column: 1 / -1; width: 100%; max-width: none; font-size: 1.1em; padding: 12px; }
  #checkBtn { grid-column: 1 / 2; width: 100%; margin: 0; }
  #hintBtn { grid-column: 2 / 3; width: 100%; height: 100%; margin: 0; }

  /* RENDIMIENTO */
  .header-img { animation: none; width: 120px; }
  .background-overlay, .side-panel, .dropdown-menu, .container, .achievement-toast {
    backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
  }
  .background-overlay { background-color: rgba(20, 18, 28, 0.9); }

  /* AJUSTES UI */
  .side-panel { width: 85%; }
  .menu-button { width: 55px; height: 55px; bottom: 20px; right: 20px; }
  .dropdown-menu { bottom: 90px; right: 20px; }
}


/* =========================================
   TYPEWRITER CURSOR
   ========================================= */

.typewriter-cursor {
  position: relative;
}

/* Cuerpo del cursor */
.typewriter-cursor::after {
  content: '';
  display: inline-block;

  width: 2px;
  height: 1.35em;

  margin-left: 6px;
  vertical-align: -0.15em;

  background: linear-gradient(
    180deg,
    rgba(255,255,255,0),
    var(--highlight-pink),
    rgba(255,255,255,0)
  );

  border-radius: 2px;

  /* Profundidad */
  box-shadow:
    0 0 6px rgba(255, 122, 168, 0.35),
    0 0 14px rgba(255, 122, 168, 0.25);

  opacity: 0.85;

  animation:
    cursorPulse 3.6s ease-in-out infinite,
    cursorFade 1.9s ease-in-out infinite;
}

/* Pulso lento */
@keyframes cursorPulse {
  0%, 100% {
    transform: scaleY(0.92);
    opacity: 0.55;
  }
  50% {
    transform: scaleY(1.08);
    opacity: 1;
  }
}

/* Desaparición suave */
@keyframes cursorFade {
  0%   { visibility: visible; }
  60%  { visibility: hidden; }
  100% { visibility: visible; }
}

/* Cartas largas: más discreto */
.mensaje-texto.typewriter-cursor::after {
  height: 1.25em;
  box-shadow:
    0 0 4px rgba(255, 122, 168, 0.25),
    0 0 10px rgba(255, 122, 168, 0.15);
  opacity: 0.55;
}

/* Dark mode */
body.dark-mode .typewriter-cursor::after {
  box-shadow:
    0 0 6px rgba(255, 174, 208, 0.35),
    0 0 16px rgba(255, 174, 208, 0.25);
}

/* Móvil: lujo silencioso */
@media (max-width: 768px) {
  .typewriter-cursor::after {
    margin-left: 4px;
    opacity: 0.45;
  }
}
