/* Variables de paleta de colores y transiciones */
:root {
    --bg-dark-1: #060214;
    --bg-dark-2: #12082b;
    --color-stem-1: #1e5927;
    --color-stem-2: #3aa64a;
    --color-leaf-1: #15451c;
    --color-leaf-2: #4ec261;
    --petal-outer-1: rgba(255, 33, 114, 0.85);
    --petal-outer-2: rgba(255, 107, 156, 0.3);
    --petal-mid-1: rgba(255, 120, 180, 0.9);
    --petal-mid-2: rgba(255, 203, 164, 0.4);
    --petal-inner-1: rgba(255, 230, 100, 0.95);
    --petal-inner-2: rgba(255, 107, 156, 0.5);
    --center-core: #ffdf43;
    --center-glow: rgba(255, 191, 0, 0.8);
    --glow-shadow: 0 0 30px rgba(255, 33, 114, 0.5);
}

/* Configuración General */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: radial-gradient(circle at center, var(--bg-dark-2) 0%, var(--bg-dark-1) 100%);
    color: #f1f1f1;
    font-family: 'Quicksand', sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

/* Canvas para partículas */
#particle-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* Estrellas estáticas / flotantes creadas por CSS */
.stars-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-image: 
        radial-gradient(white, rgba(255,255,255,.2) 2px, transparent 40px),
        radial-gradient(white, rgba(255,255,255,.15) 1px, transparent 30px),
        radial-gradient(white, rgba(255,255,255,.1) 2px, transparent 40px);
    background-size: 550px 550px, 350px 350px, 250px 250px;
    background-position: 0 0, 40px 60px, 130px 270px;
    opacity: 0.25;
    z-index: 0;
    animation: backgroundDrift 120s linear infinite;
}

@keyframes backgroundDrift {
    0% { background-position: 0 0, 40px 60px, 130px 270px; }
    100% { background-position: 550px 1100px, 390px 1110px, 130px 1270px; }
}

/* Contenedor principal */
.container {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 600px;
    text-align: center;
    padding: 20px;
}

/* Textos */
.title {
    font-family: 'Playfair Display', serif;
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #ffffff 30%, #ff89bc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 20px rgba(255, 107, 156, 0.2);
    margin-bottom: 8px;
    user-select: none;
}

.subtitle {
    font-size: 1rem;
    color: #b0a4d4;
    font-weight: 300;
    letter-spacing: 1px;
    margin-bottom: 40px;
    user-select: none;
    transition: color 0.3s ease;
}

.subtitle:hover {
    color: #ffb8d4;
}

/* Contenedor de la flor */
.flower-wrapper {
    position: relative;
    width: 300px;
    height: 450px;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

.flower {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    /* Efecto de inclinación interactiva controlada por JS */
    --tilt-x: 0deg;
    --tilt-y: 0deg;
    transform: rotateX(var(--tilt-x)) rotateY(var(--tilt-y));
    transition: transform 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    transform-origin: bottom center;
}

/* TALLO */
.stem {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 8px;
    height: 280px;
    background: linear-gradient(to top, var(--color-stem-1), var(--color-stem-2));
    border-radius: 4px;
    transform: translateX(-50%);
    box-shadow: 0 0 10px rgba(58, 166, 74, 0.4);
    z-index: 1;
    transform-origin: bottom center;
    animation: stemSway 6s ease-in-out infinite;
}

/* Hojas */
.leaf {
    position: absolute;
    width: 60px;
    height: 35px;
    background: linear-gradient(135deg, var(--color-leaf-2), var(--color-leaf-1));
    border-radius: 0 100% 0 100% / 0 100% 0 100%; /* Curvatura orgánica de hoja */
    box-shadow: 0 0 8px rgba(78, 194, 97, 0.3);
    transform-origin: bottom left;
    display: flex;
    align-items: center;
    justify-content: center;
}

.leaf-left {
    left: -52px;
    top: 100px;
    transform: rotate(-25deg);
    animation: leftLeafSway 5s ease-in-out infinite alternate;
}

.leaf-right {
    right: -52px;
    top: 150px;
    transform: scaleX(-1) rotate(-35deg); /* Espejo */
    transform-origin: bottom left;
    animation: rightLeafSway 5s ease-in-out infinite alternate;
}

/* Nervadura de la hoja */
.leaf-vein {
    width: 85%;
    height: 2px;
    background-color: rgba(255, 255, 255, 0.15);
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%) rotate(5deg);
    border-radius: 1px;
}

/* CABEZA DE LA FLOR */
.flower-head {
    position: absolute;
    bottom: 250px; /* Alineada con el final del tallo */
    left: 50%;
    width: 180px;
    height: 180px;
    transform: translate(-50%, 0) scale(0); /* Empieza en 0 y crece con la animación */
    transform-origin: center center;
    cursor: pointer;
    z-index: 2;
    filter: drop-shadow(0 0 15px rgba(255, 33, 114, 0.25));
    animation: bloomIn 1.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, headSway 6s ease-in-out infinite;
}

.flower-head:hover {
    filter: drop-shadow(0 0 25px rgba(255, 107, 156, 0.6));
    transform: translate(-50%, -5px) scale(1.05);
}

.flower-head:active {
    transform: translate(-50%, 0) scale(0.95);
    transition: transform 0.1s ease;
}

/* Capas de pétalos */
.petals-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Configuración genérica del pétalo */
.petal {
    position: absolute;
    width: 45px;
    height: 90px;
    transform-origin: bottom center;
    /* Forma de pétalo suave utilizando border-radius */
    border-radius: 50% 50% 50% 50% / 80% 80% 20% 20%;
    box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.4), 0 4px 10px rgba(0,0,0,0.3);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Pétalos Externos (8 pétalos, ángulo base de 45deg) */
