/**
 * Tirhutwani Reels & Video Modal Player Stylesheet
 * Responsive 9:16 Fullscreen Player, Overlays, and Controls
 */

/* ══════════════════════════════════════════════════════════
   MODAL BACKDROP & WRAPPER
   ══════════════════════════════════════════════════════════ */
#reelModalViewer {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
    box-sizing: border-box;
    padding: 8px;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

#reelModalViewer.is-open {
    display: flex !important;
    opacity: 1 !important;
}

/* ══════════════════════════════════════════════════════════
   FRAME WRAPPER & 9:16 VIDEO BOX (TIGHT INTEGRATED LAYOUT)
   ══════════════════════════════════════════════════════════ */
.reels-modal-frame-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100dvh;
    padding: 8px 12px;
    gap: 8px; /* Clean 8px gap between top header and video frame */
    box-sizing: border-box;
    overflow: hidden;
}

/* TOP BAR & COUNTER (DIRECTLY ATOP VIDEO FRAME) */
.reels-modal-top-bar {
    position: relative;
    width: min(calc((100dvh - 80px) * 9 / 16), calc(100vw - 24px));
    max-width: 420px;
    margin: 0 auto;
    padding: 0 2px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    z-index: 100002;
    box-sizing: border-box;
    flex-shrink: 0;
}

.reels-modal-top-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    overflow: hidden;
    flex: 1;
    text-align: center;
}

.reels-modal-counter-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 5px 11px;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #ffffff !important;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
    white-space: nowrap;
    margin-left: 2px;
}

.reel-badge-platform {
    font-size: 10px !important;
    font-weight: 700 !important;
    padding: 3px 8px !important;
    border-radius: 9999px !important;
    color: #ffffff !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4) !important;
    white-space: nowrap !important;
}

.reel-badge-category {
    background: #ffffff !important;
    color: #0f172a !important;
    border: 1px solid rgba(0, 0, 0, 0.12) !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    padding: 3px 8px !important;
    border-radius: 9999px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25) !important;
    white-space: nowrap !important;
}

:root.dark .reel-badge-category,
html.dark .reel-badge-category,
body.dark .reel-badge-category {
    background: #1e293b !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5) !important;
}

.reels-modal-time-badge {
    font-size: 10px;
    font-weight: 600;
    color: #e2e8f0;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 3px 8px;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
}

.reels-modal-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
    transition: background 0.2s, transform 0.15s;
    margin-right: 2px;
}

.reels-modal-close-btn:hover {
    background: #ef4444;
    transform: scale(1.08);
}

/* VIDEO PLAYER BODY ROW */
.reels-modal-body-row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    box-sizing: border-box;
}

.reels-modal-video-box {
    position: relative;
    height: min(calc(100dvh - 80px), calc(100vw - 24px) * 16 / 9);
    width: min(calc((100dvh - 80px) * 9 / 16), calc(100vw - 24px));
    max-width: 420px;
    aspect-ratio: 9 / 16;
    background: #000000;
    border-radius: 1.25rem;
    overflow: hidden;
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(255, 255, 255, 0.15);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    margin: 0 auto;
    box-sizing: border-box;
    flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════
   ACTIVE EMBED CONTAINER (IFRAME & VIDEO 100% RESPONSIVE)
   ══════════════════════════════════════════════════════════ */
#activeEmbedContainer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #000000 !important;
    overflow: hidden !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

#activeEmbedContainer video {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    border: none !important;
    object-fit: contain !important; /* Full video visible, no chopping/cropping from right */
    background: #000000 !important;
}

#activeEmbedContainer iframe,
#activeEmbedContainer .fb-video {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    border: none !important;
    overflow: hidden !important;
}

/* ══════════════════════════════════════════════════════════
   BOTTOM CAPTION OVERLAY (Elevated Above Progress Bar)
   ══════════════════════════════════════════════════════════ */
.reels-modal-bottom-overlay {
    position: absolute;
    bottom: 74px; /* Balanced clearance above bottom progress bar and sound controls */
    left: 10px;
    right: 10px;
    z-index: 20;
    padding: 8px 12px;
    background: rgba(15, 23, 42, 0.72) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    color: #ffffff !important;
    pointer-events: none;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 3px;
    transition: all 0.2s ease;
}

.reels-modal-bottom-overlay a,
.reels-modal-bottom-overlay button {
    pointer-events: auto;
}

.reels-modal-title {
    color: #ffffff !important;
    font-weight: 700 !important;
    font-size: 12.5px !important;
    line-height: 1.3 !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95);
    margin: 0 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.reels-modal-caption {
    color: #cbd5e1 !important;
    font-size: 11px !important;
    line-height: 1.25 !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95);
    margin: 1px 0 0 0 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.reels-link-original {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 600;
    color: #fde047;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(253, 224, 71, 0.4);
    padding: 2px 8px;
    border-radius: 9999px;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
    flex-shrink: 0;
}

.reels-link-original:hover {
    background: #fde047;
    color: #000000;
}

/* ══════════════════════════════════════════════════════════
   CENTER PLAY / PAUSE OVERLAY (FOR MOBILE / TAP PLAY)
   ══════════════════════════════════════════════════════════ */
.reels-modal-center-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.85);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 38;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
    transition: transform 0.2s ease, background 0.2s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.reels-modal-center-play:hover {
    transform: translate(-50%, -50%) scale(1.1);
    background: var(--color-primary, #b91c1c);
}

/* ══════════════════════════════════════════════════════════
   SIDE ACTION CONTROLS (DOCKED INSIDE VIDEO FRAME)
   ══════════════════════════════════════════════════════════ */
.reels-modal-side-controls {
    position: absolute;
    right: 12px;
    bottom: 84px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 40;
    pointer-events: auto;
}

.reels-ctrl-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
    transition: transform 0.15s, background 0.15s;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.reels-ctrl-btn:hover {
    background: var(--color-primary, #b91c1c);
    transform: scale(1.08);
}

.reels-ctrl-btn:active {
    transform: scale(0.94);
}

/* ══════════════════════════════════════════════════════════
   MOBILE RESPONSIVE RULES (<= 768px)
   ══════════════════════════════════════════════════════════ */
@@media (max-width: 768px) {
    #reelModalViewer {
        padding: 4px;
    }
    .reels-modal-frame-wrapper {
        padding: 4px 6px;
        gap: 6px;
        height: 100dvh;
        max-height: 100dvh;
    }
    .reels-modal-top-bar {
        width: min(calc((100dvh - 64px) * 9 / 16), calc(100vw - 12px));
        max-width: 100vw;
        padding: 0;
    }
    .reels-modal-video-box {
        height: min(calc(100dvh - 64px), calc(100vw - 12px) * 16 / 9);
        width: min(calc((100dvh - 64px) * 9 / 16), calc(100vw - 12px));
        max-width: 100vw;
        aspect-ratio: 9 / 16;
        border-radius: 0.85rem;
    }
    .reels-modal-side-controls {
        right: 8px;
        bottom: 74px;
        gap: 7px;
        z-index: 40;
    }
    .reels-modal-bottom-overlay {
        bottom: 68px;
        left: 8px;
        right: 56px; /* Space for docked side buttons */
        padding: 6px 10px;
    }
    .reels-ctrl-btn {
        width: 38px;
        height: 38px;
        background: rgba(15, 23, 42, 0.9);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.7);
    }
    .reels-modal-center-play {
        width: 56px;
        height: 56px;
    }
}
