/* Splash Screen Styles */

@keyframes splashGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes orbFloat {
    0% { transform: translate(-10%, -8%) scale(1); }
    50% { transform: translate(6%, 4%) scale(1.08); }
    100% { transform: translate(-10%, -8%) scale(1); }
}

@keyframes orbDrift {
    0% { transform: translate(8%, 10%) scale(1); }
    50% { transform: translate(-4%, -6%) scale(1.12); }
    100% { transform: translate(8%, 10%) scale(1); }
}

@keyframes logoFloat {
    0% { transform: translateY(0); }
    100% { transform: translateY(-6px); }
}

@keyframes barSweep {
    0% { background-position: 0% 0; }
    100% { background-position: 200% 0; }
}

@keyframes checkPop {
    0% { opacity: 0; transform: scale(0.7); }
    100% { opacity: 1; transform: scale(1); }
}

#splash-screen {
    /* Graphite Instrument identity — matches the app tokens for a seamless boot. */
    --splash-bg-1: #0f1214;
    --splash-bg-2: #15181b;
    --splash-bg-3: #1b1f22;
    --splash-text: #e7ecef;
    --splash-muted: #a7b0b7;
    --splash-accent: #3aa0ff;
    --splash-accent-strong: #57adff;
    --splash-good: #4fb477;
    --splash-warn: #ee6a5f;

    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 20% 20%, rgba(100, 210, 255, 0.18), transparent 45%),
        radial-gradient(circle at 80% 10%, rgba(46, 204, 113, 0.15), transparent 50%),
        linear-gradient(135deg, var(--splash-bg-1), var(--splash-bg-2), var(--splash-bg-3));
    background-size: 200% 200%;
    animation: splashGradient 16s ease infinite;
    color: var(--splash-text);
    z-index: 9999;
    overflow: hidden;
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

#splash-screen::before,
#splash-screen::after {
    content: '';
    position: absolute;
    width: 60vmax;
    height: 60vmax;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.45;
    pointer-events: none;
}

#splash-screen::before {
    background: radial-gradient(circle, rgba(100, 210, 255, 0.45), transparent 70%);
    top: -20vmax;
    left: -15vmax;
    animation: orbFloat 14s ease-in-out infinite;
}

#splash-screen::after {
    background: radial-gradient(circle, rgba(46, 204, 113, 0.4), transparent 70%);
    bottom: -25vmax;
    right: -10vmax;
    animation: orbDrift 18s ease-in-out infinite;
}

#splash-screen.fade-out {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px) scale(1.02);
}

#splash-screen .text-center {
    position: relative;
    z-index: 1;
    width: min(90vw, 520px);
    padding: 2.5rem 2.75rem 2.75rem;
    border-radius: 24px;
    background: rgba(12, 16, 22, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(14px);
}

