/* Scroll-driven Swarm Rebuild ("Rakit UI") styles */
.swarm-canvas {
    position: fixed;
    inset: 0;
    z-index: 9500;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
}

.swarm-canvas[hidden] {
    display: none;
}

/* Unbuilt box surfaces stay layout-accurate while canvas draws the blueprint */
.swarm-box-pending {
    background-color: transparent !important;
    background-image: none !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

.swarm-box-built {
    transition:
        background-color 360ms cubic-bezier(0.22, 1, 0.36, 1),
        border-color 360ms cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 360ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Media elements wait behind clip-path until scanned open */
.swarm-media-pending {
    opacity: 0 !important;
}

.swarm-media-wiping {
    opacity: 1 !important;
    will-change: clip-path, filter, transform;
}

/* Text elements wait transparently before typing/sculpting starts */
.swarm-text-pending {
    opacity: 0 !important;
}

swarm-tx,
swarm-grp,
swarm-done,
swarm-todo {
    display: inline;
}

swarm-wd {
    display: inline;
    white-space: nowrap;
}

swarm-ch {
    display: inline;
    transition: color 220ms ease, -webkit-text-stroke-color 220ms ease;
}

swarm-ch.swarm-ch--idle {
    color: transparent !important;
    -webkit-text-fill-color: transparent !important;
    -webkit-text-stroke: 1.45px transparent;
}

swarm-ch.swarm-ch--outline {
    color: transparent !important;
    -webkit-text-fill-color: transparent !important;
    -webkit-text-stroke: 1.25px #67b7ff;
}

.intro-editorial swarm-ch.swarm-ch--outline,
.founder-statement swarm-ch.swarm-ch--outline {
    -webkit-text-stroke: 1.25px #1268c2;
}

swarm-ch.swarm-ch--solid {
    -webkit-text-stroke: 0 transparent;
}

swarm-todo {
    color: transparent !important;
    -webkit-text-fill-color: transparent !important;
    user-select: none;
}

swarm-caret {
    position: relative;
    display: inline-block;
    width: 0;
    height: 0.88em;
    vertical-align: -0.06em;
    pointer-events: none;
}

swarm-caret::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 1.75px;
    height: 100%;
    border-radius: 1px;
    background: #67b7ff;
    box-shadow: 0 0 8px rgba(103, 183, 255, 0.85);
}

.intro-editorial swarm-caret::after,
.founder-statement swarm-caret::after {
    background: #1268c2;
    box-shadow: 0 0 6px rgba(18, 104, 194, 0.45);
}

swarm-caret[hidden] {
    display: none;
}

/* Bottom-left floating control dock (mirrors .azure-ai on bottom-right) */
.swarm-ui {
    position: fixed;
    left: clamp(16px, 2.4vw, 34px);
    bottom: calc(clamp(16px, 2.4vw, 34px) + env(safe-area-inset-bottom, 0px));
    z-index: 9600;
    color: #f6f9fc;
    font-family: "Manrope", "Segoe UI", sans-serif;
    transition: opacity 260ms ease, transform 260ms ease;
}

.swarm-ui *,
.swarm-ui *::before,
.swarm-ui *::after {
    box-sizing: border-box;
}

html.is-loader-active .swarm-ui,
body.is-loader-active .swarm-ui,
body.menu-open .swarm-ui {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(10px);
}

.swarm-ui__bar {
    position: relative;
    display: inline-flex;
    align-items: center;
    border: 1px solid rgba(119, 196, 255, 0.30);
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(14, 22, 34, 0.94), rgba(6, 10, 16, 0.97));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 20px 56px rgba(0, 0, 0, 0.45),
        0 0 28px rgba(47, 143, 255, 0.14);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    overflow: hidden;
}

.swarm-ui__progress {
    position: absolute;
    right: 12px;
    bottom: 0;
    left: 12px;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, #2f8fff, #67b7ff);
    box-shadow: 0 0 10px rgba(103, 183, 255, 0.75);
    transform: scaleX(0);
    transform-origin: left center;
    opacity: 0;
    transition: opacity 200ms ease;
    pointer-events: none;
}

