/* Public app loading screen – matches EGKits professional dark theme */

/* === CSS Custom Properties === */
:root {
    --pub-gradient: linear-gradient(160deg, #070b1a 0%, #0f1629 40%, #151030 100%);
    --pub-text-light: rgba(255, 255, 255, 0.98);
    --pub-text-muted: rgba(148, 163, 184, 0.8);
    --pub-text-subtle: rgba(148, 163, 184, 0.45);
    --pub-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    --pub-transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --pub-transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Base resets === */
.egk-app-public *, .egk-app-public *::before, .egk-app-public *::after { box-sizing: border-box; }
.egk-app-public { background: var(--pub-gradient); color: var(--pub-text-light); }
.egk-app-public :focus-visible { border-radius: 4px; box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.5); }
.egk-app-public.loading { overflow: hidden !important; }

body.egk-app-public {
    overflow: hidden; height: 100%; margin: 0; padding: 0;
    background: var(--pub-gradient);
    font-family: var(--pub-font);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.egk-app-public #app {
    position: relative; overflow: hidden;
    width: 100%; min-height: 100vh; min-height: 100dvh;
    background: var(--pub-gradient);
}

body.egk-app-public.app-ready {
    overflow: auto;
    background: var(--mud-palette-background, #f8fafc);
    transition: background-color var(--pub-transition-slow);
}

.egk-app-public #app.app-ready {
    overflow: visible; height: auto;
    min-height: 100vh; min-height: 100dvh;
    background: transparent;
    transition: background-color var(--pub-transition-slow);
}

/* === Loading Overlay === */
.egk-app-public .loading-overlay {
    position: fixed; top: 0; left: 0;
    z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%;
    background: var(--pub-gradient);
    user-select: none;
}

.egk-app-public .loading-overlay::before {
    content: ''; position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    background:
        radial-gradient(ellipse 600px 600px at 20% 80%, rgba(99, 102, 241, 0.1) 0%, transparent 70%),
        radial-gradient(ellipse 500px 500px at 80% 20%, rgba(139, 92, 246, 0.07) 0%, transparent 70%),
        radial-gradient(ellipse 800px 400px at 50% 50%, rgba(99, 102, 241, 0.04) 0%, transparent 60%);
    animation: pubBgShift 25s ease-in-out infinite;
}

@keyframes pubBgShift {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.7; }
}

.egk-app-public .loading-overlay.fade-out {
    animation: pubFadeOut 0.6s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes pubFadeOut {
    0% { opacity: 1; transform: scale(1); }
    100% { visibility: hidden; opacity: 0; transform: scale(1.01); pointer-events: none; }
}

/* === Loading Content === */
.egk-app-public .loading-content {
    position: relative; z-index: 10;
    max-width: min(90vw, 420px);
    margin: 0 auto; padding: 1.5rem 1rem;
    color: var(--pub-text-light); text-align: center;
}

.egk-app-public .loading-overlay.fade-out .loading-content {
    animation: pubContentUp 0.6s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes pubContentUp {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-20px) scale(0.98); }
}

/* === Logo === */
.egk-app-public .loading-logo-container {
    position: relative;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 2.5rem; perspective: 1000px;
}

.egk-app-public .loading-logo {
    position: relative; z-index: 10;
    display: flex; align-items: center; justify-content: center;
    width: 140px; height: 140px;
    border: none; border-radius: 50%;
    background: transparent;
    animation: pubFloat 8s ease-in-out infinite;
    will-change: transform;
}

.egk-app-public .loading-logo img {
    width: 82%; height: 82%;
    border-radius: 0;
    filter: drop-shadow(0 0 40px rgba(99, 102, 241, 0.25)) drop-shadow(0 0 80px rgba(99, 102, 241, 0.1)) brightness(1.05);
    object-fit: contain;
    transition: all var(--pub-transition-slow) ease;
}

@keyframes pubFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.egk-app-public .loading-logo::before {
    content: ''; position: absolute; top: 50%; left: 50%;
    width: 180%; height: 180%; transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.12) 0%, rgba(99, 102, 241, 0.04) 40%, transparent 70%);
    animation: pubGlow 5s ease-in-out infinite; opacity: 1;
}

@keyframes pubGlow {
    0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
}

/* === Brand Text === */
.egk-app-public .loading-brand { margin-bottom: 2rem; }

