/* ============================================
   FLORES AMARILLAS – Stylesheet
   Experiencia romántica interactiva
   ============================================ */

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Palette */
    --bg-cream: #FFFBF7;
    --bg-peach: #FFEEDD;
    --text-primary: #5D4037;
    --text-secondary: #9C786C;
    --accent-gold: #FFB300;
    --heart-red: #E57373;

    /* Typography */
    --font-display: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
    --font-body: 'Lato', 'Helvetica Neue', Arial, sans-serif;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    background: linear-gradient(170deg,
            var(--bg-cream) 0%,
            #FFF6ED 35%,
            #FFF2E5 65%,
            var(--bg-peach) 100%);
    font-family: var(--font-body);

    /* Prevent all default touch behaviors */
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
}

/* ---------- Background Overlays ---------- */
#warmGlow {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 50% 55%,
            rgba(255, 200, 80, 0.10) 0%,
            rgba(255, 180, 50, 0.05) 40%,
            transparent 72%);
    opacity: 0;
    transition: opacity 3s ease;
    pointer-events: none;
    z-index: 0;
}

#finalOverlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 50% 50%,
            rgba(255, 248, 235, 0.75) 0%,
            rgba(255, 240, 215, 0.50) 50%,
            rgba(255, 230, 200, 0.25) 100%);
    opacity: 0;
    transition: opacity 2.5s ease;
    pointer-events: none;
    z-index: 3;
}

/* ---------- Canvas ---------- */
#flowerCanvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    cursor: crosshair;
}

/* ---------- Message Overlay ---------- */
#overlay {
    position: fixed;
    inset: 0;
    z-index: 4;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-container {
    text-align: center;
    padding: 2rem 2.5rem;
    max-width: 90vw;
}

.message-container h1 {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(1.6rem, 6vw, 3.2rem);
    color: var(--text-primary);
    margin-bottom: 0.8rem;
    line-height: 1.4;
    letter-spacing: 0.02em;
}

.message-container p {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.85rem, 2.8vw, 1.2rem);
    color: var(--text-secondary);
    letter-spacing: 0.06em;
    line-height: 1.6;
}

/* ---------- Initial Message Entrance ---------- */
#initialMessage {
    opacity: 0;
    transform: translateY(18px);
    animation: msgFadeIn 1.8s ease 0.3s forwards;
}

#initialMessage p {
    opacity: 0;
    animation: msgFadeIn 1.5s ease 1.2s forwards;
}

@keyframes msgFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- Initial Message Fade Out ---------- */
#initialMessage.fading {
    transition: opacity 2s ease, transform 2s ease;
    opacity: 0 !important;
    transform: translateY(-12px) !important;
}

/* ---------- Final Message ---------- */
#finalMessage {
    position: absolute;
    pointer-events: none;
}

#finalMessage h1 {
    opacity: 0;
    transform: translateY(14px);
}

#finalMessage p {
    opacity: 0;
    transform: translateY(10px);
}

#finalMessage h1.visible {
    animation: msgFadeIn 2s ease forwards;
}

#finalMessage p.visible {
    animation: msgFadeIn 1.8s ease forwards;
}

.hidden {
    display: none !important;
}

/* ---------- Heart ---------- */
#heart {
    font-size: clamp(1.6rem, 5vw, 2.4rem);
    margin-top: 1.2rem;
    opacity: 0;
    transform: scale(0.3);
}

#heart.visible {
    display: block !important;
    animation: heartAppear 1.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes heartAppear {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

#heart.beating {
    animation: heartBeat 2.4s ease-in-out infinite;
}

@keyframes heartBeat {

    0%,
    100% {
        transform: scale(1);
    }

    15% {
        transform: scale(1.12);
    }

    30% {
        transform: scale(1);
    }

    45% {
        transform: scale(1.08);
    }

    60% {
        transform: scale(1);
    }
}

/* ---------- Click Ripple ---------- */
#rippleContainer {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
}

.click-ripple {
    position: absolute;
    width: 28px;
    height: 28px;
    margin-left: -14px;
    margin-top: -14px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 200, 60, 0.55);
    pointer-events: none;
    animation: rippleExpand 0.8s ease-out forwards;
}

@keyframes rippleExpand {
    0% {
        transform: scale(0);
        opacity: 1;
    }

    100% {
        transform: scale(3.5);
        opacity: 0;
    }
}

/* ---------- Milestone Toast ---------- */
.milestone-toast {
    position: fixed;
    bottom: 2.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(30px);
    z-index: 20;
    pointer-events: none;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;

    background: rgba(255, 252, 244, 0.82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(200, 165, 80, 0.22);
    border-radius: 18px;
    padding: 1.1rem 2rem 1.2rem;
    max-width: min(88vw, 420px);
    text-align: center;
    box-shadow:
        0 8px 32px rgba(100, 60, 10, 0.10),
        0 2px 8px rgba(100, 60, 10, 0.06),
        inset 0 1px 0 rgba(255, 240, 180, 0.5);

    opacity: 0;
    transition:
        opacity 0.9s ease,
        transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.milestone-toast.toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-count {
    display: block;
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(1.05rem, 3.5vw, 1.4rem);
    color: var(--text-primary);
    letter-spacing: 0.03em;
    line-height: 1.3;
}

.toast-phrase {
    display: block;
    font-family: var(--font-display);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(0.82rem, 2.6vw, 1.08rem);
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    line-height: 1.5;
}

/* Separador decorativo entre count y phrase */
.milestone-toast::before {
    content: '';
    display: block;
    width: 28px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(180, 140, 60, 0.45), transparent);
    margin: 0 auto 0.1rem;
    order: 2;
}

.toast-count {
    order: 1;
}

.toast-phrase {
    order: 3;
}

/* ---------- Music Player ---------- */
#musicPlayer {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10;
}

#musicToggle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1.5px solid rgba(180, 140, 90, 0.3);
    background: rgba(255, 250, 240, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

#musicToggle:hover {
    background: rgba(255, 245, 225, 0.9);
    border-color: var(--accent-gold);
    transform: scale(1.05);
}

#musicToggle:active {
    transform: scale(0.95);
}

#musicToggle .music-icon {
    line-height: 1;
}

/* ---------- Responsive Fine-tuning ---------- */
@media (max-width: 480px) {
    .message-container {
        padding: 1.5rem 1.8rem;
    }
}

@media (min-width: 1024px) {
    #flowerCanvas {
        cursor: crosshair;
    }
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}