.outer-petals .petal {
    background: linear-gradient(to top, var(--petal-outer-1), var(--petal-outer-2));
    width: 45px;
    height: 90px;
    bottom: 50%; /* Comienza en el centro de la flor */
    transform: rotate(calc(var(--i) * 45deg)) translateY(0px);
    z-index: 10;
}

.flower-head:hover .outer-petals .petal {
    transform: rotate(calc(var(--i) * 45deg)) translateY(-10px) scale(1.05);
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.6), 0 8px 15px rgba(255, 33, 114, 0.4);
}

/* Pétalos Medios (8 pétalos, rotados 22.5deg para cubrir huecos) */
.middle-petals .petal {
    background: linear-gradient(to top, var(--petal-mid-1), var(--petal-mid-2));
    width: 38px;
    height: 75px;
    bottom: 50%;
    transform: rotate(calc((var(--i) * 45deg) + 22.5deg)) translateY(0);
    z-index: 11;
}

.flower-head:hover .middle-petals .petal {
    transform: rotate(calc((var(--i) * 45deg) + 22.5deg)) translateY(-6px) scale(1.04);
}

/* Pétalos Internos (6 pétalos, ángulo de 60deg) */
.inner-petals .petal {
    background: linear-gradient(to top, var(--petal-inner-1), var(--petal-inner-2));
    width: 28px;
    height: 55px;
    bottom: 50%;
    transform: rotate(calc(var(--i) * 60deg)) translateY(0);
    z-index: 12;
    box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.5), 0 2px 6px rgba(0,0,0,0.25);
}

.flower-head:hover .inner-petals .petal {
    transform: rotate(calc(var(--i) * 60deg)) translateY(-3px) scale(1.03);
}

/* CENTRO RADIANTE DE LA FLOR */
.flower-center {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 48px;
    height: 48px;
    transform: translate(-50%, -50%);
    z-index: 15;
    pointer-events: none;
}

.center-core {
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, #ffffff 10%, var(--center-core) 60%, #ff8933 100%);
    border-radius: 50%;
    box-shadow: 
        0 0 15px #ffb300, 
        inset 0 0 10px rgba(255, 255, 255, 0.8),
        0 4px 10px rgba(0,0,0,0.3);
    animation: pulseGlow 2s ease-in-out infinite alternate;
}

.center-glow {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,223,67,0.35) 0%, rgba(255,223,67,0) 70%);
    pointer-events: none;
    mix-blend-mode: screen;
    animation: pulseGlow 2s ease-in-out infinite alternate-reverse;
}

/* Pistilos */
.pistil-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    animation: spinPistils 20s linear infinite;
}

.pistil {
    position: absolute;
    width: 2px;
    height: 18px;
    background: linear-gradient(to top, #ffdf43, #ff4c8c);
    bottom: 50%;
    left: 50%;
    transform-origin: bottom center;
    transform: rotate(calc(var(--p) * 60deg)) translateY(-15px);
    border-radius: 1px;
}

.pistil::after {
    content: '';
    position: absolute;
    top: -3px;
    left: -2px;
    width: 6px;
    height: 6px;
    background-color: #ffd000;
    border-radius: 50%;
    box-shadow: 0 0 5px #ffd000;
}

/* Indicador de interacción flotante */
.interaction-hint {
    margin-top: 15px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 2px;
    text-transform: uppercase;
    animation: pulseOpacity 1.5s ease-in-out infinite alternate;
    pointer-events: none;
    user-select: none;
}

/* ANIMACIONES */

/* Animación de brote inicial de la flor */
@keyframes bloomIn {
    0% {
        transform: translate(-50%, 0) scale(0) rotate(-45deg);
        opacity: 0;
    }
    60% {
        transform: translate(-50%, 0) scale(1.1) rotate(10deg);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, 0) scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Balanceo del tallo */
@keyframes stemSway {
    0%, 100% { transform: translateX(-50%) rotate(0deg); }
    33% { transform: translateX(-50%) rotate(2.5deg); }
    66% { transform: translateX(-50%) rotate(-2.5deg); }
}

/* Balanceo de la cabeza para acompañar al tallo de forma desfasada */
@keyframes headSway {
    0%, 100% { transform: translate(-50%, 0) rotate(0deg); }
    33% { transform: translate(-52%, -2px) rotate(3deg); }
    66% { transform: translate(-48%, -2px) rotate(-3deg); }
}

/* Movimiento de las hojas */
@keyframes leftLeafSway {
    0% { transform: rotate(-25deg); }
    100% { transform: rotate(-18deg) scale(1.05); }
}

@keyframes rightLeafSway {
    0% { transform: scaleX(-1) rotate(-35deg); }
    100% { transform: scaleX(-1) rotate(-28deg) scale(1.05); }
}

/* Pulso del brillo del centro */
@keyframes pulseGlow {
    0% {
        transform: scale(0.95);
        filter: brightness(1);
    }
    100% {
        transform: scale(1.05);
        filter: brightness(1.2);
    }
}

@keyframes spinPistils {
    to { transform: rotate(360deg); }
}

/* Pulso del texto guía */
@keyframes pulseOpacity {
    0% { opacity: 0.3; }
    100% { opacity: 0.85; }
}

/* Adaptabilidad para pantallas pequeñas */
@media (max-height: 700px) {
    .flower-wrapper {
        height: 350px;
    }
    .stem {
        height: 200px;
    }
    .flower-head {
        bottom: 175px;
    }
    .title {
        font-size: 2.2rem;
    }
    .subtitle {
        margin-bottom: 20px;
    }
}
