/* Design System & Variables */
:root {
    --color-gold-light: hsl(45, 100%, 80%);
    --color-gold: hsl(45, 100%, 50%);
    --color-gold-dark: hsl(35, 100%, 40%);
    --color-text-light: hsl(0, 0%, 100%);
    --color-text-muted: hsl(35, 20%, 85%);
    --color-bg-card: hsla(330, 20%, 8%, 0.45); /* Dark rose background for glassmorphism */
    --color-border-gold: hsla(45, 100%, 50%, 0.3);
    
    --font-royal: 'Cinzel', serif;
    --font-body: 'Montserrat', sans-serif;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-jump: top 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), left 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
    font-family: var(--font-body);
    height: 100vh;
    width: 100vw;
    overflow: hidden; /* Prevent all scrollbars to keep elements inside screen */
    position: relative;
}

/* Background layers for smooth cross-fade */
.bg-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-size: cover;
    background-repeat: no-repeat;
    z-index: 0;
    transition: opacity 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.bg-layer-invitation {
    background-image: url('background.jpg');
    background-position: 70% center; /* Shift to frame Princess Alessia on small screens */
    opacity: 1;
}

.bg-layer-success {
    background-image: url('success_background.jpg');
    background-position: 15% center; /* Shift to frame the Prince on small screens */
    opacity: 0;
}

/* Desktop background positioning */
@media (min-width: 1024px) {
    .bg-layer-invitation {
        background-position: center center;
    }
    .bg-layer-success {
        background-position: center center;
    }
}

/* Darkening overlay for readability */
.bg-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        135deg, 
        hsla(20, 20%, 5%, 0.4) 0%, 
        hsla(330, 25%, 8%, 0.55) 100%
    );
    z-index: 1;
    pointer-events: none;
}

/* App container */
.app-container {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
}

/* Glassmorphism Card styling */
.card {
    background: var(--color-bg-card);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    border: 1px solid var(--color-border-gold);
    border-radius: 28px;
    padding: 48px 36px;
    max-width: 480px;
    width: 100%;
    box-shadow: 
        0 20px 50px rgba(0, 0, 0, 0.5), 
        inset 0 1px 3px rgba(255, 255, 255, 0.15),
        0 0 15px rgba(212, 175, 55, 0.1);
    text-align: center;
    color: var(--color-text-light);
    transition: opacity 0.5s ease, transform 0.5s ease;
    transform: translateY(0);
}

.card.hidden {
    display: none;
    opacity: 0;
    transform: scale(0.95) translateY(10px);
}

/* Animation classes */
.fade-in {
    animation: cardEnter 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* Header & Crest */
.card-header {
    margin-bottom: 28px;
}

.royal-crest {
    font-size: 2.5rem;
    display: inline-block;
    margin-bottom: 12px;
    animation: float 4s ease-in-out infinite;
}

.animated-crest {
    font-size: 4rem;
    animation: pulsate 2.5s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-8px) rotate(3deg); }
}

@keyframes pulsate {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.3)); }
    50% { transform: scale(1.1); filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.7)); }
}

.royal-title {
    font-family: var(--font-royal);
    font-size: 2rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 3px;
    background: linear-gradient(to right, var(--color-gold-light), var(--color-gold), var(--color-gold-dark), var(--color-gold-light));
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shine 4s linear infinite;
}

@keyframes shine {
    to { background-position: 200% center; }
}

.royal-subtitle {
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 1px;
    display: block;
    margin-top: 8px;
    -webkit-text-fill-color: transparent;
}

/* Card Body & Typography */
.card-body {
    margin-bottom: 36px;
}

.invitation-text {
    font-size: 1.3rem;
    line-height: 1.6;
    font-weight: 300;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.success-text {
    font-size: 1.25rem;
    line-height: 1.6;
    margin-bottom: 16px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.success-text strong {
    color: var(--color-gold-light);
    font-weight: 600;
}

.success-subtext {
    font-size: 1rem;
    color: var(--color-text-muted);
    font-style: italic;
}

/* Royal Divider */
.royal-divider {
    height: 1px;
    width: 60%;
    background: linear-gradient(to right, transparent, var(--color-gold), transparent);
    margin: 24px auto;
}

/* Actions & Buttons */
.card-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    min-height: 52px;
    position: relative;
}

/* Buttons style */
.btn {
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 1px;
    padding: 14px 36px;
    border-radius: 50px;
    cursor: pointer;
    outline: none;
    border: none;
    transition: var(--transition-smooth);
    min-width: 140px;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-gold-light) 0%, var(--color-gold-dark) 100%);
    color: hsl(20, 30%, 8%);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.5);
    background: linear-gradient(135deg, var(--color-gold) 0%, var(--color-gold-dark) 100%);
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text-light);
    border: 1px solid rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(4px);
}

/* Transition rule for when JavaScript gives "No" button absolute positioning */
.btn-secondary.teleported {
    position: fixed;
    z-index: 999;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6), 0 0 10px rgba(255, 255, 255, 0.1);
    transition: var(--transition-jump);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
}

.btn-link {
    background: transparent;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    font-weight: 400;
    text-decoration: underline;
    padding: 8px 16px;
}

.btn-link:hover {
    color: var(--color-gold-light);
}

/* Sparkle particles overlay */
#particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.sparkle {
    position: absolute;
    color: var(--color-gold-light);
    font-size: 1.2rem;
    pointer-events: none;
    opacity: 0;
    animation: particleUp 2.5s ease-out forwards;
}

@keyframes particleUp {
    0% {
        transform: translateY(100vh) scale(0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.8;
    }
    90% {
        opacity: 0.4;
    }
    100% {
        transform: translateY(-10vh) scale(1.2) rotate(360deg);
        opacity: 0;
    }
}

/* Responsiveness adjustments */
@media (max-width: 480px) {
    .card {
        padding: 36px 24px;
        margin: 16px;
    }
    
    .royal-title {
        font-size: 1.6rem;
    }
    
    .invitation-text {
        font-size: 1.15rem;
    }
    
    .card-actions {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    /* Center absolute button on mobile if needed, but absolute positioning keeps it anywhere */
    .btn-secondary.teleported {
        width: auto;
    }
}