.splash-logo {
    font-size: clamp(2.4rem, 4vw, 3.75rem);
    font-weight: 800;
    letter-spacing: 0.02em;
    background: linear-gradient(120deg, #f4fbff, #64d2ff 55%, #a7f3d0 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
    animation: logoFloat 3.2s ease-in-out infinite alternate;
}

.splash-logo i {
    color: var(--splash-accent);
    text-shadow: 0 10px 24px rgba(100, 210, 255, 0.45);
}

.splash-subtitle {
    color: var(--splash-muted);
    font-size: var(--font-size-sm);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-top: 0.75rem;
}

.loading-progress {
    margin-top: 2.25rem;
    width: 100%;
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
}

.loading-progress .progress {
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

#loading-bar,
.progress-bar {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(120deg, var(--splash-accent), var(--splash-accent-strong), var(--splash-accent));
    background-size: 200% 100%;
    animation: barSweep 2.8s linear infinite;
}

#loading-text,
.loading-text {
    margin-top: 0.85rem;
    color: var(--splash-muted);
    font-size: var(--font-size-sm);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.check-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 0.9rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-height: 80px;
    transition: border-color 0.3s ease, background 0.3s ease, color 0.3s ease;
}

.check-box.state-idle {
    color: var(--splash-muted); 
}

.check-box.state-active {
    color: var(--splash-text);
    border-color: rgba(100, 210, 255, 0.45);
    background: rgba(100, 210, 255, 0.08);
}

.check-box.state-ok {
    color: var(--splash-good);
    background: rgba(46, 204, 113, 0.08);
    animation: neonFlickerGreen 1.2s forwards ease-in-out;
}

.check-box.state-error {
    color: var(--splash-warn);
    background: rgba(255, 107, 107, 0.1);
    animation: neonFlickerRed 1.2s forwards ease-in-out;
}

.check-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.check-title {
    font-size: var(--font-size-xs);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.check-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: var(--font-size-xs);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    box-shadow: 0 0 0 rgba(255, 255, 255, 0.2);
}

.check-box.state-active .status-dot {
    background: var(--splash-accent);
    box-shadow: 0 0 10px rgba(100, 210, 255, 0.45);
}

.check-box.state-ok .status-dot {
    background: var(--splash-good);
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.5);
}

.check-box.state-error .status-dot {
    background: var(--splash-warn);
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
}


.check-detail {
    font-size: var(--font-size-xs);
    color: var(--splash-muted);
    min-height: 2.2rem;
}

.check-box.state-ok .check-detail {
    color: rgba(46, 204, 113, 0.85);
}

.check-box.state-error .check-detail {
    color: rgba(255, 107, 107, 0.85);
}

.check-action {
    align-self: flex-start;
    padding: 0.2rem 0.4rem;
    font-size: var(--font-size-xs);
    border-radius: 999px;
    border: 1px solid rgba(100, 210, 255, 0.4);
    background: transparent;
    color: var(--splash-accent);
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.check-action:hover:not(:disabled) {
    border-color: var(--splash-accent);
    color: #e9f7ff;
    background: rgba(100, 210, 255, 0.12);
}

.check-action:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.check-info {
    align-self: flex-end;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--splash-accent);
    font-size: var(--font-size-sm);
    cursor: help;
}

.check-tooltip {
    position: absolute;
    bottom: 125%;
    right: 0;
    width: 220px;
    padding: 0.65rem 0.75rem;
    background: rgba(12, 16, 22, 0.95);
    border: 1px solid rgba(100, 210, 255, 0.3);
    border-radius: 10px;
    color: var(--splash-text);
    font-size: var(--font-size-xs);
    line-height: 1.4;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 5;
}

.check-tooltip ul {
    margin: 0.4rem 0 0;
    padding-left: 1rem;
}

.check-info:hover .check-tooltip {
    opacity: 1;
    transform: translateY(0);
}

@keyframes statusBlink {
    0%, 100% {
        opacity: 0.4;
        box-shadow: 0 0 0 rgba(0, 0, 0, 0);
    }
    50% {
        opacity: 1;
        box-shadow: 0 0 14px var(--splash-accent);
    }
}

.check-box.state-ok .status-dot.blink {
    animation: statusBlinkOk 1.2s ease-in-out infinite;
}

@keyframes statusBlinkOk {
    0%, 100% {
        opacity: 0.4;
        box-shadow: 0 0 0 rgba(0, 0, 0, 0);
    }
    50% {
        opacity: 1;
        box-shadow: 0 0 14px var(--splash-good);
    }
}

.check-box.state-error .status-dot.blink {
    animation: statusBlinkError 1.2s ease-in-out infinite;
}

@keyframes statusBlinkError {
    0%, 100% {
        opacity: 0.4;
        box-shadow: 0 0 0 rgba(0, 0, 0, 0);
    }
    50% {
        opacity: 1;
        box-shadow: 0 0 14px var(--splash-warn);
    }
}

.loading-steps,
#preflight-steps,
#app-init-steps {
    margin-top: 2rem;
    text-align: left;
    width: 100%;
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
    display: grid;
    gap: 0.5rem;
}

.loading-steps.check-grid {
    max-width: 520px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
}

.loading-step {
    color: var(--splash-muted);
    font-size: var(--font-size-sm);
    opacity: 0.5;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    border-radius: 12px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.02);
    transition: opacity 0.3s ease, color 0.3s ease, border-color 0.3s ease, background 0.3s ease;
}

.loading-step.active {
    color: var(--splash-text);
    opacity: 1;
    border-color: rgba(100, 210, 255, 0.4);
    background: rgba(100, 210, 255, 0.12);
}