.egk-app-public .loading-title {
    background: linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0.75) 100%);
    background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    line-height: 1.1; letter-spacing: -0.03em;
    font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 700;
    margin: 0 0 0.5rem;
}

.egk-app-public .loading-subtitle {
    color: var(--pub-text-muted);
    letter-spacing: 0.2em;
    font-size: clamp(0.6rem, 1.4vw, 0.72rem); font-weight: 500;
    text-transform: uppercase;
    margin-bottom: 0.6rem;
}

.egk-app-public .loading-tagline {
    max-width: 360px;
    color: var(--pub-text-subtle);
    line-height: 1.5;
    font-size: clamp(0.7rem, 1.4vw, 0.78rem); font-weight: 400;
    margin: 0 auto 2.5rem;
}

/* === Progress Bar === */
.egk-app-public .loading-progress-container {
    width: 100%; max-width: 200px; margin: 0 auto;
}

.egk-app-public .loading-progress {
    position: relative; overflow: hidden;
    width: 100%; height: 2px;
    border: none; border-radius: 2px;
    background: rgba(255, 255, 255, 0.06);
}

.egk-app-public .loading-progress-fill {
    position: absolute; top: 0; left: 0;
    width: 0%; height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, #6366f1 0%, #818cf8 50%, #a78bfa 100%);
    transition: width 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.3);
}

.egk-app-public .loading-progress-fill::after {
    content: ''; position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.15) 50%, transparent 100%);
    animation: pubProgressFlow 2.2s ease-in-out infinite;
}

@keyframes pubProgressFlow {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(200%); }
}

/* === Stage Text === */
.egk-app-public .loading-stage {
    min-height: 1.2rem;
    color: rgba(148, 163, 184, 0.5);
    letter-spacing: 0.04em;
    font-size: clamp(0.72rem, 1.3vw, 0.8rem); font-weight: 400;
    margin-top: 1.25rem;
    font-family: var(--pub-font);
    animation: pubStageIn 0.5s ease-in-out;
}

@keyframes pubStageIn {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 0.9; transform: translateY(0); }
}

/* === Content reveal === */
.egk-app-public #app > div:not(.loading-overlay) { transition: opacity 0.8s cubic-bezier(0.25, 1, 0.5, 1); opacity: 0; }
.egk-app-public #app.app-ready > div:not(.loading-overlay) { opacity: 1; }
.egk-app-public #app.show-content > div:not(.loading-overlay) { opacity: 1; }

/* === Responsive === */
@media (width <= 768px) {
    .egk-app-public .loading-logo { width: 120px; height: 120px; }
    .egk-app-public .loading-content { max-width: 95vw; padding: 1.2rem 0.8rem; }
    .egk-app-public .loading-brand { margin-bottom: 1.2rem; }
    .egk-app-public .loading-tagline { margin-bottom: 1.5rem; }
    .egk-app-public .loading-title { font-size: clamp(1.3rem, 6vw, 1.8rem); }
    .egk-app-public .loading-subtitle { font-size: clamp(0.55rem, 2.5vw, 0.65rem); }
    .egk-app-public .loading-stage { font-size: clamp(0.65rem, 2.5vw, 0.75rem); }
}

@media (width <= 480px) {
    .egk-app-public .loading-logo { width: 100px; height: 100px; }
    .egk-app-public .loading-content { max-width: 98vw; padding: 1rem 0.6rem; }
    .egk-app-public .loading-brand { margin-bottom: 1rem; }
    .egk-app-public .loading-tagline { max-width: 280px; margin-bottom: 1.2rem; }
}

@media (width >= 1025px) {
    .egk-app-public .loading-logo { width: 180px; height: 180px; }
    .egk-app-public .loading-content { max-width: 520px; padding: 2.5rem 2rem; }
    .egk-app-public .loading-progress-container { max-width: 280px; }
    .egk-app-public .loading-brand { margin-bottom: 2rem; }
    .egk-app-public .loading-tagline { margin-bottom: 2.5rem; }
}

@media (prefers-reduced-motion: reduce) {
    .egk-app-public .loading-logo,
    .egk-app-public .loading-progress-fill::after,
    .egk-app-public .loading-overlay::before {
        animation: none !important;
    }
    .egk-app-public .loading-logo { transform: none !important; }
}

@media print {
    .egk-app-public .loading-overlay { display: none !important; }
}
