/* --- 1. Configuración de Escena --- */
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at center, #050525 0%, #000 100%);
  overflow-x: hidden;
  font-family: "Arial Rounded MT Bold", "Helvetica", sans-serif;
  color: white;
}

/* Oscurecer el fondo cuando hay zoom (opcional pero recomendado) */
body.modal-open::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;

  z-index: 999;
}

/* Cuando una foto tiene zoom, el contenido central se desvanece */
body.modal-open .contenedor-principal {
  opacity: 0.3; /* Nivel de transparencia (0.2 es casi invisible) */
  filter: blur(4px); /* Opcional: añade un desenfoque para más profundidad */
  transition: all 0.5s ease; /* Transición suave */
  pointer-events: none; /* Evita clics accidentales en el botón mientras ves la foto */
}

body.modal-open .carta-overlay {
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
}

canvas {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1;
}

.contenedor-principal {
  position: relative;
  z-index: 10;
  transition: opacity 0.5s ease, filter 0.5s ease; /* Agrega esto */
}

.content-z {
  z-index: 20;
}

/* --- 2. Galería de Fotos (Ajustada) --- */
.galeria-fotos {
  position: fixed;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
}

.foto {
  position: absolute;
  width: 100px; /* Reducido para desktop estándar */
  background: white;
  padding: 8px 8px 20px 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transform: rotate(var(--r));
  transition: opacity 1s ease-in-out; /* Solo animamos la opacidad */
  cursor: zoom-in;
  pointer-events: auto; /* Asegúrate de que esto esté así para detectar el clic */
}

.foto img {
  width: 100%;
  height: 140px;
  object-fit: cover;
}

.foto.zoom img {
  height: auto !important; /* Permite que la imagen mantenga su proporción original */
  filter: brightness(1.1); /* Le da un toque de luz extra cuando se abre */
}

/* Estilos para el efecto de Zoom */
.foto.zoom {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) scale(2.5) rotate(0deg) !important;
  z-index: 5000 !important; /* Por encima de todo */
  width: 200px !important; /* Tamaño al estar ampliada */
  cursor: zoom-out;
  pointer-events: auto !important; /* Permite cerrar al hacer clic */
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8); /* Sombra para que resalte */
}

.foto.zoom::after {
  content: "×"; /* Es el símbolo de multiplicación, se ve mejor que una x */
  position: absolute;
  top: -15px;
  right: -15px;
  width: 35px;
  height: 35px;
  background: #c0392b; /* Color rojo navideño */
  color: white;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 24px;
  font-weight: bold;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  border: 2px solid white;
  z-index: 5001; /* Un nivel arriba de la foto zoom */
  cursor: pointer;
  pointer-events: none; /* Esto hace que el clic pase a través del icono hacia la foto y se cierre */
}

/* Efecto hover para el icono de cerrar */
.foto.zoom:hover::after {
  background: #e74c3c;
  transform: scale(1.1);
  transition: 0.2s;
}

/* --- 3. El Pino (Escalable) --- */
.estrella-superior {
  font-size: 4rem;
  color: #333;
  transition: 0.8s;
  z-index: 20;
}

.pino {
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: scale(0.8); /* Base más pequeña para móviles */
  z-index: 5;
}

@media (min-width: 768px) {
  .pino {
    transform: scale(1);
  }
  .foto {
    width: 130px;
  }
}

.capa {
  width: 0;
  height: 0;
  border-left: solid transparent;
  border-right: solid transparent;
  border-bottom: solid #134e2a;
  position: relative;
  margin-top: -40px;
}

.punta {
  border-left-width: 60px;
  border-right-width: 60px;
  border-bottom-width: 80px;
  z-index: 5;
}
.medio {
  border-left-width: 100px;
  border-right-width: 100px;
  border-bottom-width: 120px;
  z-index: 4;
}
.base {
  border-left-width: 140px;
  border-right-width: 140px;
  border-bottom-width: 160px;
  z-index: 3;
}

.tronco {
  width: 45px;
  height: 40px;
  background: #3d251e;
  border-radius: 0 0 5px 5px;
}

/* --- 4. Elementos y Botón --- */
.luz {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #222;
}

