﻿/** * Copyright (c) 2026 DNA Genics, S.L. All rights reserved.
 * 
 * Shared Loading Overlay Styles
 * Provides configurable, themed loading screens for ancestry reports.
 * Uses CSS custom properties for per-report theming.
 */

/* ========================================
   Loading Overlay - Main Container
   ======================================== */
.dna-loading-overlay {
    /* Theme variables with defaults */
    --loading-primary: #1a5a3a;
    --loading-secondary: #0f3a2a;
    --loading-bg-start: #0f1419;
    --loading-bg-mid: #1a2332;
    --loading-bg-end: #0d1117;
    
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--loading-bg-start) 0%, var(--loading-bg-mid) 50%, var(--loading-bg-end) 100%);
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.8s;
}

.dna-loading-overlay.dna-overlay-fadeout {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* ========================================
   Background Image Layer
   ======================================== */
.dna-loading-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.dna-loading-bg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.4;
    filter: blur(2px);
    animation: dnaLoadingBgPulse 4s ease-in-out infinite;
}

.dna-loading-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 0%, rgba(15, 20, 25, 0.5) 70%, rgba(15, 20, 25, 0.75) 100%);
}

@keyframes dnaLoadingBgPulse {
    0%, 100% { opacity: 0.35; transform: scale(1); }
    50% { opacity: 0.45; transform: scale(1.02); }
}

/* ========================================
   Loading Content Container
   ======================================== */
.dna-loading-content {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 2rem;
    max-width: 500px;
}

/* ========================================
   Spinner Animation
   ======================================== */
.dna-loading-spinner {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dna-spinner-ring {
    position: absolute;
    border-radius: 50%;
    border: 3px solid transparent;
}

.dna-ring-outer {
    width: 100%;
    height: 100%;
    border-top-color: var(--loading-primary);
    border-right-color: var(--loading-primary);
    animation: dnaSpinnerRotate 2s linear infinite;
}

.dna-ring-inner {
    width: 70%;
    height: 70%;
    border-bottom-color: var(--loading-primary);
    border-left-color: var(--loading-primary);
    opacity: 0.6;
    animation: dnaSpinnerRotate 1.5s linear infinite reverse;
}

.dna-spinner-icon {
    font-size: 2rem;
    color: var(--loading-primary);
    animation: dnaIconPulse 2s ease-in-out infinite;
}

@keyframes dnaSpinnerRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes dnaIconPulse {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* ========================================
   Typography
   ======================================== */
.dna-loading-title {
    font-size: 2.25rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.5rem;
    font-family: 'Cormorant Garamond', Georgia, serif;
    letter-spacing: 0.02em;
}

.dna-loading-subtitle {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 1rem;
    font-style: italic;
}

.dna-loading-narrative {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 1.5rem;
    min-height: 1.5em;
    transition: opacity 0.3s ease;
}

.dna-loading-hint {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 1rem;
}

.dna-loading-hint i {
    margin-right: 0.5rem;
    animation: dnaHourglassRotate 2s ease-in-out infinite;
}

@keyframes dnaHourglassRotate {
    0% { transform: rotate(0deg); }
    50% { transform: rotate(180deg); }
    100% { transform: rotate(180deg); }
}

/* ========================================
   Progress Bar
   ======================================== */
.dna-loading-progress {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto;
}

.dna-loading-progress-bar {
    width: 30%;
    height: 100%;
    background: linear-gradient(90deg, var(--loading-primary), var(--loading-secondary, var(--loading-primary)));
    border-radius: 2px;
    animation: dnaProgressSlide 1.5s ease-in-out infinite;
}

@keyframes dnaProgressSlide {
    0% { transform: translateX(-100%); width: 30%; }
    50% { width: 50%; }
    100% { transform: translateX(400%); width: 30%; }
}

/* ========================================
   Content Hidden State
   ======================================== */
.dna-content-hidden {
    opacity: 0 !important;
    visibility: hidden;
}

.dna-content-reveal {
    opacity: 1 !important;
    visibility: visible !important;
    /* Important: avoid leaving a persistent `transform` on the content wrapper.
       A transformed ancestor creates a containing block that can break `position: fixed`
       elements (e.g., report scrollspy/page navigation). */
    animation: dnaContentReveal 0.6s ease-out;
}

/* Ensure reveal overrides hidden when both classes might be present briefly */
.dna-content-hidden.dna-content-reveal {
    opacity: 1 !important;
    visibility: visible !important;
}

@keyframes dnaContentReveal {
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: none; 
    }
}

/* ========================================
   Responsive Adjustments
   ======================================== */
@media (max-width: 576px) {
    .dna-loading-content {
        padding: 1.5rem;
    }
    
    .dna-loading-spinner {
        width: 90px;
        height: 90px;
        margin-bottom: 1.5rem;
    }
    
    .dna-spinner-icon {
        font-size: 1.5rem;
    }
    
    .dna-loading-title {
        font-size: 1.75rem;
    }
    
    .dna-loading-narrative {
        font-size: 1rem;
    }
    
    .dna-loading-progress {
        width: 160px;
    }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .dna-loading-overlay {
        display: none !important;
    }
}

/* ========================================
   Reduced Motion
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .dna-loading-bg img,
    .dna-spinner-ring,
    .dna-spinner-icon,
    .dna-loading-progress-bar,
    .dna-loading-hint i {
        animation: none;
    }
    
    .dna-loading-overlay,
    .dna-content-reveal {
        transition: opacity 0.3s ease;
    }
    
    .dna-loading-progress-bar {
        width: 50%;
        transform: none;
    }
}

