/* CyberForge Arcade — Animated games-grid loader
 *
 * Loaded AFTER styles.css to override the legacy spinning-emoji loader
 * (which used `content: "🎮"` + a Loading games pill) with a polished,
 * theme-aware dual-ring spinner and a HUD-style label.
 *
 * Pure CSS, themes via --primary / --glow-color-* so it tracks any
 * preset OR custom theme automatically. Respects prefers-reduced-motion.
 */

/* Reset the legacy pseudo-elements completely. */
.games-grid.loading {
    position: relative;
    min-height: 280px;
    /* Reserve space below the rings for the label without affecting layout. */
    padding-top: 4rem;
    /* Kill any inherited legacy background image */
    background: transparent;
}

/* Outer ring: bright top + right arc, soft neon glow. */
.games-grid.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 88px;
    height: 88px;
    margin: -44px 0 0 -44px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: var(--primary);
    border-right-color: var(--primary);
    background: transparent;
    color: transparent;
    text-shadow: none;
    box-shadow:
        0 0 16px var(--glow-color-40),
        inset 0 0 10px var(--glow-color-40);
    animation: cf-loader-spin 1.1s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
    font-size: 0;
    padding: 0;
}

/* Inner ring: counter-rotating, with a pulsing glow that reads as a core. */
.games-grid.loading::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 52px;
    height: 52px;
    margin: -26px 0 0 -26px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-bottom-color: var(--primary);
    border-left-color: var(--primary);
    background: transparent;
    color: transparent;
    text-shadow: none;
    box-shadow:
        0 0 10px var(--glow-color-40),
        inset 0 0 6px var(--glow-color-40);
    animation:
        cf-loader-spin-reverse 1.4s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite,
        cf-loader-core-pulse 1.8s ease-in-out infinite;
    font-size: 0;
    padding: 0;
    /* Defeat any inherited transform/animation from legacy rules */
    transform: none;
    transform-origin: center center;
}

/* HUD-style label rendered under the rings via a separate child element. */
.games-grid.loading > .cf-loading-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, calc(-50% + 70px));
    font-size: 0.85rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--text);
    text-shadow: 0 0 8px var(--glow-color-60);
    opacity: 0.85;
    pointer-events: none;
    white-space: nowrap;
    animation: cf-loader-label-pulse 1.8s ease-in-out infinite;
}

.games-grid.loading > .cf-loading-label::after {
    content: "";
    display: inline-block;
    width: 1.6em;
    text-align: left;
    margin-left: 0.15em;
    animation: cf-loader-dots 1.4s steps(4, end) infinite;
}

@keyframes cf-loader-spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes cf-loader-spin-reverse {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(-360deg); }
}

@keyframes cf-loader-core-pulse {
    0%, 100% {
        box-shadow:
            0 0 8px var(--glow-color-40),
            inset 0 0 6px var(--glow-color-40);
    }
    50% {
        box-shadow:
            0 0 18px var(--glow-color-60),
            0 0 28px var(--glow-color-40),
            inset 0 0 10px var(--glow-color-60);
    }
}

@keyframes cf-loader-label-pulse {
    0%, 100% { opacity: 0.65; }
    50%      { opacity: 1; }
}

@keyframes cf-loader-dots {
    0%   { content: ""; }
    25%  { content: "."; }
    50%  { content: ".."; }
    75%  { content: "..."; }
    100% { content: ""; }
}

@media (prefers-reduced-motion: reduce) {
    .games-grid.loading::after,
    .games-grid.loading::before,
    .games-grid.loading > .cf-loading-label,
    .games-grid.loading > .cf-loading-label::after {
        animation: none;
    }
}
