/* ------------------------------------------------------------------ */
/* --- 1. Fonts & Root Variables --- */
/* ------------------------------------------------------------------ */
@font-face {
    font-family: 'Autography Signature';
    src: url('fonts/Autography.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

:root {
    --color-primary: #FFDDE1;
    --color-pink-dark: #ff758c;
    --color-secondary: #FFFACD;
    --color-text: #5C3A5B;
    --color-light: white;
}

/* ------------------------------------------------------------------ */
/* --- 2. Global Layout --- */
/* ------------------------------------------------------------------ */
body {
    font-family: 'Playfair Display', serif;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

.container {
    background-color: var(--color-light);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 380px;
    height: 70vh;
    position: relative;
    overflow: hidden;
}

.content-box {
    position: absolute;
    top: 45%;  /* Adjust this to move both up/down together */
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.content-box .heading-large {
    margin-bottom: 15px;  /* Space between title and subtitle */
}

.content-box .sub-heading {
    margin-top: 0;
}

/* ------------------------------------------------------------------ */
/* --- 3. Pages --- */
/* ------------------------------------------------------------------ */
.page {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.page.active {
    display: flex;
    opacity: 1;
}

/* ------------------------------------------------------------------ */
/* --- 4. Click-to-start Screen --- */
/* ------------------------------------------------------------------ */
#click-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

/* ------------------------------------------------------------------ */
/* --- 5. Music Selection --- */
/* ------------------------------------------------------------------ */
.music-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.music-card {
    background: white;
    border-radius: 15px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    transition: 0.25s ease;
}

.music-card:hover {
    transform: scale(1.02);
    background: var(--color-primary);
}

.music-card.selected {
    border: 2px solid var(--color-pink-dark);
    background: var(--color-primary);
    transform: scale(1.03);
}

.music-thumb {
    width: 60px;
    height: 60px;
    border-radius: 10px;
    object-fit: cover;
}

/* ------------------------------------------------------------------ */
/* --- 6. ENVELOPE & LETTER - CLEAN REVEAL --- */
/* ------------------------------------------------------------------ */
.envelope-scene {
    position: relative;
    width: 100%;
    max-width: 380px;
    height: 420px;
    margin: 20px 0;
}

/* ENVELOPE - Initially Visible, Then Disappears */
.envelope {
    position: absolute;
    width: 320px;
    height: 240px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.8s ease;
    z-index: 2;
}

/* Envelope Body */
.envelope-body {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #ffb3c1 0%, #ffcad4 100%);
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

/* Envelope Flap */
.flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 160px solid transparent;
    border-right: 160px solid transparent;
    border-top: 120px solid #ff9fb0;
    transform-origin: top center;
    z-index: 3;
    transition: transform 0.6s ease;
}

/* Heart Seal */
.heart-seal {
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    z-index: 4;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: heartbeat 1.5s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

.heart-seal:hover {
    transform: translate(-50%, -50%) scale(1.2);
}

@keyframes heartbeat {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
    }
}

/* When envelope opens - flap rotates */
.envelope.opening .flap {
    transform: rotateX(-180deg);
}

/* When letter appears - envelope fades and scales down */
.envelope.disappearing {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
    pointer-events: none;
}

/* LETTER - Initially Hidden, Then Appears */
.letter {
    position: absolute;
    width: 90%;
    max-width: 360px;
    height: 400px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.3);
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    opacity: 0;
    z-index: 1;
    transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Letter content */
.letter-content {
    height: 100%;
    overflow-y: auto;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--color-text);
}

.letter-content h2 {
    margin-top: 0;
    margin-bottom: 20px;
}

.letter-content p {
    margin: 15px 0;
    text-align: left;
}

/* When letter appears - scales up and fades in */
.letter.showing {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Tap instruction */
.tap-instruction {
    color: var(--color-text);
    font-size: 0.9rem;
    margin-top: 10px;
    opacity: 0.7;
    animation: pulse 2s ease-in-out infinite;
    transition: opacity 0.5s ease;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
}

/* Hide instruction when opened */
.tap-instruction.hidden {
    opacity: 0;
}

/* ------------------------------------------------------------------ */
/* --- 7. Flip Cards --- */
/* ------------------------------------------------------------------ */
.card-container {
    display: grid;
    grid-template-columns: repeat(2, 180px);
    gap: 20px;
    justify-content: center;
}

.flip-card {
    width: 180px;
    height: 240px;
    perspective: 1000px;
}

.flip-card-inner {
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flip-card:hover .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border-radius: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

.flip-card-front {
    background: #fff5f6;
    font-size: 0.8rem;
}

.flip-card-back {
    transform: rotateY(180deg);
}

.flip-card-back img {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    object-fit: cover;
}

/* ------------------------------------------------------------------ */
/* --- 8. Memories Slider with Navigation Buttons --- */
/* ------------------------------------------------------------------ */
.slideshow-wrapper {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
}

.image-slider {
    width: 100%;
    max-width: 350px;
    height: 375px;
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    background: white;
}

.slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.slide.active-slide {
    opacity: 1;
}

.slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Navigation Buttons */
.nav-photo-btn {
    background: rgba(255, 255, 255, 0.95);
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.nav-photo-btn:hover {
    background: white;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.nav-photo-btn:active {
    transform: scale(0.95);
}

.nav-photo-btn svg {
    color: var(--color-text);
    transition: color 0.3s ease;
}

.nav-photo-btn:hover svg {
    color: var(--color-pink-dark);
}

/* Slide Indicators */
.slide-indicators {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 15px 0 0 0;
}

.indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 117, 140, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
}

.indicator.active {
    background: var(--color-pink-dark);
    width: 12px;
    height: 12px;
}

.indicator:hover {
    background: var(--color-pink-dark);
}

/* ------------------------------------------------------------------ */
/* --- 9. Buttons & Text --- */
/* ------------------------------------------------------------------ */
.cta-button {
    background: linear-gradient(135deg, #ff758c, #ff7eb3);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 50px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 20px;
    transition: 0.3s;
    font-size: 1rem;
}

.cta-button:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(255, 117, 140, 0.4);
}

.cta-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.replay-button {
    background: linear-gradient(135deg, #ff758c, #ff7eb3);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 50px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 20px;
    transition: 0.3s;
    font-size: 1rem;
}

.replay-button:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(255, 117, 140, 0.4);
}

.heading-large {
    font-family: 'Great Vibes', cursive;
    font-size: 3rem;
    color: var(--color-text);
    margin: 10px 0;
}

.heading-small {
    font-family: 'Great Vibes', cursive;
    font-size: 2.2rem;
    color: var(--color-text);
    margin: 10px 0;
}

.sub-heading {
    font-size: 1.1rem;
    color: var(--color-text);
    opacity: 0.8;
}

.your-name {
    font-family: 'Autography Signature', cursive;
    font-size: 2rem;
    color: var(--color-text);
    text-align: right;
    margin-top: 20px;
}

.hidden {
    display: none !important;
}

/* ------------------------------------------------------------------ */
/* --- 10. Responsive Design --- */
/* ------------------------------------------------------------------ */
@media (max-width: 480px) {
    .envelope-scene {
        max-width: 340px;
        height: 380px;
    }

    .envelope {
        width: 280px;
        height: 200px;
    }

    .flap {
        border-left: 140px solid transparent;
        border-right: 140px solid transparent;
        border-top: 100px solid #ff9fb0;
    }

    .letter {
        max-width: 320px;
        height: 360px;
        padding: 20px;
    }

    .slideshow-wrapper {
        gap: 10px;
    }

    .nav-photo-btn {
        width: 40px;
        height: 40px;
    }

    .nav-photo-btn svg {
        width: 20px;
        height: 20px;
    }

    .image-slider {
        max-width: 280px;
        height: 300px;
    }

    .heading-large {
        font-size: 2.5rem;
    }

    .heading-small {
        font-size: 1.8rem;
    }
}

@media (max-width: 380px) {
    .envelope-scene {
        max-width: 300px;
        height: 340px;
    }

    .envelope {
        width: 240px;
        height: 180px;
    }

    .flap {
        border-left: 120px solid transparent;
        border-right: 120px solid transparent;
        border-top: 90px solid #ff9fb0;
    }

    .letter {
        max-width: 280px;
        height: 320px;
        padding: 18px;
    }

    .slideshow-wrapper {
        gap: 8px;
    }

    .nav-photo-btn {
        width: 35px;
        height: 35px;
    }

    .image-slider {
        max-width: 240px;
        height: 280px;
    }
}