/* ═══════════════════════════════════════════════════════════════
   THEME FLOWER — blooming petal selector
   Fixed bottom-right. Click the center to bloom open 6 petals.
   Each petal shows its theme's sky-to-grass gradient with
   leaf veins (SVG). Active petal glows.
   ═══════════════════════════════════════════════════════════════ */

/* ── Backdrop (click-to-close target) ── */
.theme-backdrop {
    position: fixed;
    inset: 0;
    z-index: 299;
    background: transparent;
    pointer-events: none;
    transition: background 0.25s ease;
}

.theme-flower.open ~ .theme-backdrop {
    pointer-events: auto;
}

/* ── Flower container ── */
.theme-flower {
    position: fixed;
    bottom: 18px;
    right: 18px;
    z-index: 300;
    width: 44px;
    height: 44px;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Flower drifts inward when open so all petals stay on screen */
.theme-flower.open {
    transform: translate(-70px, -70px);
}

/* ── Center button ── */
.theme-center {
    position: absolute;
    inset: 0;
    width: 44px;
    height: 44px;
    border: 2px solid var(--border);
    border-radius: 50%;
    background: var(--card);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: all 0.22s ease;
    outline: none;
    color: var(--text);
    z-index: 2;
}

.theme-center:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(100, 80, 120, 0.18);
}

.theme-center:active {
    transform: scale(0.95);
}

.theme-center:focus-visible {
    outline: 3px solid var(--yellow);
    outline-offset: 3px;
}

.theme-flower.open .theme-center {
    box-shadow: 0 4px 20px rgba(100, 80, 120, 0.2);
}

/* ── Petals wrapper ── */
.theme-petals {
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* ── Individual petal ── */
.theme-petal {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: none;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: rotate(var(--angle)) translateY(0) scale(0.3);
    transition:
        transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.25s ease,
        box-shadow 0.25s ease;
    transition-delay: 0ms;
    outline: none;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.12),
        inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

/* ── Leaf veins (SVG via custom property) ── */
.theme-petal::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: var(--veins-svg);
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
    border-radius: inherit;
    opacity: 0.9;
    transition: opacity 0.2s ease;
}

.theme-petal:hover {
    transform: rotate(var(--angle)) translateY(-58px) scale(1.1);
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.18),
        inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    z-index: 5;
}

.theme-petal:hover::after {
    opacity: 1;
}

.theme-petal:focus-visible {
    outline: 3px solid var(--yellow);
    outline-offset: 2px;
}

/* ── Open state: petals bloom outward ── */
.theme-flower.open .theme-petal {
    opacity: 1;
    pointer-events: auto;
    transform: rotate(var(--angle)) translateY(-58px) scale(1);
    transition-delay: var(--delay, 0ms);
}

/* ── Active petal: pulsing glow using the theme's accent ── */
.theme-petal.active {
    animation: petal-pulse 1.8s ease-in-out infinite;
}

@keyframes petal-pulse {
    0%, 100% {
        box-shadow:
            0 0 10px 3px var(--petal-glow, #ff6b8a),
            0 0 22px 6px var(--petal-glow, #ff6b8a),
            0 2px 8px rgba(0, 0, 0, 0.12),
            inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    }
    50% {
        box-shadow:
            0 0 18px 6px var(--petal-glow, #ff6b8a),
            0 0 36px 10px var(--petal-glow, #ff6b8a),
            0 2px 8px rgba(0, 0, 0, 0.12),
            inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    .theme-flower {
        transition: none;
    }
    .theme-petal {
        transition: none;
    }
    .theme-petal.active {
        animation: none;
        box-shadow:
            0 0 10px 3px var(--petal-glow, #ff6b8a),
            0 2px 8px rgba(0, 0, 0, 0.12),
            inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    }
    .theme-flower.open .theme-petal {
        transition: none;
    }
}
