/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Цветовая палитра */
    --color-bg: #0a0a0a;
    --color-bg-deep: #050505;
    --color-text: #ffffff;
    --color-text-muted: rgba(255, 255, 255, 0.85);
    --color-text-dim: rgba(255, 255, 255, 0.6);
    --color-accent: rgba(255, 255, 255, 0.08);
    
    /* Типографика */
    --font-display: 'Fraunces', 'Times New Roman', serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    
    /* Размеры */
    --container-padding: clamp(1.5rem, 5vw, 4rem);
    --section-padding: clamp(3rem, 8vh, 6rem);
    
    /* Анимации */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
    --duration-slow: 1.2s;
    --duration-medium: 0.8s;
    --duration-fast: 0.4s;
}

html {
    scroll-behavior: auto; /* GSAP управляет скроллом */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-body);
    font-weight: 300;
    background: var(--color-bg);
    color: var(--color-text);
    overflow-x: hidden;
    line-height: 1.5;
    min-height: 100vh;
}

body.is-loading {
    overflow: hidden;
    height: 100vh;
}

img, video {
    max-width: 100%;
    display: block;
}

/* Фон-заглушка для видео пока не загрузилось */
.video-stage {
    background-color: var(--color-bg-deep);
    background-image: none;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
}

/* ============================================
   PRELOADER
   ============================================ */
.preloader {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--duration-slow) var(--ease-out-expo),
                visibility var(--duration-slow) var(--ease-out-expo);
}

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

.preloader__inner {
    text-align: center;
}

.preloader__text {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 300;
    letter-spacing: 0.02em;
    display: block;
    margin-bottom: 2rem;
    opacity: 1;
}

.preloader__bar {
    width: 200px;
    height: 1px;
    background: var(--color-accent);
    position: relative;
    overflow: hidden;
}

.preloader__progress {
    position: absolute;
    inset: 0;
    background: var(--color-text);
    transform-origin: left;
    transform: scaleX(0);
    transition: transform 0.3s var(--ease-out-quart);
}

/* ============================================
   VIDEO STAGE
   ============================================ */
.video-stage {
    position: fixed;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    background: var(--color-bg-deep);
}

.video-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    /* will-change убран: вызывает проблемы с GPU на мобильных */
}

/* Фоллбек object-fit для старых браузеров (Samsung Internet < 12, Android 4.x) */
@supports not (object-fit: cover) {
    .video-bg {
        width: 100vw;
        height: 100vh;
        min-width: 100%;
        min-height: 100%;
    }
}

.video-overlay {
    position: absolute;
    inset: 0;
    background: 
        radial-gradient(ellipse at center, transparent 0%, rgba(0, 0, 0, 0.3) 100%),
        linear-gradient(180deg, 
            rgba(0, 0, 0, 0.4) 0%, 
            transparent 30%, 
            transparent 70%, 
            rgba(0, 0, 0, 0.5) 100%
        );
    pointer-events: none;
    z-index: 2;
}

/* ============================================
   HEADER
   ============================================ */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    padding: clamp(1.5rem, 3vh, 2.5rem) var(--container-padding);
    display: flex;
    justify-content: space-between;
    align-items: center;
    mix-blend-mode: difference;
    pointer-events: none;
}

.site-header__brand {
    font-family: var(--font-display);
    font-size: clamp(1rem, 1.5vw, 1.25rem);
    font-weight: 300;
    letter-spacing: 0.05em;
    color: var(--color-text);
}

.site-header__counter {
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 300;
    letter-spacing: 0.15em;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.site-header__current {
    display: inline-block;
    min-width: 1.5em;
    transition: opacity var(--duration-fast) var(--ease-out-quart);
}

.site-header__divider {
    opacity: 0.4;
}

.site-header__total {
    opacity: 0.6;
}

/* ============================================
   SCROLL PROGRESS
   ============================================ */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    z-index: 60;
    background: transparent;
    pointer-events: none;
}

.scroll-progress__bar {
    height: 100%;
    width: 100%;
    background: rgba(255, 255, 255, 0.6);
    transform-origin: left;
    transform: scaleX(0);
    will-change: transform;
}

/* ============================================
   SECTIONS
   ============================================ */
.scroll-container {
    position: relative;
    z-index: 10;
}

.section {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: var(--section-padding) var(--container-padding);
}

