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

:root {
    --main-font: var(--font-serif);
    --decorative-font: "Great Vibes", cursive;
    --accent-gold: var(--c-gold);
    --primary-green: var(--c-text-primary);
    --bg-light: var(--c-bg);
    --white: var(--color-elevated);
}

/* Оверлей на весь экран */
.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;
    transition: transform var(--motion-opening-duration, 2500ms) var(--ease-opening, cubic-bezier(0.4, 0, 0.2, 1));
    display: flex;
    justify-content: center;
    align-items: center;
}

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

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

.sparkle {
    position: absolute;
    background: white;
    border-radius: 50%;
    opacity: 0;
    box-shadow: 0 0 10px 2px rgba(255, 255, 255, 0.4);
    /* Combine twinkle with upward float */
    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(255, 215, 0, 0.3);
    /* Gold tint */
    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.8;
        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;
    }
}

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

/* Монограмма - Minimal Style */
.monogram-box {
    /* No border, just text */
    width: auto;
    height: auto;
    margin-bottom: 25px;
    opacity: 0.95;
    transform: scale(1.1);
}

.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: calc(52% - 20px);
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    background: none;
    border: none;
    cursor: pointer;
    transition: transform 0.3s ease;

    /* Remove system tap highlight */
    -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);
}

/* Круг печати - Premium Crystal Glass Style */
.seal-inner {
    width: 110px;
    height: 110px;
    /* Crystal clear glass gradient */
    background: linear-gradient(135deg,
            rgba(255, 255, 255, 0.45) 0%,
            rgba(255, 255, 255, 0.1) 50%,
            rgba(255, 255, 255, 0.05) 100%);
    backdrop-filter: blur(14px) saturate(120%);
    -webkit-backdrop-filter: blur(14px) saturate(120%);

    /* Sharp reflective edges */
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-top: 1.5px solid rgba(255, 255, 255, 0.7);
    border-left: 1.5px solid rgba(255, 255, 255, 0.7);

    border-radius: 50%;

    /* Ambient shadow + Inner light refraction */
    box-shadow:
        0 15px 35px -5px rgba(0, 0, 0, 0.2),
        inset 0 0 20px rgba(255, 255, 255, 0.25),
        inset 2px 2px 5px rgba(255, 255, 255, 0.4);

    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Рисунок внутри печати */
.seal-icon {
    width: 55%;
    height: 55%;
    opacity: 0.7;
}

.seal-icon path,
.seal-icon ellipse {
    stroke: var(--accent-gold);
}

/* Текст подсказки */
.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: transform 0.4s ease, opacity 0.4s ease;
}

/* Конверт завершает свою мягкую открытку поверх уже появляющегося hero */
.envelope-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.08);
    filter: blur(12px) brightness(1.2);
    transition:
        opacity var(--motion-opening-fade-opacity-duration, 750ms) ease-in-out,
        transform var(--motion-opening-fade-duration, 900ms) var(--ease-editorial),
        filter var(--motion-opening-fade-opacity-duration, 750ms) ease-in-out;
}

/* --- LUXURY FRAME EFFECTS --- */
.luxury-frame-outer {
    position: fixed;
    inset: 16px;
    border: 1px solid var(--accent-gold);
    z-index: 50;
    pointer-events: none;
    opacity: 0.8;
    mix-blend-mode: multiply;
}

.luxury-frame-inner {
    position: fixed;
    inset: 20px;
    border: 1px solid rgba(232, 213, 176, 0.4);
    z-index: 50;
    pointer-events: none;
}

/* Add corner accents to outer frame using pseudo-elements */
.luxury-frame-outer::before,
.luxury-frame-outer::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid var(--accent-gold);
    transition: opacity 0.5s ease, border-color 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;
}

/* Inner frame corners via pseudo-elements too */
.luxury-frame-inner::before,
.luxury-frame-inner::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid var(--accent-gold);
    transition: opacity 0.5s ease, border-color 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;
}

/* Fade out frame on open */
.animate-open .luxury-frame-outer,
.animate-open .luxury-frame-inner {
    opacity: 0;
    transition: opacity 0.5s ease;
}

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

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

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

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

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

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

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

[hidden] {
    display: none !important;
}

.envelope-overlay .info-block .location {
    width: auto;
    margin: 6px 0;
    padding: 0;
    color: var(--accent-gold);
    font-size: clamp(0.85rem, 2vw, 1rem);
    line-height: 1.4;
}

.envelope-overlay .wax-seal-btn:focus-visible {
    outline: 2px solid var(--accent-gold);
    outline-offset: 8px;
}

@media (prefers-reduced-motion: reduce) {
    .envelope-overlay,
    .envelope-overlay * {
        animation: none !important;
        transition: none !important;
    }

    .envelope-overlay .wax-seal-btn {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}
