/* ============================================================
   Carta para ti — estilos
   Paleta: Crepúsculo frío (lila · azul grisáceo · blanco · negro)
   ============================================================ */

:root {
  /* Colores principales — Crepúsculo frío */
  --lila-bebe: #bca9e6;
  --lila-suave: #c7d0ec;
  --lila-fuerte: #8f7fb8;
  --lila-profundo: #6b6296;
  --lavanda: #9aa6d4;
  --blanco: #ffffff;
  --negro: #0f1320;
  --negro-2: #1a1830;

  /* Cristal (glassmorphism) */
  --glass-bg: rgba(255, 255, 255, 0.07);
  --glass-bg-strong: rgba(255, 255, 255, 0.11);
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);

  /* Texto */
  --txt: #e8e9f5;
  --txt-dim: rgba(232, 233, 245, 0.72);

  /* Tipografías */
  --font-ui: "Quicksand", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-hand: "Dancing Script", "Segoe Script", cursive;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--txt);
  background: radial-gradient(120% 120% at 50% 0%, #1a1830 0%, var(--negro) 55%, #07060f 100%);
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  position: relative;
  display: grid;
  place-items: center;
  padding: 20px;
}

/* ============================================================
   Fondo: círculos difusos (blobs)
   ============================================================ */
.background {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  will-change: transform;
  mix-blend-mode: screen;
}

.blob-1 {
  width: 46vmax;
  height: 46vmax;
  background: var(--lila-fuerte);
  top: -12vmax;
  left: -10vmax;
  animation: drift1 26s ease-in-out infinite alternate;
}

.blob-2 {
  width: 38vmax;
  height: 38vmax;
  background: var(--lila-profundo);
  bottom: -14vmax;
  right: -8vmax;
  animation: drift2 32s ease-in-out infinite alternate;
}

.blob-3 {
  width: 30vmax;
  height: 30vmax;
  background: var(--lavanda);
  top: 35%;
  left: 55%;
  opacity: 0.4;
  animation: drift3 28s ease-in-out infinite alternate;
}

.blob-4 {
  width: 26vmax;
  height: 26vmax;
  background: var(--lila-bebe);
  bottom: 8%;
  left: 12%;
  animation: drift4 30s ease-in-out infinite alternate;
}

.blob-5 {
  width: 22vmax;
  height: 22vmax;
  background: #c7d0ec;
  opacity: 0.22;
  top: 8%;
  right: 18%;
  animation: drift5 34s ease-in-out infinite alternate;
}

@keyframes drift1 {
  to { transform: translate(14vmax, 10vmax) scale(1.15); }
}
@keyframes drift2 {
  to { transform: translate(-12vmax, -8vmax) scale(1.1); }
}
@keyframes drift3 {
  to { transform: translate(-16vmax, 6vmax) scale(0.85); }
}
@keyframes drift4 {
  to { transform: translate(10vmax, -12vmax) scale(1.2); }
}
@keyframes drift5 {
  to { transform: translate(-8vmax, 12vmax) scale(1.1); }
}

/* ============================================================
   Partículas (canvas)
   ============================================================ */
#particles {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* ============================================================
   Pantallas
   ============================================================ */
.screen {
  position: relative;
  z-index: 2;
  width: 100%;
  display: grid;
  place-items: center;
}

.hidden {
  display: none !important;
}

/* ============================================================
   Tarjeta de cristal (glassmorphism)
   ============================================================ */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: 28px;
  box-shadow: var(--glass-shadow), inset 0 1px 1px rgba(255, 255, 255, 0.16);
  position: relative;
  overflow: hidden;
}

/* Brillo superior sutil */
.glass-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.14), transparent 40%);
  pointer-events: none;
}

/* ============================================================
   Tarjeta de contraseña
   ============================================================ */
.lock-card {
  width: min(420px, 100%);
  padding: 44px 34px 34px;
  text-align: center;
  animation: cardIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.lock-icon {
  width: 76px;
  height: 76px;
  margin: 0 auto 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--lila-bebe);
  background: rgba(188, 169, 230, 0.12);
  border: 1px solid rgba(188, 169, 230, 0.3);
  box-shadow: 0 0 30px rgba(143, 127, 184, 0.4);
}

.lock-icon svg {
  width: 38px;
  height: 38px;
}

.lock-icon .lock-open {
  display: none;
}

.lock-icon.unlocked .lock-closed {
  display: none;
}

.lock-icon.unlocked .lock-open {
  display: block;
  animation: pop 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.lock-title {
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: 2.5rem;
  line-height: 1.1;
  margin-bottom: 8px;
  background: linear-gradient(120deg, #ffffff, var(--lila-bebe));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.lock-subtitle {
  color: var(--txt-dim);
  font-size: 0.95rem;
  margin-bottom: 26px;
  line-height: 1.5;
}

/* ===== Formulario ===== */
.input-wrap {
  position: relative;
  margin-bottom: 14px;
}

#passwordInput {
  width: 100%;
  padding: 15px 48px 15px 18px;
  font-family: var(--font-ui);
  font-size: 1rem;
  color: var(--txt);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}

#passwordInput::placeholder {
  color: rgba(232, 233, 245, 0.42);
}

