/* Design System Variables */
:root {
    --bg-gradient: radial-gradient(circle at center, #2e0811 0%, #100205 100%);
    --accent-gold: #d4af37;
    --accent-gold-glow: rgba(212, 175, 55, 0.6);
    --gold-metallic: linear-gradient(135deg, #bf953f 0%, #fcf6ba 25%, #b38728 50%, #fbf5b7 75%, #aa771c 100%);
    --crimson-red: #8b0000;
    --velvet-maroon: #4a000e;
    --text-light: #f5f5f5;
    --text-muted: #c9b0b4;
    --shadow-premium: 0 15px 35px rgba(0, 0, 0, 0.6), 0 0 15px rgba(212, 175, 55, 0.1);
    --font-primary: 'Montserrat', sans-serif;
    --font-serif: 'Playfair Display', serif;
    --font-accent: 'Dancing Script', cursive;
}

/* Reset & Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #100205;
    background-image: var(--bg-gradient);
    color: var(--text-light);
    font-family: var(--font-primary);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Starry Sky Animation */
.stars, .twinkling {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 0;
    pointer-events: none;
}

.stars {
    background: #000 url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/123103/stars.png') repeat top center;
    opacity: 0.4;
}

.twinkling {
    background: transparent url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/123103/twinkling.png') repeat top center;
    animation: move-twink-back 200s linear infinite;
    opacity: 0.3;
}

@keyframes move-twink-back {
    from { background-position: 0 0; }
    to { background-position: -10000px 5000px; }
}

/* Layout Container */
.app-container {
    width: 100%;
    max-width: 1200px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    z-index: 1;
}

/* Header Styles */
.header {
    text-align: center;
    margin-bottom: 3.5rem;
    animation: fadeInDown 1.2s ease-out;
}

.title {
    font-family: var(--font-serif);
    font-size: 3.5rem;
    font-weight: 800;
    background: var(--gold-metallic);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
    letter-spacing: 1px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
    text-shadow: 0 0 20px rgba(212, 175, 55, 0.25);
}

.subtitle {
    font-size: 1.15rem;
    font-weight: 300;
    color: var(--text-muted);
    letter-spacing: 2px;
    text-transform: uppercase;
    position: relative;
    display: inline-block;
    padding-bottom: 8px;
}

.subtitle::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 25%;
    width: 50%;
    height: 1px;
    background: var(--gold-metallic);
}

/* Doors Section Styles */
.doors-section {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.doors-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4rem;
    max-width: 900px;
    width: 100%;
}

@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }
    
    .header {
        margin-bottom: 1.5rem;
    }

    .title {
        font-size: 2rem;
        text-shadow: 0 0 15px rgba(212, 175, 55, 0.2);
    }
    
    .subtitle {
        font-size: 0.9rem;
        letter-spacing: 1px;
    }
    
    .doors-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        max-width: 220px;
    }
    
    .door-container {
        min-height: 280px;
    }
    
    .door-number {
        font-size: 1.8rem;
    }
    
    /* Responsive Modals */
    .modal-overlay {
        padding: 1rem;
        align-items: flex-start;
    }

    .modal-card {
        padding: 1.6rem 1.2rem;
        width: 100%;
        max-width: 380px;
    }

    .success-card {
        padding: 1.4rem 1rem;
    }
    
    .success-celebration {
        font-size: 1.2rem;
        margin-bottom: 0.3rem;
    }
    
    .success-title {
        font-size: 1.45rem;
        line-height: 1.25;
        margin-bottom: 0.3rem;
    }
    
    .modal-text {
        font-size: 0.85rem;
        margin-bottom: 0.8rem;
        line-height: 1.4;
    }
    
    .gift-card-container {
        width: 170px;
        height: 170px;
        margin: 0 auto 0.8rem;
    }
    
    .gift-message {
        font-size: 1.15rem;
        line-height: 1.35;
        margin-top: 0.4rem;
    }
}

/* Door Wrapper & 3D Environment */
.door-wrapper {
    perspective: 1200px;
    cursor: pointer;
}

