:root {
    --bg-color: #faf9f6;
    /* Off-white/Cream warmer than pure white */
    --text-color: #3d3b3b;
    /* Softer charcoal */
    --accent-color: #d4a373;
    /* Warm earth tone */
    --secondary-color: #4a4a4a;
    --font-heading: 'Raleway', sans-serif;
    --font-body: 'Cormorant Garamond', serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    /* Dynamic warm gradient background - Slightly more opaque/visible (Peach, Cream, Soft Rose) */
    background: linear-gradient(-45deg, #f0eee9, #ffe8df, #f7f4ed, #ffe6ea);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    /* Faster transition as requested */
    color: var(--text-color);
    overflow: hidden;
    /* Disable page scroll as requested */
    /* Use dvh for better mobile support (dynamic viewport height) handles Safari bars */
    height: 100vh;
    height: 100dvh;
    width: 100%;
    position: relative;
    /* iOS Font Smoothing */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body::before {
    content: "";
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    /* Placeholder for user image */
    background-image: url('./fondo.png');
    background-repeat: no-repeat;
    background-position: center center;
    /* Responsive size: capped at 600px or 90% of screen width */
    background-size: min(90vw, 600px);
    opacity: 0.08;
    /* Low opacity as requested */
    z-index: 0;
    pointer-events: none;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Music Player Widget */
.music-player {
    position: fixed;
    bottom: 30px;
    right: 30px;
    /* Warmer background to match theme */
    background: rgba(255, 252, 245, 0.9);
    backdrop-filter: blur(8px);
    padding: 12px 25px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 8px 30px rgba(212, 163, 115, 0.15);
    /* Warm shadow */
    z-index: 2000;
    transition: all 0.5s ease;
    border: 1px solid rgba(212, 163, 115, 0.2);
    /* Subtle accent border */
}

.music-player.hidden,
.hidden {
    display: none !important;
}

.music-info {
    display: flex;
    flex-direction: column;
    text-align: right;
    font-size: 0.8rem;
    font-family: var(--font-heading);
}

.music-title {
    font-weight: bold;
    color: var(--secondary-color);
}

.music-artist {
    color: #888;
    font-size: 0.7rem;
}

.play-btn {
    background: none;
    border: none;
    color: var(--secondary-color);
    cursor: pointer;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, color 0.2s;
}

.play-btn:hover {
    transform: scale(1.1);
    color: var(--accent-color);
    background: none;
    /* Override general button hover */
}

/* Override general button styles for play button so it doesn't look like the main CTA */
button.play-btn {
    border-radius: 0;
    width: auto;
}

/* Overlay Styles */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #faf9f6;
    /* Match body bg */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 1s ease-out;
}

.overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.question-container {
    text-align: center;
    padding: 3rem;
    max-width: 90%;
    background: #faf9f6;
    /* Removed dashed border for cleaner look */
}

.question-container h1 {
    font-family: var(--font-heading);
    font-weight: 300;
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: var(--secondary-color);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.question-container p {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    margin-bottom: 2rem;
    color: #666;
    line-height: 1.6;
}

input {
    padding: 12px 0;
    font-size: 1.1rem;
    border: none;
    border-bottom: 1px solid #ccc;
    font-family: var(--font-heading);
    outline: none;
    transition: border-color 0.3s;
    text-align: center;
    width: 200px;
    color: var(--text-color);
    background: transparent;
}

input:focus {
    border-bottom-color: var(--accent-color);
}

button {
    display: block;
    margin: 2rem auto 0;
    padding: 12px 40px;
    font-size: 0.9rem;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 50px;
    /* Softer shape */
    font-family: var(--font-heading);
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s;
}

button:hover {
    background-color: var(--accent-color);
    transform: translateY(-2px);
}

.error {
    animation: shake 0.5s;
    border-bottom-color: #d9534f;
    color: #d9534f;
}

@keyframes shake {
    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    50% {
        transform: translateX(5px);
    }

    75% {
        transform: translateX(-5px);
    }

    100% {
        transform: translateX(0);
    }
}

/* Content Styles */
.content {
    opacity: 0;
    z-index: 10;
    /* Ensure text is above petals */
}

.content.visible {
    opacity: 1;
}

.section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    justify-content: center;
    align-items: center;
    position: absolute;
    /* Sections overlap in position, visibility controlled by JS */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    /* Allow internal scroll only if content is taller than screen */
    transition: opacity 1s ease-in-out;
}

.section.hidden {
    opacity: 0;
    pointer-events: none;
    z-index: -1;
}

.text-card {
    max-width: 600px;
    margin: 0 auto;
    /* Horizontally center only */
    text-align: center;
    font-size: 1.6rem;
    line-height: 1.8;
    color: var(--text-color);
}

.text-card p {
    margin-bottom: 2rem;
}

.text-card p::first-letter {
    font-size: 3.5rem;
    float: none;
    /* Removed float to fix gap in centered text */
    line-height: 0.8;
    vertical-align: -5px;
    /* Slight vertical adjustment */
    margin-right: 2px;
    color: var(--accent-color);
}

/* Scroll Indicator */
/* Next Button */
.next-btn {
    margin-top: 0;
    /* Removed margin to keep it very close to text */
    background-color: transparent;
    color: var(--secondary-color);
    border: 1px solid var(--secondary-color);
    font-size: 1.1rem;
    padding: 10px 35px;
    letter-spacing: 2px;
}

.next-btn:hover {
    background-color: var(--secondary-color);
    color: white;
    transform: translateY(-2px);
}

/* Sound Overlay */
.sound-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
    z-index: 50;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.sound-overlay.visible {
    opacity: 1;
}

.sound-icon-container {
    text-align: center;
    color: var(--secondary-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.icon-wrapper {
    position: relative;
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Sound Wave / Ripple Effect */
.icon-wrapper::before,
.icon-wrapper::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border: 1px solid var(--accent-color);
    border-radius: 50%;
    animation: ripple 2s infinite linear;
    z-index: -1;
}

.icon-wrapper::after {
    animation-delay: 1s;
}

@keyframes ripple {
    0% {
        width: 100%;
        height: 100%;
        opacity: 0.8;
        border-width: 2px;
    }

    100% {
        width: 300%;
        height: 300%;
        opacity: 0;
        border-width: 0px;
    }
}

.sound-icon {
    /* Gentle float */
    animation: float 3s ease-in-out infinite;
}

.sound-icon-container p {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    margin-top: 2rem;
    /* Increased margin for ripples */
    letter-spacing: 2px;
    text-transform: uppercase;
    animation: fadeInOut 3s infinite;
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-5px);
    }

    100% {
        transform: translateY(0px);
    }
}

@keyframes fadeInOut {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

/* Poem Section */
#part2 {
    background: transparent;
}

.poem-card {
    max-width: 700px;
    margin: 0 auto;
    text-align: center;
    padding: 2rem;
    /* Add padding bottom to valid overlap with music player */
    padding-bottom: 120px;
}

.poem-line {
    font-size: 1.8rem;
    line-height: 2;
    margin-bottom: 0.5rem;
    opacity: 0;
    transform: translateY(20px);
    transition: all 4s ease-out;
    /* Super slow fade-in duration */
}

/* Music starts at 0s */

/* Line 1 appears at 2.5s (allowing music intro) */
.poem-card.show .poem-line:nth-child(1) {
    transition-delay: 2.5s;
}

/* Line 2 appears at 7.5s */
.poem-card.show .poem-line:nth-child(2) {
    transition-delay: 7.5s;
}

/* Line 3 appears at 12.5s */
.poem-card.show .poem-line:nth-child(3) {
    transition-delay: 12.5s;
}

/* Child 4 is <br> */

/* Line 4 appears at 17.5s */
.poem-card.show .poem-line:nth-child(5) {
    transition-delay: 17.5s;
}

/* Line 5 appears at 22.5s */
.poem-card.show .poem-line:nth-child(6) {
    transition-delay: 22.5s;
}

.poem-card.show .poem-line {
    opacity: 1;
    transform: translateY(0);
}


/* Mobile Optimization */
@media (max-width: 768px) {
    .question-container h1 {
        font-size: 2rem;
    }

    .text-card p {
        font-size: 1.2rem;
        /* Slightly smaller for better reading on phone */
        padding: 0 0.5rem;
        line-height: 1.6;
    }

    .poem-line {
        font-size: 1.3rem;
        /* Adjusted for smaller screens */
        line-height: 1.5;
        margin-bottom: 1rem;
    }

    .music-player {
        bottom: 20px;
        right: 20px;
        padding: 8px 15px;
        /* Compact player */
    }

    .music-player .music-info {
        display: flex;
        font-size: 0.7rem;
        max-width: 150px;
        /* Prevent it from taking too much space */
        line-height: 1.2;
    }

    /* Fix native input styles on iOS */
    input {
        border-radius: 0;
        -webkit-appearance: none;
        appearance: none;
    }

    button {
        -webkit-appearance: none;
        appearance: none;
        /* iOS button reset */
    }
}

/* Petal Animation */
.petal {
    position: absolute;
    top: -50px;
    opacity: 0.6;
    animation-name: fall;
    animation-timing-function: linear;
    pointer-events: none;
}

@keyframes fall {
    0% {
        transform: translateY(-50px) translateX(0) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 0.8;
    }

    100% {
        transform: translateY(110vh) translateX(100px) rotate(360deg);
        opacity: 0;
    }
}