/* ===== Видео карточки ===== */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 30px;
    padding: 20px 0 40px;
}

.video-card {
    background: #ffffff;
    border: 1px solid #e3e3e3;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
}

.video-card:hover {
    box-shadow: 0 6px 24px rgba(0, 136, 245, 0.12);
    transform: translateY(-4px);
    border-color: #0088f5;
}

/* Индикатор загрузки превью */
.video-card__preview.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2;
}

.video-card__preview.loading::after {
    content: '⏳';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ffffff;
    font-size: 32px;
    z-index: 3;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Превью видео */
.video-card__preview {
    position: relative;
    background: #1a1a1a;
    cursor: pointer;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    flex-shrink: 0;
}

.video-card__preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.video-card:hover .video-card__preview img {
    transform: scale(1.03);
}

/* Кнопка Play поверх превью */
.video-card__play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: rgba(0, 136, 245, 0.85);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    opacity: 0.9;
}

.video-card__play-btn::after {
    content: '';
    width: 0;
    height: 0;
    border-left: 18px solid #ffffff;
    border-top: 11px solid transparent;
    border-bottom: 11px solid transparent;
    margin-left: 4px;
}

.video-card__preview:hover .video-card__play-btn {
    background: rgba(0, 136, 245, 1);
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 1;
}

/* Длительность видео */
.video-card__duration {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.8);
    color: #ffffff;
    padding: 3px 10px;
    border-radius: 4px;
    font: 400 13px/18px "Open Sans", sans-serif;
    letter-spacing: 0.3px;
}

/* Контент карточки */
.video-card__content {
    padding: 18px 20px 22px;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

/* ===== ЗАГОЛОВОК - 4 СТРОКИ С ФИКСИРОВАННОЙ ВЫСОТОЙ ===== */
.video-card__title {
    font: 600 18px/24px "Open Sans", sans-serif;
    color: #3f3f3f;
    margin: 0 0 10px;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 96px; /* 24px * 4 */
    max-height: 96px; /* фиксируем высоту чтобы карточки были одинаковые */
}

.video-card__title a {
    color: #3f3f3f;
    text-decoration: none;
    transition: color 0.2s;
}

.video-card__title a:hover {
    color: #0088f5;
}

/* ===== ОПИСАНИЕ - 4 СТРОКИ ===== */
.video-card__description {
    font: 300 14px/20px "Open Sans", sans-serif;
    color: #7f7f7f;
    margin: 0 0 14px;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 80px; /* 20px * 4 */
    max-height: 80px;
}

.video-card__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
    margin-top: auto;
}

.video-card__date {
    font: 300 13px/18px "Open Sans", sans-serif;
    color: #a0a0a0;
}

.video-card__views {
    font: 300 13px/18px "Open Sans", sans-serif;
    color: #a0a0a0;
}

.video-card__views::before {
    content: '👁 ';
    font-size: 14px;
}

.video-card__link {
    display: inline-block;
    padding: 6px 18px;
    background: #0088f5;
    color: #ffffff;
    border-radius: 4px;
    font: 400 13px/18px "Open Sans", sans-serif;
    text-decoration: none;
    transition: background 0.2s;
    cursor: pointer;
    border: none;
    white-space: nowrap;
}

.video-card__link:hover {
    background: #0070d0;
    color: #ffffff;
}

/* Модальное окно для просмотра видео */
.video-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.video-modal.active {
    display: flex;
}

.video-modal__content {
    position: relative;
    width: 100%;
    max-width: 900px;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.video-modal__close {
    position: absolute;
    top: -44px;
    right: 0;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 32px;
    cursor: pointer;
    transition: opacity 0.2s;
    opacity: 0.7;
    line-height: 40px;
    text-align: center;
}

.video-modal__close:hover {
    opacity: 1;
}

.video-modal__iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: none;
    display: block;
}

.video-modal__video {
    width: 100%;
    display: block;
}

