/* ============================================
   LOMUKHIN — PORTFOLIO (Final Fix)
   ============================================ */

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

:root {
    --bg: #fafafa;
    --bg-card: #ffffff;
    --bg-hover: #f5f5f5;
    --text: #111111;
    --muted: #777777;
    --line: #e5e5e5;
    --accent: #111111;
    --transition: 0.3s ease;
}

[data-theme="dark"] {
    --bg: #0a0a0a;
    --bg-card: #111111;
    --bg-hover: #1a1a1a;
    --text: #f5f5f5;
    --muted: #888888;
    --line: #222222;
    --accent: #ffffff;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    transition: background var(--transition), color var(--transition);
}

h1, h2, h3, h4 { font-family: 'Playfair Display', serif; font-weight: 500; line-height: 1.15; letter-spacing: -0.5px; }
h1 em, h2 em, h3 em, h4 em { font-style: italic; }
a { color: inherit; transition: color var(--transition); text-decoration: none; }

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

/* ===== HEADER ===== */
.header { padding: 30px 0; background: var(--bg); transition: background var(--transition); }
.header-inner { display: flex; justify-content: space-between; align-items: center; gap: 20px; position: relative; }

.header-side { display: flex; align-items: center; flex: 1; }
.header-side.left { justify-content: flex-start; }
.header-side.right { justify-content: flex-end; gap: 30px; }

.logo { 
    font-family: 'Playfair Display', serif; 
    font-size: 22px; 
    letter-spacing: 4px; 
    text-transform: uppercase; 
    color: var(--text); 
    font-weight: 500; 
    white-space: nowrap; 
    text-align: center; 
    flex: 0 0 auto;
}

/* === ЦЕНТРИРОВАНИЕ ЛОГО НА ПОДСАЙТАХ === */
.header-inner:has(.back-link) .logo {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

/* === ПРИЖИМАЕМ МЕНЮ НА ГЛАВНОЙ === */
.header-inner:not(:has(.back-link)) .header-side.right {
    margin-left: auto; /* Отодвигаем меню вправо, но не растягиваем */
    flex: none; /* Отменяем растягивание */
}
.header-inner:not(:has(.back-link)) .header-side.left {
    flex: none; /* Отменяем растягивание */
}

.back-link { font-family: 'Inter', sans-serif; font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); display: block; }
.back-link:hover { color: var(--text); }

.nav { display: flex; gap: 40px; align-items: center; }
.nav a { color: var(--muted); font-size: 13px; letter-spacing: 2px; text-transform: uppercase; font-weight: 400; }
.nav a:hover { color: var(--text); }

