/*
 * Slider Section Redesign
 * Làm cho TikTok video slider nhất quán với DarkMode theme.
 * Override các style trong style.css
 */

/* ── Bỏ floating card look ─────────────────────────────────── */
.top-videos-slider-wrapper {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    padding: 0 0 20px !important;
    border-radius: 0 !important;
    transition: none !important;
}

.top-videos-slider-wrapper:hover {
    box-shadow: none !important;
    border-color: transparent !important;
}

.top-videos-slider-section {
    padding: 0 !important;
    margin: 0 auto 4px !important;
}

/* ── Heading: khớp với section heading của theme ────────────── */
.top-videos-slider-title h2 {
    font-size: 17px !important;
    font-weight: 700 !important;
    letter-spacing: 0 !important;
    color: #f1f1f1 !important;
    padding-left: 12px !important;
    border-left: 3px solid #ff4757 !important;
    line-height: 1.2 !important;
    margin: 0 !important;
    /* baseline làm icon + badge "HOT" lệch cao/thấp so với chữ (icon glyph và
       pill badge không có baseline chuẩn) — center cho cả 3 thẳng hàng */
    align-items: center !important;
    gap: 8px !important;
}

.tiktok-icon {
    color: #ff4757 !important;
    font-size: 1rem !important;
}

/* Subtitle: ẩn mặc định, .home-refined bật lại trong index-page.css */
body:not(.home-refined) .title-subtitle {
    display: none !important;
}

.top-videos-slider-header {
    margin-bottom: 12px !important;
    align-items: center !important;
}

/* ── View-more → chip nhỏ, có hình khối rõ ràng ───────────────
   Bản trước là chữ xám trần không viền/nền — trên mobile (không có :hover)
   nhìn như chữ tĩnh, không rõ là bấm được. Đổi thành chip có nền/viền nhẹ +
   mũi tên, giữ nguyên type "text link, không phải nút to" nhưng có affordance. */
.view-more-btn {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08)) !important;
    padding: 6px 12px !important;
    border-radius: 999px !important;
    color: rgba(255, 255, 255, 0.75) !important;
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    gap: 6px !important;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease !important;
}

.view-more-btn::after {
    content: "\203A"; /* › */
    font-weight: 700;
    font-size: 0.95em;
    line-height: 1;
    transition: transform 0.2s ease;
}

.view-more-btn:hover,
.view-more-btn:focus-visible {
    background: rgba(255, 71, 87, 0.14) !important;
    border-color: rgba(255, 71, 87, 0.35) !important;
    color: #fff !important;
}

.view-more-btn:hover::after {
    transform: translateX(2px);
}

/* Phản hồi khi chạm trên mobile — không có :hover nên cần :active riêng */
.view-more-btn:active {
    background: rgba(255, 71, 87, 0.2) !important;
    border-color: rgba(255, 71, 87, 0.4) !important;
    color: #fff !important;
}

.view-more-count {
    background: rgba(255, 71, 87, 0.16) !important;
    color: var(--accent-tint, #ff8a9b) !important;
    padding: 1px 7px !important;
    border-radius: var(--radius-sm, 6px) !important;
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    transition: background 0.2s ease, color 0.2s ease !important;
}

.view-more-btn:hover .view-more-count,
.view-more-btn:active .view-more-count {
    background: var(--accent-strong, #C4293A) !important;
    color: #fff !important;
    transform: none !important;
}

/* ── Edge fade mask – hiệu ứng "peek" trên slide track ─────── */
#topVideosSlider .splide__track {
    -webkit-mask-image: linear-gradient(
        to right,
        transparent 0%,
        #000 5%,
        #000 95%,
        transparent 100%
    ) !important;
    mask-image: linear-gradient(
        to right,
        transparent 0%,
        #000 5%,
        #000 95%,
        transparent 100%
    ) !important;
    border-radius: 0 !important;
}

/* ── Khoảng cách giữa slides ────────────────────────────────── */
#topVideosSlider .splide__slide {
    padding: 0 3px !important;
}

/* ── Card: bo góc nhẹ, không border ────────────────────────── */
.top-video-card {
    border-radius: 10px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4) !important;
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.35s ease !important;
}

