/* --- БАЗОВЫЕ СТИЛИ --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    height: 100%;
    background: url('images/bg.png') no-repeat center center fixed;
    background-size: cover;
    background-color: #000;
}

body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: transparent !important;
    font-family: 'Montserrat', sans-serif;
}

/* --- ПОЛНОЕ СКРЫТИЕ СКРОЛЛБАРА --- */
#scroll-container::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

#scroll-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* --- ШАПКА --- */
header {
    text-align: center;
    padding-top: 5vh;
}

.logo {
    height: 60px;
    width: auto;
}

/* --- ГЛАВНЫЙ БЛОК --- */
main {
    width: 100%;
    height: 80vh;
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    align-items: center;
    cursor: grab;
    -webkit-tap-highlight-color: transparent;
}

.scroll-wrapper {
    display: inline-flex;
    align-items: flex-end;
    padding: 0 120px;
}

.cases-title {
    margin-right: 120px;
    flex-shrink: 0;
}

.cases-title img {
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

.portfolio-grid {
    display: flex;
    gap: 30px;
}

/* КАРТОЧКА КЕЙСА */
.case-container {
    position: relative;
    flex-shrink: 0;
    border-radius: 20px;
    overflow: hidden;
    line-height: 0;
    transition: transform 0.3s ease;
    cursor: pointer;
}

.case-container:hover {
    transform: scale(1.02);
}

.case-item {
    height: 65vh;
    max-height: 694px;
    width: auto;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

/* --- ИКОНКА PLAY ДЛЯ ВИДЕО --- */
.video-case::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    border-radius: 50%;
    z-index: 3;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
    background-size: 40px;
    background-repeat: no-repeat;
    background-position: center center;
    transition: all 0.3s ease;
}

.video-case:hover::after {
    background-color: rgba(255, 255, 255, 0.4);
    transform: translate(-50%, -50%) scale(1.1);
}

.case-shadow {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 415px;
    object-fit: fill;
    z-index: 1;
    pointer-events: none;
}

.case-caption {
    position: absolute;
    bottom: 50px;
    left: 40px;
    color: #fff;
    font-size: 16px;
    font-weight: 500;
    z-index: 2;
    pointer-events: none;
}

/* --- ПОПАП (ОБНОВЛЕННЫЙ) --- */
.popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    overflow-y: auto; /* Позволяет скроллить длинные картинки */
    cursor: zoom-out;
}

.popup-content {
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Картинки будут прижаты к верху для скролла */
    min-height: 100%;
    width: 100%;
    padding: 40px 20px;
}

#popup-img {
    display: none;
    width: auto;      /* Реальная ширина */
    max-width: 95%;   /* Но не шире экрана */
    height: auto;     /* Реальная высота */
    cursor: default;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
    animation: fadeIn 0.3s ease;
}

#popup-video {
    display: none;
    width: 80vw;      /* Ширина — 80% от экрана */
    max-width: 1100px; /* Но не более 1100px */
    aspect-ratio: 16 / 9; /* Пропорции YouTube */
    align-self: center;  /* Видео, в отличие от фото, всегда по центру */
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- АДАПТИВ --- */
@media (max-width: 768px) {
    body { overflow-y: auto; }
    .scroll-wrapper { display: block; padding: 0 20px; width: 100%; }
    .cases-title { margin: 40px 0 20px 0; }
    .cases-title img { width: 40%; }
    main { height: auto; display: block; cursor: default; }
    .portfolio-grid { flex-direction: column; gap: 20px; padding-bottom: 40px; }
    .case-item { height: auto; width: 100%; }
    .case-caption { bottom: 25px; left: 20px; font-size: 14px; }
    .video-case::after { width: 60px; height: 60px; background-size: 30px; }
    #popup-video {
        width: 95vw;
    }
    .popup-content {
        padding: 20px 10px;
    }

}
