/* Burbujas ambientales — adaptado de danielbarreiros */

@property --blob-1-core { syntax: '<color>'; inherits: true; initial-value: rgb(220, 38, 38); }
@property --blob-1-mid { syntax: '<color>'; inherits: true; initial-value: rgb(248, 113, 113); }
@property --blob-2-core { syntax: '<color>'; inherits: true; initial-value: rgb(185, 28, 28); }
@property --blob-2-mid { syntax: '<color>'; inherits: true; initial-value: rgb(252, 165, 165); }
@property --blob-3-core { syntax: '<color>'; inherits: true; initial-value: rgb(255, 149, 0); }
@property --blob-3-mid { syntax: '<color>'; inherits: true; initial-value: rgb(251, 146, 60); }
@property --blob-4-core { syntax: '<color>'; inherits: true; initial-value: rgb(234, 88, 12); }
@property --blob-4-mid { syntax: '<color>'; inherits: true; initial-value: rgb(249, 115, 22); }
@property --blob-5-core { syntax: '<color>'; inherits: true; initial-value: rgb(234, 179, 8); }
@property --blob-5-mid { syntax: '<color>'; inherits: true; initial-value: rgb(250, 204, 21); }
@property --blob-6-core { syntax: '<color>'; inherits: true; initial-value: rgb(253, 224, 71); }
@property --blob-6-mid { syntax: '<color>'; inherits: true; initial-value: rgb(254, 240, 138); }

html {
    --scene-bg: #020915;
    --blob-opacity: 0.4;
    --blob-1-core: rgb(236, 72, 153);
    --blob-1-mid: rgb(244, 114, 182);
    --blob-2-core: rgb(219, 39, 119);
    --blob-2-mid: rgb(251, 207, 232);
    --blob-3-core: rgb(168, 85, 247);
    --blob-3-mid: rgb(216, 180, 254);
    --blob-4-core: rgb(147, 51, 234);
    --blob-4-mid: rgb(233, 213, 255);
    --blob-5-core: rgb(30, 58, 138);
    --blob-5-mid: rgb(99, 102, 241);
    --blob-6-core: rgb(30, 64, 175);
    --blob-6-mid: rgb(129, 140, 248);
    --tx: 0px;
    --ty: 0px;
}

body {
    background-color: var(--scene-bg);
    transition: background-color 0.45s ease;
}

canvas.sim-canvas {
    position: fixed;
    inset: 0;
    z-index: 1;
}

.ambient-canvas {
    position: fixed;
    inset: -25%;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    transform: translate(var(--tx), var(--ty));
    transition: transform 0.4s ease-out, opacity 0.5s ease;
    opacity: 0;
}

.ambient-canvas.ambient-canvas--on {
    opacity: 1;
}

.ambient-canvas .ambient-blob {
    position: absolute;
    z-index: 1;
    border-radius: 50%;
    filter: blur(110px) saturate(120%);
    opacity: var(--blob-opacity, 0.3);
    will-change: transform;
    transition:
        background 5s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.5s ease;
}

.ambient-blob--1 {
    width: 460px;
    height: 460px;
    background: radial-gradient(circle, var(--blob-1-core) 0%, color-mix(in srgb, var(--blob-1-mid) 22%, transparent) 38%, transparent 62%);
    top: 15%;
    left: 10%;
    animation: driftWarm1 96s ease-in-out infinite;
}

.ambient-blob--2 {
    width: 380px;
    height: 380px;
    background: radial-gradient(circle, var(--blob-2-core) 0%, color-mix(in srgb, var(--blob-2-mid) 20%, transparent) 38%, transparent 62%);
    top: 50%;
    left: 55%;
    animation: driftWarm2 114s ease-in-out infinite;
    animation-delay: -24s;
}

.ambient-blob--3 {
    width: 420px;
    height: 420px;
    background: radial-gradient(circle, var(--blob-3-core) 0%, color-mix(in srgb, var(--blob-3-mid) 22%, transparent) 38%, transparent 62%);
    top: 25%;
    left: 70%;
    animation: driftWarm3 78s ease-in-out infinite;
    animation-delay: -42s;
}

