/* ==============================================================================
   PROYECTO: "PARA BARBI ❤️"
   ESTILOS EN CONCORDANCIA CON LA CARTA FÍSICA (ROSA PASTEL, POLAROIDS Y TERNURA)
   ============================================================================== */

:root {
  /* Paleta cromática idéntica a la carta física */
  --bg-app: #F7B5C6;
  --bg-app-soft: #FCE6EC;
  --paper-bg: #FFF7F9;
  --paper-line: rgba(217, 107, 130, 0.2);
  --paper-border: rgba(232, 145, 166, 0.4);
  
  --primary-rose: #D45B77;
  --primary-deep: #661D2E;
  --accent-gold: #C9A86A;
  --seal-red: #B8334E;
  --seal-shadow: rgba(184, 51, 78, 0.4);

  --text-body: #3B2A2E;
  --text-muted: #73535B;
  --text-light: #A38088;

  --tape-color: rgba(255, 230, 238, 0.85);

  /* Tipografías */
  --font-serif: 'Cormorant Garamond', 'Playfair Display', Georgia, serif;
  --font-hand: 'Marck Script', 'Caveat', cursive;
  --font-sans: 'Plus Jakarta Sans', -apple-system, sans-serif;

  /* Sombras suaves */
  --shadow-letter: 0 18px 45px rgba(102, 29, 46, 0.12), 0 3px 10px rgba(102, 29, 46, 0.05);
  --shadow-polaroid: 0 12px 30px rgba(70, 30, 40, 0.15);
  --shadow-seal: 0 8px 22px var(--seal-shadow);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-serif);
  background-color: var(--bg-app-soft);
  background-image: 
    radial-gradient(circle at 10% 15%, rgba(247, 181, 198, 0.6) 0%, transparent 50%),
    radial-gradient(circle at 90% 85%, rgba(251, 194, 208, 0.7) 0%, transparent 50%);
  color: var(--text-body);
  line-height: 1.85;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Lienzo sutil de pétalos flotantes */
#petals-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* Destello suave al tocar la pantalla */
.touch-petal {
  position: fixed;
  pointer-events: none;
  z-index: 999;
  font-size: 18px;
  animation: floatTouch 1s ease-out forwards;
}

@keyframes floatTouch {
  0% {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(0.6) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -80px) scale(1.2) rotate(25deg);
  }
}

/* Contenedor central (optimizado formato móvil 8x8 cm en mano) */
.app-container {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: 1.25rem 1rem 5rem;
}

/* ==============================================================================
   1. PANTALLA INICIAL: SOBRE EN CONCORDANCIA CON LA CARTA FÍSICA
   ============================================================================== */
.envelope-screen {
  min-height: 85vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.envelope-screen.is-hidden {
  display: none;
  opacity: 0;
}

.envelope-card {
  width: 100%;
  max-width: 360px;
  background: var(--paper-bg);
  border: 1px solid var(--paper-border);
  border-radius: 20px;
  padding: 3.5rem 1.8rem 2.8rem;
  box-shadow: 0 20px 45px rgba(102, 29, 46, 0.14);
  position: relative;
  cursor: pointer;
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.4s ease;
}

.envelope-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 26px 55px rgba(102, 29, 46, 0.2);
}

/* Borde pespunteado delicado como el marco de la carta */
.envelope-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 20px;
  border: 1.5px dashed rgba(212, 91, 119, 0.35);
  pointer-events: none;
  margin: 8px;
}

.envelope-title {
  font-family: var(--font-hand);
  font-size: 3.2rem;
  color: var(--primary-deep);
  margin-bottom: 0.75rem;
  letter-spacing: 0.5px;
  line-height: 1.1;
}

.envelope-subtitle {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-style: italic;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 2rem;
  padding: 0 0.5rem;
}

/* Sello de cera en relieve */
.wax-seal {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #D44E6D 0%, var(--seal-red) 70%, #6E1A2C 100%);
  box-shadow: var(--shadow-seal), inset 0 2px 5px rgba(255, 255, 255, 0.4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #FFF2F4;
  margin: 0 auto 1.5rem;
  cursor: pointer;
  position: relative;
  transition: transform 0.3s ease;
  border: none;
}

.wax-seal::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  bottom: 6px;
  border-radius: 50%;
  border: 1.5px dashed rgba(255, 255, 255, 0.35);
}