.loading-step.completed {
    color: var(--splash-good);
    opacity: 1;
    border-color: rgba(46, 204, 113, 0.35);
    background: rgba(46, 204, 113, 0.1);
}

.loading-step.error {
    color: var(--splash-warn);
    opacity: 1;
    border-color: rgba(255, 107, 107, 0.4);
    background: rgba(255, 107, 107, 0.12);
}

.loading-step.idle {
    opacity: 0.35;
}

.loading-step .step-icon {
    width: 18px;
    text-align: center;
    color: inherit;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.loading-step.active .step-icon {
    animation: iconPulse 2s ease-in-out infinite;
}

.loading-step.completed .step-icon {
    opacity: 0.3;
    transform: scale(0.9);
}

.loading-step .step-text {
    flex: 1;
    transition: color 0.3s ease;
}

.loading-step .step-action-btn {
    padding: 0.125rem 0.5rem;
    font-size: var(--font-size-xs);
    line-height: 1.2;
    min-width: auto;
    height: 1.6rem;
    margin-left: 0.25rem;
    border-radius: 999px;
    border-color: rgba(100, 210, 255, 0.45);
    color: var(--splash-accent);
    background: transparent;
    transition: opacity 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.loading-step .step-action-btn:hover {
    opacity: 1;
    border-color: var(--splash-accent);
    color: #e9f7ff;
}

.loading-step .step-action-btn i {
    font-size: var(--font-size-sm);
}

.loading-step .step-check {
    margin-left: auto;
    color: var(--splash-good);
    font-size: var(--font-size-xs);
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.loading-step .step-check.check-animate {
    opacity: 1;
    transform: scale(1);
    animation: checkPop 0.3s ease-out;
}

@keyframes iconPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

#splash-actions {
    margin-top: 1rem;
}

#set-working-folder-btn,
#load-grf-file-btn {
    min-width: 150px;
}

#set-working-folder-btn:disabled,
#load-grf-file-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#splash-hint {
    margin-top: 0.5rem;
    color: var(--splash-muted);
}

#splash-error {
    margin-top: 1rem;
}

/* Boot watchdog notice — shown when the app bundle never runs (deploy window, offline,
   failed boot). Styled with the splash's own tokens so it needs no bundled CSS. */
/* Repeated from Bootstrap so the notice stays hidden even if bootstrap.min.css is the
   asset that failed to load. */
.splash-boot-notice.d-none,
.splash-boot-notice .d-none {
    display: none !important;
}

.splash-boot-notice {
    margin-top: 1.25rem;
    padding: 0.9rem 1rem;
    border: 1px solid rgba(100, 210, 255, 0.35);
    border-radius: 16px;
    background: rgba(100, 210, 255, 0.08);
    text-align: left;
}

.splash-boot-notice .sbn-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--splash-accent-strong);
    font-size: var(--font-size-xs, 0.75rem);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.splash-boot-notice .sbn-message {
    margin: 0.45rem 0 0;
    color: var(--splash-muted);
    font-size: var(--font-size-sm, 0.875rem);
    line-height: 1.45;
}

.splash-boot-notice .sbn-actions {
    margin-top: 0.75rem;
}

.splash-boot-notice .sbn-btn {
    border: 1px solid rgba(100, 210, 255, 0.45);
    border-radius: 10px;
    padding: 0.35rem 0.9rem;
    background: transparent;
    color: var(--splash-accent-strong);
    font-size: var(--font-size-xs, 0.75rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.splash-boot-notice .sbn-btn:hover {
    background: rgba(100, 210, 255, 0.16);
    color: var(--splash-text);
}

/* The progress bar is meaningless once boot has stalled — stop it pretending to work. */
#splash-screen.splash-stalled #loading-bar,
#splash-screen.splash-stalled .progress-bar {
    animation: none;
    opacity: 0.35;
}

@media (max-width: 540px) {
    #splash-screen .text-center {
        padding: 2rem 1.75rem 2.25rem;
        border-radius: 18px;
    }

    .splash-subtitle {
        letter-spacing: 0.12em;
    }
}

@media (prefers-reduced-motion: reduce) {
    #splash-screen,
    #splash-screen::before,
    #splash-screen::after,
    .splash-logo,
    #loading-bar,
    .progress-bar {
        animation: none;
    }
}
