/* Общие настройки страницы */
html, body {
    margin: 0;
    padding: 0;
    background: #1a1a1a;
    font-family: 'Inter', sans-serif;
    color: #fff;
    overflow-y: auto; 
    min-height: 100vh;
}

/* Главный контейнер */
.tech-container {
    position: relative;
    z-index: 10;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    padding-top: 120px;
}

/* Шапка навигации */
.tech-header {
    text-align: center;
    flex-shrink: 0;
    margin-bottom: 20px;
}

.page-title {
    font-size: 2.2rem;
    font-weight: 200;
    text-transform: uppercase;
    letter-spacing: 8px;
    margin: 0 0 25px 0;
    color: #fff;
}

/* Категории (Авто / Мото) */
.category-nav {
    display: inline-flex;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 6px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.cat-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    padding: 10px 28px;
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cat-btn.active {
    background: #d4af37;
    color: #000;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
}

/* Главная контентная зона */
.tech-main-content {
    flex-grow: 1;
    position: relative;
    margin-bottom: 40px;
}

/* Переключение видов (Каталог / Детали) */
.cards-view, .detail-view {
    display: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.cards-view.active, .detail-view.active {
    display: block;
    opacity: 1;
}

/* Сетка карточек с адаптивным поведением */
.tech-cards-grid {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    flex-wrap: wrap; 
    gap: 30px;
    max-width: 1440px;
    margin: 0 auto;
    padding: 30px 40px;
    box-sizing: border-box;
}

/* Карточка техники */
.tech-card {
    flex: 0 1 350px; 
    min-width: 280px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.4s ease, box-shadow 0.4s ease;
}

.tech-card.hidden {
    display: none !important;
}

.tech-card:hover {
    transform: translateY(-8px);
    border-color: rgba(212, 175, 55, 0.4);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4), 0 0 20px rgba(212, 175, 55, 0.05);
}

/* --- ОСОБАЯ СТИЛИЗАЦИЯ ДЛЯ МОТО-КАРТОЧЕК --- */
/* Уменьшаем карточки по бокам от NSF250 */
.tech-card[data-target="husqvarna65"],
.tech-card[data-target="ktm50sm"] {
    flex: 0 1 260px;
}

/* Смещаем NSF250 вниз, делаем шире и центрируем */
.tech-card[data-target="honda-nsf250"] {
    flex: 0 1 450px;
    order: 10; /* Переносит в самый конец текущего потока flex */
    width: 100%;
}
/* ------------------------------------------- */

.card-img-wrapper {
    width: 100%;
    height: auto;
    overflow: hidden;
    background: transparent; 
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-img-wrapper img {
    width: 100%;
    height: auto;
    object-fit: contain; 
    display: block;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.tech-card:hover .card-img-wrapper img {
    transform: scale(1.03);
}

.card-info {
    padding: 20px;
}

.card-tag {
    color: #d4af37;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    display: block;
    margin-bottom: 5px;
}

.card-info h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 300;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #fff;
}


/* BMW M2 Racing: аккуратная карточка, пока фотографии ещё не добавлены */
.bmw-card-image {
    position: relative;
    aspect-ratio: 4 / 3;
    background: linear-gradient(145deg, #242424, #111 70%);
}

.bmw-card-image .bmw-cover-image {
    display: none;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bmw-card-image.is-loaded .bmw-cover-image {
    display: block;
}

.bmw-image-placeholder {
    color: rgba(255, 255, 255, 0.7);
    font-size: clamp(1rem, 2vw, 1.5rem);
    font-weight: 300;
    text-align: center;
    letter-spacing: 0.16em;
    line-height: 1.8;
    padding: 20px;
}

.bmw-image-placeholder strong {
    display: block;
    color: #d4af37;
    font-weight: 500;
}

.bmw-card-image.is-loaded .bmw-image-placeholder {
    display: none;
}

.bmw-gallery-empty {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 240px;
    margin: 0;
    padding: 30px;
    color: rgba(255, 255, 255, 0.65);
    border: 1px solid rgba(212, 175, 55, 0.24);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.3);
    line-height: 1.6;
}

/* Детальный вид техники */
.tech-section {
    position: relative;
    display: none;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.tech-section.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

.tech-content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 30px;
    max-width: 1600px; 
    width: 100%;
    padding: 0 40px;
    box-sizing: border-box;
    margin: 0 auto;
}

.tech-info {
    width: 100%;
    text-align: left;
}

.tech-tag {
    color: #d4af37;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    display: block;
    margin-bottom: 10px;
}

.tech-info h2 {
    font-size: 2.5rem;
    font-weight: 300;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 3px;
    line-height: 1.2;
}

/* ДВУХКОЛОНОЧНЫЙ ВИД ГАЛЕРЕИ */
.gallery-container {
    width: 100%;
    display: flex;
    flex-direction: row;
    gap: 40px;
    align-items: flex-start;
}

/* Левая часть: Фиксированное основное фото */
.main-photo-wrapper {
    flex: 0 0 40%; 
    margin-bottom: 0;
    position: sticky;
    top: 100px; 
}

.main-tech-photo {
    width: 100%;
    height: auto;
    max-height: 75vh; 
    object-fit: contain; 
    display: block;
    background: transparent; 
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.main-tech-photo:hover {
    transform: translateY(-4px);
    border-color: rgba(212, 175, 55, 0.6);
    box-shadow: 0 20px 45px rgba(212, 175, 55, 0.15);
}

/* Правая часть: Сетка из плиток */
.photo-gallery {
    flex: 0 0 60%; 
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    width: 100%;
}

.photo-gallery img {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3; 
    object-fit: contain; 
    display: block;
    background: transparent; 
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.photo-gallery img:hover {
    transform: scale(1.05);
    border-color: rgba(212, 175, 55, 0.4);
}

/* Кнопка возврата к списку */
.back-to-catalog {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 20px auto 40px auto;
    background: #d4af37;
    color: #1a1a1a;
    border: 1px solid #d4af37;
    padding: 14px 32px;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 6px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3), 0 0 15px rgba(212, 175, 55, 0.2);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.back-to-catalog:hover {
    background: transparent;
    color: #d4af37;
    border-color: #d4af37;
    backdrop-filter: blur(10px);
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.5);
    transform: translateY(-2px);
}

/* --- LIGHTBOX МОДАЛЬНОЕ ОКНО --- */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(10px);
    z-index: 30000; 
    display: flex;
    justify-content: space-between;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 0 20px;
    box-sizing: border-box;
}

.lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.lightbox-content {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 80%;
    height: 100%;
}

.lightbox-overlay img {
    max-width: 100%;
    max-height: 85vh; 
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.lightbox-overlay.active img {
    transform: scale(1);
}

.lightbox-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 31000;
    transition: all 0.2s ease;
    user-select: none;
}

.lightbox-btn:hover {
    background: #d4af37;
    color: #000;
    border-color: #d4af37;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.5);
}

.lightbox-close {
    position: absolute;
    top: 30px;
    right: 40px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 3.5rem;
    cursor: pointer;
    line-height: 1;
    opacity: 0.6;
    z-index: 32000;
    transition: all 0.2s ease;
}

.lightbox-close:hover {
    opacity: 1;
    color: #d4af37;
    transform: scale(1.1);
}

/* Фоновое фото */
.photo-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    overflow: hidden;
}

.photo-bg img,
.photo-bg .tech-bg-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.65);
}