.theme-toggle { background: transparent; border: none; padding: 0; cursor: pointer; font-family: 'Inter', sans-serif; font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.theme-toggle:hover { color: var(--text); }
.theme-icon { font-size: 14px; display: inline-block; line-height: 1; }
.burger { display: none; flex-direction: column; gap: 4px; background: none; border: none; cursor: pointer; padding: 0; }
.burger span { display: block; width: 24px; height: 2px; background: var(--text); }

/* ===== HERO ===== */
.hero { text-align: center; padding: 140px 8% 120px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.hero-num { font-size: 12px; letter-spacing: 4px; color: var(--muted); margin-bottom: 40px; text-transform: uppercase; }
.hero-title { font-size: clamp(38px, 6vw, 72px); font-weight: 500; line-height: 1.1; max-width: 900px; margin: 0 auto 30px; letter-spacing: -1px; }
.hero-desc { color: var(--muted); font-size: 17px; max-width: 560px; margin: 0 auto 50px; line-height: 1.8; }
.hero-actions { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

/* ===== BUTTONS ===== */
.btn { display: inline-block; padding: 16px 44px; color: var(--text); border: 1px solid var(--text); font-size: 12px; letter-spacing: 3px; text-transform: uppercase; background: transparent; transition: all var(--transition); cursor: pointer; text-align: center; }
.btn:hover { background: var(--text); color: var(--bg); }
.btn-outline { border-color: var(--line); color: var(--muted); }
.btn-outline:hover { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ===== SECTIONS ===== */
.categories, .about, .contacts { padding: 100px 0; border-bottom: 1px solid var(--line); }
.section-head { margin-bottom: 70px; }
.section-head.center { text-align: center; }
.section-num { display: block; font-size: 12px; letter-spacing: 4px; color: var(--muted); margin-bottom: 20px; text-transform: uppercase; }
.section-title { font-size: clamp(32px, 4.5vw, 52px); font-weight: 500; letter-spacing: -1px; line-height: 1.1; }
.section-sub { color: var(--muted); font-size: 15px; margin-top: 16px; }

/* ===== CATEGORIES ===== */
.categories-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border: 1px solid var(--line); }
.category-card { padding: 50px 40px; color: var(--text); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; background: var(--bg-card); min-height: 280px; transition: background var(--transition); }
.category-card:nth-child(3n) { border-right: none; }
.category-card:nth-last-child(-n+2) { border-bottom: none; }
.category-card:hover { background: var(--bg-hover); }
.category-num { font-size: 12px; letter-spacing: 3px; color: var(--muted); }
.category-card h3 { font-size: 26px; font-weight: 500; letter-spacing: -0.5px; }
.category-card p { color: var(--muted); font-size: 14.5px; line-height: 1.6; flex: 1; }
.category-count { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--text); margin-top: auto; }

/* ===== ABOUT ===== */
.about-inner { display: grid; grid-template-columns: 1.5fr 1fr; gap: 80px; align-items: start; }
.about-content p { color: var(--muted); font-size: 16px; line-height: 1.8; margin: 30px 0; }
.about-list { list-style: none; border-top: 1px solid var(--line); }
.about-list li { font-size: 15px; padding: 16px 0; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; }
.about-list li::before { content: '—'; color: var(--muted); }
.about-stats { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.stat-card { padding: 30px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; gap: 20px; }
.stat-card strong { font-family: 'Playfair Display', serif; font-size: 44px; font-weight: 500; line-height: 1; }
.stat-card span { color: var(--muted); font-size: 13px; letter-spacing: 2px; text-transform: uppercase; }

/* ===== CONTACTS ===== */
.contacts-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; max-width: 800px; margin: 0 auto; border: 1px solid var(--line); }
.contact-card { padding: 50px 40px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; border-right: 1px solid var(--line); background: var(--bg-card); transition: background var(--transition); }
.contact-card:last-child { border-right: none; }
.contact-card:hover { background: var(--bg-hover); }
.contact-icon { font-size: 28px; margin-bottom: 8px; color: var(--muted); }
.contact-card strong { font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 500; }
.contact-card span:last-child { color: var(--muted); font-size: 14px; }

/* ===== FOOTER ===== */
.footer { padding: 50px 0; text-align: center; }
.footer p { font-size: 11px; letter-spacing: 3px; color: var(--muted); text-transform: uppercase; }

/* ===== PAGE HEAD ===== */
.page-head { padding: 100px 0 60px; text-align: center; border-bottom: 1px solid var(--line); }
.page-head .section-title { margin-bottom: 16px; }
.page-head .section-sub { max-width: 560px; margin: 0 auto; }

/* ===== PROJECTS ===== */
.projects { padding: 80px 0 100px; }
.projects-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.project-card { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--bg-card); display: flex; flex-direction: column; overflow: hidden; transition: background 0.3s; }
.project-card:hover { background: var(--bg-hover); }

.project-preview { position: relative; height: 280px; overflow: hidden; background: var(--bg-hover); border-bottom: 1px solid var(--line); }
.project-preview span { font-size: 72px; display: flex; align-items: center; justify-content: center; height: 100%; }
.project-preview img.main-img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.5s ease; }
.project-card:hover .main-img { transform: scale(1.03); }

.project-info { padding: 36px 40px; display: flex; flex-direction: column; flex: 1; gap: 12px; }
.project-num { font-size: 11px; letter-spacing: 3px; color: var(--muted); text-transform: uppercase; }
.project-info h3 { font-family: 'Playfair Display', serif; font-size: 26px; font-weight: 500; letter-spacing: -0.5px; line-height: 1.2; }
.project-info p { color: var(--muted); font-size: 14.5px; line-height: 1.6; flex: 1; word-wrap: break-word; }

.project-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.project-tags span { font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); padding: 4px 10px; }
.project-link { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; margin-top: 12px; align-self: flex-start; }
.project-link:hover { color: var(--muted); }