.door-container {
    width: 100%;
    aspect-ratio: 9 / 16;
    min-height: 320px;
    position: relative;
    transform-style: preserve-3d;
    box-shadow: var(--shadow-premium);
    border-radius: 8px;
    border: 3px solid #1a0508;
    background: #0d0103;
}

/* Behind the door (Revealed Content) */
.door-inside {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #6b0f1a 0%, #1e0307 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 5px;
    z-index: 1;
    overflow: hidden;
}

.glow-effect {
    position: absolute;
    width: 150%;
    height: 150%;
    background: radial-gradient(circle at center, rgba(212, 175, 55, 0.4) 0%, rgba(212, 175, 55, 0) 65%);
    top: -25%;
    left: -25%;
    animation: pulsing-glow 3s ease-in-out infinite;
    mix-blend-mode: screen;
}

.heart-symbol {
    font-size: 3rem;
    color: var(--accent-gold);
    text-shadow: 0 0 20px var(--accent-gold);
    z-index: 2;
    animation: heartPulse 1.5s infinite alternate;
}

/* The actual moving door */
.door-body {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transform-origin: left center;
    transition: transform 1.4s cubic-bezier(0.25, 1, 0.5, 1);
    z-index: 2;
    border-radius: 5px;
}

/* Door wrapper when open state is active */
.door-wrapper.open .door-body {
    transform: rotateY(-135deg);
    pointer-events: none; /* Disable interaction with open door */
}

/* Disable closed interactions if already clicked */
.door-wrapper.disabled {
    cursor: default;
}

/* Door Front Face design */
.door-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 5px;
    box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.5rem;
}

.door-front {
    background: linear-gradient(145deg, var(--velvet-maroon) 0%, #1c0206 100%);
    border: 4px solid;
    border-image: var(--gold-metallic) 1;
    position: relative;
}

/* Decorative wood/metallic panels on door */
.door-panel {
    border: 2px solid rgba(212, 175, 55, 0.25);
    background: rgba(0, 0, 0, 0.3);
    width: 100%;
    height: 40%;
    border-radius: 3px;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.9);
    position: relative;
}

.door-knob {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--gold-metallic);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5), 0 0 8px rgba(212, 175, 55, 0.4);
    border: 1px solid rgba(0, 0, 0, 0.3);
    z-index: 5;
}

.door-knob::after {
    content: '';
    position: absolute;
    width: 25px;
    height: 6px;
    background: var(--gold-metallic);
    right: 8px;
    top: 5px;
    border-radius: 2px;
    border: 1px solid rgba(0, 0, 0, 0.3);
}

.door-number {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-serif);
    font-size: 2.2rem;
    font-weight: 600;
    background: var(--gold-metallic);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    opacity: 0.85;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

/* Modals Overlay (Try Again and Success) */
.modal-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    /* The overlay itself scrolls, so tall cards are fully reachable on mobile */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1.5rem;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Glassmorphism Card Style */
.modal-card {
    background: rgba(26, 5, 8, 0.9);
    border: 2px solid;
    border-image: var(--gold-metallic) 1;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(212, 175, 55, 0.15);
    padding: 3rem 2.5rem;
    border-radius: 12px;
    text-align: center;
    max-width: 480px;
    width: 100%;
    /* margin:auto centres the card while still letting the overlay scroll
       past its top edge when the content is taller than the viewport */
    margin: auto;
    transform: scale(0.85) translateY(20px);
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.modal-overlay.active .modal-card {
    transform: scale(1) translateY(0);
}

.modal-heart {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
    animation: floatHeart 3s ease-in-out infinite;
}

.modal-title {
    font-family: var(--font-serif);
    font-size: 2.2rem;
    background: var(--gold-metallic);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1.2rem;
}

.modal-text {
    font-size: 1.05rem;
    font-weight: 300;
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* Buttons */
.btn-primary {
    background: var(--gold-metallic);
    color: #1a0508;
    border: none;
    padding: 0.9rem 2.2rem;
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
    transition: all 0.3s ease;
    outline: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.5), 0 0 10px rgba(212, 175, 55, 0.3);
}

.btn-primary:active {
    transform: translateY(1px);
}

/* Success Modal Modifications */
.modal-overlay.success {
    background: rgba(14, 2, 4, 0.92);
}

.success-card {
    max-width: 650px;
    padding: 3.5rem 3rem;
}

.success-celebration {
    font-size: 1.8rem;
    margin-bottom: 0.8rem;
    color: var(--accent-gold);
    letter-spacing: 4px;
    text-shadow: 0 0 10px var(--accent-gold-glow);
}

.success-title {
    font-size: 2.6rem;
    margin-bottom: 0.5rem;
}

.success-subtitle {
    margin-bottom: 1.8rem;
}

/* Gift Card Styling (reliable cross-fade reveal, no 3D) */
.gift-card-container {
    width: 250px;
    height: 250px;
    margin: 0 auto 1.8rem;
    cursor: pointer;
}

/* Card inner container holds the two stacked faces */
.gift-card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 12px;
}

