/* Lo que comparten todas las plantillas de invitación:
     1. el sobre que se abre al entrar, cerrado con el sello de los novios
     2. el sello en la portada
     3. los iconos de línea de las secciones
     4. la aparición suave de cada bloque al llegar a él
   Cada plantilla define las letras por tipo de texto (--f-nombres, --f-titulos, --f-etiquetas…)
   y puede dar sus colores al sobre con estas variables:
     --sobre-color        los dos lados del sobre
     --sobre-color-base   el triángulo de abajo
     --sobre-solapa       la solapa que se levanta
     --sobre-interior     el interior, que se ve al abrir
     --sobre-borde        dobleces y borde
     --sobre-escena       fondo de la pantalla mientras se abre
     --sello-color        cera del sello (js/sello.js) */

/* ═══════════ 1. Sobre ═══════════ */
.sobre-escena {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--sobre-escena, radial-gradient(ellipse at center, var(--champagne) 0%, var(--champagne-medio) 60%, var(--champagne-profundo) 100%));
}
.sobre-escena.scene-fade-out { animation: sobreSalir 0.7s ease-out forwards; }
@keyframes sobreSalir { to { opacity: 0; } }

.sobre-caja {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    animation: sobreEntrar 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes sobreEntrar {
    from { opacity: 0; transform: scale(0.78); }
    to   { opacity: 1; transform: scale(1); }
}

/* El sobre se adapta al ancho del teléfono; sus textos se miden con su propio ancho (cqw). */
.sobre {
    position: relative;
    width: min(84vw, 340px);
    aspect-ratio: 340 / 230;
    perspective: 1000px;
    container-type: inline-size;
}
.sobre-fondo {
    position: absolute;
    inset: 0;
    background: var(--sobre-interior, var(--primario-medio));
    box-shadow: 0 24px 44px -14px rgba(var(--primario-oscuro-rgb), 0.5);
}

/* Carta */
.sobre-carta {
    position: absolute;
    left: 6%; right: 6%; bottom: 5%;
    height: 86%;
    z-index: 2;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    text-align: center;
    background: linear-gradient(160deg, var(--papel) 0%, var(--papel-calido) 100%);
    border: 1px solid rgba(var(--gold-rgb), 0.45);
    border-radius: 3px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
    transform: translateY(0);
    transition: transform 1.1s cubic-bezier(0.22, 1, 0.36, 1) 1s, box-shadow 1.1s ease 1s;
}
.sobre.abierto .sobre-carta {
    transform: translateY(-58%);
    box-shadow: 0 18px 44px rgba(var(--primario-rgb), 0.3), 0 4px 14px rgba(0, 0, 0, 0.14);
}
.sobre-carta-texto { width: 100%; padding: 7% 6% 0; }
.sobre-carta-adorno { display: block; font-size: 9px; letter-spacing: 6px; color: var(--gold); margin-bottom: 2px; }
.sobre-carta-nombre {
    margin: 0;
    font-family: var(--f-nombres);
    font-weight: 400;
    line-height: 1.15;
    color: var(--rojo-intenso);
    font-size: 26px;
    font-size: min(calc(8.4cqw * var(--escala-nombres, 1)), 11cqw);
}
.sobre-carta-y { margin: 0; font-family: var(--f-titulos); font-style: italic; font-size: 15px; line-height: 1.3; color: var(--gold-oscuro); }
.sobre-carta-pie {
    margin: 5px 0 0;
    font-family: var(--f-etiquetas);
    font-size: 9.5px;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--texto-suave);
}

/* Frente y solapa */
.sobre-frente { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; z-index: 3; display: block; }
.sobre-lado { fill: var(--sobre-color, var(--rojo-intenso)); }
.sobre-base { fill: var(--sobre-color-base, var(--primario-medio)); }
.sobre-doblez { fill: none; stroke: var(--sobre-borde, var(--gold)); stroke-width: 1; vector-effect: non-scaling-stroke; opacity: 0.75; }
.sobre-marco { fill: none; stroke: var(--sobre-borde, var(--gold)); stroke-width: 2; vector-effect: non-scaling-stroke; }

