/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    position: relative;
}

/* Container visibility management */
#start-container,
#slideshow-container,
#gift-container,
#explosion-container,
#reveal-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
}

#start-container.active,
#slideshow-container.active,
#gift-container.active,
#explosion-container.active,
#reveal-container.active {
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
}

/* Start page styling */
#start-container {
    background: linear-gradient(135deg, #ffd6e8, #c8e6ff, #fff4c8, #d4f4dd);
    background-size: 400% 400%;
    animation: gradientShift 8s ease infinite;
}

#start-arrow {
    width: min(20vw, 120px);
    height: auto;
    cursor: pointer;
    transition: transform 0.3s ease, opacity 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    transform-origin: center center;
}

#start-arrow:hover {
    transform: scale(1.1);
}

#start-arrow:active {
    transform: scale(0.95);
    opacity: 0.8;
}

#start-arrow.animating {
    animation: arrowSpringExpand 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    pointer-events: none;
}

@keyframes arrowSpringExpand {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    20% {
        transform: scale(1.3);
        opacity: 1;
    }
    40% {
        transform: scale(0.9);
        opacity: 1;
    }
    60% {
        transform: scale(1.1);
        opacity: 1;
    }
    100% {
        transform: scale(var(--arrow-scale, 15));
        opacity: 0;
    }
}

/* Gift container background */
#gift-container {
    background-image: url('bg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Explosion container background */
#explosion-container {
    background-image: url('bg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Phase 0: Slideshow container */
#slideshow-container {
    background-image: url('bg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: background-image 0.8s ease-in-out;
}

/* Individual slide styling */
.slideshow-slide {
    display: none;
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
    width: 90%;
    max-width: 1250px;
    text-align: center;
    padding: 40px;
}

.slideshow-slide.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 1;
}

/* Slide text styling */
.slide-text {
    font-family: 'Sour Gummy', 'Comic Sans MS', cursive, sans-serif;
    font-size: min(12vw, 100px);
    font-weight: 900;
    color: white;
    text-transform: uppercase;
    text-shadow:
        0 4px 8px rgba(102, 63, 148, 0.6),
        0 2px 4px rgba(102, 63, 148, 0.4),
        0 6px 12px rgba(118, 75, 162, 0.3);
    letter-spacing: 0.05em;
    line-height: 1.3;
    margin: 0;
    animation: slideTextAppear 0.8s ease-out;
}

/* Slide image styling */
.slide-image {
    max-width: 100%;
    max-height: 70vh;
    width: auto;
    height: auto;
    margin-top: 30px;
    border-radius: 12px;
    animation: slideTextAppear 0.8s ease-out 0.05s backwards;
}

@keyframes slideTextAppear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Polaroid slide specific layout */
.polaroid-slide.active {
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.polaroid-text {
    font-family: 'Sour Gummy', 'Comic Sans MS', cursive, sans-serif;
    font-size: min(12vw, 100px);
    font-weight: 900;
    color: white;
    text-transform: uppercase;
    text-shadow:
        0 4px 8px rgba(102, 63, 148, 0.6),
        0 2px 4px rgba(102, 63, 148, 0.4),
        0 6px 12px rgba(118, 75, 162, 0.3);
    letter-spacing: 0.05em;
    line-height: 1.3;
    margin: 0 0 40px 0;
    animation: slideTextAppear 0.8s ease-out;
}

.polaroid-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 40px;
    max-width: 1100px;
    width: 90%;
    padding: 20px;
}

/* Individual Polaroid styling */
.polaroid {
    background: white;
    padding: 15px 15px 45px 15px;
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.15),
        0 8px 16px rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    --rotation: 0deg;
    animation: polaroidAppear 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.polaroid img {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
}

/* Animation keyframes */
@keyframes polaroidAppear {
    from {
        opacity: 0;
        transform: scale(0.3) translateY(30px) rotate(0deg);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0) rotate(var(--rotation));
    }
}

/* Animation delays - text appears first, then polaroids */
.polaroid-3 { animation-delay: 1s; }
.polaroid-1 { animation-delay: 1.3s; }
.polaroid-5 { animation-delay: 1.6s; }
.polaroid-6 { animation-delay: 1.9s; }
.polaroid-2 { animation-delay: 2.2s; }
.polaroid-4 { animation-delay: 2.5s; }

