/* ===================================
   Read+ Loading Screen Styles
   Professional Loading with Logo Transition
   =================================== */

/* Loading Overlay */
#page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(30, 58, 138, 0.85); /* Primary color with 85% opacity */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: opacity 0.6s ease-out, visibility 0.6s ease-out;
}

#page-loader.loaded {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Loading Container */
.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.5rem;
    max-width: 90%;
    width: 100%;
}

/* Logo Container with Transition Effect */
.loader-logo-container {
    position: relative;
    width: 180px;
    height: 180px;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (min-width: 640px) {
    .loader-logo-container {
        width: 220px;
        height: 220px;
        margin-bottom: 2.5rem;
    }
}

@media (min-width: 1024px) {
    .loader-logo-container {
        width: 260px;
        height: 260px;
        margin-bottom: 3rem;
    }
}

/* Grayscale Logo (Base) */
.loader-logo-gray,
.loader-logo-color {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 0.8s ease-in-out;
}

.loader-logo-gray {
    opacity: 1;
    z-index: 1;
}

.loader-logo-color {
    opacity: 0;
    z-index: 2;
}

/* Logo Animation - Pulse Effect */
@keyframes logoPulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.05);
    }
}

.loader-logo-container.animating .loader-logo-gray,
.loader-logo-container.animating .loader-logo-color {
    animation: logoPulse 2s ease-in-out infinite;
}

/* Progress Container */
.loader-progress-container {
    width: 100%;
    max-width: 400px;
    margin-bottom: 1.5rem;
}

@media (min-width: 640px) {
    .loader-progress-container {
        max-width: 500px;
        margin-bottom: 2rem;
    }
}

/* Progress Bar Background */
.loader-progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 100px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

@media (min-width: 640px) {
    .loader-progress-bar {
        height: 10px;
    }
}

/* Progress Bar Fill */
.loader-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, 
        #f97316 0%,    /* Secondary orange */
        #fb923c 50%,   /* Lighter orange */
        #fdba74 100%   /* Even lighter orange */
    );
    border-radius: 100px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: 0 0 10px rgba(249, 115, 22, 0.5);
}

/* Progress Bar Shimmer Effect */
.loader-progress-fill::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.4) 50%,
        transparent 100%
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 200%;
    }
}

/* Percentage Text */
.loader-percentage {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1.5rem;
    font-size: 3rem;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

@media (min-width: 640px) {
    .loader-percentage {
        font-size: 3.5rem;
        margin-top: 1.75rem;
    }
}

@media (min-width: 1024px) {
    .loader-percentage {
        font-size: 4rem;
        margin-top: 2rem;
    }
}

/* Percentage Symbol */
.loader-percentage-symbol {
    font-size: 2rem;
    margin-left: 0.25rem;
    opacity: 0.8;
}

@media (min-width: 640px) {
    .loader-percentage-symbol {
        font-size: 2.5rem;
        margin-left: 0.35rem;
    }
}

@media (min-width: 1024px) {
    .loader-percentage-symbol {
        font-size: 2.75rem;
        margin-left: 0.5rem;
    }
}

/* Loading Text */
.loader-text {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 1rem;
    font-weight: 500;
    letter-spacing: 0.05em;
}

@media (min-width: 640px) {
    .loader-text {
        font-size: 1.125rem;
        margin-top: 1.25rem;
    }
}

@media (min-width: 1024px) {
    .loader-text {
        font-size: 1.25rem;
        margin-top: 1.5rem;
    }
}

/* Loading Dots Animation */
.loader-dots {
    display: inline-block;
}

.loader-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% {
        content: '';
    }
    40% {
        content: '.';
    }
    60% {
        content: '..';
    }
    80%, 100% {
        content: '...';
    }
}

/* Spinner (Optional - For additional visual feedback) */
.loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #f97316; /* Secondary orange */
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-top: 2rem;
    display: none; /* Hidden by default, can be shown for slower connections */
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Brand Text Below Logo (Optional) */
.loader-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
    margin-top: 1rem;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    opacity: 0;
    animation: fadeInBrand 0.6s ease-out 0.3s forwards;
}

@media (min-width: 640px) {
    .loader-brand {
        font-size: 1.75rem;
    }
}

@media (min-width: 1024px) {
    .loader-brand {
        font-size: 2rem;
    }
}

.loader-brand-highlight {
    color: #f97316; /* Secondary orange */
}

@keyframes fadeInBrand {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Optimization */
@media (max-width: 480px) {
    .loader-container {
        padding: 1rem;
    }
    
    .loader-logo-container {
        width: 150px;
        height: 150px;
        margin-bottom: 1.5rem;
    }
    
    .loader-percentage {
        font-size: 2.5rem;
        margin-top: 1.25rem;
    }
    
    .loader-percentage-symbol {
        font-size: 1.75rem;
    }
    
    .loader-text {
        font-size: 0.875rem;
        margin-top: 0.75rem;
    }
    
    .loader-progress-container {
        max-width: 300px;
    }
    
    .loader-progress-bar {
        height: 6px;
    }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    #page-loader,
    .loader-logo-gray,
    .loader-logo-color,
    .loader-progress-fill,
    .loader-brand {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
    
    .loader-logo-container.animating .loader-logo-gray,
    .loader-logo-container.animating .loader-logo-color {
        animation: none;
    }
    
    .loader-progress-fill::before {
        animation: none;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    #page-loader {
        background: rgba(0, 0, 0, 0.95);
    }
    
    .loader-progress-bar {
        background: rgba(255, 255, 255, 0.3);
        border: 2px solid #ffffff;
    }
    
    .loader-progress-fill {
        background: #f97316;
    }
}