/* Card Faces — stacked on top of each other and cross-faded */
.gift-card-face {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    border: 3px solid;
    border-image: var(--gold-metallic) 1;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #1a0508;
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.25);
    animation: giftGlow 2.5s infinite alternate;
    transition: opacity 0.6s ease;
}

/* Front Face (gift box) visible by default */
.gift-card-front {
    z-index: 2;
    opacity: 1;
}

/* Back Face (voucher) hidden until revealed */
.gift-card-back {
    z-index: 1;
    opacity: 0;
}

/* Revealed state: fade gift out, fade voucher in */
.gift-card-inner.flipped .gift-card-front {
    opacity: 0;
    pointer-events: none;
}

.gift-card-inner.flipped .gift-card-back {
    opacity: 1;
    z-index: 3;
}

/* Gift card image scale/fit */
.gift-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* The voucher carries text, so show it whole instead of cropping it */
.gift-card-back .gift-card-image {
    object-fit: contain;
    background: #1a0508;
}

/* Subtle tap hint overlay on the front face */
.gift-tap-hint {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(26, 5, 8, 0.95);
    color: var(--accent-gold);
    border: 1px solid var(--accent-gold);
    padding: 0.35rem 0.9rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 1px;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
    animation: pulseHint 1.2s infinite alternate;
    white-space: nowrap;
}

@keyframes pulseHint {
    from { opacity: 0.8; transform: translateX(-50%) scale(0.95); }
    to { opacity: 1; transform: translateX(-50%) scale(1.05); }
}

.gift-message {
    font-family: var(--font-accent);
    font-size: 1.8rem;
    line-height: 1.4;
    color: #ffd6e0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    margin-top: 1rem;
    animation: fadeIn 1.5s ease-out;
}

.reveal-hidden {
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.reveal-hidden.visible {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* Floating Hearts System */
.hearts-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 99;
    overflow: hidden;
}

.floating-heart {
    position: absolute;
    bottom: -50px;
    color: rgba(220, 20, 60, 0.65);
    font-size: 20px;
    user-select: none;
    pointer-events: none;
    animation: floatUp 6s linear forwards;
}

/* Animation Keyframes */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes heartPulse {
    from { transform: scale(0.95); opacity: 0.8; }
    to { transform: scale(1.1); opacity: 1; }
}

@keyframes pulsing-glow {
    0% { transform: scale(0.9); opacity: 0.3; }
    50% { transform: scale(1.1); opacity: 0.6; }
    100% { transform: scale(0.9); opacity: 0.3; }
}

@keyframes floatHeart {
    0% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(5deg); }
    100% { transform: translateY(0px) rotate(0deg); }
}

@keyframes giftGlow {
    from { box-shadow: 0 0 25px rgba(212, 175, 55, 0.2); transform: scale(0.98); }
    to { box-shadow: 0 0 45px rgba(212, 175, 55, 0.55); transform: scale(1.02); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes floatUp {
    0% {
        transform: translateY(0) translateX(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(-105vh) translateX(var(--drift)) rotate(var(--rotation));
        opacity: 0;
    }
}
