/* ====================================================
   ELEGANT ENVELOPE - Luxury 4-Flap Design
   All tips converge at center under the seal
   ==================================================== */

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

/* --- ОБЩИЕ СТИЛИ КЛАПАНОВ --- */
.flap {
    position: absolute;
    /* Замедлили открытие до 2.5 секунд */
    transition: transform 2.5s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ... (skipped lines) ... */

/* --- PREMIUM PAPER TEXTURE --- */
.envelope-overlay::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 10;
    pointer-events: none;
    opacity: 0.06;
    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-svg path {
    /* Глубокий, насыщенный бордовый (Burgundy Red) */
    fill: var(--primary-green);
    stroke: var(--accent-gold);
    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.4));
    transition: fill 0.3s ease;
}

/* Содержимое поверх стекла */
.flap-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    /* padding-top будет переопределяться для каждого клапана */
    width: 100%;
    position: relative;
    z-index: 2;
}

/* --- ВЕРХНИЙ КЛАПАН (треугольник вниз) --- */
.top-flap {
    top: 0;
    left: 0;
    width: 100%;
    height: 55%;
    /* Slightly larger to ensure overlap */
    z-index: 5;
    transform-origin: top center;
    pointer-events: none;
    /* Let clicks pass through to seal if needed */
}

.flap-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 8vh;
    width: 100%;
    position: relative;
    z-index: 2;
}

/* Монограмма */
.monogram-box {
    width: 80px;
    height: 100px;
    border: 1px solid var(--accent-gold);
    border-radius: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    opacity: 0.9;
}

.monogram-text {
    font-family: var(--decorative-font);
    font-size: 1.5rem;
    color: var(--accent-gold);
    line-height: 1.2;
    text-align: center;
}

/* Заголовки */
.title-script {
    font-family: var(--decorative-font);
    font-size: clamp(2rem, 6vw, 3rem);
    font-weight: 400;
    margin: 0;
    line-height: 1;
    color: var(--white);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.subtitle-serif {
    font-family: var(--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(--accent-gold);
    opacity: 0.9;
}

/* --- НИЖНИЙ КЛАПАН (треугольник вверх) --- */
.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(--accent-gold);
}

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

.star-deco {
    position: absolute;
    bottom: 20px;
    right: 20px;
    font-size: 1rem;
    color: var(--accent-gold);
    opacity: 0.5;
}

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

.left-content {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding-left: 6vw;
    height: 100%;
}

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

.right-content {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding-right: 6vw;
    height: 100%;
}

/* --- SVG STYLES --- */
.flap-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    /* Drop shadow applied to the SVG shape */
    filter: drop-shadow(0 0 15px rgba(0, 0, 0, 0.4));
    overflow: visible;
    /* Allow stroke to be fully visible */
}

/* Old rule removed to apply new glass style */

/* 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;
    /* Default for top */
}

.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;
    /* Align text left */
}

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

/* Сургучная печать */
.wax-seal-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    background: none;
    border: none;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    /* Защита от системных рамок и выделения */
    outline: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

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

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

.seal-inner {
    width: 160px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    filter: drop-shadow(0 12px 25px rgba(0, 0, 0, 0.35));
}

.seal-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Запрет перетаскивания и долгого нажатия для мобилок */
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

/* Текст подсказки */
.click-hint {
    position: absolute;
    bottom: -55px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--accent-gold);
    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%);
    /* Opacity removed */
}

.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;
}

/* Final fade out of the entire overlay */
.envelope-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease-in-out;
}

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

    .monogram-box {
        width: 70px;
        height: 95px;
    }

    .monogram-text {
        font-size: 1.4rem;
    }

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



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