/* --- 1. Сброс и Базовые стили --- */
:root {
    --primary-color: #b71234;
    --dark-color: #333;
    --light-bg: #f4f4f4;
    --white: #ffffff;
    --font-main: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

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

/* ВАЖНО: Добавляем html и max-width */
html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden; /* Обрезает всё, что торчит сбоку */
    position: relative; /* Помогает зафиксировать контейнер */
}

body {
    font-family: var(--font-main);
    line-height: 1.6;
    color: var(--dark-color);
}

a { text-decoration: none; color: inherit; transition: 0.3s; }
ul { list-style: none; }
img { max-width: 100%; display: block; }

/* --- 2. Хедер и Навигация --- */
header {
    background: var(--white);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center; /* ВАЖНО: Это выравнивает меню и логотип по вертикали (top to bottom) */
    height: 80px;
}

/* Стили для блока с логотипом */
.logo {
    display: flex;        /* Ставит картинку и текст в одну линию */
    align-items: center;  /* Центрирует текст относительно картинки */
    gap: 12px;            /* Расстояние между картинкой и текстом */
    text-decoration: none;
    color: var(--primary-color); /* Цвет текста */
    font-size: 1.5rem;
    font-weight: bold;
    text-transform: uppercase;
}

/* Стили для самой картинки логотипа */
.logo img {
    max-height: 50px;     /* Размер логотипа (чуть меньше высоты хедера) */
    width: auto;          /* Сохраняем пропорции круга */
    display: block;
}

.logo span {
    line-height: 1;
}

.nav-links {
    display: flex;
    gap: 30px;
}

.nav-links a {
    font-weight: 500;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.nav-links a:hover { color: var(--primary-color); }

/* Мобильное меню (Гамбургер) */
.burger { display: none; cursor: pointer; }
.burger div { width: 25px; height: 3px; background: var(--dark-color); margin: 5px; transition: 0.3s; }

/* --- 3. Hero Секция (Главный экран) --- */
.hero {
    /* Меняем старую ссылку на ваш локальный файл */
    /* Увеличили темноту градиента (0.6), чтобы белый текст был лучше виден на светлой стене */
    background: linear-gradient(rgba(0,0,0,0.6), rgba(0,0,0,0.6)), url('images/header.JPG');
    
    background-size: cover;
    background-position: center;
    height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--white);
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.btn {
    display: inline-block;
    background: var(--primary-color);
    color: var(--white);
    padding: 12px 30px;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: bold;
}

.btn:hover { background: #8a0e26; }

/* --- 4. Услуги (Сетка) --- */
.services { padding: 60px 0; background: var(--white); }
.section-title { text-align: center; margin-bottom: 40px; }
.section-title h2 { font-size: 2rem; text-transform: uppercase; margin-bottom: 10px; }
.section-title p { color: #777; max-width: 600px; margin: 0 auto; }

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
}

.service-card {
    text-align: center;
    padding: 20px;
    border: 1px solid #eee;
    transition: 0.3s;
}

.service-card:hover { transform: translateY(-5px); box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.service-card h3 { margin: 15px 0; color: var(--primary-color); }

/* --- 5. О нас (Текст + Картинка) --- */
.about { padding: 60px 0; background: var(--light-bg); }
.about-content {
    display: flex;
    align-items: center;
    gap: 40px;
    flex-wrap: wrap;
}
.about-text { flex: 1; min-width: 300px; }
.about-image { flex: 1; min-width: 300px; }
.about-image img { width: 100%; border-radius: 4px; }

/* --- 6. Галерея / Портфолио --- */
.gallery { padding: 60px 0; }
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 10px;
}
.gallery-item { height: 250px; overflow: hidden; position: relative; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; transition: 0.5s; }
.gallery-item:hover img { transform: scale(1.1); }

/* --- 7. Футер --- */
footer {
    background: #222;
    color: #ddd;
    padding: 40px 0;
    text-align: center;
}
.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    text-align: left;
    margin-bottom: 20px;
}
.footer-col h4 { color: var(--white); margin-bottom: 15px; }

/* --- Адаптивность (Media Queries) --- */
@media (max-width: 768px) {
    .nav-links {
        position: absolute;
        right: 0px;
        height: 90vh;
        top: 80px;
        background: var(--white);
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 50%;
        transform: translateX(100%);
        transition: transform 0.5s ease-in;
        box-shadow: -2px 0 5px rgba(0,0,0,0.1);
    }
    .nav-links.nav-active { transform: translateX(0%); }
    .burger { display: block; }
    .hero h1 { font-size: 2rem; }
}

/* --- Стили для Мини-Галерей (Карусель) --- */

/* Карточка проекта */
.project-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

/* Контейнер для скролла (сама карусель) */
.carousel {
    display: flex;
    overflow-x: auto;       /* Разрешаем горизонтальный скролл */
    scroll-snap-type: x mandatory; /* Магия CSS: заставляет картинки "прилипать" при скролле */
    -webkit-overflow-scrolling: touch; /* Плавность на iPhone */
    scrollbar-width: none;  /* Скрываем полосу прокрутки в Firefox */
}

/* Скрываем полосу прокрутки в Chrome/Safari */
.carousel::-webkit-scrollbar {
    display: none;
}

/* Картинки внутри карусели */
.carousel img {
    flex: 0 0 100%;         /* Каждая картинка занимает 100% ширины карточки */
    height: 300px;          /* Фиксированная высота */
    object-fit: cover;      /* Обрезка лишнего, чтобы не сплющивало */
    scroll-snap-align: start; /* Точка прилипания */
}

/* Информация под картинками */
.project-info {
    padding: 15px;
    text-align: center;
}

.project-info h3 {
    font-size: 1.1rem;
    margin-bottom: 5px;
    color: var(--primary-color);
}

.project-info p {
    font-size: 0.9rem;
    color: #666;
}

/* --- Стили для Кнопок Карусели --- */

.carousel-container {
    position: relative; /* Чтобы кнопки позиционировались относительно этого блока */
}

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%); /* Центрируем по вертикали */
    background-color: rgba(0, 0, 0, 0.5); /* Полупрозрачный черный */
    color: white;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 18px;
    border-radius: 50%; /* Круглые кнопки */
    z-index: 10;
    transition: 0.3s;
    user-select: none; /* Чтобы текст не выделялся при клике */
}

