/* ==================== PLAYER PAGE STYLES ==================== */
html, body {
    touch-action: manipulation;
    -ms-touch-action: manipulation;
}

.player-page {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    background: #000;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* ==================== AUTH MODAL ==================== */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-content {
    background: linear-gradient(180deg, #1a1a1a 0%, #0d0d0d 100%);
    border-radius: 20px;
    padding: 40px 30px;
    width: 100%;
    max-width: 360px;
    text-align: center;
    border: 1px solid #2a2a2a;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.auth-header h2 {
    font-size: 1.4rem;
    margin-bottom: 8px;
    color: #fff;
}

.auth-header p {
    color: #888;
    margin-bottom: 30px;
    font-size: 0.95rem;
}

.auth-content .form-group {
    margin-bottom: 16px;
}

.auth-content input {
    width: 100%;
    padding: 16px;
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 12px;
    color: #fff;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.auth-content input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.15);
}

.btn-watch {
    width: 100%;
    padding: 16px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
}

.btn-watch:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    filter: brightness(1.1);
}

.btn-watch .play-icon {
    font-size: 1rem;
}

.back-link {
    display: inline-block;
    margin-top: 24px;
    color: #666;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: #fff;
}

/* ==================== PLAYER CONTAINER ==================== */
.player-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.player-container.blurred {
    filter: blur(20px);
    pointer-events: none;
}

/* ==================== BACK BUTTON ==================== */
.back-button {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 100;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s ease;
}

.back-button svg {
    width: 24px;
    height: 24px;
}

.back-button:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

