/**
 * Facebook-Style Video Features CSS
 */

.fb-video-wrapper {
    position: relative;
    display: block;
    width: 100%;
    background: #000;
    border-radius: 0;
    overflow: hidden;
    /* Mobile: Prevent double-tap zoom and other gestures */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

.fb-video-wrapper video {
    display: block;
    width: 100%;
    cursor: pointer;
}

/* Sound Indicator */
.fb-sound-indicator {
    position: absolute;
    bottom: 50px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    z-index: 10;
}

.fb-sound-indicator:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.fb-sound-indicator svg {
    width: 20px;
    height: 20px;
    color: #fff;
}

.fb-sound-indicator.fb-sound-muted .fb-icon-unmuted,
.fb-sound-indicator.fb-sound-unmuted .fb-icon-muted {
    display: none;
}

.fb-sound-indicator.fb-sound-muted .fb-icon-muted,
.fb-sound-indicator.fb-sound-unmuted .fb-icon-unmuted {
    display: block;
}

/* Progress Bar */
.fb-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    z-index: 10;
}

.fb-progress-fill {
    height: 100%;
    background: var(--hbn-primary, #7B3FF2);
    width: 0;
    transition: width 0.1s linear;
}

.fb-video-wrapper:hover .fb-progress-bar {
    height: 6px;
}

/* Picture-in-Picture Button */
.fb-pip-button {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.75);
    border: none;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.2s, background 0.2s;
    z-index: 15;
    padding: 0;
}

.fb-video-wrapper:hover .fb-pip-button {
    opacity: 1;
}

.fb-pip-button:hover {
    background: rgba(0, 0, 0, 0.95);
}

.fb-pip-button svg {
    width: 20px;
    height: 20px;
    fill: #ffffff !important;
    color: #ffffff !important;
    display: block;
}

/* Heart Animation (double-tap to like) */
.fb-heart-animation {
    position: absolute;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0);
    animation: fb-heart-pop 1s ease-out forwards;
    z-index: 100;
}

.fb-heart-animation svg {
    width: 80px;
    height: 80px;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

@keyframes fb-heart-pop {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    15% {
        transform: translate(-50%, -50%) scale(1.2);
    }
    30% {
        transform: translate(-50%, -50%) scale(0.95);
    }
    45% {
        transform: translate(-50%, -50%) scale(1);
    }
    80% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1) translateY(-30px);
        opacity: 0;
    }
}

/* Autoplay indicator */
.fb-video-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.1) 0%,
        transparent 20%,
        transparent 80%,
        rgba(0, 0, 0, 0.2) 100%
    );
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s;
}

.fb-video-wrapper:hover::before {
    opacity: 1;
}

/* Mobile Touch Feedback */
@media (max-width: 768px) {
    .fb-sound-indicator {
        width: 44px;
        height: 44px;
        bottom: 56px;
        right: 8px;
    }
    
    .fb-sound-indicator svg {
        width: 24px;
        height: 24px;
    }
    
    /* Always show controls on mobile (no hover) */
    .fb-pip-button,
    .fb-fullscreen-button {
        width: 44px;
        height: 44px;
        opacity: 1 !important;
        background: rgba(0, 0, 0, 0.8) !important;
    }
    
    .fb-pip-button svg,
    .fb-fullscreen-button svg {
        width: 24px;
        height: 24px;
        fill: #ffffff !important;
        color: #ffffff !important;
    }
    
    .fb-progress-bar {
        height: 5px;
    }
    
    .fb-heart-animation svg {
        width: 100px;
        height: 100px;
    }
    
    /* Active/pressed state for touch feedback */
    .fb-sound-indicator:active,
    .fb-pip-button:active,
    .fb-fullscreen-button:active {
        transform: scale(0.9);
        background: rgba(255, 255, 255, 0.3);
    }
    
    /* Safe area for notched devices */
    .fb-video-wrapper {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
    
    /* Larger tap hint text on mobile */
    .fb-video-wrapper.fb-show-tap-hint::after {
        font-size: 16px;
        padding: 14px 24px;
    }
}

/* Fullscreen button */
.fb-fullscreen-button {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.75);
    border: none;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.2s, background 0.2s;
    z-index: 15;
    padding: 0;
}

.fb-video-wrapper:hover .fb-fullscreen-button {
    opacity: 1;
}

.fb-fullscreen-button:hover {
    background: rgba(0, 0, 0, 0.95);
}