.nav-btn:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

.prev-btn { left: 10px; }
.next-btn { right: 10px; }

/* На телефонах кнопки можно скрыть, так как там удобно свайпать */
@media (max-width: 768px) {
    .nav-btn {
        display: none;
    }
}

/* ========================================= */
/* СТИЛИ ДЛЯ НОВОЙ ГАЛЕРЕИ-МОЗАИКИ */
/* ========================================= */

.masonry-grid {
    display: grid;
    /* Автоматическое заполнение колонками, минимум 200px шириной */
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    /* Базовая высота ряда */
    grid-auto-rows: 200px;
    gap: 15px;
    /* "Плотная" упаковка, чтобы заполнять дыры */
    grid-auto-flow: dense; 
}

.masonry-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    cursor: pointer;
    display: block; /* Важно для ссылки */
}

.masonry-item img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Обрезка, чтобы заполнить блок */
    transition: transform 0.3s ease;
}

/* Эффект увеличения при наведении */
.masonry-item:hover img {
    transform: scale(1.05);
}

/* --- Классы для разных размеров (Эффект разброса) --- */
.masonry-item.wide {
    grid-column: span 2; /* Занимает 2 колонки в ширину */
}

.masonry-item.tall {
    grid-row: span 2; /* Занимает 2 ряда в высоту */
}

/* На мобильных убираем "широкие" блоки, чтобы не ломать верстку */
@media (max-width: 600px) {
    .masonry-item.wide, .masonry-item.tall {
        grid-column: span 1;
        grid-row: span 1;
    }
    .masonry-grid {
        display: grid;
        /* БЫЛО: minmax(200px, 1fr) */
        /* СТАЛО: minmax(120px, 1fr) -> Картинки станут почти в 2 раза меньше */
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        
        /* Высоту ряда тоже уменьшаем, чтобы они были квадратными */
        grid-auto-rows: 120px;
        
        gap: 10px; /* Уменьшили отступы между картинками (было 15px) */
        grid-auto-flow: dense; 
    }
}


/* ========================================= */
/* СТИЛИ ДЛЯ ЛАЙТБОКСА (Всплывающее окно) */
/* ========================================= */
.lightbox-modal {
    display: none; /* Скрыто по умолчанию */
    position: fixed;
    z-index: 2000; /* Поверх всего */
    padding-top: 50px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.9); /* Черный полупрозрачный фон */
}

.lightbox-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 85vh;
    border-radius: 5px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    animation: zoomIn 0.3s; /* Плавное появление */
}

@keyframes zoomIn {
    from {transform:scale(0)}
    to {transform:scale(1)}
}

.close-lightbox {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
    z-index: 2001;
}

.close-lightbox:hover,
.close-lightbox:focus {
    color: var(--primary-color);
    text-decoration: none;
    cursor: pointer;
}

/* ========================================= */
/* СТИЛИ ДЛЯ МОДАЛЬНОГО ОКНА (POP-UP) */
/* ========================================= */

/* Затемненный фон (Оверлей) */
.modal-overlay {
    display: none; /* Скрыто по умолчанию */
    position: fixed;
    z-index: 3000; /* Самый верхний слой */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6); /* Темный полупрозрачный фон */
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Когда окно активно (добавляется через JS) */
.modal-overlay.active {
    display: flex;
    opacity: 1;
}

/* Само белое окно с формой */
.modal-content {
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px; /* Не шире 500px */
    position: relative;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0); /* Эффект плавного всплытия */
}

/* Кнопка закрытия (Крестик) */
.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #333;
    cursor: pointer;
    line-height: 1;
}

.close-modal:hover { color: var(--primary-color); }

/* Заголовки внутри окна */
.modal-content h2 { margin-bottom: 10px; color: var(--primary-color); }
.modal-content p { margin-bottom: 20px; color: #666; font-size: 0.9rem; }

/* Поля ввода */
.form-group { margin-bottom: 15px; text-align: left; }
.form-group label { display: block; margin-bottom: 5px; font-weight: bold; font-size: 0.9rem; }
.form-group input, 
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
}

/* Кнопка отправки */
.btn-submit {
    width: 100%;
    background: var(--primary-color);
    color: #fff;
    padding: 12px;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
    transition: 0.3s;
}

.btn-submit:hover { background: #8a0e26; }