/* ==============================================
   TikTok Video Module — Стили
   Автор: Seofisher | t.me/Seofisher
   ============================================== */


/* -----------------------------------------------
   Галерея — карусель (горизонтальный скролл)
----------------------------------------------- */

.tiktok-gallery {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    margin: 20px 0 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
}


.tiktok-gallery::-webkit-scrollbar {
    height: 3px;
}
.tiktok-gallery::-webkit-scrollbar-track {
    background: transparent;
}
.tiktok-gallery::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

.tiktok-video {
    position: relative;
    cursor: pointer;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    scroll-snap-align: start;
    width: 100px;
}

.video-thumbnail {
    position: relative;
    width: 100%;
}

.video-thumbnail img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    border-radius: 12px;
}

/* Заглушка если превью не загрузилось */
.tiktok-no-thumb {
    width: 100%;
    height: 177px;
    background: #222;
    border-radius: 12px;
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.15);
    transition: background 0.2s ease;
    border-radius: 12px;
}

.tiktok-video:hover .video-overlay {
    background: rgba(0, 0, 0, 0.35);
}

.play-button {
    background: rgba(22, 24, 35, 0.6);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background 0.2s ease;
}

.play-button svg {
    width: 28px;
    height: 28px;
}

.tiktok-video:hover .play-button {
    transform: scale(1.12);
    background: rgba(22, 24, 35, 0.85);
}


/* -----------------------------------------------
   Модальное окно
----------------------------------------------- */

#tiktok-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.88);
    z-index: 99999;
    align-items: center;
    justify-content: center;
}

.tiktok-modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Кнопка закрытия × */
.tiktok-close-modal {
    position: absolute;
    top: -44px;
    right: -8px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 38px;
    line-height: 1;
    cursor: pointer;
    padding: 0 6px;
    opacity: 0.75;
    transition: opacity 0.2s ease;
}

.tiktok-close-modal:hover {
    opacity: 1;
}

.tiktok-modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* Контейнер iframe */
.tiktok-video-container {
    width: 325px;
    height: 575px;
}

.tiktok-video-container iframe {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 12px;
    display: block;
}

/* Навигация (стрелки) */
.tiktok-navigation {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
}

.tiktok-nav-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s ease;
}

.tiktok-nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.tiktok-nav-btn:disabled {
    opacity: 0.25;
    cursor: default;
}


/* -----------------------------------------------
   Адаптив — мобильный (до 768px)
----------------------------------------------- */

@media (max-width: 768px) {

    /* Карточки — ровно 3.5 в ряд
       Формула: (100vw - gap*3 - боковые отступы) / 3.5
       gap: 10px * 3 = 30px, без боковых паддингов у галереи */
    .tiktok-video {
        width: calc((100vw - 30px) / 3.5);
    }

    .tiktok-no-thumb {
        /* Высота пропорциональна ширине 9:16 */
        height: calc((100vw - 30px) / 3.5 * 16 / 9);
    }

    /* Модал — на весь экран */
    .tiktok-modal-content {
        width: 100%;
        height: 100%;
        justify-content: center;
    }

    .tiktok-close-modal {
        position: fixed;
        top: 12px;
        right: 12px;
        font-size: 42px;
        z-index: 100001;
    }

    .tiktok-modal-body {
        padding-top: 56px;
        gap: 12px;
    }

    .tiktok-video-container {
        /* Ширина — почти весь экран */
        width: calc(100vw - 24px);
        /* Высота — пропорция 9:16 */
        height: calc((100vw - 24px) * 16 / 9);
        /* Если высота экрана маленькая — ограничиваем и пересчитываем ширину */
        max-height: calc(100vh - 110px);
        max-width: calc((100vh - 110px) * 9 / 16);
    }

    .tiktok-nav-btn {
        width: 40px;
        height: 40px;
    }
}




