:root {
    /* ТЕМНАЯ ТЕМА (По умолчанию) */
    --bg-color: #050505;               
    --text-color: #f5f5f7;             
    --text-secondary: #6e6e73;         
    --header-bg: rgba(5, 5, 5, 0.8);    
    --border-color: transparent;
    --video-border: transparent;  
    --video-shadow: none;              
    --card-title: #d2d2d7;
    --card-title-hover: #ffffff;
}

@media (prefers-color-scheme: light) {
    :root {
        /* СВЕТЛАЯ ТЕМА */
        --bg-color: #ffffff;               
        --text-color: #1d1d1f;             
        --text-secondary: #86868b;         
        --header-bg: rgba(255, 255, 255, 0.85); 
        --border-color: #e5e5ea;           
        --video-border: 1px solid #e5e5ea; 
        --video-shadow: 0 20px 40px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.02); 
        --card-title: #1d1d1f;
        --card-title-hover: #000000;
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    padding-top: 100px; 
    transition: background-color 0.4s ease, color 0.4s ease;
}

.container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 48px;
}

/* ============================================================================
   Шапка и Навигация (Десктоп)
   ============================================================================ */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 90;
    background-color: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.4s ease, border-color 0.4s ease;
}

.header-inner {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 24px 48px; 
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    text-decoration: none;
    color: var(--text-color); 
    transition: opacity 0.3s;
}
.logo:hover { opacity: 0.7; }

nav {
    display: flex;
    align-items: center;
    gap: 32px;
}
nav a {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    text-decoration: none;
    color: var(--text-secondary);
    transition: color 0.3s;
}
nav a:hover { color: var(--text-color); }

/* ============================================================================
   Главный блок (Hero) и Фильтры (Десктоп)
   ============================================================================ */
.hero {
    padding: 40px 0 60px 0;
    max-width: 750px;
}

h1 {
    font-size: 56px;
    font-weight: 300;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--text-color);
    margin-bottom: 24px;
}
h1 span { color: var(--text-secondary); transition: color 0.4s ease; }

.hero-desc {
    color: var(--text-secondary); 
    transition: color 0.4s ease;
    font-size: 16px;
    font-weight: 300;
    line-height: 1.6;
    max-width: 450px;
}

.filter-section {
    position: sticky;
    top: 71px; 
    z-index: 85;
    background-color: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    margin-bottom: 48px;
    padding: 16px 0;
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.filter-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    cursor: pointer;
    padding: 6px 0;
    transition: color 0.3s, border-color 0.3s;
    border-bottom: 2px solid transparent;
}
.filter-btn:hover, .filter-btn.active { color: var(--text-color); }
.filter-btn.active { border-color: var(--text-color); }

/* ============================================================================
   Главный Шоурил
   ============================================================================ */
.showreel-section { width: 100%; margin-bottom: 64px; }
.showreel-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: #121212;
    overflow: hidden;
    border-radius: 6px;
    border: var(--video-border);
    box-shadow: var(--video-shadow);
    cursor: pointer;
}
.showreel-wrapper video {
    width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0.85;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
}
.showreel-wrapper:hover video { transform: scale(1.015); opacity: 1; }
.showreel-overlay {
    position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center;
    padding-bottom: 14%; pointer-events: none; z-index: 2;
}
.showreel-badge {
    background: rgba(255, 255, 255, 0.12); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.18); color: #ffffff; padding: 14px 28px; border-radius: 30px;
    font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.15em;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.15); transition: background-color 0.3s ease, transform 0.3s ease, border-color 0.3s ease;
    will-change: transform, background-color;
}
.showreel-wrapper:hover .showreel-badge { background-color: rgba(255, 255, 255, 0.22); border-color: rgba(255, 255, 255, 0.3); transform: scale(1.04); }
.video-num { position: absolute; bottom: 24px; right: 24px; font-size: 11px; font-weight: 500; letter-spacing: 0.1em; color: rgba(255, 255, 255, 0.45); transition: color 0.3s ease; }
.showreel-wrapper:hover .video-num { color: rgba(255, 255, 255, 0.8); }

/* ============================================================================
   Адаптивная Сетка и Карточки Галереи (Десктоп)
   ============================================================================ */
.gallery-grid {
    display: grid;
    grid-template-columns: 1fr;
    column-gap: 32px;
    row-gap: 64px;
    padding-bottom: 120px;
}
@media (min-width: 640px) { .gallery-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .gallery-grid { grid-template-columns: repeat(3, 1fr); } }

.video-card { cursor: pointer; display: block; transition: opacity 0.4s ease, transform 0.4s ease; }
.video-card.hidden { display: none !important; opacity: 0; transform: scale(0.95); }

