/* ================================
   ENVELOPE INTRO SCREEN
   ================================ */

/* Pantalla completa */
.envelope-screen {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

.envelope-screen.is-gone {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

body.has-envelope {
    overflow: hidden;
}

/* Fondo con textura sutil de papel */
.envelope-screen__bg {
    position: absolute;
    inset: 0;
    background-color: var(--color-bg-secondary, #F0EDE8);
    background-image:
        url("data:image/svg+xml,%3Csvg width='6' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.75' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
}

/* ================================
   EL SOBRE
   ================================ */
.envelope-body {
    position: relative;
    width: min(520px, 90vw);
    aspect-ratio: 5 / 3;
    perspective: 800px;
}

/* Parte trasera del sobre - fondo visible */
.envelope-body__back {
    position: absolute;
    inset: 0;
    background: var(--color-bg-surface, #FDFCFA);
    border-radius: var(--radius-md, 0.5rem);
    border: 1px solid var(--color-border, rgba(0,0,0,0.06));
    box-shadow:
        0 4px 24px rgba(0,0,0,0.06),
        0 12px 48px rgba(0,0,0,0.04);
    z-index: 1;
}

/* La carta que sube al abrir */
.envelope-body__card {
    position: absolute;
    left: 8%;
    right: 8%;
    bottom: 10%;
    top: 10%;
    z-index: 2;
    transition: transform 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.envelope-screen.is-opening .envelope-body__card {
    transform: translateY(-55%);
}

.envelope-card {
    width: 100%;
    height: 100%;
    background: var(--color-bg-surface, #FDFCFA);
    border: 1px solid var(--color-border, rgba(0,0,0,0.08));
    border-radius: var(--radius-sm, 0.25rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg, 2rem);
    text-align: center;
    gap: var(--space-sm, 1rem);
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.envelope-card__invitation {
    font-size: 0.75rem;
    font-weight: var(--font-weight-medium, 500);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--color-text-muted, #999);
    margin: 0;
}

.envelope-card__names {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.envelope-card__name {
    font-family: var(--font-heading);
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    font-weight: var(--font-weight-regular, 400);
    color: var(--color-text-heading, #1A1917);
    line-height: 1.15;
}

.envelope-card__connector {
    font-family: var(--font-heading);
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    font-weight: var(--font-weight-light, 300);
    color: var(--color-primary, #A65D57);
    line-height: 1.5;
}

.envelope-card__date {
    font-size: 0.85rem;
    font-weight: var(--font-weight-light, 300);
    letter-spacing: 0.1em;
    color: var(--color-text-body, #333);
    margin: 0;
}

.envelope-card__venue {
    font-size: 0.75rem;
    color: var(--color-text-muted, #999);
    margin: 0;
}

/* Parte delantera inferior del sobre (tapa la parte baja de la carta) */
.envelope-body__front {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 55%;
    background: var(--color-bg-secondary, #F0EDE8);
    border-radius: 0 0 var(--radius-md, 0.5rem) var(--radius-md, 0.5rem);
    border: 1px solid var(--color-border, rgba(0,0,0,0.06));
    border-top: none;
    z-index: 3;
    /* Textura de papel sutil */
    background-image:
        linear-gradient(135deg, rgba(0,0,0,0.01) 25%, transparent 25%),
        linear-gradient(225deg, rgba(0,0,0,0.01) 25%, transparent 25%);
    background-size: 20px 20px;
}

/* Solapa triangular superior */
.envelope-body__flap {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: var(--color-bg-secondary, #F0EDE8);
    clip-path: polygon(0 0, 50% 100%, 100% 0);
    z-index: 4;
    transform-origin: top center;
    transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--color-border, rgba(0,0,0,0.06));
    /* Sombra interna para profundidad */
    background-image:
        linear-gradient(to bottom, rgba(0,0,0,0.02), transparent 50%);
}

.envelope-screen.is-opening .envelope-body__flap {
    transform: rotateX(180deg);
    z-index: 0;
}

/* Sello / boton para abrir */
.envelope-body__seal {
    position: absolute;
    top: 44%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 0.85rem 1.8rem;
    background: var(--color-primary, #A65D57);
    color: #fff;
    border: none;
    border-radius: var(--radius-full, 9999px);
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: var(--font-weight-semibold, 600);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.4s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    white-space: nowrap;
}

.envelope-body__seal:hover {
    transform: translate(-50%, -50%) scale(1.05);
    box-shadow: 0 6px 24px rgba(0,0,0,0.16);
}

.envelope-body__seal .material-symbols-outlined {
    font-size: 20px;
}

.envelope-body__seal-text {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.envelope-screen.is-opening .envelope-body__seal {
    opacity: 0;
    pointer-events: none;
}

/* ================================
   MUSIC TOGGLE
   ================================ */
.music-toggle {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 9999;
}

.music-toggle__btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-surface, #fff);
    border: 1px solid var(--color-border, rgba(0,0,0,0.08));
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    transition: background 0.2s ease, transform 0.2s ease;
    position: relative;
}

.music-toggle__btn:hover {
    transform: scale(1.08);
}

.music-toggle__icon {
    font-size: 20px;
    color: var(--color-text-body, #333);
}

.music-toggle__btn.is-muted .music-toggle__icon {
    opacity: 0.4;
}

.music-toggle__btn:not(.is-muted)::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--color-primary, #A65D57);
    opacity: 0;
    animation: music-pulse 2s ease-in-out infinite;
}

@keyframes music-pulse {
    0% { transform: scale(1); opacity: 0.4; }
    100% { transform: scale(1.3); opacity: 0; }
}

/* ================================
   MOBILE
   ================================ */
@media (max-width: 600px) {
    .envelope-body {
        width: 92vw;
        aspect-ratio: 4 / 3;
    }

    .envelope-card {
        padding: var(--space-md, 1.5rem);
        gap: var(--space-xs, 0.75rem);
    }

    .envelope-card__invitation {
        font-size: 0.65rem;
    }

    .envelope-body__seal {
        padding: 0.75rem 1.4rem;
        font-size: 0.8rem;
    }

    .music-toggle {
        bottom: 16px;
        left: 16px;
    }
}
