/* ============================================
   BASE STYLES
   Базовые стили: reset, body, container, preloader
   ============================================ */

/* Base reset styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--color-bg-primary) !important;
    color: var(--color-text-primary);
    font-family: var(--font-primary);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    color-scheme: dark;
    /* Предотвращаем scroll chaining от canvas */
    overscroll-behavior: none !important;
}

/* Screen reader only - for SEO H1 headings */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Settings page override */
body.settings-page {
    overflow: visible;
    height: auto;
    min-height: 100vh;
}

/* Subscribe page override */
body.subscribe-page {
    overflow-x: hidden !important; /* Убираем горизонтальный скролл */
    overflow-y: auto !important; /* Разрешаем только вертикальный скролл */
    height: 100vh !important;
    min-height: 100vh !important;
    background: var(--color-bg-primary) !important;
    width: 100vw;
    max-width: 100vw; /* Предотвращаем горизонтальный скролл */
    box-sizing: border-box;
}

/* Light theme: Subscribe page body override */
body.light-theme.subscribe-page {
    background: #ffffff !important;
}

html.light-theme {
    background: #ffffff !important;
}

.subscribe-page {
    overflow-x: hidden !important; /* Убираем горизонтальный скролл */
    overflow-y: auto !important; /* Разрешаем только вертикальный скролл */
    height: 100vh !important;
    min-height: 100vh !important;
    width: 100%;
    max-width: 100vw; /* Предотвращаем горизонтальный скролл */
    box-sizing: border-box;
}

@media (max-width: 800px) {
    body {
        overflow-x: hidden;
        overflow-y: auto;
    }
}

/* Remove underline from all links */
a {
    text-decoration: none;
    color: inherit;
}

a:hover,
a:focus,
a:visited,
a:active {
    text-decoration: none;
}

/* Container */
.container {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    box-sizing: border-box;
    transition: opacity 0.4s ease;
}

.preloader-active .container {
    opacity: 0;
    pointer-events: none;
}

/* Preloader */
.navorina-preloader-inner {
    padding: var(--spacing-xl) var(--spacing-3xl);
    border-radius: var(--radius-full);
    border: none;
    background: transparent;
}

.navorina-preloader-logo {
    width: 81px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    font-family: var(--font-serif);
    font-style: normal;
    font-weight: var(--font-weight-normal);
    font-size: var(--font-size-xl);
    line-height: var(--line-height-tight);
    text-transform: uppercase;
    color: var(--color-text-primary);
}

.navorina-preloader-letter {
    display: inline-block;
    opacity: 0;
    transform: translate(-12px, 6px) scale(0.92);
    color: inherit;
}

.navorina-preloader-letter.entering {
    animation: preloaderLetterIn 0.38s ease forwards;
}

.navorina-preloader-letter.exiting {
    animation: preloaderLetterOut 0.38s ease forwards;
}

@keyframes preloaderLetterIn {
    0% {
        opacity: 0;
        transform: translate(-16px, 6px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
}

@keyframes preloaderLetterOut {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(16px, -6px) scale(0.9);
    }
}

/* Hide preloader */
.hidden {
    display: none !important;
}

.navorina-preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0A0A0A;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

.navorina-preloader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* ============================================
   Loading Animation CSS (CodePen Style)
   Оригинальная анимация из CodePen, адаптированная под Navorina
   ============================================ */

/* Контейнер для анимации загрузки */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 99999;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

.loading.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    z-index: -1;
}

/* Адаптация фона под тему */
body.light-theme .loading,
html:not(.dark) .loading {
    background: var(--color-bg-primary);
}

/* Контейнер для текста загрузки - центрирование */
.loading-text {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
    text-align: center;
    width: 100%;
    height: 60px;
    line-height: 60px;
}

/* Каждая буква в отдельном span */
.loading-text-words {
    display: inline-block;
    margin: 0 3px;
    color: #fff;
    /* Instrument Serif: без FOUT — в HTML Google Fonts &display=block (не swap) + preload woff2 см. index.html */
    font-family: 'Instrument Serif', 'Georgia', 'Times New Roman', 'Times', serif;
    font-size: 2.5rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    filter: blur(0px);
    opacity: 0.95;
}

/* Анимация размытия для каждой буквы с задержкой */
.loading-text-words:nth-child(1) {
    animation: blur-text 1.5s 0s infinite linear alternate;
}

.loading-text-words:nth-child(2) {
    animation: blur-text 1.5s 0.2s infinite linear alternate;
}

.loading-text-words:nth-child(3) {
    animation: blur-text 1.5s 0.4s infinite linear alternate;
}

.loading-text-words:nth-child(4) {
    animation: blur-text 1.5s 0.6s infinite linear alternate;
}

.loading-text-words:nth-child(5) {
    animation: blur-text 1.5s 0.8s infinite linear alternate;
}

.loading-text-words:nth-child(6) {
    animation: blur-text 1.5s 1s infinite linear alternate;
}

.loading-text-words:nth-child(7) {
    animation: blur-text 1.5s 1.2s infinite linear alternate;
}

.loading-text-words:nth-child(8) {
    animation: blur-text 1.5s 1.4s infinite linear alternate;
}

/* Анимация размытия текста */
@keyframes blur-text {
    0% {
        filter: blur(0px);
    }
    100% {
        filter: blur(4px);
    }
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .loading-text {
        height: 50px;
        line-height: 50px;
    }
    
    .loading-text-words {
        font-size: 2rem;
        margin: 0 2px;
    }
}

@media (max-width: 480px) {
    .loading-text {
        height: 40px;
        line-height: 40px;
    }
    
    .loading-text-words {
        font-size: 1.75rem;
        margin: 0 1px;
    }
}

/* Адаптация цвета под тему */
body.light-theme .loading-text-words,
html:not(.dark) .loading-text-words {
    color: var(--color-text-primary);
}