/* Gift image styling */
#gift {
    width: min(60vw, 300px);
    height: auto;
    cursor: pointer;
    position: absolute;
    transition: top 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
                left 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.8s ease-in-out;
    will-change: transform, top, left;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    z-index: 10;
    opacity: 0;
}

#gift.fade-in {
    opacity: 1;
}

/* Phase 1: Gentle pulse */
#gift.pulse-gentle {
    animation: pulseGentle 2s ease-in-out infinite;
}

@keyframes pulseGentle {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Phase 3: Fast pulse */
#gift.pulse-fast {
    animation: pulseFast 0.3s ease-in-out infinite;
}

@keyframes pulseFast {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Phase 3: Faster pulse */
#gift.pulse-faster {
    animation: pulseFaster 0.15s ease-in-out infinite;
}

@keyframes pulseFaster {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Animated background during explosion buildup */
#explosion-container.building::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at var(--gift-x, 50%) var(--gift-y, 50%),
                rgba(255, 100, 200, 0.7) 0%,
                rgba(200, 100, 255, 0.5) 30%,
                rgba(150, 50, 255, 0.3) 50%,
                transparent 80%);
    animation: backgroundPulse 0.25s ease-in-out infinite;
    pointer-events: none;
    z-index: 5;
    filter: blur(20px);
}

#explosion-container.building::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at var(--gift-x, 50%) var(--gift-y, 50%),
                rgba(255, 200, 255, 0.9) 0%,
                rgba(255, 150, 255, 0.6) 25%,
                transparent 60%);
    animation: backgroundPulseGlow 0.25s ease-in-out infinite;
    pointer-events: none;
    z-index: 4;
    filter: blur(40px);
}

@keyframes backgroundPulse {
    0%, 100% {
        opacity: 0.4;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1.5);
    }
}

@keyframes backgroundPulseGlow {
    0%, 100% {
        opacity: 0.3;
        transform: scale(0.6);
    }
    50% {
        opacity: 0.9;
        transform: scale(2);
    }
}

/* Particle/confetti for explosion */
.particle {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    pointer-events: none;
}

/* Reveal container */
#reveal-container {
    background: linear-gradient(135deg, #ffd6e8, #c8e6ff, #fff4c8, #d4f4dd);
    background-size: 400% 400%;
    animation: gradientShift 8s ease infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Cards container */
.cards-container {
    display: flex;
    gap: 30px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    padding: 20px;
    position: relative;
    z-index: 10;
}

/* Reveal card container */
.reveal-card {
    width: min(40vw, 300px);
    height: min(50vh, 400px);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    animation: cardAppear 0.6s ease-out backwards;
    position: relative;
}

#card-1 {
    animation-delay: 0.1s;
}

#card-2 {
    animation-delay: 0.3s;
}

@keyframes cardAppear {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Card front */
.card-front {
    width: 100%;
    height: 100%;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 4px solid rgba(255, 255, 255, 0.3);
    animation: cardFloat 3s ease-in-out infinite;
}

@keyframes cardFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.question-mark {
    font-size: min(20vw, 150px);
    font-weight: bold;
    color: white;
    text-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    animation: questionPulse 2s ease-in-out infinite;
}

@keyframes questionPulse {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.1); opacity: 1; }
}

/* Revealed images container */
.revealed-images {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

.revealed-image {
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    opacity: 0;
    animation: imageReveal 0.6s ease-out forwards;
}

.revealed-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@keyframes imageReveal {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .slide-text {
        font-size: min(12vw, 80px);
        padding: 20px;
    }

    .slideshow-slide {
        padding: 20px;
    }

    .polaroid-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(3, 1fr);
        gap: 20px;
        padding: 10px;
    }

    .polaroid {
        padding: 10px 10px 30px 10px;
    }

    .cards-container {
        flex-direction: column;
        gap: 20px;
    }

    .reveal-card {
        width: 80vw;
        height: 60vh;
    }
}

@media (max-width: 480px) {
    .polaroid-grid {
        gap: 15px;
    }

    .polaroid {
        padding: 8px 8px 25px 8px;
    }
}
