/* ============================================================
   INTRO — carta (máquina de escribir) + contador de meses
   ============================================================ */

/* Utilidad para mostrar/ocultar con desvanecido
   (sin visibility para que el fundido funcione al entrar y al salir) */
.oculto {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ---------------- Carta sobre fondo negro ---------------- */
.carta-overlay {
  z-index: 5;
  background: #000;
  flex-direction: column;
  gap: 1.5rem;
  transition: opacity 1.2s ease;
}

.carta-marco {
  max-width: 720px;
  max-height: 74vh;
  overflow-y: auto;
  padding: 1rem 1.6rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(159, 208, 255, 0.4) transparent;
}
.carta-marco::-webkit-scrollbar { width: 6px; }
.carta-marco::-webkit-scrollbar-thumb {
  background: rgba(159, 208, 255, 0.35);
  border-radius: 6px;
}

.carta-texto {
  font-family: "Kalam", "Patrick Hand", cursive;
  font-size: clamp(1.05rem, 3.2vw, 1.5rem);
  line-height: 1.85;
  color: #eaf2ff;
  white-space: pre-wrap;
  text-align: left;
  text-shadow: 0 0 18px rgba(120, 170, 255, 0.25);
}

/* Cursor parpadeante al final del texto */
.carta-texto.escribiendo::after {
  content: "▌";
  color: #9fd0ff;
  margin-left: 2px;
  animation: parpadeo 1s steps(1) infinite;
}

@keyframes parpadeo {
  50% { opacity: 0; }
}

.carta-skip {
  position: fixed;
  bottom: 5%;
  right: 6%;
  padding: 0.5rem 1.2rem;
  border: 1px solid rgba(159, 208, 255, 0.4);
  border-radius: 40px;
  background: rgba(255, 255, 255, 0.06);
  color: #cfe2ff;
  font-family: "Poppins", sans-serif;
  font-size: 0.85rem;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background 0.3s ease;
}
.carta-skip:hover { background: rgba(255, 255, 255, 0.16); }

/* ---------------- Contador de meses ---------------- */
#contador {
  z-index: 5;
  flex-direction: column;
  gap: 0.2rem;
  transition: opacity 1s ease;
}

.contador-corazon {
  font-size: clamp(2rem, 7vw, 3.2rem);
  color: #ff5b8a;
  text-shadow: 0 0 26px rgba(255, 91, 138, 0.7);
  animation: latir 1.1s ease-in-out infinite;
}

.contador-num {
  font-family: "Pacifico", cursive;
  font-size: clamp(6rem, 26vw, 15rem);
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 40px rgba(120, 180, 255, 0.7),
    0 0 90px rgba(80, 140, 255, 0.4);
}

.contador-num span {
  display: inline-block;
}

.contador-num span.cambia {
  animation: saltoNum 0.9s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.contador-label {
  font-family: "Amatic SC", cursive;
  font-weight: 700;
  font-size: clamp(2rem, 9vw, 4rem);
  letter-spacing: 8px;
  color: #cfe2ff;
  text-shadow: 0 0 24px rgba(120, 180, 255, 0.5);
}

@keyframes saltoNum {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.7) rotate(-6deg); filter: brightness(1.6); }
  100% { transform: scale(1) rotate(0); }
}

@keyframes latir {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

/* ---------------- Navegación del libro ---------------- */
.nav-flecha {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 6;
  width: 46px;
  height: 72px;
  border: none;
  background: transparent;
  color: rgba(255, 232, 205, 0.8);
  font-size: 3rem;
  line-height: 1;
  cursor: pointer;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.85);
  transition: color 0.2s ease, transform 0.2s ease;
  opacity: 0;
  animation: aparecerNav 1s ease 0.8s forwards;
}
.nav-flecha:hover { color: #fff; transform: translateY(-50%) scale(1.25); }
.nav-flecha.izq { left: 3%; }
.nav-flecha.der { right: 3%; }
.nav-flecha.der { animation-name: aparecerNavDer; }

@keyframes aparecerNav {
  to { opacity: 1; transform: translateY(-50%) translateX(0); }
}
@keyframes aparecerNavDer {
  from { opacity: 0; transform: translateY(-50%) translateX(10px); }
  to { opacity: 1; transform: translateY(-50%) translateX(0); }
}

.nav-hint {
  position: fixed;
  bottom: 4%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  color: rgba(255, 217, 168, 0.7);
  font-family: "Patrick Hand", cursive;
  font-size: 0.95rem;
  letter-spacing: 1px;
  pointer-events: none;
  animation: pulsarHint 2.4s ease-in-out infinite;
}
@keyframes pulsarHint {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.9; }
}