.section__content {
    position: relative;
    text-align: left;
    max-width: 900px;
    width: 100%;
    opacity: 0;
    transform: translateY(40px);
    will-change: opacity, transform;
}

.section__eyebrow {
    display: inline-block;
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: clamp(1.5rem, 3vh, 2.5rem);
    position: relative;
    padding: 0 2rem;
}

.section__eyebrow::before,
.section__eyebrow::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 1.5rem;
    height: 1px;
    background: var(--color-text-dim);
}

.section__eyebrow::before { left: 0; }
.section__eyebrow::after { right: 0; }

.section__title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 8vw, 7rem);
    font-weight: 300;
    line-height: 0.95;
    letter-spacing: -0.02em;
    color: var(--color-text);
    margin-bottom: clamp(1.5rem, 4vh, 3rem);
    font-variation-settings: 'opsz' 144, 'SOFT' 50;
}

.section__text {
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.5vw, 1.25rem);
    font-weight: 300;
    line-height: 1.7;
    color: var(--color-text-muted);
    max-width: 520px;
    margin: 0;
    letter-spacing: 0.01em;
}

.section__text br {
    display: block;
    content: "";
    margin-top: 0.25em;
}

/* Финальная секция — остаётся видимой */
.section--final .section__content {
    /* Будет управляться GSAP */
}

/* ============================================
   SCROLL HINT
   ============================================ */
.scroll-hint {
    position: fixed;
    bottom: clamp(2rem, 4vh, 3rem);
    left: var(--container-padding);
    z-index: 40;
    text-align: left;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    transition: opacity var(--duration-medium) var(--ease-out-quart);
    pointer-events: none;
}

.scroll-hint.is-hidden {
    opacity: 0;
}

.scroll-hint__text {
    display: block;
    margin-bottom: 1rem;
}

.scroll-hint__line {
    width: 1px;
    height: 40px;
    background: linear-gradient(to bottom, transparent, var(--color-text-muted));
    margin: 0;
    position: relative;
    overflow: hidden;
}

.scroll-hint__line::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: var(--color-text);
    animation: scrollLine 2s var(--ease-out-quart) infinite;
}

@keyframes scrollLine {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100%); }
}

/* ============================================
   RESPONSIVE — TABLET
   ============================================ */
@media (max-width: 1024px) {
    .section__title {
        font-size: clamp(2.25rem, 9vw, 4.5rem);
    }
    
    .section__text {
        max-width: 480px;
    }
}

/* ============================================
   RESPONSIVE — MOBILE
   ============================================ */
@media (max-width: 640px) {
    :root {
        --container-padding: 1.5rem;
        --section-padding: 2.5rem;
    }
    
    .site-header {
        padding: 1.25rem var(--container-padding);
    }
    
    .site-header__brand {
        font-size: 0.95rem;
    }
    
    .site-header__counter {
        font-size: 0.75rem;
    }
    
    .section__eyebrow {
        font-size: 0.65rem;
        letter-spacing: 0.25em;
        padding: 0 1.5rem;
    }
    
    .section__eyebrow::before,
    .section__eyebrow::after {
        width: 1rem;
    }
    
    .section__title {
        font-size: clamp(2rem, 11vw, 3rem);
        line-height: 1;
        letter-spacing: -0.01em;
    }
    
    .section__text {
        font-size: 0.95rem;
        line-height: 1.6;
        max-width: 100%;
    }
    
    .section__text br {
        display: none;
    }
    
    .scroll-hint {
        bottom: 1.5rem;
        font-size: 0.65rem;
    }
    
    .scroll-hint__line {
        height: 30px;
    }
}

/* ============================================
   MOBILE VIDEO FIXES
   ============================================ */
@media (max-width: 640px) {
    .video-bg {
        /* На iOS object-fit: cover有时会导致黑边, добавляем фикс */
        object-position: center center;
    }
    
    /* Samsung Internet: object-fit фоллбек */
    @supports not (object-fit: cover) {
        .video-bg {
            width: auto;
            height: 100vh;
            left: 50%;
            transform: translateX(-50%);
        }
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .scroll-hint__line::after {
        animation: none;
    }
}

/* ============================================
   SELECTION
   ============================================ */
::selection {
    background: rgba(255, 255, 255, 0.2);
    color: var(--color-text);
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}