.top-video-card:hover {
    transform: translateY(-6px) scale(1.02) !important;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 71, 87, 0.3) !important;
}

/* ── Hover/motion sinh động hơn ──────────────────────────────
   Ảnh zoom mạnh + mượt hơn, scrim đậm hơn, tiêu đề nhích lên,
   like-btn nảy nhẹ khi hover card, tim "pop" khi hover trực tiếp. */
.top-video-thumbnail img {
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

.top-video-card:hover .top-video-thumbnail img {
    transform: scale(1.12) !important;
}

.top-video-thumbnail::after {
    transition: background 0.35s ease !important;
}

.top-video-title-overlay {
    transition: transform 0.3s ease !important;
}

.top-video-card:hover .top-video-title-overlay {
    transform: translateY(-4px) !important;
}

.slider-like-btn {
    transition: background 0.25s ease, border-color 0.25s ease,
        transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

.top-video-card:hover .slider-like-btn {
    transform: translateY(-2px) !important;
}

.slider-like-btn:hover i {
    animation: slider-heart-pop 0.4s ease;
}

@keyframes slider-heart-pop {
    0%, 100% { transform: scale(1); }
    40% { transform: scale(1.4); }
}

/* Nút mũi tên + pagination: thêm phản hồi bấm rõ ràng hơn */
#topVideosSlider .splide__arrow {
    transition: all 0.25s ease, transform 0.2s ease !important;
}

#topVideosSlider .splide__arrow:hover {
    transform: scale(1.1) !important;
}

#topVideosSlider .splide__arrow:active {
    transform: scale(0.92) !important;
}

#topVideosSlider .splide__pagination__page {
    transition: all 0.3s ease, transform 0.2s ease !important;
}

#topVideosSlider .splide__pagination__page:hover {
    transform: scale(1.4) !important;
}

/* ── Giữ portrait (9:16) nhất quán trên MỌI màn hình ────────── */
@media (max-width: 768px) {
    .top-video-thumbnail {
        padding-bottom: 177.78% !important;
        aspect-ratio: unset !important;
        min-height: unset !important;
    }

    .top-videos-slider-wrapper {
        padding: 0 0 12px !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }

    .top-videos-slider-header {
        /* wrap thay vì ép 1 hàng: tiêu đề dài (icon + chữ + badge HOT) +
           "Xem thêm 999+" từng bị chật/đè nhau trên màn hình hẹp */
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        row-gap: 6px !important;
        gap: 8px !important;
    }

    .top-videos-slider-title {
        text-align: left !important;
        flex: 1 1 100% !important;
        min-width: 0 !important;
    }

    .top-videos-slider-title h2 {
        min-width: 0;
    }

    .view-more-btn {
        /* giữ dạng chip (nền/viền/bo góc) trên mobile — đây mới là nơi cần rõ
           "bấm được" nhất vì không có :hover để gợi ý */
        width: auto !important;
        max-width: none !important;
        justify-content: flex-end !important;
        font-size: 0.75rem !important;
        padding: 6px 12px !important;
        /* xuống hàng riêng, dồn về mép phải thay vì chen cạnh tiêu đề */
        margin-left: auto !important;
    }

    #topVideosSlider .splide__slide {
        padding: 0 2px !important;
    }

    /* perPage tăng 2→3 làm card hẹp lại (~⅓ màn hình) — thu nhỏ badge tim
       theo để không tràn/đè lên ảnh */
    .slider-like-btn {
        padding: 4px 8px !important;
        gap: 4px !important;
        font-size: 0.68rem !important;
    }

    .slider-like-btn i {
        font-size: 0.7rem !important;
    }
}

@media (max-width: 480px) {
    .top-videos-slider-title h2 {
        font-size: 14px !important;
    }

    .top-video-thumbnail {
        padding-bottom: 177.78% !important;
        aspect-ratio: unset !important;
        min-height: unset !important;
    }

    .top-videos-slider-wrapper {
        padding: 0 0 10px !important;
        margin: 0 !important;
    }

    .slider-like-btn {
        padding: 3px 6px !important;
        gap: 3px !important;
        font-size: 0.6rem !important;
    }

    .slider-like-btn i {
        font-size: 0.62rem !important;
    }
}

