/**
 * GilGamez Visual Preloader & View Transitions — Effects & Keyframes Stylesheet
 * Conforms to Rule #1 (Pure CSS), Rule #6 (Responsive), GPU hardware acceleration
 */

:root {
    --preloader-primary-color: var(--primary, var(--theme-accent, #6366f1));
    --preloader-secondary-color: var(--secondary, var(--primary-light, #38bdf8));
    --preloader-ambient-glow-color: var(--primary-glow, var(--primary, var(--theme-accent, #6366f1)));
    --preloader-text-primary: var(--text-primary, #f8fafc);
    --preloader-text-secondary: var(--text-muted, #94a3b8);
    --preloader-bg-solid: var(--bg-base, #0b0f19);
    --preloader-backdrop-blur: 20px;
    --preloader-backdrop-opacity: 0.95;
    --preloader-emblem-size: 46px;
    --preloader-outer-speed: 1.8s;
    --preloader-inner-speed: 1.2s;
    --preloader-glow-radius: 40px;
}

/* ==========================================================================
   Base Fullscreen & Container Preloader Shells
   ========================================================================== */

/* ==========================================================================
   Background Page Animation Freezing Engine
   Freezes all underlying page CSS keyframes, transitions, and transforms while
   the preloader is covering the viewport so entrance animations play fresh on exit.
   ========================================================================== */
html.is-preloading *:not(.global-preloader, .global-preloader *, .ggz-preloader-root, .ggz-preloader-root *),
body.is-preloading *:not(.global-preloader, .global-preloader *, .ggz-preloader-root, .ggz-preloader-root *) {
    animation-play-state: paused !important;
}

html.is-preloading [data-animate-on-load],
body.is-preloading [data-animate-on-load] {
    opacity: 0 !important;
    transform: translateY(16px) !important;
}

.ggz-preloader-root {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    pointer-events: auto;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s ease;
    will-change: opacity, transform;
}

.ggz-preloader-root.is-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden;
}

/* Background Variations */
.ggz-preloader-bg--solid {
    background-color: var(--preloader-bg-solid);
}

.ggz-preloader-bg--radial {
    background: radial-gradient(circle at center, rgba(15, 23, 42, 0.85) 0%, var(--preloader-bg-solid) 80%);
}

.ggz-preloader-bg--glass {
    background-color: rgba(11, 15, 25, var(--preloader-backdrop-opacity));
    backdrop-filter: blur(var(--preloader-backdrop-blur));
    -webkit-backdrop-filter: blur(var(--preloader-backdrop-blur));
}

/* Ambient Glow Bloom */
.ggz-preloader-ambient-glow {
    position: absolute;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--preloader-ambient-glow-color) 0%, rgba(0, 0, 0, 0) 70%);
    filter: blur(var(--preloader-glow-radius));
    opacity: 0.35;
    pointer-events: none;
    animation: preloader-ambient-pulse 3s ease-in-out infinite alternate;
    will-change: transform, opacity;
}

/* Central Stage Container */
.ggz-preloader-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    text-align: center;
    padding: 24px;
}

/* Visual Hub */
.ggz-preloader-hub {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

/* Emblem Container */
.ggz-preloader-emblem {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--preloader-emblem-size);
    height: var(--preloader-emblem-size);
}

.ggz-preloader-emblem img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
}

.ggz-preloader-emblem .emblem-icon {
    font-size: calc(var(--preloader-emblem-size) * 0.75);
    line-height: 1;
}

/* Emblem Animations */
.emblem-anim--pulse {
    animation: preloader-emblem-breath 2s ease-in-out infinite;
}
.emblem-anim--float {
    animation: preloader-emblem-float 2.5s ease-in-out infinite;
}
.emblem-anim--rotate {
    animation: preloader-spin-cw 6s linear infinite;
}
.emblem-anim--shimmer {
    animation: preloader-emblem-shimmer 2s linear infinite;
}

/* Typography & Tips */
.ggz-preloader-text-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    max-width: 440px;
}

.ggz-preloader-title {
    font-family: var(--theme-font-heading, 'Space Grotesk', system-ui, sans-serif);
    font-size: var(--preloader-title-size, 1.25rem);
    font-weight: var(--preloader-title-weight, 800);
    letter-spacing: var(--preloader-title-spacing, 0.05em);
    color: var(--preloader-title-color, var(--preloader-text-primary));
    margin: 0;
    text-transform: var(--preloader-title-transform, none);
    text-align: center;
    transition: all 0.2s ease;
}

/* Title Visual Effects */
.title-fx--neon_glow {
    text-shadow: 0 0 12px var(--preloader-primary-color), 0 0 24px var(--preloader-primary-color), 0 0 40px var(--preloader-primary-color);
}

.title-fx--cyber_gradient {
    background: linear-gradient(135deg, var(--preloader-primary-color) 0%, var(--preloader-secondary-color) 50%, #ffffff 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: titleGradientShift 3s ease-in-out infinite alternate;
}

@keyframes titleGradientShift {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

.title-fx--glitch_flicker {
    text-shadow: 2px 0 var(--preloader-primary-color), -2px 0 var(--preloader-secondary-color);
    animation: titleGlitchPulse 2s steps(2, start) infinite;
}

@keyframes titleGlitchPulse {
    0%, 100% { transform: translate(0); text-shadow: 2px 0 var(--preloader-primary-color), -2px 0 var(--preloader-secondary-color); }
    20% { transform: translate(-2px, 1px); text-shadow: -2px 0 var(--preloader-primary-color), 2px 0 var(--preloader-secondary-color); }
    40% { transform: translate(2px, -1px); text-shadow: 2px 0 var(--preloader-secondary-color), -2px 0 var(--preloader-primary-color); }
    60% { transform: translate(-1px, -1px); text-shadow: 1px 0 var(--preloader-primary-color), -1px 0 var(--preloader-secondary-color); }
    80% { transform: translate(1px, 1px); text-shadow: -1px 0 var(--preloader-secondary-color), 1px 0 var(--preloader-primary-color); }
}

.title-fx--shimmer_wave {
    background: linear-gradient(90deg, var(--preloader-text-primary) 0%, var(--preloader-primary-color) 50%, var(--preloader-text-primary) 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: titleShimmerSweep 2.5s ease-in-out infinite;
}

@keyframes titleShimmerSweep {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.title-fx--gold_metallic {
    background: linear-gradient(135deg, #ffd700 0%, #fff6c2 35%, #d4af37 65%, #aa771c 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.45));
}

.ggz-preloader-subtitle {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--preloader-text-secondary);
    margin: 0;
    line-height: 1.4;
}

.ggz-preloader-tip-box {
    margin-top: 14px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 9999px;
    font-size: 0.78rem;
    color: var(--preloader-text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.ggz-preloader-tip-box.tip-fade {
    opacity: 0;
    transform: translateY(4px);
}

/* ==========================================================================
   Preset 1: Cyber Rings (Default)
   ========================================================================== */
.preset-cyber-rings .ring-outer {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: var(--preloader-primary-color);
    border-right-color: var(--preloader-primary-color);
    box-shadow: 0 0 15px var(--preloader-ambient-glow-color, var(--preloader-primary-color));
    animation: preloader-spin-cw var(--preloader-outer-speed) linear infinite;
}

.preset-cyber-rings .ring-inner {
    position: absolute;
    inset: 12px;
    border-radius: 50%;
    border: 2px dashed transparent;
    border-bottom-color: var(--preloader-secondary-color);
    border-left-color: var(--preloader-secondary-color);
    animation: preloader-spin-ccw var(--preloader-inner-speed) linear infinite;
}

/* ==========================================================================
   Preset 2: Pulse Emblem
   ========================================================================== */
.preset-pulse-emblem .pulse-halo-1 {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--preloader-primary-color);
    animation: preloader-halo-pulse 2s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}

.preset-pulse-emblem .pulse-halo-2 {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--preloader-secondary-color);
    animation: preloader-halo-pulse 2s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
    animation-delay: 0.6s;
}

/* ==========================================================================
   Preset 3: Quantum Orbital
   ========================================================================== */
.preset-quantum-orbital .quantum-track {
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    animation: preloader-spin-cw 4s linear infinite;
}

.preset-quantum-orbital .quantum-electron {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--preloader-primary-color);
    box-shadow: 0 0 10px var(--preloader-primary-color);
    top: -5px;
    left: calc(50% - 5px);
}

.preset-quantum-orbital .quantum-electron-2 {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--preloader-secondary-color);
    box-shadow: 0 0 8px var(--preloader-secondary-color);
    bottom: -4px;
    right: calc(50% - 4px);
}

/* ==========================================================================
   Preset 4: 3D Geometric Cube
   ========================================================================== */
.preset-geometric-cube .cube-viewport {
    width: 50px;
    height: 50px;
    perspective: 400px;
}

.preset-geometric-cube .cube-wireframe {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    animation: preloader-cube-rotate 3s linear infinite;
}

.preset-geometric-cube .cube-face {
    position: absolute;
    width: 50px;
    height: 50px;
    border: 2px solid var(--preloader-primary-color);
    background: transparent;
    box-shadow: 0 0 8px var(--preloader-primary-color);
}

.preset-geometric-cube .cube-face-front  { transform: rotateY(0deg) translateZ(25px); }
.preset-geometric-cube .cube-face-back   { transform: rotateY(180deg) translateZ(25px); }
.preset-geometric-cube .cube-face-right  { transform: rotateY(90deg) translateZ(25px); border-color: var(--preloader-secondary-color); }
.preset-geometric-cube .cube-face-left   { transform: rotateY(-90deg) translateZ(25px); border-color: var(--preloader-secondary-color); }
.preset-geometric-cube .cube-face-top    { transform: rotateX(90deg) translateZ(25px); }
.preset-geometric-cube .cube-face-bottom { transform: rotateX(-90deg) translateZ(25px); }

/* ==========================================================================
   Preset 5: Minimal Dots
   ========================================================================== */
.preset-minimal-dots .dots-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.preset-minimal-dots .dot-node {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--preloader-primary-color), var(--preloader-secondary-color));
    box-shadow: 0 0 10px var(--preloader-primary-color);
    animation: preloader-dot-bounce 1.2s ease-in-out infinite;
}

.preset-minimal-dots .dot-node:nth-child(2) { animation-delay: 0.2s; }
.preset-minimal-dots .dot-node:nth-child(3) { animation-delay: 0.4s; }

/* ==========================================================================
   Preset 6: Energy Bar
   ========================================================================== */
.preset-energy-bar .energy-track {
    width: 140px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

.preset-energy-bar .energy-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50%;
    background: linear-gradient(90deg, transparent, var(--preloader-primary-color), var(--preloader-secondary-color), transparent);
    box-shadow: 0 0 12px var(--preloader-primary-color);
    animation: preloader-energy-sweep 1.5s ease-in-out infinite;
}

/* ==========================================================================
   Preset 7: Matrix Glitch
   ========================================================================== */
.preset-matrix-glitch .matrix-scanner {
    position: absolute;
    inset: 0;
    border: 1px solid var(--preloader-primary-color);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.preset-matrix-glitch .matrix-laser {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--preloader-primary-color);
    box-shadow: 0 0 10px var(--preloader-primary-color), 0 0 20px var(--preloader-primary-color);
    animation: preloader-matrix-scan 1.6s ease-in-out infinite alternate;
}

/* ==========================================================================
   Preset 8: Gamepad Flow
   ========================================================================== */
.preset-gamepad-flow .gamepad-aura {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px dashed var(--preloader-secondary-color);
    animation: preloader-spin-cw 8s linear infinite;
}

/* ==========================================================================
   Mode B: Container Overlay Spinner
   ========================================================================== */
.container-preloader-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 160px;
    background: rgba(11, 15, 25, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.container-preloader-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.container-spinner-hub {
    position: relative;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.container-ring-outer {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: var(--preloader-primary-color, #22c55e);
    border-right-color: var(--preloader-primary-color, #22c55e);
    animation: preloader-spin-cw 1s linear infinite;
}

.container-ring-inner {
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    border: 2px dashed transparent;
    border-bottom-color: var(--preloader-secondary-color, #38bdf8);
    border-left-color: var(--preloader-secondary-color, #38bdf8);
    animation: preloader-spin-ccw 0.8s linear infinite;
}

.container-emblem-icon {
    font-size: 1.25rem;
    line-height: 1;
    z-index: 2;
}

/* ==========================================================================
   Keyframe Animations
   ========================================================================== */
@keyframes preloader-spin-cw {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@keyframes preloader-spin-ccw {
    from { transform: rotate(360deg); }
    to   { transform: rotate(0deg); }
}

@keyframes preloader-ambient-pulse {
    0%   { transform: scale(0.9); opacity: 0.25; }
    100% { transform: scale(1.15); opacity: 0.45; }
}

@keyframes preloader-emblem-breath {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3)); }
    50%      { transform: scale(1.08); filter: drop-shadow(0 4px 16px var(--preloader-primary-color)); }
}

@keyframes preloader-emblem-float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}

@keyframes preloader-emblem-shimmer {
    0%   { filter: brightness(1); }
    50%  { filter: brightness(1.3) drop-shadow(0 0 12px var(--preloader-primary-color)); }
    100% { filter: brightness(1); }
}

@keyframes preloader-halo-pulse {
    0%   { transform: scale(0.6); opacity: 0.8; }
    100% { transform: scale(1.4); opacity: 0; }
}

@keyframes preloader-cube-rotate {
    0%   { transform: rotateX(0deg) rotateY(0deg); }
    100% { transform: rotateX(360deg) rotateY(360deg); }
}

@keyframes preloader-dot-bounce {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50%      { transform: translateY(-12px); opacity: 1; filter: drop-shadow(0 4px 8px var(--preloader-primary-color)); }
}

@keyframes preloader-energy-sweep {
    0%   { left: -50%; }
    100% { left: 100%; }
}

@keyframes preloader-matrix-scan {
    0%   { top: 0%; }
    100% { top: 96%; }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .ring-outer, .ring-inner, .cube-wireframe, .quantum-track, .matrix-laser, .energy-fill, .dot-node, .emblem-anim--pulse, .emblem-anim--float, .emblem-anim--rotate {
        animation: none !important;
    }
}