.regalo {
  width: 35px;
  height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.mensaje-alegria {
  font-family: "Georgia", serif;
  font-style: italic;
  font-size: 1rem;
  color: #555;
  transition: 1s;
}

h1 {
  font-size: 1.8rem;
  color: #333;
  transition: 1s;
}

@media (min-width: 768px) {
  h1 {
    font-size: 2.8rem;
  }
  .mensaje-alegria {
    font-size: 1.2rem;
  }
}

.btn-magic {
  padding: 12px 30px;
  font-size: 1rem;
  border: none;
  border-radius: 50px;
  background: #c0392b;
  color: white;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  transition: 0.3s;
}

/* --- 5. Estados Encendido --- */
.encendido .estrella-superior {
  color: #ffed4b;
  filter: drop-shadow(0 0 30px gold);
}

.encendido h1 {
  color: #fff;
  text-shadow: 0 0 15px gold;
}
.encendido .mensaje-alegria {
  color: #f0f0f0;
}
.encendido .foto {
  opacity: 1;
  transform: rotate(var(--r));
}

.adorno {
  position: absolute;
  opacity: 0.2;
  transition: 0.5s;
  filter: grayscale(100%);
}
.encendido .adorno {
  opacity: 1;
  filter: grayscale(0%);
  /*animation: brillar-adorno 1s infinite alternate;*/
}

/* --- AJUSTES DE RESPONSIVIDAD --- */

/* 1. Ajustes para Tablets y Laptops pequeñas (Pantallas menores a 1024px) */
@media (max-width: 1024px) {
  .foto-polaroid {
    width: 100px; /* Fotos un poco más pequeñas */
  }
  .foto-polaroid img {
    height: 150px;
  }
}

/* 2. Ajustes críticos para Celulares (Pantallas menores a 768px) */
@media (max-width: 767px) {
  /* Evitamos que el árbol y texto se vean gigantes */
  h1 {
    font-size: 1.8rem !important;
  }
  .mensaje-alegria {
    font-size: 0.9rem !important;
    padding: 0 20px;
  }

  .estrella-superior {
    margin-bottom: -48px !important; /* Valor negativo para "empujar" el pino hacia arriba */
    position: relative;
    z-index: 25; /* Asegura que la estrella quede por encima de la punta */
    font-size: 4rem !important; /* Un poco más pequeña para que encaje mejor */
  }

  .pino {
    transform: scale(0.7);
    margin: -20px 0;
  }

  /* Reposicionamos las fotos para que NO tapen el centro */
  .galeria-fotos {
    pointer-events: none; /* Para que puedas tocar el botón aunque haya una foto cerca */
  }

  .foto.zoom {
    width: 80% !important; /* Que ocupe el 80% del ancho del celular */
    max-width: 300px; /* Evita que crezca demasiado */
    transform: translate(-50%, -50%) scale(1) rotate(0deg) !important; /* Quitamos el scale(2.5) porque en móvil es demasiado */
    transition: transform 0.3s ease-in-out;
  }

  .foto.zoom::after {
    top: -10px;
    right: -10px;
    width: 30px;
    height: 30px;
    font-size: 20px;
  }

  /* Reducimos el tamaño para que quepan las 8 */
  .foto-polaroid {
    width: 75px !important;
  }
  .foto-polaroid img {
    height: 85px !important;
  }

  /* Distribución en móvil para dejar libre el centro */
  .foto-polaroid:nth-child(1) {
    top: 2% !important;
    left: 10% !important;
  }
  .foto-polaroid:nth-child(2) {
    top: 25% !important;
    left: 5% !important;
  }
  .foto-polaroid:nth-child(3) {
    top: 68% !important;
    left: 8% !important;
  }
  .foto-polaroid:nth-child(4) {
    top: 85% !important;
    left: 25% !important;
  }

  .foto-polaroid:nth-child(5) {
    top: 2% !important;
    right: 10% !important;
  }
  .foto-polaroid:nth-child(6) {
    top: 25% !important;
    right: 12% !important;
  }
  .foto-polaroid:nth-child(7) {
    top: 70% !important;
    right: 8% !important;
  }
  .foto-polaroid:nth-child(8) {
    top: 85% !important;
    right: 25% !important;
  }
}

/* Overlay que no bloquea la vista total */
.carta-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4); /* Fondo muy suave para ver el pino */
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 3000;
}

.carta-pergamino {
  background: rgba(253, 245, 230, 0.85); /* Papel con transparencia */
  padding: 30px;
  width: 85%;
  max-width: 400px;
  border-radius: 15px;
  border: 2px solid gold;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
  position: relative;
  text-align: center;
  animation: none !important; /* Esto fuerza a que ignore cualquier animación externa */
  transform: scale(1) !important; /* Evita que herede escalas de otros lados */
}

.titulo-elegante {
  font-family: "Dancing Script", cursive; /* Fuente elegante */
  color: #c0392b;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
  font-weight: bold;
  margin-bottom: 20px;
}

.cuerpo-carta p {
  color: #2c3e50;
  font-style: italic;
  font-size: 1.1rem;
  line-height: 1.4;
}

.firma {
  margin-top: 20px;
  font-weight: bold;
  font-size: 1.2rem !important;
}

.cerrar-carta {
  position: absolute;
  top: 5px;
  right: 10px;
  background: none;
  border: none;
  font-size: 25px;
  cursor: pointer;
  color: #7f8c8d;
}

/* Animación de entrada */
.carta-overlay.show {
  display: flex;
}

/* Botón para volver a abrir la carta */
.btn-reabrir {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 10px 20px;
  background: rgba(212, 175, 55, 0.9); /* Color dorado */
  color: #fff;
  border: none;
  border-radius: 25px;
  font-weight: bold;
  z-index: 3001;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  display: none; /* Oculto inicialmente */
  animation: bounce 2s infinite;
  transition: transform 0.3s;
}

.btn-reabrir:hover {
  transform: scale(1.1);
  background: #c0392b;
}

/* Solo mostramos el botón si el cuerpo tiene la clase 'encendido' */
.encendido #btn-reabrir-carta {
  display: block;
}

.animar-elemento {
  animation: latido 2s infinite ease-in-out;
}

/* Contenedor para que no estorben los elementos al hacer clic */
.nieve-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Permite hacer clic a través de ellos */
  z-index: 9999;
  overflow: hidden;
}

.copo,
.nochebuena {
  position: absolute;
  top: -50px;
  user-select: none;
  pointer-events: none;
  animation: caer linear infinite;
}

@keyframes caer {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(110vh) rotate(360deg);
    opacity: 0;
  }
}

@keyframes aparecerOpacidad {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes brillar-adorno {
  to {
    transform: scale(1.5);
    text-shadow: 0 0 10px white;
  }
}

@keyframes latido {
  0% {
    transform: scale(1.08);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1.08);
  }
}
