/* =====================================================
   Craftnex AI — Floating AI agent bots ambient layer
   ===================================================== */

.lava-lamp {
    --lava-color-1: #ff5a3c;
    --lava-color-2: #ffb347;
    --lava-glow: rgba(255, 110, 64, 0.45);
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
    opacity: 0.55;
    transition: opacity 700ms ease;
    contain: layout style paint;
}
.lava-lamp.is-soft { opacity: 0.28; }
.lava-lamp.is-paused .lava-blob,
.lava-lamp.is-paused .lava-blob *,
.lava-lamp.is-paused .lava-blob::before,
.lava-lamp.is-paused .lava-blob::after {
    animation-play-state: paused !important;
}

.lava-lamp__svg {
    position: absolute;
    width: 0;
    height: 0;
}

.lava-lamp__stage {
    position: absolute;
    inset: 0;
}

/* ── AI agent bot body ──────────────────────────── */
.lava-blob {
    position: absolute;
    border-radius: 50%;
    background:
        radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 38%),
        radial-gradient(circle at 50% 55%,
            var(--lava-color-2) 0%,
            var(--lava-color-1) 58%,
            rgba(0, 0, 0, 0.35) 100%);
    box-shadow:
        0 0 70px var(--lava-glow),
        0 18px 40px rgba(0, 0, 0, 0.35),
        inset 0 -10px 28px rgba(0, 0, 0, 0.28),
        inset 0 8px 18px rgba(255, 255, 255, 0.22);
    will-change: transform;
    opacity: 0.96;
}

/* Subtle metallic ring around the bot */
.lava-blob::before {
    content: "";
    position: absolute;
    inset: 6%;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.08);
    pointer-events: none;
}

/* Visor / face panel */
.lava-blob::after {
    content: "";
    position: absolute;
    top: 22%;
    left: 16%;
    width: 68%;
    height: 36%;
    border-radius: 48% 48% 46% 46% / 60% 60% 40% 40%;
    background:
        radial-gradient(ellipse at 50% 30%, rgba(255, 255, 255, 0.18) 0%, rgba(0, 0, 0, 0.45) 70%, rgba(0, 0, 0, 0.7) 100%);
    box-shadow:
        inset 0 2px 6px rgba(255, 255, 255, 0.25),
        inset 0 -4px 10px rgba(0, 0, 0, 0.45);
    pointer-events: none;
}

/* ── Antenna ────────────────────────────────────── */
.lava-blob__antenna {
    position: absolute;
    top: -16%;
    left: 50%;
    transform: translateX(-50%);
    width: 3%;
    height: 22%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.35), var(--lava-color-1));
    border-radius: 999px;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.25);
}
.lava-blob__antenna::before {
    content: "";
    position: absolute;
    top: -55%;
    left: 50%;
    transform: translateX(-50%);
    width: 380%;
    height: 60%;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #ffffff 0%, var(--lava-color-2) 45%, var(--lava-color-1) 100%);
    box-shadow:
        0 0 14px var(--lava-glow),
        0 0 24px var(--lava-glow);
    animation: antennaPulse 4.2s ease-in-out infinite;
}
@keyframes antennaPulse {
    0%, 100% {
        box-shadow: 0 0 10px var(--lava-glow), 0 0 18px var(--lava-glow);
        filter: brightness(1);
    }
    50% {
        box-shadow: 0 0 18px var(--lava-glow), 0 0 36px var(--lava-glow), 0 0 8px #fff;
        filter: brightness(1.35);
    }
}

/* ── Eyes ───────────────────────────────────────── */
.lava-blob__eye {
    position: absolute;
    top: 30%;
    width: 17%;
    height: 22%;
    border-radius: 50%;
    background: radial-gradient(circle at 38% 32%, #ffffff 0%, #dde8ff 55%, #7d97c9 100%);
    box-shadow:
        inset 0 -3px 5px rgba(0, 0, 0, 0.22),
        0 1px 2px rgba(0, 0, 0, 0.45);
    overflow: hidden;
    animation: blink 9s ease-in-out infinite;
    transform-origin: 50% 50%;
}
.lava-blob__eye--left { left: 22%; }
.lava-blob__eye--right { right: 22%; animation-delay: -0.05s; }

/* Pupil */
.lava-blob__eye::before {
    content: "";
    position: absolute;
    top: 24%;
    left: 26%;
    width: 50%;
    height: 50%;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, #1d2a4a 0%, #06091a 70%);
    box-shadow: 0 0 6px rgba(120, 200, 255, 0.55);
    animation: pupilGleam 7s ease-in-out infinite;
}
/* Highlight */
.lava-blob__eye::after {
    content: "";
    position: absolute;
    top: 18%;
    left: 22%;
    width: 22%;
    height: 22%;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.9);
}

