/**
 * GilGamez Critical Preloader Stylesheet
 * Self-contained, zero-FOUC, hardware-accelerated critical preloader styles.
 * Conforms to Rule #1, Rule #6, and Rule #11. Strictly uses theme accent variables.
 */

: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, #08090d);
    --preloader-backdrop-blur: 20px;
    --preloader-backdrop-opacity: 1;
    --preloader-emblem-size: 46px;
    --preloader-outer-speed: 1.8s;
    --preloader-inner-speed: 1.2s;
    --preloader-glow-radius: 40px;
}

html, body {
    margin: 0;
    padding: 0;
    background-color: #08090d;
    color: #f8fafc;
}

/* ==========================================================================
   Background Page Animation Freezing & Total Isolation Engine
   1. Completely hides and pauses underlying DOM while preloader is active.
   2. Prevents off-screen animation execution and transparent bleed-through.
   ========================================================================== */
html.is-preloading body > *:not(#global-preloader, .global-preloader, script, style) {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

html.is-preloading *:not(#global-preloader, #global-preloader *, .global-preloader, .global-preloader *, .ggz-preloader-root, .ggz-preloader-root *) {
    animation-play-state: paused !important;
}

/* Base Preloader Shell (100% Solid Opaque Viewport Cover) */
#global-preloader,
.global-preloader,
.ggz-preloader-root {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background-color: #08090d !important;
    background: radial-gradient(circle at 50% 50%, #141724 0%, #08090d 100%) !important;
    z-index: 999999 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s ease;
    overflow: hidden;
    pointer-events: auto;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

#global-preloader.is-hidden,
.global-preloader.is-hidden,
.ggz-preloader-root.is-hidden {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    display: none !important;
}

/* Background Modes */
.ggz-preloader-bg--solid {
    background-color: var(--preloader-bg-solid, #08090d) !important;
    background-image: none !important;
}

.ggz-preloader-bg--radial {
    background: radial-gradient(circle at center, rgba(20, 23, 36, 1) 0%, var(--preloader-bg-solid, #08090d) 85%) !important;
}

.ggz-preloader-bg--glass {
    background-color: rgba(8, 9, 13, 0.98) !important;
    backdrop-filter: blur(var(--preloader-backdrop-blur, 20px));
    -webkit-backdrop-filter: blur(var(--preloader-backdrop-blur, 20px));
}

/* Ambient Glow Bloom */
.preloader-ambient-glow,
.ggz-preloader-ambient-glow {
    position: absolute;
    width: 280px;
    height: 280px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--preloader-ambient-glow-color, var(--primary, #6366f1)) 0%, rgba(0, 0, 0, 0) 70%);
    filter: blur(var(--preloader-glow-radius, 40px));
    opacity: 0.35;
    pointer-events: none;
    animation: preloader-ambient-pulse 3s ease-in-out infinite alternate;
}

/* 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;
    box-sizing: border-box;
    max-width: 90vw;
}

/* Visual Hub */
.preloader-visual-hub,
.ggz-preloader-hub {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

/* Preset 1: Cyber Rings */
.preset-cyber-rings .ring-outer,
.preloader-ring-outer {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2.5px solid transparent;
    border-top-color: var(--preloader-primary-color, var(--primary, #6366f1));
    border-right-color: var(--preloader-primary-color, var(--primary, #6366f1));
    box-shadow: 0 0 15px var(--preloader-ambient-glow-color, var(--preloader-primary-color, var(--primary, #6366f1)));
    animation: preloader-spin-cw var(--preloader-outer-speed, 1.8s) linear infinite;
    box-sizing: border-box;
}

.preset-cyber-rings .ring-inner,
.preloader-ring-inner {
    position: absolute;
    inset: 12px;
    border-radius: 50%;
    border: 2px dashed transparent;
    border-bottom-color: var(--preloader-secondary-color, var(--secondary, #38bdf8));
    border-left-color: var(--preloader-secondary-color, var(--secondary, #38bdf8));
    animation: preloader-spin-ccw var(--preloader-inner-speed, 1.2s) linear infinite;
    box-sizing: border-box;
}

/* Emblem Container */
.preloader-emblem-center,
.ggz-preloader-emblem {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--preloader-emblem-size, 46px);
    height: var(--preloader-emblem-size, 46px);
    border-radius: 50%;
    box-sizing: border-box;
}

.preloader-emblem-img,
.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));
}

.emblem-icon,
.ggz-preloader-emblem .emblem-icon {
    font-size: calc(var(--preloader-emblem-size, 46px) * 0.75);
    line-height: 1;
    display: inline-block;
}

/* 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;
}

/* Typography & Subtitles */
.ggz-preloader-text-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.ggz-preloader-title {
    font-size: var(--preloader-title-size, 1.25rem);
    font-weight: var(--preloader-title-weight, 800);
    letter-spacing: var(--preloader-title-spacing, 1px);
    color: var(--preloader-title-color, var(--preloader-text-primary, #f8fafc));
    margin: 0 0 6px 0;
    line-height: 1.2;
    text-transform: var(--preloader-title-transform, none);
}

.ggz-preloader-subtitle {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--preloader-text-secondary, #94a3b8);
    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, #94a3b8);
    display: flex;
    align-items: center;
    gap: 8px;
    box-sizing: border-box;
    max-width: 480px;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.ggz-preloader-tip-box.tip-fade {
    opacity: 0;
    transform: translateY(4px);
}

/* Keyframes */
@keyframes preloader-spin-cw {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes preloader-spin-ccw {
    from { transform: rotate(0deg); }
    to { transform: rotate(-360deg); }
}

@keyframes preloader-emblem-breath {
    0%, 100% { transform: scale(0.94); opacity: 0.9; }
    50% { transform: scale(1.06); opacity: 1; filter: drop-shadow(0 0 10px var(--preloader-primary-color, var(--primary, #6366f1))); }
}

@keyframes preloader-emblem-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes preloader-ambient-pulse {
    0% { transform: scale(0.85); opacity: 0.25; }
    100% { transform: scale(1.15); opacity: 0.5; }
}