.ambient-blob--4 {
    width: 320px;
    height: 320px;
    background: radial-gradient(circle, var(--blob-4-core) 0%, color-mix(in srgb, var(--blob-4-mid) 20%, transparent) 38%, transparent 62%);
    top: 65%;
    left: 15%;
    animation: driftOrange 102s ease-in-out infinite;
    animation-delay: -18s;
}

.ambient-blob--5 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--blob-5-core) 0%, color-mix(in srgb, var(--blob-5-mid) 22%, transparent) 38%, transparent 62%);
    top: 75%;
    left: 45%;
    animation: driftWarm4 84s ease-in-out infinite;
    animation-delay: -36s;
}

.ambient-blob--6 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--blob-6-core) 0%, color-mix(in srgb, var(--blob-6-mid) 24%, transparent) 38%, transparent 62%);
    top: 40%;
    left: 30%;
    animation: driftWarm5 90s ease-in-out infinite;
    animation-delay: -54s;
}

@keyframes driftWarm1 {
    0% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(35vw, 20vh) scale(1.1); }
    50% { transform: translate(15vw, 45vh) scale(0.92); }
    75% { transform: translate(-25vw, 25vh) scale(1.08); }
    100% { transform: translate(0, 0) scale(1); }
}

@keyframes driftWarm2 {
    0% { transform: translate(0, 0) scale(1.05); }
    25% { transform: translate(-30vw, -15vh) scale(0.95); }
    50% { transform: translate(-45vw, 20vh) scale(1.12); }
    75% { transform: translate(-10vw, 35vh) scale(1); }
    100% { transform: translate(0, 0) scale(1.05); }
}

@keyframes driftWarm3 {
    0% { transform: translate(0, 0) scale(0.95); }
    33% { transform: translate(-35vw, 30vh) scale(1.1); }
    66% { transform: translate(20vw, -25vh) scale(1.05); }
    100% { transform: translate(0, 0) scale(0.95); }
}

@keyframes driftWarm4 {
    0% { transform: translate(0, 0) scale(1); }
    20% { transform: translate(40vw, -30vh) scale(1.08); }
    45% { transform: translate(25vw, -10vh) scale(0.9); }
    70% { transform: translate(-15vw, -35vh) scale(1.1); }
    100% { transform: translate(0, 0) scale(1); }
}

@keyframes driftOrange {
    0% { transform: translate(0, 0) scale(1.02); }
    30% { transform: translate(-40vw, -20vh) scale(0.94); }
    60% { transform: translate(-20vw, -40vh) scale(1.1); }
    100% { transform: translate(0, 0) scale(1.02); }
}

@keyframes driftWarm5 {
    0% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30vw, 35vh) scale(1.12); }
    50% { transform: translate(-25vw, 15vh) scale(0.88); }
    75% { transform: translate(10vw, -30vh) scale(1.06); }
    100% { transform: translate(0, 0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .ambient-blob { animation: none !important; }
    .ambient-canvas { transition: none; }
}

/* --- Controles de estilo --- */
.bg-preset-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
}

.bg-preset-btn {
    aspect-ratio: 1;
    border-radius: 0.65rem;
    border: 2px solid rgba(255, 255, 255, 0.12);
    cursor: pointer;
    padding: 0;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.bg-preset-btn:hover {
    transform: scale(1.06);
    border-color: rgba(255, 255, 255, 0.28);
}

.bg-preset-btn.bg-preset-btn--active {
    border-color: rgba(255, 149, 0, 0.65);
    box-shadow: 0 0 0 2px rgba(255, 149, 0, 0.2);
}

.color-picker-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.glass-color-input {
    width: 2.75rem;
    height: 2.75rem;
    padding: 0.15rem;
    border-radius: 0.65rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    flex-shrink: 0;
}

.glass-color-input::-webkit-color-swatch-wrapper { padding: 2px; }
.glass-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 0.45rem;
}

.palette-preview {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-top: 0.35rem;
}

.palette-preview__dot {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.palette-preview__dot--lg {
    width: 1.65rem;
    height: 1.65rem;
}
