/*
 * The floor motif (parts/motif-floor.php) in the Services hero. Each state class on the
 * SVG (s-heat, s-bars, s-flag, s-cursor, s-swap, s-goal) turns on one beat; the markup
 * carries them all, so it rests on the final frame. assets/js/floor.js clears them and
 * adds them back in a loop. is-live is set while it plays (the one-off pulses run only
 * then); is-still switches the transitions off while it resets.
 * Cabinets and players are the shared glyphs (.rm-sd-*, motif-art.css).
 */
.rm-motif--floor {
    position: relative;
    width: 800px;
    max-width: 100%;
    overflow: hidden;
    border-radius: 30px;
    background: var(--rm-lavender);
}

.rm-floor {
    display: block;
    width: 100%;
    height: 100%;
}

.rm-floor * {
    transition-timing-function: var(--rm-ease);
}

.rm-floor.is-still * {
    transition: none !important;
    animation: none !important;
}

.rm-floor__pause {
    top: 16px;
    left: 16px;
}

.mf-card {
    fill: var(--rm-white);
}

/* s-heat: cabinets glow by demand, data drops toward the benchmark card */
.mf-heat {
    opacity: 0;
    fill: var(--rm-blurple);
    transform: scale(.4);
    transform-box: fill-box;
    transform-origin: center;
    transition: opacity .9s, transform .9s;
}

.s-heat .mf-heat {
    opacity: var(--o);
    transform: scale(1);
}

.mf-stream {
    opacity: 0;
    fill: var(--rm-blurple);
}

.is-live.s-heat .mf-stream {
    animation: rm-floor-flow 1.6s var(--d) 2 ease-in;
}

@keyframes rm-floor-flow {
    0% {
        opacity: 0;
        transform: translateY(0);
    }

    20% {
        opacity: .9;
    }

    100% {
        opacity: 0;
        transform: translateY(120px);
    }
}

/* s-bars: one bar per cabinet against the market line; the KPI runs flat under its goal */
.mf-bar {
    fill: var(--rm-blurple-medium);
    transform: scaleY(0);
    transform-box: fill-box;
    transform-origin: center bottom;
    transition: transform 1s, fill .5s;
    transition-delay: var(--d);
}

.s-bars .mf-bar {
    transform: scaleY(1);
}

.s-bars .mf-bar--swap {
    transform: scaleY(var(--pre));
}

.mf-market {
    opacity: 0;
    stroke: var(--rm-grey);
    stroke-width: 1.5;
    stroke-dasharray: 5 6;
    transition: opacity .6s .6s;
}

.s-bars .mf-market {
    opacity: .7;
}

/* s-flag: games under the market line turn red and their cabinets dim */
.mf-cab {
    transform-box: fill-box;
    transform-origin: center bottom;
    transition: opacity .6s, transform .7s;
}

.s-flag .mf-cab.mf-low {
    opacity: .3;
}

.s-flag .mf-bar.mf-low {
    fill: var(--rm-red);
    transition-delay: 0s;
}

.s-flag .mf-bar.mf-high {
    fill: var(--rm-blurple);
    transition-delay: 0s;
}

/* s-cursor: the analyst goes to the weakest game */
.mf-cursor {
    opacity: 0;
    fill: var(--rm-red);
    stroke: var(--rm-white);
    stroke-width: 1.5;
    transform: translate(590px, 250px);
    transition: transform 1.3s, opacity .4s;
}

.s-cursor .mf-cursor {
    opacity: 1;
    transform: translate(var(--cx), var(--cy));
}

.s-goal .mf-cursor {
    opacity: 0;
}

.mf-ring {
    opacity: 0;
    fill: none;
    stroke: var(--rm-red);
    stroke-width: 2;
    transform-box: fill-box;
    transform-origin: center;
}

.is-live.s-cursor .mf-ring {
    animation: rm-floor-ping 1s 1.3s ease-out;
}

@keyframes rm-floor-ping {
    0% {
        opacity: .9;
        transform: scale(.6);
    }

    100% {
        opacity: 0;
        transform: scale(1.6);
    }
}

/* s-swap: the game is replaced, players move to it and a pulse carries the gain to the KPI */
.s-swap .mf-cab.mf-out {
    opacity: 0;
    transform: translateY(-26px);
}

