@import url('https://fonts.googleapis.com/css2?family=Dancing+Script:wght@700&family=Outfit:wght@300;400;500&display=swap');

:root {
    --daisy-yellow: #fcd34d;
    --daisy-white: #ffffff;
    --envelope-color: #f3f4f6;
    --text-dark: #1f2937;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: #a7f3d0;
    background-image: url('daisy-bg.png');
    background-size: cover;
    background-position: center;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    position: relative;
    width: 100%;
    max-width: 800px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    perspective: 1000px;
}

/* Zarf Temeli */
.envelope-container {
    position: relative;
    width: 340px;
    height: 240px;
    cursor: pointer;
    z-index: 10;
    transition: transform 1.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    transform-style: preserve-3d;
}

.envelope-container.flipped {
    transform: rotateY(180deg);
}

.envelope {
    position: relative;
    width: 100%;
    height: 100%;
    background: var(--envelope-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border-radius: 0 0 10px 10px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    backface-visibility: hidden;
}

/* Kapak - EN ÜST KATMAN (Kapalıyken) */
.flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('envelope-cover.jpeg');
    background-size: cover;
    background-position: center;
    clip-path: polygon(0 0, 100% 0, 50% 55%);
    transform-origin: top;
    transition: transform 1.2s ease-in-out, z-index 1.2s, filter 1.2s;
    z-index: 20;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5));
    /* En üstte */
}

.envelope.open .flap {
    transform: rotateX(180deg);
    z-index: 0;
    filter: brightness(0.85);
    /* Açılınca en alta */
}

/* Cep - ÖN KATMAN (Kağıdın önünde duran üçgen) */
.pocket-front {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('envelope-cover.jpeg');
    background-size: cover;
    background-position: center;
    clip-path: polygon(0 100%, 50% 41%, 100% 100%);
    z-index: 10;
    /* Kağıt bunun arkasından çıkacak */
}

/* Yan Cepler */
.pocket {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9;
    pointer-events: none;
    border-radius: 0 0 10px 10px;
    overflow: hidden;
}

.pocket-left,
.pocket-right {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 100%;
    background-image: url('envelope-cover.jpeg');
    background-size: cover;
    background-position: center;
}

.pocket-left {
    left: 0;
    clip-path: polygon(0 0, 50% 50%, 0 100%);
    filter: brightness(0.95);
}

.pocket-right {
    right: 0;
    clip-path: polygon(100% 0, 50% 50%, 100% 100%);
    filter: brightness(0.90);
}

/* Kağıt */
.letter-paper {
    position: absolute;
    /* Başlangıç konumu: Tamamen içeride */
    bottom: 0;
    width: 300px;
    height: 200px;
    background: white;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);

    /* Animasyon */
    transition: transform 2s 1.2s ease-in-out, height 2s 1.2s ease-in-out, bottom 2s 1.2s ease-in-out;

    /* Z-Index: Cep (z=10) ile Arka (z=0) arasında olmalı */
    z-index: 5;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
}

.envelope.open .letter-paper {
    /* Sadece yukarı kayıyor, z-index değişmiyor! */
    /* Böylece öne "ışınlanma" (spam) olmuyor, içinden süzülüyor */
    transform: translateY(-80px);
    height: 380px;
    /* Bottom sabit kalsın veya yumuşak artsın */
    bottom: 40px;
}

.lyrics-text {
    font-family: 'Dancing Script', cursive;
    font-size: 1.8rem;
    line-height: 1.4;
    color: #d97706;
    margin-top: 20px;
    transition: opacity 0.5s;
    width: 100%;
    /* Yazı kağıt büyüdükçe görünür olacak */
}

.heart-pulse-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    color: #ef4444;
    /* Kırmızı kalp */
    animation: heartBeat 1.5s infinite;
    display: inline-block;
}

@keyframes heartBeat {
    0% {
        transform: scale(1);
    }

    14% {
        transform: scale(1.3);
    }

    28% {
        transform: scale(1);
    }

    42% {
        transform: scale(1.3);
    }

    70% {
        transform: scale(1);
    }
}

/* 3D Inner Wrapper */
.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transform-style: preserve-3d;
}

.card-front {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    z-index: 2;
}

.card-back {
    position: absolute;
    width: 100%;
    height: 156%;
    top: -28%;
    background-color: rgba(255, 255, 255, 0.98);
    transform: rotateY(180deg);
    backface-visibility: hidden;

    border-radius: 15px;
    padding: 20px;
    color: #333;
    border: 4px solid #fcd34d;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.final-message {
    font-family: 'Dancing Script', cursive;
    font-size: 1.3rem;
    line-height: 1.5;
    color: #000;
    width: 100%;
}

.signature {
    margin-top: 15px;
    font-family: 'Outfit', sans-serif;
    font-style: italic;
    font-size: 0.9rem;
    font-weight: 500;
    color: #666;
    align-self: flex-end;
}

/* --- PARTİKÜLLER --- */
.realistic-petal {
    position: absolute;
    /* Başlangıç: Zarfın içi için JS ile ayarlanacak ama varsayılan gizli */
    opacity: 0;
    pointer-events: none;
    z-index: 15;
    /* Zarfın (z=10) önünde, partiküller patlasın */

    /* Fountain Effect */
    animation:
        ejectUp var(--eject-speed) ease-out forwards,
        driftDown var(--fall-duration) var(--eject-speed) ease-in forwards,
        swaySide var(--sway-duration) ease-in-out infinite alternate;
}

.petal-shape-real {
    width: var(--size);
    height: var(--size);
    background-color: #fff;
    border-radius: 0% 100% 50% 50% / 0% 50% 100% 100%;
    transform: rotate(45deg);
    box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.heart-shape-real {
    font-size: var(--size);
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Önce yukarı fırlama (Zarfın içinden çıkış) */
@keyframes ejectUp {
    0% {
        opacity: 0;
        transform: translate(0, 0) scale(0.5);
    }

    20% {
        opacity: 1;
    }

    100% {
        /* Yukarı ve dışa doğru rastgele saçılma JS ile --tx, --ty verilecek */
        transform: translate(var(--tx), var(--ty)) scale(1);
        opacity: 1;
    }
}

/* Sonra aşağı süzülme */
@keyframes driftDown {
    0% {
        /* Eject bittiği yerden devam (Transform override etmemek için top/left kullanabiliriz veya composite)
       Ancak CSS animasyon çatışması olmasın diye eject transform'u koruyup top'ı değiştireceğiz.
    */
        top: var(--start-top);
        opacity: 1;
    }

    100% {
        top: 110vh;
        /* Ekran dibi */
        opacity: 0;
    }
}

@keyframes swaySide {
    0% {
        margin-left: -20px;
        rotate: 0deg;
    }

    100% {
        margin-left: 20px;
        rotate: 40deg;
    }
}

/* --- MOBILE RESPONSIVE --- */
@media (max-width: 600px) {
    .envelope-container {
        width: 300px;
        height: 220px;
    }

    .letter-paper {
        width: 270px;
    }

    .envelope.open .letter-paper {
        height: 380px;
        transform: translateY(-80px);
    }

    .card-back {
        height: 160%;
        top: -30%;
        padding: 15px;
    }

    .final-message {
        font-size: 1.2rem;
    }
}