#passwordInput:focus {
  border-color: var(--lila-bebe);
  background: rgba(255, 255, 255, 0.09);
  box-shadow: 0 0 0 4px rgba(143, 127, 184, 0.28);
}

.toggle-visibility {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  color: var(--txt-dim);
  cursor: pointer;
  border-radius: 10px;
  transition: color 0.2s, background 0.2s;
}

.toggle-visibility:hover {
  color: var(--lila-bebe);
  background: rgba(255, 255, 255, 0.06);
}

.toggle-visibility svg {
  width: 20px;
  height: 20px;
}

.toggle-visibility .eye-off {
  display: none;
}

.toggle-visibility.show .eye {
  display: none;
}

.toggle-visibility.show .eye-off {
  display: block;
}

.btn-unlock {
  width: 100%;
  padding: 15px 18px;
  font-family: var(--font-ui);
  font-size: 1.02rem;
  font-weight: 600;
  color: #1e1a33;
  background: linear-gradient(120deg, var(--lila-suave), var(--lila-bebe) 55%, var(--lila-fuerte));
  border: none;
  border-radius: 16px;
  cursor: pointer;
  letter-spacing: 0.2px;
  box-shadow: 0 10px 26px rgba(107, 98, 150, 0.45);
  transition: transform 0.18s ease, box-shadow 0.25s ease, filter 0.2s;
}

.btn-unlock:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(107, 98, 150, 0.6);
  filter: brightness(1.05);
}

.btn-unlock:active {
  transform: translateY(0) scale(0.99);
}

.hint {
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--txt-dim);
  font-style: italic;
}

.error {
  margin-top: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #e3a0bd;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.25s, transform 0.25s;
  min-height: 1.1em;
}

.error.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Sacudida en error */
.shake {
  animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* ============================================================
   La carta
   ============================================================ */
.letter-card {
  width: min(580px, 100%);
  max-height: min(86vh, 760px);
  padding: 8px;
  animation: letterIn 0.8s cubic-bezier(0.22, 1, 0.36, 1) both;
  background: var(--glass-bg-strong);
}

.close-letter {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--txt);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.close-letter:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: rotate(90deg);
}

.close-letter svg {
  width: 20px;
  height: 20px;
}

.letter-scroll {
  max-height: calc(min(86vh, 760px) - 16px);
  overflow-y: auto;
  padding: 40px 38px 36px;
  text-align: left;
}

/* Scrollbar estilizada */
.letter-scroll::-webkit-scrollbar {
  width: 8px;
}
.letter-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.letter-scroll::-webkit-scrollbar-thumb {
  background: rgba(188, 169, 230, 0.4);
  border-radius: 99px;
}
.letter-scroll {
  scrollbar-width: thin;
  scrollbar-color: rgba(188, 169, 230, 0.4) transparent;
}

.letter-date {
  font-size: 0.82rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--txt-dim);
  margin-bottom: 6px;
}

.letter-greeting {
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: 2.3rem;
  line-height: 1.15;
  margin-bottom: 22px;
  color: var(--lila-bebe);
}

.letter-body p {
  font-size: 1.06rem;
  line-height: 1.85;
  margin-bottom: 16px;
  color: var(--txt);
  /* aparición escalonada */
  opacity: 0;
  transform: translateY(14px);
}

.letter-body p.reveal {
  animation: lineIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.letter-signature {
  margin-top: 26px;
  font-size: 1rem;
  color: var(--txt-dim);
  line-height: 1.6;
}

.letter-signature span {
  font-family: var(--font-hand);
  font-size: 1.9rem;
  color: var(--lila-bebe);
}

.letter-hearts {
  text-align: center;
  font-size: 1.5rem;
  margin-top: 22px;
  color: var(--lila-bebe);
  animation: twinkle 3.2s ease-in-out infinite;
}

/* ============================================================
   Animaciones
   ============================================================ */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes letterIn {
  from { opacity: 0; transform: translateY(40px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes lineIn {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}

@keyframes pop {
  0%   { transform: scale(0.4); opacity: 0; }
  60%  { transform: scale(1.18); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes twinkle {
  0%, 100% { opacity: 0.45; transform: scale(0.95); }
  50%      { opacity: 1; transform: scale(1.12); }
}

/* Fundido al salir (para la transición lock -> carta) */
.fade-out {
  animation: fadeOut 0.5s ease forwards;
}

@keyframes fadeOut {
  to { opacity: 0; transform: scale(0.94); }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 480px) {
  .lock-card { padding: 36px 24px 28px; }
  .lock-title { font-size: 2.1rem; }
  .letter-scroll { padding: 34px 24px 30px; }
  .letter-greeting { font-size: 2rem; }
  .letter-body p { font-size: 1rem; }
}

/* Respeto por quienes prefieren menos movimiento */
@media (prefers-reduced-motion: reduce) {
  .blob { animation: none; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