.video-wrapper {
    position: relative;
    width: 100%;
    background-color: transparent;
    overflow: hidden;
    border-radius: 6px;
    margin-bottom: 16px;
    border: var(--video-border);
    box-shadow: var(--video-shadow);
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    transition: box-shadow 0.4s ease, border-color 0.4s ease;
}
.video-wrapper video {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain; 
    /* opacity: 0.7;
    transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.5s; */
}
.video-card:hover .video-wrapper video { transform: scale(1.02); opacity: 1; }
.video-meta { display: block; padding: 0 4px; }
.video-title { font-size: 14px; font-weight: 500; letter-spacing: 0.02em; color: var(--card-title); transition: color 0.3s; line-height: 1.4; }
.video-card:hover .video-title { color: var(--card-title-hover); }
.video-category { font-size: 12px; color: var(--text-secondary); font-weight: 300; margin-top: 6px; padding: 0 4px; }

/* ============================================================================
   Секция Избранного Проекта, Резюме, О Себе и Модалка
   ============================================================================ */
.featured-project-section { padding: 100px 0; border-top: 1px solid var(--border-color); margin-top: 60px; }
.featured-project-container { display: flex; gap: 64px; align-items: center; }
.featured-project-video { flex: 1; background-color: var(--bg-color) !important; border-radius: 6px; overflow: hidden; cursor: pointer; border: var(--video-border); box-shadow: var(--video-shadow); transform: translateZ(0); -webkit-transform: translateZ(0); }
.featured-project-video video { width: 100%; height: auto; display: block; object-fit: contain; /* opacity: 0.85;*/ transition: opacity 0.3s, transform 0.5s ease; background-color: var(--bg-color) !important; outline: none; border: none; }
/*.featured-project-video:hover video { opacity: 1; transform: scale(1.01); }*/
.featured-project-info { flex: 1; }
.project-tag { font-size: 11px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--text-secondary); display: block; margin-bottom: 12px; }
.featured-project-info h2 { font-size: 32px; font-weight: 400; line-height: 1.25; margin-bottom: 20px; color: var(--text-color); }
.featured-project-info p { font-size: 15px; line-height: 1.6; color: var(--text-secondary); font-weight: 300; margin-bottom: 32px; }
.project-meta-list { font-size: 13px; color: var(--text-secondary); line-height: 2; }
.project-meta-list strong { color: var(--text-color); font-weight: 500; }

.experience-section { padding: 60px 0 100px 0; }
.table-headline { font-size: 14px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--text-secondary); margin-bottom: 32px; font-weight: 500; }
.resume-table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.6; }
.resume-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-secondary); padding-bottom: 16px; border-bottom: 1px solid var(--border-color); font-weight: 400; }
.resume-table td { padding: 24px 0; border-bottom: 1px solid var(--border-color); vertical-align: top; color: var(--text-secondary); }
.resume-table td strong { color: var(--text-color); font-weight: 500; }
.type-cell { width: 15%; color: var(--text-secondary); font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; }
.name-cell { width: 25%; }
.date-cell { width: 15%; color: var(--text-secondary) !important; }
.company-cell { width: 25%; color: var(--text-secondary); }
.role-cell { width: 15%; color: var(--text-color); }
.link-cell { width: 5%; text-align: center !important; }
.table-ext-link { color: var(--text-secondary); text-decoration: none; font-weight: 400; transition: color 0.3s; font-size: 13px; display: inline-block; }
.table-ext-link:hover { color: var(--text-color); }
.resume-table tbody tr { transition: background-color 0.3s ease; }
.resume-table tbody tr:hover td { color: var(--text-color); }