.wax-seal svg {
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
}

.envelope-card:hover .wax-seal {
  transform: scale(1.08);
}

.envelope-hint {
  font-family: var(--font-sans);
  font-size: 0.92rem;
  color: var(--primary-rose);
  font-weight: 500;
  letter-spacing: 0.2px;
}

/* ==============================================================================
   2. REPRODUCTOR DISCRETO SUPERIOR (OPCIONAL, SIN AUTOPLAY)
   ============================================================================== */
.top-music-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.music-toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(212, 91, 119, 0.25);
  padding: 0.45rem 1.1rem;
  border-radius: 9999px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--primary-deep);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(102, 29, 46, 0.08);
  transition: all 0.3s ease;
}

.music-toggle-pill:hover {
  background: #FFFFFF;
  border-color: var(--primary-rose);
  transform: scale(1.03);
}

.music-toggle-pill svg {
  width: 14px;
  height: 14px;
  color: var(--primary-rose);
}

.music-toggle-pill.is-playing {
  background: #FFF0F4;
  border-color: var(--primary-rose);
}

/* ==============================================================================
   3. LA CARTA DE PAPEL (DESPLIEGUE CONTINUO Y TIERNO)
   ============================================================================== */
.letter-screen {
  display: none;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.letter-screen.is-visible {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.letter-sheet {
  background: var(--paper-bg);
  border-radius: 16px;
  padding: 3.2rem 1.8rem 4rem;
  box-shadow: var(--shadow-letter);
  border: 1px solid var(--paper-border);
  position: relative;
}

/* Marco interior con pespunte */
.letter-sheet::before {
  content: '';
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  bottom: 14px;
  border: 1.5px dashed rgba(212, 91, 119, 0.2);
  border-radius: 12px;
  pointer-events: none;
}

.letter-salutation {
  font-family: var(--font-serif);
  font-size: 2.3rem;
  font-weight: 600;
  font-style: italic;
  color: var(--primary-deep);
  margin-bottom: 2rem;
  letter-spacing: 0.5px;
}

.letter-p {
  font-family: var(--font-serif);
  font-size: 1.18rem;
  line-height: 1.95;
  color: var(--text-body);
  margin-bottom: 1.6rem;
  text-align: justify;
  text-justify: inter-word;
}

.letter-p:last-of-type {
  margin-bottom: 2rem;
}

/* Línea de trayectoria punteada como en el reverso de la carta */
.memory-dashed-path {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
  color: var(--primary-rose);
  opacity: 0.6;
}

.memory-dashed-path::before,
.memory-dashed-path::after {
  content: '';
  flex: 1;
  border-bottom: 1.5px dashed var(--primary-rose);
}

/* ==============================================================================
   4. POLAROIDS INTERACTIVAS CON VOLTEO 3D (REVERSO CON DEDICATORIA)
   ============================================================================== */
.photo-memory-block {
  margin: 2.5rem auto 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  perspective: 1200px;
}

.polaroid-frame-wrapper {
  position: relative;
  max-width: 290px;
  width: 100%;
}

.polaroid-tape {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 72px;
  height: 22px;
  background: var(--tape-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  border-radius: 2px;
  opacity: 0.9;
  z-index: 10;
  pointer-events: none;
}

.polaroid-card-3d {
  width: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.polaroid-card-3d.is-flipped {
  transform: rotateY(180deg) !important;
}

/* Cara frontal (Foto) */
.polaroid-front, .polaroid-back {
  background: #FFFFFF;
  padding: 12px 12px 18px 12px;
  border-radius: 4px;
  box-shadow: var(--shadow-polaroid);
  border: 1px solid rgba(0, 0, 0, 0.06);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  position: relative;
}

.polaroid-image-box {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #FCE6EC;
  overflow: hidden;
  border-radius: 2px;
  margin-bottom: 10px;
}

.polaroid-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.polaroid-note {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-style: italic;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.45;
  padding: 0 4px;
}

.polaroid-flip-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  color: var(--primary-rose);
  margin-top: 6px;
  opacity: 0.85;
}

/* Cara trasera (Dedicatoria manuscrita íntima) */
.polaroid-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: rotateY(180deg);
  background: #FFFDF9;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem 1.5rem;
}

.polaroid-back::before {
  content: '';
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  bottom: 10px;
  border: 1px dashed rgba(212, 91, 119, 0.25);
  border-radius: 2px;
}

.polaroid-back-text {
  font-family: var(--font-hand);
  font-size: 1.55rem;
  color: var(--primary-deep);
  line-height: 1.45;
  margin-bottom: 1rem;
}

.polaroid-back-heart {
  font-size: 1.3rem;
  color: var(--primary-rose);
}

.polaroid-zoom-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(212, 91, 119, 0.3);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-deep);
  cursor: pointer;
  z-index: 5;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease;
}