/* Botón para agregar una aventura (solo visible con el libro) */
#adminLink {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 8;
  width: 50px;
  height: 50px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 217, 168, 0.4);
  border-radius: 50%;
  background: rgba(40, 24, 16, 0.7);
  color: #ffd9a8;
  font-size: 1.7rem;
  cursor: pointer;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.25s ease, background 0.25s ease;
}
body.viendo-libro #adminLink { display: flex; }
#adminLink:hover { transform: scale(1.1) rotate(90deg); background: rgba(60, 40, 24, 0.9); }

/* ============================================================
   Romper el "2" (contador)
   ============================================================ */
.contador-num { position: relative; }
.shard {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  color: #fff;
  text-shadow: 0 0 30px rgba(120, 180, 255, 0.7);
  will-change: transform, opacity;
  pointer-events: none;
}
.contador-num span.aparece {
  animation: aparece3 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes aparece3 {
  0% { transform: scale(0.2) rotate(-30deg); opacity: 0; filter: brightness(2.5); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* ============================================================
   Login
   ============================================================ */
#login { z-index: 9; background: rgba(0, 0, 0, 0.55); }
.login-caja {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  width: min(90vw, 360px);
  padding: 2.2rem 1.8rem;
  background: rgba(20, 26, 40, 0.85);
  border: 1px solid rgba(120, 160, 255, 0.25);
  border-radius: 20px;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.login-corazon {
  font-size: 2.2rem;
  color: #ff5b8a;
  text-shadow: 0 0 24px rgba(255, 91, 138, 0.7);
}
.login-titulo {
  font-family: "Pacifico", cursive;
  font-size: 1.9rem;
  color: #fff;
}
.login-sub {
  font-family: "Patrick Hand", cursive;
  color: #b9cdf0;
  font-size: 0.9rem;
  margin-bottom: 0.6rem;
  text-align: center;
}
.login-input {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(120, 160, 255, 0.3);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  color: #1a2238;
  font-family: "Poppins", sans-serif;
  font-size: 1rem;
}
.login-input:focus { outline: none; border-color: #4a86ff; }
.login-btn {
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.8rem;
  border: none;
  border-radius: 40px;
  background: linear-gradient(135deg, #3a86ff, #4d9bff);
  color: #fff;
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(58, 134, 255, 0.45);
  transition: transform 0.15s ease;
}
.login-btn:hover { transform: translateY(-2px); }
.login-msg { min-height: 1.2em; color: #ff9bb0; font-size: 0.85rem; font-family: "Poppins", sans-serif; }
.login-caja.error { animation: temblar 0.4s; }
@keyframes temblar {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

/* ============================================================
   Aviso de girar el teléfono
   ============================================================ */
#rotar {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  background: #0a0e18;
  text-align: center;
  padding: 2rem;
}
.rotar-tel {
  font-size: 4.5rem;
  animation: girarTel 2s ease-in-out infinite;
}
.rotar-texto {
  font-family: "Pacifico", cursive;
  font-size: 1.8rem;
  color: #fff;
}
.rotar-sub {
  font-family: "Patrick Hand", cursive;
  color: #b9cdf0;
  font-size: 1rem;
}
.rotar-auto {
  margin-top: 0.4rem;
  font-family: "Patrick Hand", cursive;
  color: rgba(185, 205, 240, 0.65);
  font-size: 0.85rem;
}
@keyframes girarTel {
  0%, 40% { transform: rotate(0); }
  60%, 100% { transform: rotate(90deg); }
}
/* Lo controla JS (temporizador de 6s y rotación del teléfono) */
body.rotar-activo #rotar { display: flex; }

/* ============================================================
   Formulario emergente (modal)
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.65);
  transition: opacity 0.3s ease;
}
.modal-caja {
  position: relative;
  width: min(94vw, 560px);
  max-height: 92vh;
  overflow-y: auto;
  background: #fbf3e2;
  color: #3a2a18;
  border-radius: 18px;
  padding: 1.8rem;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}
.modal-cerrar {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  color: #6a4a2a;
  font-size: 1.1rem;
  cursor: pointer;
}
.modal-cerrar:hover { background: rgba(0, 0, 0, 0.18); }
.modal-titulo { font-family: "Caveat", cursive; font-size: 2.2rem; color: #8a5a2b; }
.modal-sub { color: #9a7b5b; font-size: 0.85rem; margin-bottom: 1rem; font-family: "Poppins", sans-serif; }
#formNueva label { display: block; font-family: "Poppins", sans-serif; font-weight: 600; font-size: 0.85rem; margin: 0.9rem 0 0.3rem; }
#formNueva input, #formNueva textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid #d8c3a0;
  border-radius: 10px;
  font-family: "Poppins", sans-serif;
  font-size: 1rem;
  background: #fff;
  color: #3a2a18;
}
#formNueva input:focus, #formNueva textarea:focus { outline: none; border-color: #c2683b; }
#formNueva textarea { resize: vertical; min-height: 80px; }
.modal-fila { display: flex; gap: 1rem; }
.modal-fila > div { flex: 1; }
.modal-archivos {
  border: 2px dashed #d8b58f;
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  background: #fff8ec;
  cursor: pointer;
  font-family: "Poppins", sans-serif;
  font-size: 0.9rem;
}
.modal-preview { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 0.7rem; }
.media-item { display: flex; flex-direction: column; gap: 4px; width: 92px; }
.media-item img, .media-item video {
  width: 92px; height: 92px; object-fit: cover; border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); background: #000;
}
#formNueva .media-detalle {
  width: 92px;
  padding: 5px 7px;
  font-size: 0.72rem;
  border-radius: 6px;
}
.modal-enviar {
  width: 100%;
  margin-top: 1.4rem;
  padding: 0.9rem;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, #c2683b, #d9824e);
  color: #fff;
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(194, 104, 59, 0.4);
  transition: transform 0.15s ease;
}
.modal-enviar:hover { transform: translateY(-2px); }
.modal-enviar:disabled { opacity: 0.6; transform: none; cursor: default; }
.modal-msg { margin-top: 0.8rem; text-align: center; font-weight: 600; min-height: 1.3em; font-family: "Poppins", sans-serif; }
.modal-msg.ok { color: #4f7d52; }
.modal-msg.err { color: #c2402b; }

/* Móvil: que nada se distorsione */
@media (max-width: 440px) {
  .modal-fila { flex-direction: column; gap: 0; }
  .modal-caja { padding: 1.3rem; }
  .nav-flecha { width: 46px; height: 46px; font-size: 1.6rem; }
}

/* ============================================================
   Animación de guardado con éxito
   ============================================================ */
.exito {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 24, 0.72);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
.exito.activo { display: flex; }

.exito-caja {
  position: relative;
  background: #fff;
  border-radius: 22px;
  padding: 2.4rem 2.8rem 2rem;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  animation: exitoPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.exito-check { width: 96px; height: 96px; display: block; margin: 0 auto; }
.exito-circulo {
  stroke: #43c06a;
  stroke-width: 3;
  stroke-dasharray: 151;
  stroke-dashoffset: 151;
  animation: dibujarCirculo 0.5s ease forwards;
}
.exito-tic {
  stroke: #43c06a;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: dibujarTic 0.35s 0.45s ease forwards;
}
.exito-texto {
  font-family: "Caveat", cursive;
  font-weight: 700;
  font-size: 2rem;
  color: #2e7d4f;
  margin-top: 0.6rem;
}
.exito-sub {
  font-family: "Patrick Hand", cursive;
  color: #8a7a68;
  font-size: 1rem;
}

/* corazones que flotan */
.exito-corazones { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.exito-corazones span {
  position: absolute;
  bottom: 20%;
  color: #ff5b8a;
  font-size: 1.2rem;
  opacity: 0;
  animation: flotarCorazon 1.6s ease-out forwards;
}
.exito-corazones span:nth-child(1) { left: 18%; animation-delay: 0.5s; }
.exito-corazones span:nth-child(2) { left: 38%; animation-delay: 0.75s; font-size: 1.6rem; }
.exito-corazones span:nth-child(3) { left: 60%; animation-delay: 0.6s; }
.exito-corazones span:nth-child(4) { left: 80%; animation-delay: 0.85s; font-size: 1.4rem; }

@keyframes exitoPop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes dibujarCirculo { to { stroke-dashoffset: 0; } }
@keyframes dibujarTic { to { stroke-dashoffset: 0; } }
@keyframes flotarCorazon {
  0% { opacity: 0; transform: translateY(0) scale(0.6); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-90px) scale(1.1); }
}