.about-hero-section { padding: 60px 0 40px 0; max-width: 800px; }
.about-hero-section .subtitle { font-size: 18px; color: var(--text-secondary); line-height: 1.5; font-weight: 300; margin-top: -10px; }
.about-grid-block { display: grid; grid-template-columns: 1fr 1fr; gap: 80px; align-items: center; padding: 80px 0; }
.about-text-col h2 { font-size: 28px; font-weight: 400; color: var(--text-color); margin-bottom: 24px; letter-spacing: -0.01em; }
.about-text-col p { font-size: 15px; line-height: 1.7; color: var(--text-secondary); font-weight: 300; margin-bottom: 20px; }
.about-img-col { width: 100%; aspect-ratio: 4 / 3; background-color: #0e0e10; border-radius: 4px; overflow: hidden; }
.about-img-col img { width: 100%; height: 100%; object-fit: cover; opacity: 0.9; transition: opacity 0.3s; }
.about-img-col:hover img { opacity: 1; }
.about-quote-section { padding: 100px 0; max-width: 1000px; margin: 0 auto; text-align: center; border-top: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); }
.about-quote-section blockquote { font-size: 24px; line-height: 1.5; color: var(--text-color); font-weight: 300; font-style: italic; margin-bottom: 16px; }
.about-quote-section cite { font-size: 12px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--text-secondary); font-style: normal; }
.about-img-gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; width: 100%; }
.mini-thumb { width: 100%; aspect-ratio: 3 / 4; background-color: #0e0e10; border-radius: 3px; overflow: hidden; }
.mini-thumb img { width: 100%; height: 100%; object-fit: cover; opacity: 0.8; transition: opacity 0.3s, transform 0.5s ease; }
.mini-thumb:hover img { opacity: 1; transform: scale(1.04); }

.lightbox { position: fixed; inset: 0; z-index: 2000; display: flex; flex-direction: column; align-items: center; justify-content: center; background-color: rgba(5, 5, 5, 0.98); opacity: 0; pointer-events: none; transition: opacity 0.4s ease; padding: 24px; }
.lightbox.active { opacity: 1; pointer-events: auto; }
.lightbox-header { width: 100%; max-width: 1100px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: #86868b; }
.lb-close-btn { background: none; border: none; color: #86868b; cursor: pointer; font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; transition: color 0.3s; }
.lb-close-btn:hover { color: #fff; }
.player-container { position: relative; width: 90vw; max-width: 100%; height: 80vh; background-color: #000000; border-radius: 4px; overflow: hidden; }
.player-container video { width: 100%; height: 100%; object-fit: contain; }
.player-controls { position: absolute; bottom: 0; left: 0; right: 0; padding: 24px; background: linear-gradient(transparent, rgba(0,0,0,0.85)); display: flex; flex-direction: column; gap: 14px; opacity: 0; transition: opacity 0.3s; }
.player-controls.visible { opacity: 1; }
.progress-bar { width: 100%; height: 4px; background-color: rgba(255,255,255,0.2); cursor: pointer; position: relative; }
.progress-fill { height: 100%; background-color: #ffffff; width: 0%; }
.controls-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: #d2d2d7; }
.play-btn, .mute-btn { background: none; border: none; color: #d2d2d7; cursor: pointer; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; }
.play-btn:hover, .mute-btn:hover { color: #fff; }
.time-info { font-family: monospace; color: #86868b; }

.animate-on-scroll { opacity: 0; transform: translateY(20px); transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1); will-change: opacity, transform; }
.animate-on-scroll.revealed-auto { opacity: 1; transform: translateY(0); }
.text-link { color: var(--text-color); text-decoration: none; border-bottom: 1px solid var(--text-secondary); transition: border-color 0.3s ease; }
.text-link:hover { border-color: var(--text-color); }
footer { border-top: 1px solid var(--border-color); padding: 64px 0; display: flex; justify-content: space-between; font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.1em; }
.footer-links a { color: var(--text-secondary); text-decoration: none; margin-left: 24px; transition: color 0.3s; }
.footer-links a:hover { color: var(--text-color); }

video {
    -webkit-touch-callout: none; 
    user-select: none;           
}


/* ============================================================================
   📱 АДАПТИВНОСТЬ ДЛЯ МОБИЛЬНЫХ ТЕЛЕФОНОВ (Меньше 768px)
   ============================================================================ */
@media (max-width: 768px) {
    .container { padding: 0 24px; }
    
    .showreel-section { margin-bottom: 40px; }
    .showreel-section video,
    .showreel-section .showreel-wrapper {
        aspect-ratio: 16 / 9 !important; 
        border-radius: 4px;
        width: 100% !important;
        height: auto !important;
    }
    .showreel-badge { padding: 10px 20px; font-size: 10px; letter-spacing: 0.12em; }    
    .video-num { bottom: 16px; right: 16px; font-size: 9px; }
    
    body { padding-top: 120px; } 
    
    h1 { font-size: 32px; margin-bottom: 16px; }
    .hero-desc { font-size: 15px; }
    .hero { padding: 16px 0 32px 0; }

    .header-inner { padding: 12px 24px; }
    .logo { font-size: 12px; letter-spacing: 0.15em; }
    
    nav { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
    nav a { font-size: 11px; letter-spacing: 0.1em; }
    
    .gallery-grid { row-gap: 40px; padding-bottom: 64px; }

    .featured-project-container { flex-direction: column; gap: 24px; }
    .featured-project-section { padding: 48px 0; }
    .featured-project-info h2 { font-size: 24px; margin-bottom: 12px; }
    .featured-project-info p { margin-bottom: 24px; }

    .resume-table, .resume-table thead, .resume-table tbody, .resume-table th, .resume-table td, .resume-table tr { display: block; width: 100%; }
    .resume-table thead { display: none; }
    .resume-table td { padding: 8px 0; border: none; }
    .resume-table tr { padding: 16px 0; border-bottom: 1px solid var(--border-color); }
    
    .type-cell, .name-cell, .date-cell, .company-cell, .role-cell, .link-cell { width: 100% !important; word-break: break-word; }
    .type-cell { font-size: 11px; margin-bottom: 2px; }
    .name-cell { font-size: 15px; margin-bottom: 4px; color: var(--text-color); font-weight: 500; }
    .date-cell, .company-cell, .role-cell { font-size: 13px; margin-top: 2px; }
    .link-cell { text-align: left !important; padding: 4px 0 8px 0 !important; }

    .about-grid-block, .about-grid-block.reverse { grid-template-columns: 1fr; gap: 24px; padding: 32px 0; }
    .about-grid-block .about-text-col, .about-grid-block.reverse .about-text-col { grid-column: 1 !important; order: 2; }
    .about-grid-block .about-img-col, .about-grid-block.reverse .about-img-col { grid-column: 1 !important; order: 1; }
    .about-text-col h2 { font-size: 22px; margin-bottom: 12px; }
    .about-quote-section { padding: 48px 0; }
    .about-quote-section blockquote { font-size: 18px; }
    .about-img-gallery { gap: 12px; margin-bottom: 8px; order: 1; }

    .player-container { width: 100% !important; /* 🔥 ИСПРАВЛЕНО: Плеер аккуратно впишется в экран с учетом padding, не растягивая его */ height: auto; aspect-ratio: 16 / 9; border-radius: 0; }
    footer { flex-direction: column; gap: 24px; padding: 48px 0; }
    .footer-links a { margin-left: 0; margin-right: 24px; }
}


/* ============================================================================
 * 📱 УМНЫЙ СНАП-СКРОЛЛ ДЛЯ МОБИЛЬНЫХ И ПЛАНШЕТОВ (ФИНАЛЬНАЯ СИНХРОНИЗАЦИЯ)
 * ============================================================================ */
@media (max-width: 1100px) {
    
    html.page-with-snap {
        scroll-snap-type: y mandatory !important;
        scroll-behavior: smooth;
    }

    body { scroll-snap-type: none !important; }

    html.page-with-snap header, 
    html.page-with-snap .hero-section, 
    html.page-with-snap .hero-desc {
        scroll-snap-align: start !important;
    }

    /* 📌 ЛИПКИЙ ФИЛЬТР: top: 57px заставляет его заходить на 1px под шапку, исключая щели в Safari */
    .filter-section, .filters, .categories { 
        position: sticky !important;
        top: 57px !important; 
        z-index: 1000 !important; 
        background-color: var(--header-bg) !important; 
        backdrop-filter: blur(12px) !important;
        -webkit-backdrop-filter: blur(12px) !important;
        padding: 6px 0 !important; 
        margin-bottom: 0 !important;
        scroll-snap-align: none !important; 
    }
      
    .gallery-grid {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: 1fr !important; 
        gap: 50px !important; 
        padding-top: 30px !important; 
        padding-bottom: 40vh !important;
        width: 100% !important;
        box-sizing: border-box;
    }

    .video-card, .featured-project-video {
        width: 85vmin !important; 
        max-width: 100% !important; 
        height: auto !important;
        margin: 0 auto !important;
        
        scroll-snap-align: start !important; 
        scroll-margin-top: 112px !important;  
        scroll-snap-stop: always !important;   
    }

    /* Убираем любые возможные артефакты обводки у Важного видео */
    .featured-project-video {
        background-color: var(--bg-color) !important;
        box-shadow: none !important;
        border: none !important;
    }
}
/* ============================================================================
 * 📱 ОПТИМИЗАЦИЯ ПОД LANDSCAPE (Горизонтальный режим телефонов)
 * ============================================================================ */
@media (max-height: 550px) and (max-width: 1100px) {
    body { 
        padding-top: 105px !important; /* Увеличиваем отступ страницы, чтобы полностью вместить шапку + фильтры */
    }
    
    .header-inner { 
        padding: 8px 24px !important; 
    }
    
    nav { 
        flex-direction: row !important; 
        gap: 16px !important; 
    }
    
    nav a {
        font-size: 10px !important; 
    }
    
    /* ФИКС НАЕЗДА: Сдвигаем фильтры ровно под границу сжатой шапки */
    .filter-section, .filters, .categories { 
        top: 52px !important; 
        padding: 6px 0 !important;
    }
    
    /* КРУПНЫЕ КАРТОЧКИ: Увеличиваем коэффициент vmin, чтобы активное видео доминировало на экране */
    .video-card, .featured-project-video {
        width: 120vmin !important; 
        max-width: 92vw !important; 
        height: auto !important;
        scroll-margin-top: 110px !important; /* Пересчитываем точку остановки скролл-магнита */
    }
}