* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none; 
}

body {
    font-family: 'Amatic SC', cursive;
    background-color: #1a1612;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: #3e3a35;
    overflow: hidden;
}

/* Skip link visible on focus for keyboard users */
.skip-link {
    position: absolute;
    left: -999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
.skip-link:focus {
    left: 12px; top: 12px; width: auto; height: auto; padding: 8px 12px; background: #fff; color: #222; z-index: 9999; border-radius: 4px; text-decoration: none;
}

/* ==========================================================================
   AMBIENT BACKGROUND (CANDLES)
   ========================================================================== */
.ambient-background {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 1;
    pointer-events: none;
    background: radial-gradient(circle at center, #2e261f 0%, #110e0a 100%);
}

.ambient-background::after {
    content: '';
    position: absolute; top:0; left:0; width:100%; height:100%;
    background-image: 
        radial-gradient(circle, #ffeab3 1px, transparent 2px),
        radial-gradient(circle, #ffeab3 1px, transparent 2px);
    background-size: 100px 100px, 150px 150px;
    background-position: 0 0, 50px 50px;
    opacity: 0.3;
    animation: firefliesMove 20s linear infinite;
    pointer-events: none;
}

@keyframes firefliesMove {
    0% { background-position: 0 0, 50px 50px; opacity: 0.1; }
    50% { opacity: 0.5; }
    100% { background-position: -100px 100px, -50px 150px; opacity: 0.1; }
}

.candle {
    position: absolute;
    width: 16px;
    height: 50px;
    background: linear-gradient(to right, #d4c5b0, #f8eee0 30%, #b8a68d);
    border-radius: 2px 2px 0 0;
    box-shadow: 2px 5px 10px rgba(0,0,0,0.5);
}
.c1 { top: 20%; left: 10%; transform: scale(1.2); }
.c2 { top: 60%; left: 5%; transform: scale(0.8); }
.c3 { top: 15%; right: 15%; transform: scale(1.5); }
.c4 { top: 75%; right: 10%; transform: scale(1.1); }
.c5 { top: 40%; right: 5%; transform: scale(0.9); }

.flame {
    position: absolute;
    top: -15px; left: 3px; width: 10px; height: 18px;
    background: radial-gradient(ellipse at bottom, #fff 0%, #ffeb99 30%, #ff8c00 80%, transparent 100%);
    border-radius: 50% 50% 20% 20%;
    animation: flicker 0.15s infinite alternate;
    box-shadow: 0 0 10px #ffb347;
}

.glow {
    position: absolute;
    top: -50px; left: -40px; width: 100px; height: 100px;
    background: radial-gradient(circle, rgba(255,180,80,0.15) 0%, transparent 60%);
    animation: pulseGlow 3s infinite alternate;
    pointer-events: none;
}

@keyframes flicker {
    0% { transform: scale(1) skewX(0deg); opacity: 0.9; }
    50% { transform: scale(1.05) skewX(2deg); opacity: 1; }
    100% { transform: scale(0.95) skewX(-2deg); opacity: 0.85; }
}

@keyframes pulseGlow {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.2); opacity: 1; }
}

/* ==========================================================================
   ENVELOPE (COVER)
   ========================================================================== */
.table-background {
    width: 100%;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    z-index: 10;
}

.envelope-container {
    position: absolute;
    width: 100%;
    max-width: 500px;
    height: 70vh;
    max-height: 700px;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 1s ease, transform 1s ease;
}

.envelope {
    position: relative;
    width: 100%;
    height: 100%;
    background-image: url('assets/paper.png');
    background-size: cover;
    background-color: #fbf7f0;
    box-shadow: 0 18px 36px rgba(0,0,0,0.55);
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.envelope-front { text-align: center; z-index: 10; }
.envelope-names { font-family: 'Great Vibes', cursive; font-size: clamp(2.5rem, 8vw, 3.5rem); color: #4a3f35; margin-bottom: 0.5rem; }
.envelope-date { font-family: 'Amatic SC', cursive; font-size: clamp(1.5rem, 6vw, 2rem); letter-spacing: 2px; color: #3e3a35; font-weight: 700; }

.btn-audio-open { display: none; }

/* Accessible focus styles for keyboard users */
.btn-audio-open:focus {
    outline: 3px solid rgba(142,31,31,0.18);
    outline-offset: 4px;
    box-shadow: 0 4px 14px rgba(142,31,31,0.12);
}

/* Global focus-visible for accessibility */
:focus-visible {
    outline: 3px solid rgba(121,85,72,0.18);
    outline-offset: 3px;
}

/* Audio toggle button */
.audio-toggle { display: none; }

/* Respect user preference for reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

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

.wax-seal {
    position: absolute;
    top: 30%; left: 50%;
    transform: translate(-50%, -50%);
    width: 80px; height: 80px;
    background: radial-gradient(circle at 30% 30%, #b32d2d, #7a1515);
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4), inset 0 2px 5px rgba(255,255,255,0.2);
    display: flex; justify-content: center; align-items: center;
    z-index: 20; cursor: pointer;
    border: 2px solid #8e1f1f;
    clip-path: polygon(50% 0%, 83% 12%, 100% 43%, 94% 78%, 68% 100%, 32% 100%, 6% 78%, 0% 43%, 17% 12%);
}

.seal-heart { color: #ebd9d9; font-size: 2rem; }

.wax-seal.broken {
    animation: breakSeal 1s forwards;
    pointer-events: none;
}

@keyframes breakSeal {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    40% { transform: translate(-50%, -50%) scale(1.2); opacity: 0.8; }
    100% { transform: translate(-50%, -50%) scale(0); opacity: 0; display: none; }
}

.envelope-container.opening {
    transform: scale(1.1);
    opacity: 0;
    pointer-events: none;
}

/* ==========================================================================
   SIMPLE STACKED CARDS LAYOUT (Replaces 3D Book)
   ========================================================================== */
.book-container {
    position: absolute;
    width: 100%;
    max-width: 500px;
    height: 70vh;
    max-height: 700px;
    min-height: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 1s;
}

.book-container.hidden {
    opacity: 0;
    pointer-events: none;
}

.book {
    position: relative;
    width: 100%;
    height: 100%;
}

.page {
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.page.turned {
    opacity: 0;
    transform: scale(1.08);
    pointer-events: none;
}

/* Base styles for the faces of the page */
.page-front {
    position: relative;
    width: 100%;
    height: 100%;
    background-image: url('assets/paper.png');
    background-size: cover;
    background-color: #f6eedb; 
    color: #302a23; 
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    overflow: hidden;
    padding: clamp(15px, 5vw, 30px);
    border-radius: 4px;
    box-shadow: 0 18px 36px rgba(0,0,0,0.55);
}

.page-back {
    display: none;
}

.inner-page-bg {
    background-color: #efe5ce; 
}

@media (max-width: 760px) {
    .envelope-container, .book-container {
        max-width: 95vw;
    }

    .guitar-wrapper, .dolphin-wrapper { width: 120px; }
    .water-waves { width: 90px; height: 90px; }
    .wave { width: 140px; height: 140px; }

    .countdown-elegant { flex-wrap: wrap; gap: 10px; }
    .countdown-number { font-size: 2.2rem; }
    
    .leaf-decor { display: none; }
}

/* ==========================================================================
   DECORATIONS & LAYOUT
   ========================================================================== */
.string-lights {
    position: absolute; top: 0; left: 0; width: 100%; height: 50px; z-index: 10;
}

.bulb { animation: glowBulb 2s infinite alternate; }
.bulb:nth-child(even) { animation-delay: 1s; }

@keyframes glowBulb {
    0% { fill: #fada9d; filter: drop-shadow(0 0 2px #fff); }
    100% { fill: #fff3db; filter: drop-shadow(0 0 8px #ffdf91); }
}

.leaf-decor {
    position: absolute; font-size: 3rem; opacity: 0.6; filter: sepia(0.5) hue-rotate(50deg);
}
.leaf-left { top: 80px; left: 10px; transform: rotate(45deg); }
.leaf-right { top: 150px; right: 10px; transform: rotate(-45deg); }

.subtitle-handwritten {
    font-family: 'Amatic SC', cursive; font-size: 2rem; color: #4a3f35; letter-spacing: 2px;
    text-shadow: 1px 1px 0px rgba(255,255,255,0.6);
    text-align: center;
    width: 100%;
}

.title-main {
    font-family: 'Great Vibes', cursive; font-size: clamp(3rem, 8vw, 4.5rem); color: #3b332b; line-height: 0.8; margin: 20px 0; z-index: 5; position: relative;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1), 1px 1px 0px rgba(255,255,255,0.5);
}

.title-main .groom {
    display: block;
    margin-top: 24px; /* significant downward space between 'y' and Javier */
}

.ampersand {
    font-family: 'Great Vibes', cursive;
    font-size: 3.2rem;
    color: #8e1f1f;
    position: relative;
    display: inline-block;
    margin: 0; /* minimal gap so 'y' stays close to Javier */
    line-height: 0.95;
    transform: translateY(1px);
}

/* Small adjustment to keep guitar illustration from overlapping text */
.guitar-wrapper { transform: translateX(-4%); }

.text-romantic {
    font-family: 'Amatic SC', cursive; font-size: clamp(1.2rem, 4vw, 1.6rem); line-height: 1.2; color: #3b332b; font-weight: 700;
    text-shadow: 1px 1px 0px rgba(255,255,255,0.6);
}

.date-main {
    font-family: 'Amatic SC', cursive; font-size: 2rem; color: #4a3f35; margin-top: 20px; font-weight: 700;
    text-shadow: 1px 1px 0px rgba(255,255,255,0.6);
}

/* ==========================================================================
   ANIMATED SVGS (GUITAR & DOLPHIN)
   ========================================================================== */
.art-container {
    display: flex; justify-content: space-between; align-items: flex-end; width: 100%; margin-top: auto; padding: 0 10px; z-index: 5; position: relative;
}

.guitar-wrapper, .dolphin-wrapper {
    position: relative; width: 170px;
}

/* User's Custom Transparent PNGs */
.illust-png {
    width: 100%;
    height: auto;
    /* Subtle shadow for depth, preserving the user's original colors */
    filter: drop-shadow(2px 2px 5px rgba(0,0,0,0.3));
}

.jumping-dolphin {
    animation: jumpDolphin 4s cubic-bezier(0.4, 0.0, 0.2, 1) infinite;
    transform-origin: bottom center;
    opacity: 1; /* ensure visible immediately */
}

@keyframes jumpDolphin {
    0% { transform: translateY(0px) rotate(-5deg); opacity: 1; }
    15% { transform: translateY(-24px) rotate(10deg); opacity: 1; }
    50% { transform: translateY(-50px) rotate(25deg); opacity: 1; }
    85% { transform: translateY(10px) rotate(45deg); opacity: 1; }
    100% { transform: translateY(40px) rotate(50deg); opacity: 1; }
}

.water-waves {
    position: absolute; bottom: -40px; right: -50px; width: 180px; height: 180px;
    overflow: hidden; border-radius: 50%;
    /* To soften the edges */
    box-shadow: inset 0 0 20px rgba(246, 238, 219, 1);
}

.wave {
    position: absolute; bottom: 0; left: 50%; width: 300px; height: 300px;
    background: #4a7c8f; border-radius: 40%;
    transform: translateX(-50%) translateY(75%);
    animation: liquidRotate 6s linear infinite;
}
.w2 { background: #86a8b5; animation: liquidRotate 7s linear infinite; border-radius: 45%; opacity: 0.8; }
.w3 { background: #3b5c6b; animation: liquidRotate 6s linear infinite; border-radius: 38%; opacity: 0.5; }

@keyframes liquidRotate {
    0% { transform: translateX(-50%) translateY(75%) rotate(0deg); }
    100% { transform: translateX(-50%) translateY(75%) rotate(360deg); }
}

/* Guitar notes */
.guitar-wrapper .music-note {
    position: absolute; color: #4a3f35; font-size: 1.5rem; opacity: 0;
}
.n1 { top: 0; left: 60%; animation: floatNote 3s linear infinite; }
.n2 { top: 20%; left: 80%; animation: floatNote 4s linear infinite 1s; }

@keyframes floatNote {
    0% { transform: translate(0, 0) scale(0.5); opacity: 0; }
    20% { opacity: 0.8; }
    100% { transform: translate(30px, -50px) scale(1.2); opacity: 0; }
}

/* ==========================================================================
   PAGE 2: DETAILS LIST
   ========================================================================== */
.details-list {
    display: flex; flex-direction: column; gap: 1.5rem; width: 100%; margin-top: 1rem; text-align: left; padding-left: 10px;
}

.detail-row {
    display: flex; align-items: center; gap: 15px; border-bottom: 1px solid rgba(139,121,94,0.3); padding-bottom: 10px;
}
.detail-row:last-child { border-bottom: none; }

.detail-icon-svg {
    width: 30px; height: 30px; color: #4a3f35; flex-shrink: 0;
}

.detail-content h4 { font-family: 'Amatic SC', cursive; font-size: 1.5rem; color: #4a3f35; margin-bottom: 2px; }
.detail-content p { font-family: 'Playfair Display', serif; font-size: 0.9rem; font-style: italic; color: #5a4f44; }

.mb-spaced { margin-bottom: 2rem; }
.mt-spaced { margin-top: 2rem; }

/* ==========================================================================
   PAGE 3: FINAL
   ========================================================================== */
.final-layout { justify-content: center; }

.countdown-elegant { display: flex; justify-content: center; gap: 20px; margin: 2rem 0; }
.countdown-item { display: flex; flex-direction: column; align-items: center; font-family: 'Amatic SC', cursive; color: #4a3f35; }
.countdown-number { font-size: 3.5rem; line-height: 0.8; }
.countdown-label { font-size: 1.5rem; color: #7a6a5b; }

.signature { font-family: 'Great Vibes', cursive; font-size: clamp(2.5rem, 6vw, 3.5rem); margin-top: 1.5rem; color: #3b332b; }

.page-hint {
    position: absolute; bottom: 15px; right: 15px; font-family: 'Amatic SC', cursive; font-size: 1.2rem; color: #8c7b6c; animation: pulse 2s infinite; pointer-events: none;
}
