/**
 * GenCueBox Global Branded Loading System
 * Phase 10 - Premium Logo-Fill Loader
 * 
 * Features:
 * - Scoped CSS (.gcb-loader)
 * - Bottom-to-top color reveal via clip-path
 * - Full-page and section-level variants
 * - Tabular numeral percentage display
 * - Reduced-motion accessibility
 * - Subtle completion glow pulse (NO rotation)
 */

/* ==========================================================================
   1. ROOT VARIABLES & SCOPED CONTAINER
   ========================================================================== */
:root {
    --gcb-loader-orange: #ff5e1a;
    --gcb-loader-gold: #ff7a00;
    --gcb-loader-bg-dark: #07090d;
    --gcb-loader-text-muted: #94a3b8;
    --gcb-loader-text-dim: #64748b;
}

.gcb-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-sizing: border-box;
    position: relative;
    user-select: none;
    transition: opacity 0.28s ease, transform 0.28s ease;
}

/* Section-level loader (natural content replacement) */
.gcb-loader--section {
    width: 100%;
    min-height: 220px;
    padding: 48px 24px;
    background: transparent;
    border-radius: 12px;
    grid-column: 1 / -1;
}

/* Full-page blocking overlay */
.gcb-loader--fullpage {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99999;
    background: rgba(7, 9, 13, 0.96);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    overflow: hidden;
}

/* Fading out state */
.gcb-loader--fading {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ==========================================================================
   2. LOGO MARK & BOTTOM-TO-TOP REVEAL
   ========================================================================== */
.gcb-loader__mark-wrap {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
    margin-bottom: 14px;
    transform: translateZ(0);
}

/* Section sizing: ~52px desktop, 46px mobile */
.gcb-loader--section .gcb-loader__mark-wrap {
    width: 54px;
    height: 52px;
}

/* Fullpage sizing: ~90px desktop, 72px mobile */
.gcb-loader--fullpage .gcb-loader__mark-wrap {
    width: 92px;
    height: 88px;
    margin-bottom: 20px;
}

/* Layer 1: Muted monochrome base */
.gcb-loader__mark-base {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: grayscale(100%) brightness(0.32) opacity(0.32);
    pointer-events: none;
}

/* Layer 2: Vibrant orange foreground clipped bottom-to-top */
.gcb-loader__mark-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    /* clip-path: inset(top right bottom left) reveals bottom-up as top inset decreases */
    clip-path: inset(calc(100% - var(--gcb-progress, 0%)) 0 0 0);
    -webkit-clip-path: inset(calc(100% - var(--gcb-progress, 0%)) 0 0 0);
    will-change: clip-path;
}

/* Completion subtle glow pulse */
.gcb-loader--complete .gcb-loader__mark-wrap {
    animation: gcbGlowPulse 0.32s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes gcbGlowPulse {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 0 0 rgba(255, 94, 26, 0));
    }
    50% {
        transform: scale(1.05);
        filter: drop-shadow(0 0 18px rgba(255, 94, 26, 0.85)) drop-shadow(0 0 30px rgba(255, 122, 0, 0.45));
    }
    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 12px rgba(255, 94, 26, 0.65));
    }
}

/* ==========================================================================
   3. TABULAR PERCENTAGE & STATUS TYPOGRAPHY
   ========================================================================== */
.gcb-loader__meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.gcb-loader__percentage {
    font-size: 0.95rem;
    font-weight: 800;
    line-height: 1;
    color: #ffffff;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.gcb-loader--fullpage .gcb-loader__percentage {
    font-size: 1.35rem;
    font-weight: 800;
}

.gcb-loader__status {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--gcb-loader-text-muted);
    line-height: 1.4;
    margin: 0;
    max-width: 380px;
}

.gcb-loader--fullpage .gcb-loader__status {
    font-size: 0.92rem;
    color: #cbd5e1;
}

/* ==========================================================================
   4. ERROR & RETRY STATE
   ========================================================================== */
.gcb-loader__error-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-width: 420px;
    padding: 24px;
}

.gcb-loader__error-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 77, 77, 0.12);
    border: 1px solid rgba(255, 77, 77, 0.35);
    color: #ff4d4d;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2px;
}

.gcb-loader__error-title {
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
}

.gcb-loader__error-desc {
    font-size: 0.84rem;
    color: var(--gcb-loader-text-muted);
    line-height: 1.45;
    margin: 0;
}

.gcb-loader__retry-btn {
    background: rgba(255, 94, 26, 0.15);
    border: 1px solid rgba(255, 94, 26, 0.4);
    color: #ffffff;
    font-weight: 600;
    font-size: 0.84rem;
    padding: 8px 18px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 6px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.gcb-loader__retry-btn:hover {
    background: var(--gcb-loader-orange);
    color: #000000;
    border-color: var(--gcb-loader-orange);
    box-shadow: 0 4px 14px rgba(255, 94, 26, 0.4);
}

/* ==========================================================================
   5. RESPONSIVE BREAKPOINTS
   ========================================================================== */
@media (max-width: 768px) {
    .gcb-loader--section {
        min-height: 180px;
        padding: 36px 16px;
    }

    .gcb-loader--section .gcb-loader__mark-wrap {
        width: 46px;
        height: 44px;
    }

    .gcb-loader--fullpage .gcb-loader__mark-wrap {
        width: 76px;
        height: 72px;
    }

    .gcb-loader__percentage {
        font-size: 0.88rem;
    }

    .gcb-loader--fullpage .gcb-loader__percentage {
        font-size: 1.15rem;
    }
}

/* ==========================================================================
   6. REDUCED MOTION (ACCESSIBILITY COMPLIANCE)
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    .gcb-loader,
    .gcb-loader__mark-wrap,
    .gcb-loader__mark-fill,
    .gcb-loader * {
        animation: none !important;
        transition: none !important;
    }
}
