/* ====================================================
   ELEGANT ENVELOPE - Luxury 4-Flap Design
   Adapted for Template 6 design (warm beige / chocolate)
   ==================================================== */

:root {
    --env-main-font: 'Playfair Display', serif;
    --env-decorative-font: 'Santa Catarina', serif;
    --env-accent: #8c6b53;
    /* Warm brown */
    --env-primary: #ecdfc3;
    /* Beige (flap fill) */
    --env-border: #c0b29e;
    /* Muted gold-brown */
    --env-text-light: #faf5ef;
    /* Light cream text */
    --env-text-dark: #4d342c;
    /* Dark chocolate text */
}

/* Оверлей на весь экран */
.envelope-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    /* Transparent so content is visible behind flaps */
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--env-main-font);
    color: var(--env-text-dark);
    opacity: 1;
}

/* Premium paper texture */
.envelope-overlay::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 10;
    pointer-events: none;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* --- ОБЩИЕ СТИЛИ КЛАПАНОВ --- */
.flap {
    position: absolute;
    transition: transform 2.5s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    justify-content: center;
    align-items: center;
}

.flap-svg path {
    fill: var(--env-primary);
    stroke: var(--env-border);
    stroke-width: 1.5px;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.15));
    transition: fill 0.3s ease;
}

/* --- SVG STYLES --- */
.flap-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    filter: drop-shadow(0 0 12px rgba(0, 0, 0, 0.15));
    overflow: visible;
}

/* Content positioning */
.flap-content {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.top-flap .flap-content {
    padding-top: 8vh;
    justify-content: flex-start;
}

.bottom-flap .flap-content {
    justify-content: flex-end;
    padding-bottom: 8vh;
}

.left-flap .flap-content {
    justify-content: flex-start;
    padding-left: 6vw;
    align-items: flex-start;
}

.right-flap .flap-content {
    justify-content: flex-end;
    padding-right: 6vw;
    align-items: flex-end;
}

/* --- SPARKLE EFFECTS --- */
.sparkles-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 20;
    overflow: hidden;
}

.sparkle {
    position: absolute;
    background: var(--env-border);
    border-radius: 50%;
    opacity: 0;
    box-shadow: 0 0 8px 2px rgba(192, 178, 158, 0.3);
    animation:
        twinkle 4s ease-in-out infinite,
        floatUp 10s linear infinite;
}

.sparkle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 140%;
    height: 140%;
    border: 1px solid rgba(140, 107, 83, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
    animation: pulseRing 3s ease-out infinite;
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 0;
        transform: scale(0.5);
    }

    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }
}

@keyframes floatUp {
    0% {
        transform: translateY(0) translateX(0);
    }

    33% {
        transform: translateY(-30px) translateX(10px);
    }

    66% {
        transform: translateY(-60px) translateX(-10px);
    }

    100% {
        transform: translateY(-100px) translateX(0);
    }
}

@keyframes pulseRing {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0.5;
    }

    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* Монограмма — инициалы пары */
.monogram-box {
    width: auto;
    height: auto;
    margin-bottom: 20px;
    position: relative;
    padding-bottom: 12px;
}

/* Декоративная линия под монограммой */
.monogram-box::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--env-accent), transparent);
}

.monogram-text {
    display: flex;
    flex-direction: column;
    /* Вертикально: А, и, Б */
    align-items: center;
    justify-content: center;
    gap: 0;
}

.m-initial {
    font-family: var(--env-decorative-font);
    font-size: clamp(2rem, 8vw, 2.8rem);
    /* Уменьшил размер */
    color: var(--env-text-dark);
    line-height: 1;
    font-weight: 400;
}

.m-amp {
    font-family: var(--env-main-font);
    font-style: italic;
    font-size: clamp(0.9rem, 3vw, 1.1rem);
    /* Маленькое "и" (&) */
    color: var(--env-accent);
    opacity: 0.7;
    margin: 2px 0;
}

/* Заголовки */
.title-script {
    font-family: var(--env-decorative-font);
    font-size: clamp(2.5rem, 7vw, 3.5rem);
    font-weight: 400;
    margin: 0;
    line-height: 1;
    color: var(--env-text-dark);
}

.subtitle-serif {
    font-family: var(--env-main-font);
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    font-weight: 300;
    text-transform: lowercase;
    margin-top: 5px;
    letter-spacing: 0.15em;
    color: var(--env-accent);
    opacity: 0.9;
}

/* --- ВЕРХНИЙ КЛАПАН --- */
.top-flap {
    top: 0;
    left: 0;
    width: 100%;
    height: 55%;
    z-index: 5;
    transform-origin: top center;
    pointer-events: none;
}