/* ===== Пустой результат ===== */
.video-empty {
    text-align: center;
    padding: 60px 20px;
    background: #fafafa;
    border: 1px solid #e3e3e3;
    border-radius: 8px;
}

.video-empty__icon {
    font-size: 48px;
    color: #0088f5;
    opacity: 0.4;
    margin-bottom: 16px;
}

.video-empty__title {
    font: 300 24px/32px "Open Sans", sans-serif;
    color: #3f3f3f;
}

.video-empty__text {
    font: 300 16px/24px "Open Sans", sans-serif;
    color: #7f7f7f;
}

/* ===== Пагинация ===== */
.video-pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 20px 0 10px;
    flex-wrap: wrap;
}

.video-pagination .bx-pagination-item {
    list-style: none;
}

.video-pagination a,
.video-pagination span {
    display: inline-block;
    padding: 6px 14px;
    font: 400 14px/20px "Open Sans", sans-serif;
    color: #3f3f3f;
    border: 1px solid #e3e3e3;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.2s;
    background: #ffffff;
}

.video-pagination a:hover {
    background: #0088f5;
    color: #ffffff;
    border-color: #0088f5;
}

.video-pagination .bx-pag-current {
    background: #0088f5;
    color: #ffffff;
    border-color: #0088f5;
}

.video-pagination .bx-pag-prev a,
.video-pagination .bx-pag-next a {
    padding: 6px 18px;
}

/* ===== Адаптив ===== */
@media screen and (max-width: 1023px) {
    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 20px;
        padding: 10px 0 30px;
    }

    .video-card__content {
        padding: 14px 16px 18px;
    }

    .video-card__title {
        font-size: 16px;
        line-height: 22px;
        -webkit-line-clamp: 4;
        min-height: 88px; /* 22px * 4 */
        max-height: 88px;
    }

    .video-card__description {
        font-size: 13px;
        line-height: 19px;
        -webkit-line-clamp: 4;
        min-height: 76px; /* 19px * 4 */
        max-height: 76px;
    }

    .video-modal {
        padding: 10px;
    }

    .video-modal__close {
        top: -38px;
        font-size: 28px;
    }
}

@media screen and (max-width: 767px) {
    .video-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 5px 0 20px;
    }

    .video-card__play-btn {
        width: 48px;
        height: 48px;
    }

    .video-card__play-btn::after {
        border-left: 14px solid #ffffff;
        border-top: 9px solid transparent;
        border-bottom: 9px solid transparent;
    }

    .video-card__title {
        font-size: 15px;
        line-height: 20px;
        -webkit-line-clamp: 4;
        min-height: 80px; /* 20px * 4 */
        max-height: 80px;
    }

    .video-card__description {
        font-size: 13px;
        line-height: 18px;
        -webkit-line-clamp: 4;
        min-height: 72px; /* 18px * 4 */
        max-height: 72px;
    }

    .video-modal__close {
        top: -34px;
        font-size: 24px;
        width: 32px;
        height: 32px;
        line-height: 32px;
    }

    .video-empty {
        padding: 40px 16px;
    }

    .video-empty__title {
        font-size: 20px;
        line-height: 28px;
    }

    .video-pagination a,
    .video-pagination span {
        padding: 4px 10px;
        font-size: 13px;
    }
}

@media screen and (max-width: 480px) {
    .video-grid {
        gap: 12px;
    }

    .video-card__meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

/* ===== Дополнительный стиль для темной темы ===== */
@media (prefers-color-scheme: dark) {
    .video-card {
        background: #1a1a1a;
        border-color: #333;
    }
    
    .video-card__title {
        color: #e0e0e0;
    }
    
    .video-card__description {
        color: #999;
    }
    
    .video-card__meta {
        border-top-color: #333;
    }
    
    .video-card__date,
    .video-card__views {
        color: #777;
    }
    
    .video-empty {
        background: #1a1a1a;
        border-color: #333;
    }
    
    .video-empty__title {
        color: #e0e0e0;
    }
    
    .video-empty__text {
        color: #999;
    }
}