/* ── Chống giật khi tải slider ───────────────────────────────
   Skeleton cùng tỉ lệ 9:16 và cùng số cột với Splide (6 / 4 / 38% / 44%)
   nên chiều cao khung không đổi khi slide thật thay vào. Skeleton và
   slider chồng cùng một ô grid; .is-ready ẩn skeleton. */
.topv-stage {
    display: grid;
}

.topv-stage > * {
    grid-area: 1 / 1;
    min-width: 0;
}

.topv-skeleton {
    display: flex;
    overflow: hidden;
    pointer-events: none;
}

.topv-skeleton-card {
    flex: 0 0 calc(100% / 6);
    padding: 0 3px;
    box-sizing: border-box;
}

.topv-skeleton-card > span {
    display: block;
    width: 100%;
    aspect-ratio: 9 / 16;
    border-radius: 10px;
    background: linear-gradient(100deg, #161a22 30%, #1f2430 50%, #161a22 70%) 0 0 / 200% 100%;
    animation: topv-shimmer 1.4s linear infinite;
}

@keyframes topv-shimmer {
    to { background-position: -200% 0; }
}

.topv-error {
    display: none;
    align-self: center;
    justify-self: center;
    text-align: center;
    padding: 40px 16px;
    color: rgba(255, 255, 255, 0.6);
}

.topv-error button {
    background: #ff4757;
    color: #fff;
    border: 0;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
}

.topv-stage.is-ready .topv-skeleton,
.topv-stage.is-error .topv-skeleton {
    display: none;
}

.topv-stage.is-error .topv-error {
    display: block;
}

/* Trước khi mount, slider rỗng không được chiếm chỗ hay hiện ra */
.topv-stage.is-loading #topVideosSlider {
    visibility: hidden;
}

@media (max-width: 1024px) {
    .topv-skeleton-card { flex-basis: 25%; }
}

@media (max-width: 768px) {
    .topv-skeleton-card { flex-basis: 38%; padding: 0 2px; }
}

@media (max-width: 480px) {
    .topv-skeleton-card { flex-basis: 44%; }
}

@media (prefers-reduced-motion: reduce) {
    .topv-skeleton-card > span { animation: none; }
}

/* ── Slider TOP: thẻ "thanh xéo" (parallelogram) ──────────────────
   Mỗi thẻ cắt chéo hai cạnh bên bằng clip-path (ảnh vẫn thẳng, không méo như skew).
   Thẻ rộng hơn ô slide một đoạn --slat và lùi vào nửa đoạn đó, nên hai thẻ kề nhau chồng lên
   vùng tam giác của nhau và chỉ còn một khe xéo rộng --seam. Splide vẫn tính theo độ rộng ô gốc
   (gap:0), nên kéo/loop/perPage không đổi. Bóng đổ dùng drop-shadow ở <li> vì clip-path cắt box-shadow. */
#topVideosSlider,
.topv-skeleton {
    --slat: 26px;
    --seam: 6px;
    --slat-shape: polygon(
        calc(var(--slat) + var(--seam) / 2) 0,
        calc(100% - var(--seam) / 2) 0,
        calc(100% - var(--slat) - var(--seam) / 2) 100%,
        calc(var(--seam) / 2) 100%
    );
}

#topVideosSlider .splide__slide {
    padding: 0 !important;
    filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.45));
}

#topVideosSlider .splide__slide:hover,
#topVideosSlider .splide__slide:focus-within {
    z-index: 2;
}

#topVideosSlider .top-video-card {
    width: calc(100% + var(--slat)) !important;
    margin-left: calc(var(--slat) / -2);
    border-radius: 0 !important;
    box-shadow: none !important;
    clip-path: var(--slat-shape);
}

#topVideosSlider .top-video-card:hover {
    box-shadow: none !important;
}

#topVideosSlider .top-video-thumbnail {
    border-radius: 0 !important;
}

/* Vệt đỏ chạy dọc mép xéo bên trái khi hover/focus */
#topVideosSlider .top-video-card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    background: var(--accent, #ff4757);
    clip-path: polygon(
        calc(var(--slat) + var(--seam) / 2) 0,
        calc(var(--slat) + var(--seam) / 2 + 3px) 0,
        calc(var(--seam) / 2 + 3px) 100%,
        calc(var(--seam) / 2) 100%
    );
    opacity: 0;
    transition: opacity 0.25s ease;
}

