/* ============================================
   PAGE LOADER ANIMATION
   ============================================ */

/* Снижает белый кадр до первой отрисовки контента */
html {
    background-color: #0f0e0b;
}

/* Loader overlay - covers entire viewport */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f0e0b 0%, #1a1410 50%, #0f0e0b 100%);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    pointer-events: none;
    will-change: opacity;
}

.page-loader.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

/* Card silhouettes container */
.loader-cards-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    perspective: 1000px;
}

/* Individual card silhouette */
.loader-card {
    position: relative;
    width: 80px;
    height: 112px;
    background: linear-gradient(145deg, rgba(201, 169, 97, 0.15), rgba(139, 107, 71, 0.1));
    border: 2px solid rgba(201, 169, 97, 0.3);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(201, 169, 97, 0.2), inset 0 0 20px rgba(201, 169, 97, 0.05);
    will-change: transform, opacity;
    animation: cardPulse 2s ease-in-out infinite;
    flex-shrink: 0;
}

/* Card inner glow effect */
.loader-card::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, rgba(201, 169, 97, 0.2), transparent);
    transform: translate(-50%, -50%);
    border-radius: 4px;
    animation: innerGlow 2s ease-in-out infinite;
}

/* Card decorative elements */
.loader-card::after {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 1px solid rgba(201, 169, 97, 0.2);
    border-radius: 4px;
}

/* Different card positions and animations */
.loader-card:nth-child(1) {
    animation-delay: 0s;
}

.loader-card:nth-child(2) {
    animation-delay: 0.3s;
}

.loader-card:nth-child(3) {
    animation-delay: 0.6s;
}

.loader-card:nth-child(4) {
    animation-delay: 0.9s;
}

.loader-card:nth-child(5) {
    animation-delay: 1.2s;
}

/* Card pulse animation */
@keyframes cardPulse {
    0%, 100% {
        opacity: 0.4;
        transform: scale(1);
        box-shadow: 0 8px 32px rgba(201, 169, 97, 0.2), inset 0 0 20px rgba(201, 169, 97, 0.05);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
        box-shadow: 0 12px 48px rgba(201, 169, 97, 0.4), inset 0 0 30px rgba(201, 169, 97, 0.1);
    }
}

/* Inner glow animation */
@keyframes innerGlow {
    0%, 100% {
        opacity: 0.3;
    }
    50% {
        opacity: 0.6;
    }
}


/* Loading text */
.loader-text {
    margin-top: 40px;
    font-family: var(--title-font, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color, #c9a961);
    text-transform: uppercase;
    letter-spacing: 3px;
    text-shadow: 0 0 20px rgba(201, 169, 97, 0.5), 0 0 40px rgba(201, 169, 97, 0.3);
    animation: textPulse 1.5s ease-in-out infinite;
    will-change: opacity, transform;
}

/* Loading text pulse animation */
@keyframes textPulse {
    0%, 100% {
        opacity: 0.7;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.02);
    }
}

/* Loading dots */
.loader-dots {
    display: flex;
    gap: 8px;
    margin-top: 15px;
}

.loader-dot {
    width: 8px;
    height: 8px;
    background: var(--primary-color, #c9a961);
    border-radius: 50%;
    animation: dotPulse 1.4s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(201, 169, 97, 0.5);
}

.loader-dot:nth-child(1) {
    animation-delay: 0s;
}

.loader-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loader-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {
    0%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Ambient particles */
.loader-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(201, 169, 97, 0.4);
    border-radius: 50%;
    animation: particleFloat 4s ease-in-out infinite;
    will-change: transform, opacity;
}

.particle:nth-child(1) {
    top: 20%;
    left: 10%;
    animation-delay: 0s;
    animation-duration: 5s;
}

.particle:nth-child(2) {
    top: 30%;
    left: 80%;
    animation-delay: 1s;
    animation-duration: 4s;
}

.particle:nth-child(3) {
    top: 60%;
    left: 15%;
    animation-delay: 2s;
    animation-duration: 6s;
}

.particle:nth-child(4) {
    top: 70%;
    left: 85%;
    animation-delay: 0.5s;
    animation-duration: 5s;
}

.particle:nth-child(5) {
    top: 40%;
    left: 50%;
    animation-delay: 1.5s;
    animation-duration: 4.5s;
}

.particle:nth-child(6) {
    top: 80%;
    left: 30%;
    animation-delay: 2.5s;
    animation-duration: 5.5s;
}

@keyframes particleFloat {
    0%, 100% {
        opacity: 0;
        transform: translateY(0) scale(0);
    }
    50% {
        opacity: 0.6;
        transform: translateY(-30px) scale(1);
    }
}

/* Performance optimization - reduced motion */
@media (prefers-reduced-motion: reduce) {
    .loader-card,
    .loader-text,
    .loader-dot,
    .particle {
        animation-duration: 3s;
        animation-timing-function: ease;
    }
    
    .loader-card::before {
        animation-duration: 3s;
    }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .loader-cards-container {
        max-width: 400px;
        height: 250px;
        gap: 15px;
    }
    
    .loader-card {
        width: 60px;
        height: 84px;
    }
    
    .loader-text {
        font-size: 1.2rem;
        letter-spacing: 2px;
    }
}

@media (max-width: 480px) {
    .loader-cards-container {
        max-width: 300px;
        height: 200px;
        gap: 10px;
    }
    
    .loader-card {
        width: 50px;
        height: 70px;
    }
    
    .loader-text {
        font-size: 1rem;
        letter-spacing: 1.5px;
        margin-top: 30px;
    }
    
    .loader-dot {
        width: 6px;
        height: 6px;
    }
}

/* Блокировка скроллинга и взаимодействий во время загрузки */
body.page-loading {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Блокировка всех взаимодействий с контентом под загрузчиком */
.page-loader.active ~ * {
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Hide loader when page is fully loaded */
.page-loader.loaded {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

body.page-loading .page-loader.loaded ~ * {
    pointer-events: auto;
    user-select: auto;
    -webkit-user-select: auto;
    -moz-user-select: auto;
    -ms-user-select: auto;
}

/* Уведомление об отсутствии сети (page-loader.js) */
.page-loader-offline-notice {
    position: fixed;
    left: 50%;
    bottom: 1.25rem;
    transform: translateX(-50%);
    z-index: 1000000;
    max-width: min(92vw, 28rem);
    padding: 0.9rem 2.5rem 0.9rem 1rem;
    background: rgba(17, 15, 11, 0.96);
    border: 1px solid rgba(201, 169, 97, 0.45);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    color: #ece6da;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.45;
}

.page-loader-offline-notice[hidden] {
    display: none !important;
}

.page-loader-offline-notice__title {
    margin: 0 0 0.35rem;
    font-weight: 700;
    color: #c9a961;
    font-size: 1rem;
}

.page-loader-offline-notice__hint {
    margin: 0;
    color: rgba(236, 230, 218, 0.88);
    font-size: 0.9rem;
}

.page-loader-offline-notice__close {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    background: transparent;
    color: rgba(201, 169, 97, 0.85);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
}

.page-loader-offline-notice__close:hover {
    background: rgba(201, 169, 97, 0.12);
    color: #ece6da;
}
