/* Estilos de la Carta Interactiva - Nueva Versión Paso 1: El Botón (Rosadito) */

@import url('https://fonts.googleapis.com/css2?family=Montserrat+Alternates:wght@500&display=swap');

/* Fuente Mona Sans */
@font-face {
  font-family: "Mona Sans";
  src: url("https://assets.codepen.io/64/Mona-Sans.woff2") format("woff2 supports variations"),
       url("https://assets.codepen.io/64/Mona-Sans.woff2") format("woff2-variations");
  font-weight: 100 1000;
}

@property --icon-scale {
  syntax: '<number>';
  initial-value: 0;
  inherits: true;
}

@property --icon-rotation {
  syntax: '<number>';
  initial-value: 0;
  inherits: true;
}

@property --icon-opacity {
  syntax: '<number>';
  initial-value: 0;
  inherits: true;
}

:root {
  --icon-scale: 0;
  --icon-rotation: 0;
  --icon-opacity: 0;

  /* Gama de Dorados Brillantes */
  --color-gold-main: #c5a065;
  --color-gold-light: #e4c896;
  --color-gold-dark: #a08250;
  --color-gold-cream: #fdf5e6;
  --color-gold-shadow: rgba(197, 160, 101, 0.4);
}

.btn-creative-letter {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 1.8rem;
  font-weight: 700; /* Ajustado para GFS Didot */
  color: var(--color-gold-main); /* Texto dorado al inicio */
  position: relative;
  transition: transform .3s ease, color .3s ease;
  font-family: "GFS Didot", serif; /* Fuente elegante del título */
  margin: 40px auto 0;
  display: block;
  text-align: center;
  animation: fadeInUpCreative 0.8s ease-out both; /* Animación de entrada estilo productos */
  --color-mix: color-mix(
        in lch,
        var(--color-gold-main) 60%,
        white
      );
    transition: all 0.3s ease;
}

