/**
 * Video Reels - Carousel + Vertical Snap-Scroll Player
 * Two modes: thumbnail carousel + full-screen swipeable player
 */

/* ============================================
   CAROUSEL VIEW — Horizontal thumbnail strip
   ============================================ */
.video-reels-container {
    direction: ltr;
    text-align: left;
    position: relative;
    width: 100%;
    overflow: hidden;
    padding: 12px 0;
}

.video-reels-feed {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    padding: 0 16px;
    -webkit-overflow-scrolling: touch;
}

.video-reels-feed::-webkit-scrollbar {
    display: none;
}

/* Carousel card */
.video-reel-card {
    direction: ltr;
    flex: 0 0 130px;
    width: 130px;
    height: 200px;
    border-radius: 14px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    background: #1a1a2e;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.video-reel-card:hover {
    transform: scale(1.04);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.reel-video-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.reel-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.reel-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, transparent 40%, rgba(0, 0, 0, 0.75) 100%);
    pointer-events: none;
}

.reel-card-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.video-reel-card:hover .reel-card-play {
    opacity: 1;
}

.reel-card-play svg {
    width: 18px;
    height: 18px;
    color: #fff;
    margin-left: 2px;
}

.reel-card-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 10px;
    z-index: 2;
}

.reel-card-title {
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.reel-card-views {
    display: flex;
    align-items: center;
    gap: 3px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 11px;
    margin-top: 4px;
}

.reel-card-views svg {
    width: 12px;
    height: 12px;
    opacity: 0.8;
}

/* Carousel scroll arrows */
.reels-scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: background 0.2s;
    color: #333;
}

.reels-scroll-btn:hover {
    background: #fff;
}

.reels-scroll-btn svg {
    width: 18px;
    height: 18px;
}

.reels-scroll-prev {
    left: 4px;
}

.reels-scroll-next {
    right: 4px;
}

/* Loader */
.video-reels-loader {
    flex: 0 0 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.loader-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.video-reels-loader.hidden {
    display: none;
}

/* ============================================
   FULL-SCREEN PLAYER — Overlay + Snap Scroll
   ============================================ */
.reels-player-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    background: #000;
    z-index: 2147483647 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    direction: ltr;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.reels-player-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Player wrapper — contains the scroll container */
.reels-player-wrapper {
    position: relative;
    width: 100%;
    max-width: 420px;
    height: 100%;
    overflow: hidden;
    background: #000;
}

@media (min-width: 768px) {
    .reels-player-wrapper {
        height: 92vh;
        border-radius: 16px;
        box-shadow: 0 0 80px rgba(0, 0, 0, 0.5);
    }
}

/* Vertical snap-scroll container */
.reels-scroll-container {
    width: 100%;
    height: 100%;
    overflow-y: scroll;
    overflow-x: hidden;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.reels-scroll-container::-webkit-scrollbar {
    display: none;
}

/* Each reel slide = one full screen */
.reel-slide {
    position: relative;
    width: 100%;
    height: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    flex-shrink: 0;
    overflow: hidden;
    background: #000;
}

/* Video fills the slide */
.slide-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
}

/* Close button — top left */
.reels-close-btn {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 100;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: background 0.2s;
}

.reels-close-btn:hover {
    background: rgba(0, 0, 0, 0.6);
}

.reels-close-btn svg {
    width: 20px;
    height: 20px;
}

/* Mute button — top right */
.player-mute-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 100;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: background 0.2s;
}

.player-mute-btn:hover {
    background: rgba(0, 0, 0, 0.6);
}

.player-mute-btn svg {
    width: 18px;
    height: 18px;
}

/* Progress bar per slide */
.slide-progress {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
    z-index: 20;
}

.slide-progress-bar {
    height: 100%;
    width: 0%;
    background: #fff;
    transition: width 0.1s linear;
}

/* Play/Pause indicator */
.slide-play-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15;
    pointer-events: none;
    opacity: 0;
    transition: transform 0.15s ease, opacity 0.25s ease;
}

.slide-play-indicator.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.slide-play-indicator svg {
    width: 32px;
    height: 32px;
    color: #fff;
}

/* Info overlay — bottom left */
.slide-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 16px 24px;
    z-index: 15;
    background: linear-gradient(#00000000, #00000000, #00000030, #0000003b 40%);
    pointer-events: none;
}

.slide-title {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.slide-caption {
    margin: 0 0 8px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.4;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.slide-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.slide-tag {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Action buttons — right side */
.slide-actions {
    position: absolute;
    right: 10px;
    bottom: 110px;
    z-index: 15;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.slide-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
    color: #fff;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
    transition: transform 0.15s ease;
}

.slide-action-btn:hover {
    transform: scale(1.1);
}

.slide-action-btn:active {
    transform: scale(0.95);
}

.slide-action-btn .icon-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.slide-action-btn svg {
    width: 22px;
    height: 22px;
}

.slide-action-btn .action-label {
    font-size: 11px;
    font-weight: 500;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.slide-action-btn.copied .icon-circle {
    background: rgba(16, 185, 129, 0.5);
}

/* Scroll hint — a subtle down-arrow animation */
.reel-slide:first-child::after {
    content: '';
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 4px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 2px;
    z-index: 20;
    animation: scrollHint 2s ease-in-out infinite;
}

@keyframes scrollHint {

    0%,
    100% {
        opacity: 0.4;
        transform: translateX(-50%) translateY(0);
    }

    50% {
        opacity: 0.8;
        transform: translateX(-50%) translateY(4px);
    }
}

/* Mobile adjustments */
@media (max-width: 600px) {
    .reels-player-wrapper {
        max-width: 100%;
        border-radius: 0;
    }

    .reels-close-btn {
        top: 12px;
        left: 12px;
    }

    .player-mute-btn {
        top: 12px;
        right: 12px;
    }
}