#topVideosSlider .top-video-card:hover::before,
#topVideosSlider .top-video-card:focus-within::before {
    opacity: 1;
}

/* Tiêu đề: tấm kính mờ (frosted glass) nổi trên ảnh, thụt vào khỏi hai cạnh xéo.
   backdrop-filter làm mờ chính ảnh phía sau nên chữ đọc rõ trên mọi thumbnail mà không cần
   scrim đen đặc; viền sáng + vệt sáng mép trên tạo cảm giác bóng. Cạnh phải ở đáy thẻ bị cắt chéo
   nên thụt phải = --slat + --seam/2 + khoảng đệm. */
#topVideosSlider .top-video-title-overlay {
    left: calc(var(--seam) / 2 + 10px);
    right: calc(var(--slat) + var(--seam) / 2 + 10px);
    bottom: 12px;
    padding: 8px 11px 9px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.14) 0%, rgba(18, 20, 28, 0.42) 100%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
    backdrop-filter: blur(12px) saturate(150%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 6px 16px rgba(0, 0, 0, 0.28);
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* Có kính rồi thì scrim đáy nhẹ lại, ảnh sáng hơn */
#topVideosSlider .top-video-thumbnail::after {
    height: 38%;
}

/* Nút tim ở góc trên phải: cạnh phải ở đỉnh chỉ lùi --seam/2, giữ cách mép đủ để không bị cắt */
#topVideosSlider .slider-like-btn {
    right: calc(var(--seam) / 2 + 10px) !important;
}

/* Điều hướng bàn phím: outline thường bị clip-path cắt nên vẽ vào trong ảnh */
#topVideosSlider .top-video-card a:focus-visible {
    outline: none;
}

#topVideosSlider .top-video-card a:focus-visible .top-video-thumbnail {
    outline: 3px solid var(--accent, #ff4757);
    outline-offset: -4px;
}

/* Skeleton cùng hình dạng để lúc nạp thật không đổi khung */
.topv-skeleton-card {
    padding: 0 !important;
}

.topv-skeleton-card > span {
    width: calc(100% + var(--slat));
    margin-left: calc(var(--slat) / -2);
    border-radius: 0 !important;
    clip-path: var(--slat-shape);
}

@media (max-width: 768px) {
    #topVideosSlider,
    .topv-skeleton {
        --slat: 14px;
        --seam: 4px;
    }

    #topVideosSlider .splide__slide {
        padding: 0 !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    #topVideosSlider .top-video-card:hover {
        transform: none !important;
    }

    #topVideosSlider .top-video-card::before {
        transition: none;
    }
}

/* Desktop: thẻ ngắn lại (3:4 thay vì 9:16) - cả khung chờ cùng tỉ lệ để nạp không giật */
@media (min-width: 769px) {
    #topVideosSlider .top-video-thumbnail {
        padding-bottom: 133.33% !important;
        aspect-ratio: unset !important;
        min-height: unset !important;
    }

    .topv-skeleton-card > span {
        aspect-ratio: 3 / 4;
    }
}

@media (max-width: 768px) {
    #topVideosSlider .top-video-title-overlay {
        left: calc(var(--seam) / 2 + 6px);
        right: calc(var(--slat) + var(--seam) / 2 + 6px);
        bottom: 8px;
        padding: 6px 8px 7px;
        border-radius: 8px;
        font-size: 0.78rem;
        line-height: 1.3;
    }
}

/* Cắt tiêu đề 2 dòng ở <span> bên trong, không ở khung kính: -webkit-line-clamp + padding trên cùng
   một phần tử làm dòng thứ 3 lộ ra trong vùng đệm phía dưới (overflow cắt ở mép padding). */
#topVideosSlider .top-video-title-overlay {
    display: block;
    max-height: none;
    overflow: visible;
    -webkit-line-clamp: unset;
    line-clamp: unset;
}

#topVideosSlider .top-video-title-text {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Nhãn HOT lấy chữ từ data-label (không nằm trong nội dung H2 nên không bị tính vào heading) */
.hot-badge::before {
    content: attr(data-label);
}