.mf-cab.mf-in {
    opacity: 0;
    transform: translateY(26px);
}

.s-swap .mf-cab.mf-in {
    opacity: 1;
    transform: none;
    transition-delay: .35s;
}

.s-swap .mf-bar.mf-bar--swap {
    fill: var(--rm-blurple);
    transform: scaleY(1);
    transition-delay: .6s;
}

.mf-link {
    fill: none;
    stroke: var(--rm-blurple-medium);
    stroke-width: 2;
    transition: opacity .5s;
}

.s-swap .mf-link--moves {
    opacity: 0;
}

.mf-link--new {
    stroke: var(--rm-blurple);
    stroke-dasharray: 120;
    stroke-dashoffset: 120;
    transition: stroke-dashoffset .9s;
    transition-delay: var(--d);
}

.s-swap .mf-link--new {
    stroke-dashoffset: 0;
}

.mf-spark {
    opacity: 0;
    fill: var(--rm-blurple);
}

.is-live.s-swap .mf-spark {
    animation: rm-floor-spark 1s 1.5s var(--rm-ease) both;
}

@keyframes rm-floor-spark {
    0% {
        opacity: 0;
        transform: translate(var(--sx), var(--sy)) scale(.5);
    }

    15%,
    85% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translate(var(--ex), var(--ey)) scale(1.2);
    }
}

/* The KPI tile: flat under the goal flag (s-bars) until s-goal lifts it through the goal */
.mf-kgrid {
    stroke: var(--rm-grey-medium);
    stroke-width: 1;
}

.mf-flat {
    fill: none;
    stroke: var(--rm-grey);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    transition: stroke-dashoffset 1.2s, stroke .6s;
}

.s-bars .mf-flat {
    stroke-dashoffset: 0;
}

.s-goal .mf-flat {
    stroke: var(--rm-blurple-medium);
}

.mf-kdot {
    opacity: 0;
    fill: var(--rm-grey);
    transition: opacity .4s;
}

.s-bars .mf-kdot--now {
    opacity: 1;
    transition-delay: 1.1s;
}

.s-goal .mf-kdot--now {
    opacity: 0;
    transition-delay: 0s;
}

.mf-kdot--end {
    fill: var(--rm-blurple);
}

.s-goal .mf-kdot--end {
    opacity: 1;
    transition-delay: 1.3s;
}

.mf-kring {
    opacity: 0;
    fill: none;
    stroke: var(--rm-blurple);
    stroke-width: 2;
    transform-box: fill-box;
    transform-origin: center;
}

.is-live.s-goal .mf-kring {
    animation: rm-floor-ping 1.4s 1.5s ease-out 2;
}

.mf-rise {
    fill: none;
    stroke: var(--rm-blurple);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 120;
    stroke-dashoffset: 120;
    transition: stroke-dashoffset 1.3s;
}

.s-goal .mf-rise {
    stroke-dashoffset: 0;
}

.mf-karea {
    opacity: 0;
    fill: var(--rm-blurple);
    transition: opacity .8s 1s;
}

.s-goal .mf-karea {
    opacity: .14;
}

.mf-goal {
    stroke: var(--rm-red);
    stroke-width: 1.5;
    stroke-dasharray: 4 5;
    transition: stroke .6s 1.3s;
}

.s-goal .mf-goal {
    stroke: var(--rm-blurple);
}

.mf-flag {
    transition: opacity .4s 1.2s;
}

.mf-flag line {
    stroke: var(--rm-red);
    stroke-width: 1.5;
}

.mf-flag path {
    fill: var(--rm-red);
}

.s-goal .mf-flag {
    opacity: 0;
}

.mf-tick {
    opacity: 0;
    transform: scale(.3);
    transform-box: fill-box;
    transform-origin: center;
    transition: opacity .4s 1.4s, transform .6s 1.4s;
}

.s-goal .mf-tick {
    opacity: 1;
    transform: scale(1);
}

.mf-tick circle {
    fill: var(--rm-blurple);
}

.mf-tick path {
    fill: none;
    stroke: var(--rm-white);
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@media (max-width: 767px) {
    .rm-motif--floor {
        border-radius: 22px;
    }

    .rm-floor__pause {
        top: 10px;
        left: 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .rm-floor * {
        transition: none !important;
        animation: none !important;
    }
}