@keyframes blink {
    0%, 46%, 50%, 96%, 100% { transform: scaleY(1); }
    48%, 98%               { transform: scaleY(0.08); }
}
@keyframes pupilGleam {
    0%, 100% { box-shadow: 0 0 4px rgba(120, 200, 255, 0.45); }
    50%      { box-shadow: 0 0 10px rgba(120, 200, 255, 0.85); }
}

/* ── Robot mouth (LED grille) ───────────────────── */
.lava-blob__mouth {
    position: absolute;
    bottom: 22%;
    left: 50%;
    transform: translateX(-50%);
    width: 42%;
    height: 13%;
    border-radius: 8px;
    background: linear-gradient(180deg, #060a18 0%, #11192e 100%);
    box-shadow:
        inset 0 1px 2px rgba(255, 255, 255, 0.18),
        inset 0 -2px 4px rgba(0, 0, 0, 0.6),
        0 1px 2px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(0, 0, 0, 0.5);
    overflow: hidden;
}
.lava-blob__mouth::before {
    content: "";
    position: absolute;
    inset: 18% 10%;
    background: repeating-linear-gradient(90deg,
        var(--lava-color-2) 0 14%,
        transparent 14% 22%);
    border-radius: 2px;
    filter: drop-shadow(0 0 3px var(--lava-color-2));
    transform-origin: 50% 100%;
    animation: mouthTalk 2.4s ease-in-out infinite alternate;
}
.lava-blob__mouth::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 30%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.18), transparent);
    pointer-events: none;
}
@keyframes mouthTalk {
    0%   { transform: scaleY(0.45); opacity: 0.85; }
    35%  { transform: scaleY(1);    opacity: 1; }
    70%  { transform: scaleY(0.6);  opacity: 0.9; }
    100% { transform: scaleY(0.85); opacity: 1; }
}

/* ── Float animation ────────────────────────────── */
.lava-blob:nth-child(1) {
    width: 200px; height: 200px;
    left: 12%; bottom: -120px;
    animation: lavaRise 18s ease-in-out infinite;
}
.lava-blob:nth-child(2) {
    width: 150px; height: 150px;
    left: 32%; bottom: -100px;
    animation: lavaRise 22s ease-in-out -4s infinite;
}
.lava-blob:nth-child(3) {
    width: 240px; height: 240px;
    left: 55%; bottom: -160px;
    animation: lavaRise 26s ease-in-out -10s infinite;
}
.lava-blob:nth-child(4) {
    width: 130px; height: 130px;
    left: 72%; bottom: -90px;
    animation: lavaRise 16s ease-in-out -7s infinite;
}
.lava-blob:nth-child(5) {
    width: 180px; height: 180px;
    left: 84%; bottom: -130px;
    animation: lavaRise 24s ease-in-out -14s infinite;
}
.lava-blob:nth-child(6) {
    width: 110px; height: 110px;
    left: 22%; bottom: -80px;
    animation: lavaRise 20s ease-in-out -2s infinite;
}
.lava-blob:nth-child(7) {
    width: 170px; height: 170px;
    left: 45%; bottom: -120px;
    animation: lavaRise 28s ease-in-out -18s infinite;
}

/* Stagger blink/talk timing per bot */
.lava-blob:nth-child(2) .lava-blob__eye { animation-delay: -1.2s; }
.lava-blob:nth-child(3) .lava-blob__eye { animation-delay: -2.4s; }
.lava-blob:nth-child(4) .lava-blob__eye { animation-delay: -3.6s; }
.lava-blob:nth-child(5) .lava-blob__eye { animation-delay: -0.8s; }
.lava-blob:nth-child(6) .lava-blob__eye { animation-delay: -2.0s; }
.lava-blob:nth-child(7) .lava-blob__eye { animation-delay: -4.4s; }