.sobre-solapa {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 56.5%;
    z-index: 4;
    transform-origin: top center;
    transform: rotateX(0deg);
    /* Al terminar de levantarse pasa detrás de la carta, que sale por encima */
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.35s, z-index 0s linear 0.8s;
}
.sobre-solapa svg { width: 100%; height: 100%; max-width: none; display: block; overflow: visible; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.22)); }
.sobre-solapa polygon { fill: var(--sobre-solapa, var(--primario-claro)); }
.sobre.abierto .sobre-solapa { transform: rotateX(180deg); z-index: 1; }

/* Sello sobre la punta de la solapa */
.sobre-sello {
    position: absolute;
    left: 50%;
    top: 56.5%;
    width: 27%;
    aspect-ratio: 1;
    z-index: 5;
    transform: translate(-50%, -50%);
    transition: transform 0.45s cubic-bezier(0.5, 0, 0.75, 0), opacity 0.4s ease;
    animation: selloLatir 1s ease-in-out 0.45s 1 both;
}
.sobre-sello svg { width: 100%; height: 100%; max-width: none; display: block; filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.38)); }
.sobre-sello.con-imagen {
    border-radius: 50%;
    background: var(--papel) center / cover no-repeat;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35), 0 0 0 2px var(--gold);
}
.sobre.abierto .sobre-sello { transform: translate(-50%, -50%) scale(1.3) rotate(-12deg); opacity: 0; animation: none; }
@keyframes selloLatir {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50%      { transform: translate(-50%, -50%) scale(1.08); }
}

.sobre-aviso {
    margin: 0;
    padding: 0 12px;
    text-align: center;
    font-family: var(--f-etiquetas);
    font-size: 13px;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--texto-suave);
    animation: sobrePulso 1.8s ease-in-out infinite;
}
@keyframes sobrePulso {
    0%, 100% { opacity: 0.5; }
    50%      { opacity: 0.95; }
}

/* Destellos alrededor */
.sobre-destello {
    position: absolute;
    color: var(--gold);
    opacity: 0;
    font-size: 1.2rem;
    animation: sobreDestello 4s ease-in-out infinite;
    pointer-events: none;
    user-select: none;
}
.sobre-destello.d1 { top: 15%; left: 10%;  animation-delay: 0.2s; }
.sobre-destello.d2 { top: 25%; right: 12%; animation-delay: 0.9s; font-size: 0.8rem; }
.sobre-destello.d3 { top: 62%; left: 8%;   animation-delay: 1.5s; font-size: 1.5rem; }
.sobre-destello.d4 { top: 72%; right: 9%;  animation-delay: 0.5s; }
.sobre-destello.d5 { top: 42%; left: 5%;   animation-delay: 2s;   font-size: 0.9rem; }
.sobre-destello.d6 { top: 10%; right: 6%;  animation-delay: 1.2s; font-size: 1.1rem; }
@keyframes sobreDestello {
    0%   { opacity: 0; transform: translateY(20px) rotate(0deg); }
    30%  { opacity: 0.7; }
    70%  { opacity: 0.5; }
    100% { opacity: 0; transform: translateY(-60px) rotate(20deg); }
}

/* ═══════════ 2. Sello en la portada ═══════════ */
.sello-portada { width: 108px; height: 108px; margin: 0 auto; flex: none; }
.sello-portada:empty:not(.con-imagen) { display: none; }
.sello-portada svg { width: 100%; height: 100%; max-width: none; display: block; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3)); }
.sello-portada.con-imagen {
    border-radius: 50%;
    background: center / cover no-repeat;
    border: 2px solid var(--champagne);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* ═══════════ 3. Iconos de sección ═══════════ */
.icono {
    width: 2.6rem;
    height: 2.6rem;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    overflow: visible;
}

/* ═══════════ 4. Aparición al llegar a cada bloque ═══════════ */
/* Solo se oculta si main.js confirmó que puede volver a mostrarlo (clase con-apariciones). */
.con-apariciones [data-aparecer] {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.con-apariciones [data-aparecer].visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
    .sobre-caja, .sobre-destello, .sobre-aviso, .sobre-sello { animation: none; }
    .sobre-solapa, .sobre-carta, .sobre-sello { transition-duration: 0.01s; transition-delay: 0s; }
    .con-apariciones [data-aparecer] { opacity: 1; transform: none; transition: none; }
}