/* --- НИЖНИЙ КЛАПАН --- */
.bottom-flap {
    bottom: 0;
    left: 0;
    width: 100%;
    height: 55%;
    z-index: 4;
    transform-origin: bottom center;
    pointer-events: none;
}

.bottom-content {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 8vh;
    text-align: center;
    width: 100%;
    height: 100%;
}

.info-block {
    text-align: center;
}

.info-block p {
    margin: 6px 0;
    font-size: clamp(0.85rem, 2vw, 1rem);
    font-weight: 300;
    letter-spacing: 0.08em;
    color: var(--env-accent);
}

.info-block .date {
    font-style: italic;
}

/* --- ЛЕВЫЙ КЛАПАН --- */
.left-flap {
    left: 0;
    top: 0;
    width: 55%;
    height: 100%;
    z-index: 3;
    transform-origin: left center;
    pointer-events: none;
}

/* --- ПРАВЫЙ КЛАПАН --- */
.right-flap {
    right: 0;
    top: 0;
    width: 55%;
    height: 100%;
    z-index: 3;
    transform-origin: right center;
    pointer-events: none;
}

/* --- СУРГУЧНАЯ ПЕЧАТЬ --- */
.wax-seal-btn {
    position: absolute;
    top: calc(52% - 20px);
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    background: none;
    border: none;
    cursor: pointer;
    transition: transform 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.wax-seal-btn:hover {
    transform: translate(-50%, -50%) scale(1.08);
}

.wax-seal-btn:active {
    transform: translate(-50%, -50%) scale(0.95);
}

/* Печать — PNG изображение */
.seal-image {
    width: 140px;
    /* Размер сургучной печати */
    height: auto;
    display: block;
    filter: drop-shadow(0 8px 15px rgba(0, 0, 0, 0.3));
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.wax-seal-btn:hover .seal-image {
    transform: rotate(5deg) scale(1.05);
}

/* Текст подсказки */
.click-hint {
    position: absolute;
    bottom: -55px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--env-accent);
    opacity: 0.8;
    font-size: 0.85rem;
    font-weight: 300;
    letter-spacing: 0.15em;
    text-transform: lowercase;
    pointer-events: none;
}

.click-hint span:first-child {
    font-size: 1.2rem;
    margin-bottom: 4px;
    animation: bounceArrow 1.5s ease-in-out infinite;
}

@keyframes bounceArrow {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

/* --- АНИМАЦИЯ ОТКРЫТИЯ --- */
.animate-open .top-flap {
    transform: translateY(-110%);
}

.animate-open .bottom-flap {
    transform: translateY(110%);
}

.animate-open .left-flap {
    transform: translateX(-110%);
}

.animate-open .right-flap {
    transform: translateX(110%);
}

.animate-open .wax-seal-btn {
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 0;
    transition: all 0.4s ease;
}

/* Конверт исчезает */
.envelope-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease-out;
}

/* --- LUXURY FRAME --- */
.luxury-frame-outer {
    position: fixed;
    inset: 16px;
    border: 1px solid var(--env-border);
    z-index: 50;
    pointer-events: none;
    opacity: 0.5;
}

.luxury-frame-inner {
    position: fixed;
    inset: 20px;
    border: 1px solid rgba(192, 178, 158, 0.3);
    z-index: 50;
    pointer-events: none;
}

.luxury-frame-outer::before,
.luxury-frame-outer::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid var(--env-border);
    transition: all 0.5s ease;
}

.luxury-frame-outer::before {
    top: -1px;
    left: -1px;
    border-right: none;
    border-bottom: none;
}

.luxury-frame-outer::after {
    bottom: -1px;
    right: -1px;
    border-left: none;
    border-top: none;
}

.luxury-frame-inner::before,
.luxury-frame-inner::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid var(--env-border);
    transition: all 0.5s ease;
}

.luxury-frame-inner::before {
    top: -1px;
    right: -1px;
    border-left: none;
    border-bottom: none;
}

.luxury-frame-inner::after {
    bottom: -1px;
    left: -1px;
    border-right: none;
    border-top: none;
}

.animate-open .luxury-frame-outer,
.animate-open .luxury-frame-inner {
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* --- АДАПТИВНОСТЬ --- */
@media (max-width: 600px) {
    .top-flap .flap-content {
        padding-top: 8vh;
    }

    .luxury-frame-outer {
        inset: 12px;
    }

    .luxury-frame-inner {
        inset: 15px;
    }

    .seal-inner {
        width: 90px;
        height: 90px;
    }

    .bottom-content {
        padding-bottom: 10vh;
    }
}