.btn-creative-letter:before {
  content: "";
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: white; /* Fondo blanco inicial */
  border: 1px solid var(--color-gold-main); /* Borde dorado inicial */
  transform: scale(0.9);
  border-radius: 1e5px;
  transition: all 0.3s ease;
  z-index: 1;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.btn-creative-letter span:nth-child(2) {
  position: relative;
  padding: 0.6em 1.5em;
  width: 100%;
  height: 100%;
  z-index: 5;
  display: block;
  border-radius: 1e5px;
  transition: transform 0.2s ease;
  text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Filtro UNIFICADO para que los 4 corazones sean DORADITOS */
.btn-creative-letter span:before,
.btn-creative-letter span:after {
  filter: sepia(1.2) saturate(500%) hue-rotate(5deg) brightness(1.1) drop-shadow(0 2px 4px rgba(0,0,0,0.2)) !important;
}

.btn-creative-letter span:nth-child(2):before,
.btn-creative-letter span:nth-child(2):after {
  content: "";
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  opacity: var(--icon-opacity);
  transform: scale(var(--icon-scale)) rotate(calc(var(--icon-rotation) * -1deg));
  transition: transform 0.2s ease, opacity .2s ease, --icon-rotation 0.4s cubic-bezier(.02,1.02,.67,1.06);
  pointer-events: none;
  z-index: -1;
}

.btn-creative-letter span:nth-child(2):before {
  width: 2.1em;
  top: -1.2em;
  left: -1.2em;
  background: url(https://assets.codepen.io/64/heart+%286%29+%281%29.png) no-repeat center center / contain;
}

.btn-creative-letter span:nth-child(2):after {
  width: 1.4em;
  top: 1.3em;
  left: -0.6em;
  background: url(https://assets.codepen.io/64/heart+%285%29+%281%29.png) no-repeat center center / contain;
}

.btn-creative-letter span:nth-child(1) {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background: transparent;
  z-index: 2;
}

.btn-creative-letter span:nth-child(1):before,
.btn-creative-letter span:nth-child(1):after {
  content: "";
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  right: 0;
  opacity: var(--icon-opacity);
  transform: scale(var(--icon-scale)) rotate(calc(var(--icon-rotation) * -1deg));
  transition: transform 0.2s ease, opacity .2s ease, --icon-rotation 0.4s cubic-bezier(.02,1.02,.67,1.06);
  pointer-events: none;
}

.btn-creative-letter span:nth-child(1):before {
  width: 1.75em;
  top: -1.2em;
  right: 0.2em;
  background: url(https://assets.codepen.io/64/heart+%283%29+%281%29.png) no-repeat center center / contain;
}

.btn-creative-letter span:nth-child(1):after {
  width: 2em;
  top: 1.2em;
  right: -0.8em;
  background: url(https://assets.codepen.io/64/heart+%284%29+%281%29.png) no-repeat center center / contain;
}

.btn-creative-letter:hover {
  --icon-scale: 1.1;
  --icon-rotation: 15;
  --icon-opacity: 1;
  color: white; /* Texto blanco en hover */
}

.btn-creative-letter:hover:before {
  transform: scale(1.05);
  background: linear-gradient(
    to bottom right,
    var(--color-gold-main),
    var(--color-gold-light)
  );
  border: 0; /* Eliminado el borde para la animación */
  box-shadow: 0 6px 20px var(--color-gold-shadow);
}

.btn-creative-letter:hover span:nth-child(2) {
  transform: scale(0.95);
}

.btn-creative-letter:active {
  transform: scale(1.05);
}

.btn-creative-letter:active:before {
  box-shadow: 0 2px 12px var(--color-hot-pink);
  transform: scale(0.95);
}

.btn-creative-letter:active {
  --icon-scale: 0.8;
  --icon-rotation: 20;
}

.btn-creative-letter:active span:nth-child(odd):before,
.btn-creative-letter:active span:nth-child(even):before {
  --icon-rotation: -20;
}

.btn-creative-letter:active span:nth-child(odd):after,
/* ============================================= */
/* MODAL OVERLAY Y CONTENEDORES */
/* ============================================= */

.letter-overlay {
  position: fixed;
  inset: 0;
  background: rgb(176, 48, 64, 0.2); /* Color más oscuro sugerido */
  backdrop-filter: blur(8px); /* Blur como pediste */
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
}

.letter-overlay.active {
  display: flex;
}

/* ============================================= */
/* EL SOBRE (Basado en el snippet del usuario) */
/* ============================================= */

.envelope-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  perspective: 1000px;
}

.envelope-wrap {
  cursor: pointer;
  user-select: none;
}

.envelope {
  width: 320px;
  height: 210px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.3s ease;
  filter: drop-shadow(0 20px 40px rgba(0,0,0,0.55));
}

.envelope-wrap:hover .envelope:not(.open) {
  transform: translateY(-8px) rotateX(6deg);
}

.env-body {
  position: absolute;
  inset: 0;
  background: linear-gradient(155deg, #d8c9ae 0%, #c9b89a 100%);
  border-radius: 4px 4px 10px 10px;
}

.env-left  { position:absolute;left:0;top:0;width:0;height:0;border-style:solid;border-width:105px 0 105px 160px;border-color:transparent transparent #bead92 #bead92; }
.env-right { position:absolute;right:0;top:0;width:0;height:0;border-style:solid;border-width:105px 160px 105px 0;border-color:transparent #bead92 #bead92 transparent; }
.env-bottom{ position:absolute;bottom:0;left:0;width:0;height:0;border-style:solid;border-width:0 0 105px 320px;border-color:transparent transparent #bead92 transparent; }

.env-top {
  position:absolute;top:0;left:0;width:320px;height:140px;
  transform-origin:top center;
  transition:transform 0.75s cubic-bezier(0.4,0,0.2,1);
  z-index:10;
}

.env-top::before {
  content:'';position:absolute;top:0;left:0;width:0;height:0;border-style:solid;
  border-width:135px 160px 0 160px;
  border-color:#d4c4a8 transparent transparent transparent;
  filter:drop-shadow(0 5px 8px rgba(0,0,0,0.18));
}

.seal {
  position:absolute;top:75px;left:50%;transform:translateX(-50%);
  width:50px;height:50px;border-radius:50%;
  background:radial-gradient(circle at 35% 35%, #b03040, #8b2635 65%, #5e1520);
  box-shadow:0 4px 14px rgba(0,0,0,0.55),inset 0 -2px 5px rgba(0,0,0,0.35);
  display:flex;align-items:center;justify-content:center;
  color:rgba(255,220,200,0.9);z-index:20;
  transition:transform 0.45s 0.25s,opacity 0.45s 0.25s;
}

.letter-peek {
  position:absolute;bottom:198px;left:20px;right:20px;height:0;
  background:#f8f4ed;border-radius:3px 3px 0 0;
  transition:height 0.6s 0.5s cubic-bezier(0.34,1.4,0.64,1);
  box-shadow:0 -6px 20px rgba(0,0,0,0.22);overflow:hidden;z-index:12;
}

.envelope.open .env-top { transform: rotateX(-172deg); }
.envelope.open .seal    { transform: translateX(-50%) scale(0); opacity: 0; }
.envelope.open .letter-peek { height: 95px; }

.hint-text {
  font-family: 'Lora', serif;
  font-style: italic;
  color: #c4882a;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  opacity: 0.7;
  transition: opacity 0.4s;
  pointer-events: none;
}

/* ============================================= */
/* EL FORMULARIO (MODAL SHELL) */
/* ============================================= */

.modal-shell {
  display: flex;
  width: 100%;
  max-width: 1000px;
  height: min(92vh, 780px);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 40px 100px rgba(0,0,0,0.7);
  background: #1f1910;
  border: 1px solid rgba(210,185,145,0.2);
}

.modal-form {
  width: 380px;
  background: #1a150e; /* Tono más profundo sugerido */
  border-right: 1px solid rgba(196, 136, 42, 0.15);
  display: flex;
  flex-direction: column;
}

.modal-head {
  padding: 24px 24px 18px;
  border-bottom: 1px solid rgba(196, 136, 42, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.close-btn {
  background: rgba(196, 136, 42, 0.08);
  border: 1px solid rgba(196, 136, 42, 0.2);
  cursor: pointer;
  color: #c4882a;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover { 
  background: #c4882a;
  color: #1a150e;
  transform: rotate(90deg);
  box-shadow: 0 0 15px rgba(196, 136, 42, 0.4);
}

.modal-title {
  font-family: 'Playfair Display', serif;
  color: #e6d9c2;
  font-size: 1.4rem;
}

.modal-title small {
  display: block;
  font-family: 'Lora', serif;
  font-size: 0.8rem;
  color: #c4882a;
  margin-top: 4px;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.section-label {
  font-family: 'Playfair Display', serif;
  font-size: 0.8rem;
  color: #c4882a;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 15px;
  border-bottom: 1px solid rgba(210,185,145,0.1);
}

.form-group { margin-bottom: 15px; }
.form-group label {
  display: block;
  font-size: 0.8rem;
  color: #e0ab52;
  margin-bottom: 5px;
  font-style: italic;
}

/* Estilos Bespoke para Inputs (No genéricos) */
#inputPara, #inputMensaje, #inputDespedida {
  width: 100%;
  background: rgba(30, 25, 20, 0.6);
  border: 1px solid rgba(196, 136, 42, 0.2);
  padding: 12px 14px;
  border-radius: 8px;
  color: #e6d9c2;
  font-family: 'Lora', serif;
  font-size: 0.9rem;
  outline: none;
  transition: all 0.25s;
}

#inputPara:focus, #inputMensaje:focus, #inputDespedida:focus {
  border-color: #c4882a;
  background: rgba(196, 136, 42, 0.05);
  box-shadow: inset 0 0 10px rgba(196, 136, 42, 0.05);
}

#inputMensaje {
  min-height: 100px;
  resize: none;
  border-left: 3px solid #c4882a; /* Detalle distintivo */
}

#inputPara {
  background: rgba(255, 255, 255, 0.02);
  border: 1.5px solid rgba(196, 136, 42, 0.25) !important;
  border-radius: 12px;
  padding: 14px;
}

#inputPara:focus {
  border-color: #c4882a !important;
  background: rgba(196, 136, 42, 0.04);
}

#inputDespedida {
  font-style: italic;
  font-family: 'Playfair Display', serif;
}

.form-group input[type="color"] {
  padding: 0;
  height: 30px;
  cursor: pointer;
  border: 1px solid rgba(196, 136, 42, 0.3);
  background: transparent !important;
  border-radius: 6px;
  overflow: hidden;
}

.form-group input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.form-group input[type="color"]::-webkit-color-swatch { border: none; border-radius: 0; }

/* Imagen de Fondo Zone */
.upload-zone {
  border: 1.5px dashed rgba(196, 136, 42, 0.3);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 8px;
}
.upload-zone:hover { border-color: #c4882a; background: rgba(196, 136, 42, 0.05); }

.upload-inner { padding: 15px; text-align: center; color: rgba(210, 185, 145, 0.5); }
.upload-text { font-style: italic; font-size: 0.85rem; color: #e6d9c2; opacity: 0.7; }
.upload-sub { font-size: 0.7rem; }

.upload-preview { position: relative; height: 100px; display: none; }
.upload-preview img { width: 100%; height: 100%; object-fit: cover; }
.remove-bg {
  position: absolute; top: 5px; right: 5px; 
  background: rgba(0,0,0,0.6); border: none; color: white;
  width: 20px; height: 20px; border-radius: 50%; cursor: pointer;
}

.opacity-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }

/* Custom Slider (Match Image Style) */
#bgOpacity {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: rgba(255, 255, 255, 0.08); /* Fondo base muy sutil */
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  margin: 0;
  padding: 0;
}

#bgOpacity::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #c4882a;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 12px rgba(196, 136, 42, 0.4);
  transition: transform 0.2s;
  margin-top: 0; /* Centrado automático */
}

#bgOpacity::-webkit-slider-thumb:hover { transform: scale(1.18); }

.opacity-val { 
  font-size: 0.76rem; 
  color: #e0ab52; 
  min-width: 34px; 
  text-align: right;
  font-style: italic;
  font-family: 'Lora', serif;
}


/* Decoraciones */
.deco-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.deco-btn {
  width: 42px; height: 42px; border: 1.5px solid rgba(210,185,145,0.15);
  border-radius: 10px; background: rgba(255,255,255,0.02);
  display: flex; align-items: center; justify-content: center;
  color: rgba(210, 185, 145, 0.4); cursor: pointer; transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.deco-btn svg { transition: transform 0.25s; stroke-width: 1.25; }
.deco-btn:hover { border-color: rgba(196, 136, 42, 0.5); background: rgba(196, 136, 42, 0.05); color: #e6d9c2; }
.deco-btn:hover svg { transform: scale(1.1); }
.deco-btn.active { border-color: #c4882a; background: rgba(196, 136, 42, 0.12); color: #c4882a; box-shadow: 0 0 15px rgba(196, 136, 42, 0.15); }
.deco-none-label { font-size: 0.6rem; color: #c4882a; font-family: 'Lora', serif; font-style: italic; opacity: 0.8; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }

.modal-actions {
  padding: 20px;
  border-top: 1px solid rgba(210,185,145,0.2);
  display: flex;
  justify-content: center;
  align-items: center;
}

.btn-primary-gold {
  background: #c4882a;
  color: #1f1910;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-family: 'Playfair Display', serif;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-primary-gold:hover {
  background: #e0ab52;
}

/* ============================================= */
/* PREVIEW PANEL */
/* ============================================= */

.preview-panel {
  flex: 1;
  background: #16120c;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px;
  overflow-y: auto;
}

.preview-label {
  align-self: flex-start;
  font-family: 'Playfair Display', serif;
  color: rgba(210,185,145,0.5);
  font-size: 0.8rem;
  margin-bottom: 20px;
}

.a4-wrap {
  width: 100%;
  max-width: 350px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.5);
}

.a4-sheet {
  width: 100%;
  aspect-ratio: 210/297;
  background: #faf7f2;
  color: #3a2610;
  font-family: 'Lora', serif;
  position: relative;
  overflow: hidden;
  background-image: repeating-linear-gradient(transparent, transparent 27px, rgba(180,155,110,0.15) 28px);
}

.a4-bg-layer { position: absolute; inset: 0; background-size: cover; background-position: center; pointer-events: none; }
.a4-deco { position: absolute; top: 15px; right: 15px; z-index: 5; font-size: 1.2rem; }
.a4-content { height: 100%; display: flex; flex-direction: column; padding: 60px 50px; position: relative; z-index: 2; }
.a4-date { text-align: right; font-size: 0.7rem; margin-bottom: 20px; opacity: 0.7; }
.a4-greeting { font-size: 0.9rem; margin-bottom: 10px; }
.a4-body { flex: 1; font-size: 0.8rem; line-height: 1.8; white-space: pre-wrap; }
.a4-farewell { font-size: 0.8rem; margin-top: 20px; }
.a4-signature { font-size: 1rem; font-family: 'Playfair Display', serif; margin-top: 5px; }

/* ============================================= */
/* FULL VIEW */
/* ============================================= */

.letter-full-view {
  position: fixed;
  inset: 0;
  background: rgb(56 29 4 / 80%);
  display: none; /* JS */
  z-index: 11000;
  padding: 40px;
  align-items: center;
  justify-content: center;
}

.letter-full-view.active { display: flex; }

.full-a4-wrap {
  width: min(100%, 500px);
  animation: fadeInUpCreative 0.8s ease-out both;
}

.full-a4-sheet {
  width: 100%;
  aspect-ratio: 210/297;
  background: #faf7f2;
  padding: 8%;
  box-shadow: 0 40px 100px rgba(0,0,0,0.8);
  position: relative;
}

.full-view-actions {
  position: absolute;
  top: 30px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 15px;
  z-index: 100;
}

.action-btn {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 10px 22px;
  border-radius: 12px;
  cursor: pointer;
  font-family: 'Playfair Display', serif;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.3s;
  backdrop-filter: blur(5px);
}

.action-btn:hover {
  background: rgba(255,255,255,0.2);
  transform: translateY(-2px);
}

.action-btn.gold {
  background: #c4882a;
  color: #1a150e;
  border-color: #c4882a;
}

.action-btn.gold:hover {
  background: #e0ab52;
  box-shadow: 0 4px 15px rgba(196, 136, 42, 0.4);
}

/* Responsive */
@media (max-width: 850px) {
  .modal-shell { flex-direction: column; height: 95vh; }
  .modal-form { width: 100%; border-right: none; border-bottom: 1px solid rgba(210,185,145,0.2); }
  .preview-panel { display: none; }
}