/* ===== PREVIEW GALLERY ===== */
.preview-gallery { position: absolute; bottom: 0; left: 0; right: 0; padding: 30px 12px 12px; display: flex; gap: 8px; background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 100%); justify-content: center; opacity: 0; transition: opacity 0.3s; }
.project-card:hover .preview-gallery { opacity: 1; }
.preview-gallery img { width: 70px; height: 52px; object-fit: cover; border-radius: 8px; border: 2px solid rgba(255, 255, 255, 0.25); cursor: pointer; opacity: 0.85; transition: all 0.2s; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5); }
.preview-gallery img:hover, .preview-gallery img.active { opacity: 1; transform: scale(1.1); border-color: #fff; }
@media (hover: none) { .preview-gallery { opacity: 1; transform: none; } }

/* ===== RESPONSIVE ===== */
@media (max-width: 960px) {
    .categories-grid { grid-template-columns: 1fr; }
    .category-card { border-right: none; min-height: auto; }
    .category-card:nth-last-child(-n+2) { border-bottom: 1px solid var(--line); }
    .category-card:last-child { border-bottom: none; }
    .about-inner { grid-template-columns: 1fr; gap: 40px; }
    .contacts-grid { grid-template-columns: 1fr; }
    .contact-card { border-right: none; border-bottom: 1px solid var(--line); }
    .contact-card:last-child { border-bottom: none; }
    .projects-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .header { padding: 15px 0; }
    .header-inner { position: relative; }
    
    .logo { position: absolute; left: 50%; transform: translateX(-50%); font-size: 18px; letter-spacing: 2px; }
    
    .burger { display: flex; z-index: 100; }
    
    .nav {
        position: fixed; top: 0; left: -100%; width: 250px; height: 100vh;
        background: rgba(10, 10, 10, 0.85); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
        flex-direction: column; align-items: flex-start; padding: 80px 20px 20px;
        transition: left 0.3s ease, visibility 0.3s ease; z-index: 99; visibility: hidden;
        border-right: none; padding-right: 20px;
    }
    .nav.open { left: 0; visibility: visible; display: flex; }
    .nav a { font-size: 16px; padding: 10px 0; width: 100%; }
    
    .header-side.right { gap: 15px; }
    .header-side.left .back-link { margin-left: 35px; }
}

@media (max-width: 640px) {
    /* --- Твои старые правила --- */
    .container { padding: 0 15px !important; } /* Я сразу поменял 24px на 15px, чтобы дать больше места на экране */
    .hero { padding: 80px 24px 70px; }
    .hero-actions { flex-direction: column; }
    .btn { width: 100%; padding: 14px 30px; }
    .categories, .about, .contacts { padding: 60px 0; }
    .project-info { padding: 24px 20px; }
    .project-preview { height: 200px; }

    /* --- Новые правила для хедера (от жены S24) --- */
    .header-side.left .back-link { 
        margin-left: 0 !important; 
        font-size: 11px; 
        letter-spacing: 1px;
    }

    .logo { 
        font-size: 16px !important; 
        letter-spacing: 1px !important;
    }

    .theme-toggle {
        gap: 4px !important;
        font-size: 11px;
    }
    
    .header-side.left {
        padding-right: 10px;
    }
}
/* ===== ПАЛОЧКИ НА ПК/ПЛАНШЕТЕ ===== */
@media (min-width: 901px) {
    
    /* 1. Палка между Лого и Меню (на главной) */
    .header-inner:not(:has(.back-link)) .header-side.left::after {
        content: '';
        display: inline-block;
        width: 1px;
        height: 20px;
        background-color: var(--line);
        margin-left: 30px; /* Расстояние от лого до палки */
        margin-right: 30px; /* Расстояние от палки до меню */
    }

    /* 2. Палка между Меню и Темой (на главной) */
    .header-inner:not(:has(.back-link)) .nav::after {
        content: '';
        display: inline-block;
        width: 1px;
        height: 20px;
        background-color: var(--line);
        margin-left: 30px; /* Расстояние от меню до палки */
        margin-right: 30px; /* Расстояние от палки до темы */
    }

    /* 3. Палка СПРАВА от кнопки Тема (на главной) */
    .header-inner:not(:has(.back-link)) .theme-toggle::after {
        content: '';
        display: inline-block;
        width: 1px;
        height: 20px;
        background-color: var(--line);
        margin-left: 30px; 
        margin-right: 30px; 
    }

    /* 4. Палка между Назад и Лого (на подсайтах) */
    .header-inner:has(.back-link) .header-side.left::after {
        content: '';
        display: inline-block;
        width: 1px;
        height: 20px;
        background-color: var(--line);
        margin-left: 20px;
    }
}
/* ===== ДОБАВЛЯЕМ ДВЕ НЕДОСТАЮЩИЕ ПАЛКИ ===== */
@media (min-width: 901px) {
    /* Палка СЛЕВА от меню (на главной) */
    .header-inner:not(:has(.back-link)) .nav {
        border-left: 1px solid var(--line);
        padding-left: 30px;
    }

    /* Палка СЛЕВА от кнопки "Тема" (на подсайтах) */
    .header-inner:has(.back-link) .theme-toggle {
        border-left: 1px solid var(--line);
        padding-left: 30px;
    }
}