/* =============================================
   Reels Feed — scoped under .reels-feed
   ============================================= */

/* Feed container — arranca justo debajo del header del theme v2 */
.reels-feed {
    position: fixed;
    top: var(--tn-header-height, 90px);
    left: 0;
    width: 100%;
    height: calc(100vh  - var(--tn-header-height, 90px)); /* fallback */
    height: calc(100svh - var(--tn-header-height, 90px)); /* small viewport (más conservador) */
    height: calc(100dvh - var(--tn-header-height, 90px)); /* dynamic viewport (ideal) */
    overflow-y: scroll;
    overflow-x: hidden;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
    z-index: 1031; /* por encima del navbar Bootstrap (1030) */
    background: #000;
}

/* Ocultar solo lo innecesario en reels: toolbar y sidebar */
body.page-reels .tn-shop-toolbar,
body.page-reels .tn-shop-sidebar,
body.page-reels #WAButton {
    display: none !important;
}

body.page-reels .col-xl-10,
body.page-reels .col-lg-9,
body.page-reels .col-md-8 {
    max-width: 100%;
    flex: 0 0 100%;
    padding: 0;
}

/* Each reel item */
.reel-item {
    position: relative;
    width: 100%;
    height: calc(100vh  - var(--tn-header-height, 90px)); /* fallback */
    height: calc(100svh - var(--tn-header-height, 90px)); /* small viewport */
    height: calc(100dvh - var(--tn-header-height, 90px)); /* dynamic viewport */
    scroll-snap-align: start;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Media wrapper */
.reel-media-wrapper {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    overflow: hidden;
    touch-action: pan-y;
}

/* Horizontal media track */
.reel-media-track {
    display: flex;
    height: 100%;
    transition: transform 0.25s ease;
    will-change: transform;
}

.reel-media-slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    position: relative;
}

/* Video */
.reel-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Image — blurred backdrop effect */
.reel-image-bg {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(20px) brightness(0.55);
    transform: scale(1.1);
    z-index: 0;
}

.reel-image {
    position: relative;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 1;
}

/* YouTube wrapper */
.reel-youtube-wrapper {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #000;
    overflow: hidden;
}

.reel-youtube-poster {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.4s ease;
    z-index: 1;
}

.reel-youtube {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    border: none;
    z-index: 2;
}

/* Video progress bar */
.reel-video-progress {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 3px;
    background: rgba(255,255,255,0.3);
    z-index: 5;
}

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

/* Unmute button */
.reel-unmute-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(0,0,0,0.5);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    font-size: 18px;
}

.reel-unmute-btn:focus { outline: 2px solid #fff; }

/* Dots */
.reel-dots {
    position: absolute;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 10;
}

.reel-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
    transition: background 0.2s;
}

.reel-dot.active { background: #fff; }

/* Caption overlay */
.reel-caption {
    position: absolute;
    bottom: 0; left: 0; right: 80px;
    padding: 40px 16px calc(80px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 100%);
    color: #fff;
    z-index: 10;
}

.reel-brand {
    font-size: 13px;
    color: rgba(255,255,255,0.75);
    margin: 0 0 6px;
}

.reel-title {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    margin-bottom: 4px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.reel-title:hover { color: rgba(255,255,255,0.85); text-decoration: none; }

.reel-price { font-size: 14px; color: #fff; }

/* Side action buttons */
.reel-actions {
    position: absolute;
    right: 12px;
    bottom: calc(80px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 10;
}

.reel-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.reel-action-btn:hover,
.reel-action-btn:focus {
    background: rgba(0,0,0,0.75);
    color: #fff;
    outline: 2px solid #fff;
    text-decoration: none;
}

.reel-cart-form {
    margin: 0;
    padding: 0;
}

/* Empty state */
.reel-empty-state {
    min-height: 100vh;
    color: #fff;
    background: #111;
}

/* Desktop: centrar el reproductor */
@media (min-width: 992px) {
    .reels-feed {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .reel-item {
        width: 450px;
        max-width: 100vw;
    }
}

/* Shop view toggle button */
.shop-view .reel-view {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 2px;
    color: #606975;
    transition: color 0.2s;
}

.shop-view .reel-view.active,
.shop-view .reel-view:hover { color: #0da9ef; }

/* Swipe hint (primera visita) */
.reel-swipe-hint {
    position: fixed;
    bottom: calc(140px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 2000;
    pointer-events: none;
    animation: reelHintFade 3.2s ease forwards;
}

.reel-hint-icon {
    font-size: 32px;
    color: #fff;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6));
    animation: reelHintBounce 0.7s ease infinite alternate;
}

.reel-hint-label {
    font-size: 13px;
    color: rgba(255,255,255,0.9);
    background: rgba(0,0,0,0.45);
    padding: 4px 12px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

@keyframes reelHintFade {
    0%   { opacity: 0; }
    15%  { opacity: 1; }
    75%  { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes reelHintBounce {
    from { transform: translateY(0); }
    to   { transform: translateY(-10px); }
}