.polaroid-zoom-btn:hover {
  transform: scale(1.1);
}

.polaroid-zoom-btn svg {
  width: 16px;
  height: 16px;
}

/* ==============================================================================
   5. POSDATA INTERACTIVA (DOBLADA Y DESPLEGABLE)
   ============================================================================== */
.postscript-container {
  margin-top: 2.5rem;
  text-align: center;
}

.postscript-folded-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #FFEBF1;
  border: 1px dashed var(--primary-rose);
  border-radius: 8px;
  padding: 0.75rem 1.4rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(212, 91, 119, 0.1);
}

.postscript-folded-badge:hover {
  background: #FDE0EA;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(212, 91, 119, 0.18);
}

.postscript-badge-text {
  font-family: var(--font-hand);
  font-size: 1.45rem;
  color: var(--primary-deep);
}

.postscript-badge-icon {
  color: var(--primary-rose);
  transition: transform 0.3s ease;
}

.postscript-content {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.6s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.5s ease, margin 0.5s ease;
  background: #FFFBF8;
  border-radius: 8px;
  border: 1px solid rgba(212, 91, 119, 0.2);
  margin-top: 0;
  padding: 0 1.25rem;
  box-shadow: 0 4px 14px rgba(102, 29, 46, 0.06);
}

.postscript-container.is-open .postscript-content {
  max-height: 200px;
  opacity: 1;
  margin-top: 1rem;
  padding: 1.35rem;
}

.postscript-container.is-open .postscript-badge-icon {
  transform: rotate(180deg);
}

.postscript-text {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-style: italic;
  color: var(--primary-deep);
  line-height: 1.7;
}

/* ==============================================================================
   6. CIERRE, FIRMA Y FECHA (23.04)
   ============================================================================== */
.letter-closing {
  margin-top: 2.5rem;
  text-align: right;
  padding-right: 0.5rem;
}

.closing-line {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-style: italic;
  color: var(--primary-deep);
  margin-bottom: 0.4rem;
}

.letter-signature {
  font-family: var(--font-hand);
  font-size: 2.6rem;
  color: var(--primary-rose);
  margin-top: 0.8rem;
  line-height: 1.2;
}

.letter-special-date {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  letter-spacing: 1px;
  color: var(--accent-gold);
  margin-top: 0.4rem;
  font-weight: 600;
}

.letter-restart-wrap {
  text-align: center;
  margin-top: 3.5rem;
}

.btn-restart-letter {
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-light);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 4px;
  transition: color 0.2s ease;
}

.btn-restart-letter:hover {
  color: var(--primary-rose);
}

/* ==============================================================================
   7. VISOR LIGHTBOX PARA VER FOTOS AMPLIADAS
   ============================================================================== */
.lightbox-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(35, 20, 25, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 1.25rem;
}

.lightbox-modal.is-active {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-content {
  background: #FFFFFF;
  padding: 1rem 1rem 1.4rem;
  border-radius: 8px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
  position: relative;
  transform: scale(0.94);
  transition: transform 0.3s ease;
}

.lightbox-modal.is-active .lightbox-content {
  transform: scale(1);
}

.lightbox-img-wrapper {
  width: 100%;
  max-height: 70vh;
  overflow: hidden;
  border-radius: 4px;
}

.lightbox-img {
  width: 100%;
  height: auto;
  max-height: 65vh;
  object-fit: contain;
  display: block;
}

.lightbox-caption {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-style: italic;
  color: var(--text-body);
  text-align: center;
  margin-top: 1rem;
}

.lightbox-close-btn {
  position: absolute;
  top: -45px;
  right: 0;
  background: transparent;
  border: none;
  color: #FFFFFF;
  cursor: pointer;
  padding: 6px;
}

.lightbox-close-btn svg {
  width: 28px;
  height: 28px;
}