/* ==================== BACK TO TOP BUTTON ==================== */
.back-to-top-btn {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    width: 44px;
    height: 44px;
    background: var(--primary);
    opacity: 0.9;
    backdrop-filter: blur(10px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.back-to-top-btn svg {
    width: 24px;
    height: 24px;
}

.back-to-top-btn:hover {
    background: var(--primary);
    opacity: 1;
    transform: translateX(-50%) scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.back-to-top-btn:active {
    transform: translateX(-50%) scale(0.95);
}

/* ==================== NEW VIDEO INDICATOR ==================== */
.new-video-btn {
    position: fixed;
    top: 75px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    height: 36px;
    padding: 0 14px;
    background: rgba(37, 211, 102, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
    font-weight: 600;
    font-size: 0.9rem;
    animation: pulse-new 2s infinite;
}

@keyframes pulse-new {
    0%, 100% { box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4); }
    50% { box-shadow: 0 4px 25px rgba(37, 211, 102, 0.7); }
}

.new-video-btn svg {
    width: 18px;
    height: 18px;
}

.new-video-btn:hover {
    background: rgba(37, 211, 102, 1);
    transform: translateX(-50%) scale(1.05);
}

.new-video-btn:active {
    transform: translateX(-50%) scale(0.95);
}

.new-video-count {
    font-weight: 700;
}

/* ==================== VIDEOS FEED ==================== */
.videos-feed {
    width: 100%;
    height: 100%;
    height: 100vh;
    height: 100dvh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    overscroll-behavior-y: contain;
}

.videos-feed::-webkit-scrollbar {
    display: none;
}

/* ==================== VIDEO SLIDE ==================== */
.video-slide {
    width: 100%;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    flex-shrink: 0;
}

/* Poster thumbnail — covers the slide until video is confirmed playing */
.video-poster {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-color: #000;
    z-index: 2;
}

/* Video element — hidden until playback is confirmed smooth.
   This prevents the frozen first-frame flash on iOS. */
.video-player {
    position: relative;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% center;
    cursor: pointer;
    touch-action: pan-y;
    z-index: 1;
    background: #000;
    opacity: 0;
}

/* When loaded, show the video and fade out the poster.
   A very fast fade (80ms) blends the slight color difference between
   JPEG thumbnail and decoded video so it's imperceptible. */
.video-slide.video-ready .video-player {
    opacity: 1;
}

.video-slide.video-ready .video-poster {
    opacity: 0;
    pointer-events: none;
    transition: opacity 80ms ease;
}

/* ==================== VIDEO OVERLAY ==================== */
.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    z-index: 2;
}

/* Play/Pause Indicator */
.play-pause-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.play-pause-indicator.show {
    opacity: 1;
}

.play-pause-indicator .indicator-icon {
    font-size: 2rem;
    color: white;
    display: none;
}

.play-pause-indicator.show-play .play {
    display: block;
}

.play-pause-indicator.show-pause .pause {
    display: block;
}

/* Video Info */
.video-info {
    padding: 20px;
    padding-bottom: 30px;
    padding-right: 80px;
    background: linear-gradient(0deg, rgba(0,0,0,0.8) 0%, transparent 100%);
}

.video-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.event-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: rgba(255,255,255,0.9);
    margin-bottom: 4px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.event-date {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.6);
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.video-description {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.8);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Progress Bar */
.progress-container {
    width: 100%;
    height: 3px;
    background: rgba(255,255,255,0.2);
    position: absolute;
    bottom: 0;
    left: 0;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.1s linear;
}

/* ==================== SIDE ACTIONS ==================== */
.side-actions {
    position: absolute;
    right: 12px;
    bottom: 100px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 10;
}

.action-btn {
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: rgba(0, 0, 0, 0.6);
    transform: scale(1.1);
}

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

.action-btn.muted .icon-muted {
    display: block;
}

.action-btn.muted .icon-unmuted {
    display: none;
}

.action-btn:not(.muted) .icon-muted {
    display: none;
}

.action-btn:not(.muted) .icon-unmuted {
    display: block;
}

/* ==================== VIDEO COUNTER ==================== */
.video-counter {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.9);
}

/* ==================== FULLSCREEN TOGGLE ==================== */
.fullscreen-toggle {
    position: fixed;
    top: 60px;
    right: 20px;
    z-index: 100;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fullscreen-toggle svg {
    width: 20px;
    height: 20px;
}

.fullscreen-toggle:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

/* Fit-width mode */
.video-slide.fit-width .video-player {
    object-fit: contain;
    object-position: center center;
}

.video-slide.fit-width .video-poster {
    background-size: contain;
    background-repeat: no-repeat;
}

/* ==================== LANDSCAPE MODE ==================== */
@media (orientation: landscape) and (max-height: 500px) {
    /* Minimize UI to maximize video area */
    .back-button {
        top: 8px;
        left: 8px;
        width: 36px;
        height: 36px;
        opacity: 0.6;
    }

    .back-button svg {
        width: 18px;
        height: 18px;
    }

    .video-counter {
        top: 8px;
        right: 8px;
        padding: 4px 10px;
        font-size: 0.75rem;
        opacity: 0.6;
    }

    .fullscreen-toggle {
        top: 8px;
        right: 70px;
        width: 32px;
        height: 32px;
        opacity: 0.6;
    }

    .fullscreen-toggle svg {
        width: 16px;
        height: 16px;
    }

    .scroll-indicator {
        display: none;
    }

    .video-info {
        padding: 10px 70px 12px 10px;
    }

    .video-title {
        font-size: 1rem;
    }

    .side-actions {
        right: 8px;
        bottom: 50px;
        gap: 12px;
    }

    .action-btn {
        width: 38px;
        height: 38px;
    }

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

    .progress-container {
        height: 2px;
    }

    .back-to-top-btn {
        display: none !important;
    }

    .new-video-btn {
        display: none !important;
    }
}

/* ==================== SCROLL INDICATOR ==================== */
.scroll-indicator {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: rgba(255,255,255,0.7);
    font-size: 0.8rem;
    animation: bounce 2s infinite;
    transition: opacity 0.3s ease;
}

.scroll-indicator.hidden {
    opacity: 0;
    pointer-events: none;
}

.scroll-indicator svg {
    width: 24px;
    height: 24px;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    40% {
        transform: translateX(-50%) translateY(-10px);
    }
    60% {
        transform: translateX(-50%) translateY(-5px);
    }
}

/* ==================== NO VIDEOS ==================== */
.no-videos {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #666;
    text-align: center;
    padding: 20px;
}

.no-videos .empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.no-videos h3 {
    font-size: 1.3rem;
    margin-bottom: 10px;
    color: #888;
}

.no-videos p {
    color: #555;
}

/* ==================== SHARE MODAL ==================== */
.share-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1001;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

.share-content {
    background: #1a1a1a;
    border-radius: 20px 20px 0 0;
    padding: 30px 20px;
    width: 100%;
    max-width: 500px;
    text-align: center;
}

.share-content h3 {
    margin-bottom: 20px;
    font-size: 1.2rem;
}

.share-link-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.share-link-container input {
    flex: 1;
    padding: 14px;
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 10px;
    color: #fff;
    font-size: 0.9rem;
}

.btn-copy {
    padding: 14px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-copy:hover {
    filter: brightness(0.9);
}

.btn-close {
    width: 100%;
    padding: 14px;
    background: transparent;
    border: 1px solid #333;
    color: #888;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-close:hover {
    border-color: #666;
    color: #fff;
}

/* ==================== SAFE AREAS (iOS) ==================== */
@supports (padding-top: env(safe-area-inset-top)) {
    .back-button {
        top: calc(20px + env(safe-area-inset-top));
    }
    
    .video-counter {
        top: calc(20px + env(safe-area-inset-top));
    }
    
    .video-info {
        padding-bottom: calc(30px + env(safe-area-inset-bottom));
    }
    
    .side-actions {
        bottom: calc(100px + env(safe-area-inset-bottom));
    }
    
    .scroll-indicator {
        bottom: calc(30px + env(safe-area-inset-bottom));
    }
}

/* ==================== VIDEO LOADING STATE ==================== */
.video-slide .video-player {
    background: #000;
}

.video-slide::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 3;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.video-slide.show-spinner::before {
    opacity: 1;
}

.video-slide.loaded::before {
    opacity: 0;
    pointer-events: none;
}

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

/* ==================== RESPONSIVE ==================== */
/* Desktop only (wide + tall + has hover = not a phone in landscape) */
@media (min-width: 768px) and (min-height: 500px) {
    .video-slide {
        display: flex;
        justify-content: center;
    }
    
    .video-player {
        max-width: 400px;
        object-fit: contain;
        border-radius: 12px;
    }
    
    .video-overlay {
        max-width: 400px;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .side-actions {
        right: calc(50% - 230px);
    }
    
    .share-modal {
        align-items: center;
    }
    
    .share-content {
        border-radius: 20px;
    }
}

/* ==================== TAP FOR SOUND HINT ==================== */
.tap-for-sound-hint {
    position: fixed;
    right: 72px;
    bottom: 148px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: 20px;
    opacity: 0;
    transform: translateX(10px);
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s ease;
    white-space: nowrap;
}

.tap-for-sound-hint svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.tap-for-sound-hint.show {
    opacity: 1;
    transform: translateX(0);
    animation: hint-pulse 1.5s ease-in-out 2;
}

.tap-for-sound-hint.fade-out {
    opacity: 0;
    transform: translateX(10px);
    pointer-events: none;
}

@keyframes hint-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Position hint relative to side-actions in landscape */
@media (orientation: landscape) and (max-height: 500px) {
    .tap-for-sound-hint {
        right: 58px;
        bottom: 98px;
        font-size: 0.75rem;
        padding: 6px 12px;
    }
}

/* Position hint for desktop */
@media (min-width: 768px) and (min-height: 500px) {
    .tap-for-sound-hint {
        right: calc(50% - 180px);
    }
}

/* Safe area adjustment for iOS */
@supports (padding-top: env(safe-area-inset-top)) {
    .tap-for-sound-hint {
        bottom: calc(148px + env(safe-area-inset-bottom));
    }
}