.lava-blob:nth-child(2) .lava-blob__mouth::before { animation-delay: -0.4s; }
.lava-blob:nth-child(3) .lava-blob__mouth::before { animation-delay: -0.7s; }
.lava-blob:nth-child(4) .lava-blob__mouth::before { animation-delay: -0.2s; }
.lava-blob:nth-child(5) .lava-blob__mouth::before { animation-delay: -0.9s; }
.lava-blob:nth-child(6) .lava-blob__mouth::before { animation-delay: -0.5s; }
.lava-blob:nth-child(7) .lava-blob__mouth::before { animation-delay: -1.1s; }

@keyframes lavaRise {
    0%   { transform: translate3d(0, 0, 0) rotate(0deg) scale(0.9); }
    25%  { transform: translate3d(var(--blob-dx1, 18px),  -32vh, 0) rotate(-3deg) scale(1.02); }
    50%  { transform: translate3d(var(--blob-dx2, -22px), -64vh, 0) rotate(2deg)  scale(0.98); }
    75%  { transform: translate3d(var(--blob-dx3, 14px),  -90vh, 0) rotate(-2deg) scale(1.05); }
    100% { transform: translate3d(0, -120vh, 0) rotate(0deg) scale(0.85); }
}

@media (prefers-reduced-motion: reduce) {
    .lava-blob,
    .lava-blob__eye,
    .lava-blob__antenna::before,
    .lava-blob__mouth::before,
    .lava-blob__eye::before { animation: none; }
}

/* ── Color picker control ───────────────────────── */
.lava-lamp-control {
    position: fixed;
    right: 18px;
    bottom: 96px;
    z-index: 60;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
}

.lava-lamp-control__toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(10, 22, 50, 0.65);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: #f0f6ff;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    transition: transform 0.18s ease, border-color 0.18s ease;
}
.lava-lamp-control__toggle:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.35);
}
.lava-lamp-control__swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--lava-current, #ff5a3c);
    box-shadow: 0 0 10px var(--lava-current, #ff5a3c);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.lava-lamp-control__panel {
    display: none;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(10, 22, 50, 0.82);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
    color: #e7eeff;
    min-width: 220px;
}
.lava-lamp-control.is-open .lava-lamp-control__panel {
    display: flex;
}

.lava-lamp-control__title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(231, 238, 255, 0.7);
    margin: 0;
}
.lava-lamp-control__presets {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    max-width: 220px;
}
.lava-lamp-control__preset {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    padding: 0;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.lava-lamp-control__preset:hover {
    transform: scale(1.12);
}
.lava-lamp-control__preset.is-active {
    border-color: #fff;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35),
                0 0 16px currentColor;
}
.lava-lamp-control__custom {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.78rem;
}
.lava-lamp-control__custom input[type="color"] {
    appearance: none;
    -webkit-appearance: none;
    width: 36px;
    height: 28px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
}
.lava-lamp-control__custom input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.lava-lamp-control__custom input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }

@media (max-width: 640px) {
    .lava-lamp-control { right: 12px; bottom: 84px; }
    .lava-lamp-control__panel { min-width: 200px; }
}

/* ── Back-to-top tinted with selected lava color ─── */
:root {
    --lava-color-1: #ff5a3c;
    --lava-color-2: #ffb347;
    --lava-glow: rgba(255, 110, 64, 0.45);
}

.back-to-top {
    background:
        radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.34), transparent 36%),
        linear-gradient(145deg, var(--lava-color-2), var(--lava-color-1)) !important;
    border-color: var(--lava-color-2) !important;
    box-shadow:
        0 18px 44px rgba(6, 28, 84, 0.42),
        0 0 22px var(--lava-glow),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset !important;
}
.back-to-top::before {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.04)) !important;
}
.back-to-top::after {
    border-color: var(--lava-color-2) !important;
}
.back-to-top:hover,
.back-to-top:focus-visible {
    box-shadow:
        0 24px 54px rgba(6, 28, 84, 0.5),
        0 0 36px var(--lava-glow) !important;
}