.swarm-ui__progress.is-visible {
    opacity: 1;
}

.swarm-ui__trigger,
.swarm-ui__replay-btn,
.swarm-ui__settings-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    border: 0;
    background: transparent;
    color: #f6f9fc;
    cursor: pointer;
    font: inherit;
    transition: background-color 160ms ease, color 160ms ease;
}

.swarm-ui__trigger {
    padding: 8px 14px 8px 13px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.swarm-ui__replay-btn,
.swarm-ui__settings-btn {
    padding: 8px 11px;
    border-left: 1px solid rgba(151, 190, 231, 0.16);
    color: #9eb3ca;
}

.swarm-ui__trigger:hover,
.swarm-ui__replay-btn:hover,
.swarm-ui__settings-btn:hover {
    background: rgba(47, 143, 255, 0.14);
    color: #ffffff;
}

.swarm-ui__icon {
    width: 16px;
    height: 16px;
    color: #67b7ff;
    flex-shrink: 0;
}

.swarm-ui__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 10px #34d399;
    animation: swarmPulseDot 1.2s ease-in-out infinite;
    flex-shrink: 0;
}

.swarm-ui__dot[hidden] {
    display: none;
}

@keyframes swarmPulseDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.45; transform: scale(0.8); }
}

.swarm-ui__badge {
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(47, 143, 255, 0.18);
    border: 1px solid rgba(103, 183, 255, 0.3);
    color: #8ccbff;
    font-family: "Space Grotesk", "Manrope", sans-serif;
    font-size: 0.68rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.swarm-ui__popover {
    position: absolute;
    left: 0;
    bottom: 54px;
    width: min(296px, calc(100vw - 32px));
    padding: 14px;
    border: 1px solid rgba(119, 196, 255, 0.28);
    border-radius: 16px;
    background: rgba(8, 12, 18, 0.97);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.56);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.swarm-ui__popover[hidden] {
    display: none;
}

.swarm-ui__pop-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(151, 190, 231, 0.14);
}

.swarm-ui__pop-head strong {
    font-family: "Space Grotesk", "Manrope", sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #8ccbff;
}

.swarm-ui__pop-head kbd {
    padding: 2px 6px;
    border-radius: 5px;
    border: 1px solid rgba(151, 190, 231, 0.2);
    background: rgba(255, 255, 255, 0.04);
    color: #8e9baa;
    font-family: monospace;
    font-size: 0.64rem;
}

.swarm-ui__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 0.75rem;
    color: #b7c4d4;
}

.swarm-ui__chips {
    display: inline-flex;
    gap: 4px;
}

.swarm-ui__chip {
    padding: 4px 8px;
    border-radius: 7px;
    border: 1px solid rgba(151, 190, 231, 0.18);
    background: rgba(255, 255, 255, 0.03);
    color: #a9b8ca;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 140ms ease;
}

.swarm-ui__chip:hover {
    border-color: rgba(103, 183, 255, 0.5);
    color: #ffffff;
}

.swarm-ui__chip.is-active {
    border-color: #2f8fff;
    background: rgba(47, 143, 255, 0.22);
    color: #ffffff;
}

.swarm-ui__run-btn {
    width: 100%;
    margin-top: 4px;
    padding: 8px 12px;
    border: 1px solid rgba(103, 183, 255, 0.45);
    border-radius: 9px;
    background: linear-gradient(135deg, rgba(47, 143, 255, 0.28), rgba(47, 143, 255, 0.14));
    color: #ffffff;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter 160ms ease, border-color 160ms ease;
}

.swarm-ui__run-btn:hover {
    border-color: #67b7ff;
    filter: brightness(1.1);
}

@media (max-width: 600px) {
    .swarm-ui {
        left: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .swarm-ui__trigger {
        min-height: 40px;
        padding: 7px 11px;
        font-size: 0.74rem;
    }

    .swarm-ui__replay-btn,
    .swarm-ui__settings-btn {
        min-height: 40px;
        padding: 7px 9px;
    }

    .swarm-ui__badge {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .swarm-ui__dot,
    swarm-ch {
        animation: none !important;
        transition: none !important;
    }
}