.photo-bg .tech-bg-video {
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .photo-bg .tech-bg-video {
        display: none;
    }
}

.photo-bg .overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 2;
}

.overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, transparent 20%, rgba(0, 0, 0, 0.6) 90%);
}

/* --- МЕДИА-ЗАПРОСЫ И АДАПТИВНОСТЬ --- */
@media (max-width: 1366px) {
    .tech-cards-grid {
        gap: 20px;
        padding: 20px;
    }
    .tech-card {
        flex: 0 1 310px; 
    }
    /* Сбрасываем кастомные flex-пропорции на экранах поменьше */
    .tech-card[data-target="husqvarna65"],
    .tech-card[data-target="ktm50sm"] {
        flex: 0 1 310px;
    }
    .tech-card[data-target="honda-nsf250"] {
        flex: 0 1 310px;
        order: unset;
        width: auto;
    }
    .photo-gallery {
        grid-template-columns: repeat(4, minmax(0, 1fr)); 
    }
}

@media (max-width: 1100px) {
    .photo-gallery {
        grid-template-columns: repeat(3, minmax(0, 1fr)); 
    }
}

@media (max-width: 1024px) {
    .gallery-container {
        flex-direction: column;
        gap: 30px;
    }
    .main-photo-wrapper {
        position: static;
        width: 100%;
    }
    .photo-gallery {
        width: 100%;
        grid-template-columns: repeat(4, minmax(0, 1fr)); 
    }
    .tech-container {
        padding-top: 140px;
    }
    .lightbox-content {
        max-width: 75%;
    }
}

@media (max-width: 768px) {
    .tech-container {
        padding-top: 80px;
    }
    .page-title {
        font-size: 1.8rem;
        letter-spacing: 4px;
    }
    .tech-info h2 {
        font-size: 1.8rem;
    }
    .photo-gallery {
        grid-template-columns: repeat(3, minmax(0, 1fr)); 
    }
    .lightbox-btn {
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
    }
    .lightbox-close {
        top: 15px;
        right: 20px;
        font-size: 2.5rem;
    }
}

@media (max-width: 500px) {
    .photo-gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr)); 
    }
    .lightbox-overlay {
        padding: 0 5px;
    }
    .lightbox-content {
        max-width: 70%;
    }
    .lightbox-btn {
        min-width: 44px;
        min-height: 44px;
    }
}