.fb-fullscreen-button svg {
    width: 20px;
    height: 20px;
    fill: #ffffff !important;
    color: #ffffff !important;
    display: block;
}

/* Hide fullscreen when in fullscreen mode */
.fb-video-wrapper:fullscreen .fb-fullscreen-button,
.fb-video-wrapper:-webkit-full-screen .fb-fullscreen-button {
    display: none;
}

/* Fullscreen video styling */
.fb-video-wrapper:fullscreen,
.fb-video-wrapper:-webkit-full-screen {
    background: #000;
    border-radius: 0;
}

.fb-video-wrapper:fullscreen video,
.fb-video-wrapper:-webkit-full-screen video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* YouTube/Vimeo iframe support */
.ps-media--video .fb-video-wrapper,
.video-thumbnail .fb-video-wrapper {
    border-radius: 0;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .fb-video-wrapper {
        background: #1a1a1a;
    }
    
    .fb-progress-bar {
        background: rgba(255, 255, 255, 0.2);
    }
}

/* PeepSo video integration */
.ps-media-video video,
.cstream-attachment video,
.ps-lightbox video {
    cursor: pointer;
}

/* ===========================================
   9:16 Portrait Video Handling (TikTok/Reels)
   =========================================== */

/* Portrait video container - capped height with centered video */
.fb-video-wrapper.fb-video-portrait {
    max-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.fb-video-wrapper.fb-video-portrait video {
    width: auto;
    height: 100%;
    max-height: 600px;
    max-width: 100%;
    object-fit: contain;
    position: relative;
    z-index: 2;
}

/* Blur background for portrait videos */
.fb-blur-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    overflow: hidden;
}

.fb-blur-canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(30px) saturate(1.2) brightness(0.6);
    transform: scale(1.2);
}

/* Landscape videos - standard full-width display */
.fb-video-wrapper.fb-video-landscape video {
    width: 100%;
    height: auto;
}

/* Square videos */
.fb-video-wrapper.fb-video-square video {
    width: 100%;
    height: auto;
}

/* Fullscreen hint for mobile portrait videos */
.fb-fullscreen-hint {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    z-index: 20;
    cursor: pointer;
    transition: opacity 0.3s, transform 0.2s;
    animation: fb-hint-bounce 2s ease-in-out infinite;
}

.fb-fullscreen-hint svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.fb-fullscreen-hint:active {
    transform: translateX(-50%) scale(0.95);
}

.fb-fullscreen-hint.fb-hint-fade-out {
    opacity: 0;
    pointer-events: none;
}

@keyframes fb-hint-bounce {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    50% {
        transform: translateX(-50%) translateY(-5px);
    }
}

/* Mobile portrait video adjustments */
@media (max-width: 768px) {
    .fb-video-wrapper.fb-video-portrait {
        max-height: 80vh;
    }
    
    .fb-video-wrapper.fb-video-portrait video {
        max-height: 80vh;
    }
    
    .fb-fullscreen-hint {
        bottom: 70px;
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .fb-fullscreen-hint svg {
        width: 20px;
        height: 20px;
    }
}

/* Small mobile - even more compact */
@media (max-width: 480px) {
    .fb-video-wrapper.fb-video-portrait {
        max-height: 70vh;
    }
    
    .fb-video-wrapper.fb-video-portrait video {
        max-height: 70vh;
    }
}

/* Portrait video in fullscreen - full native display */
.fb-video-wrapper.fb-video-portrait:fullscreen,
.fb-video-wrapper.fb-video-portrait:-webkit-full-screen {
    max-height: none;
}

.fb-video-wrapper.fb-video-portrait:fullscreen video,
.fb-video-wrapper.fb-video-portrait:-webkit-full-screen video {
    max-height: 100vh;
    width: auto;
    height: 100%;
}

.fb-video-wrapper.fb-video-portrait:fullscreen .fb-blur-bg,
.fb-video-wrapper.fb-video-portrait:-webkit-full-screen .fb-blur-bg {
    display: block;
}

/* Hide fullscreen hint in fullscreen mode */
.fb-video-wrapper:fullscreen .fb-fullscreen-hint,
.fb-video-wrapper:-webkit-full-screen .fb-fullscreen-hint {
    display: none;
}

/* Tap hint on first visit */
.fb-video-wrapper.fb-show-tap-hint::after {
    content: 'Tap to unmute';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    pointer-events: none;
    animation: fb-hint-fade 3s ease-out forwards;
    z-index: 20;
}

@keyframes fb-hint-fade {
    0%, 70% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}
