/* Mobile-First Optimizations for Adult Site */
/* Focused on performance, usability, and touch interactions */

/* ============================================
   MOBILE PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* Enable animations and previews on mobile */
@media (max-width: 768px) {
    * {
        -webkit-tap-highlight-color: rgba(255, 144, 0, 0.2);
    }

    /* Smooth scrolling */
    html {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        overflow-y: auto;
    }

    /* Prevent text size adjustment on orientation change */
    body {
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
        overflow-y: auto;
        position: relative;
    }

    /* Optimize images for mobile */
    img {
        max-width: 100%;
        height: auto;
        image-rendering: -webkit-optimize-contrast;
    }

    /* Hardware acceleration for smooth scrolling and previews */
    .preview-video,
    .preview-container {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }

    /* Enable video preview on mobile */
    .preview-container {
        position: relative;
        width: 100%;
        height: 100%;
    }
}

/* ============================================
   MOBILE HEADER & NAVIGATION
   ============================================ */

@media (max-width: 768px) {

    /* Non-sticky header on mobile - scrolls away */
    .header {
        position: relative;
        z-index: 1000;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    }

    /* Non-sticky navigation on mobile - scrolls away */
    .nav {
        position: relative;
        z-index: 999;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    }

    /* Horizontal scroll indicator */
    .nav::after {
        content: '';
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 30px;
        background: linear-gradient(to left, #1a1a1a, transparent);
        pointer-events: none;
    }

    /* Hide scrollbar but keep functionality */
    .nav .container::-webkit-scrollbar {
        display: none;
    }

    .nav .container {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
}

/* ============================================
   MOBILE VIDEO GRID OPTIMIZATIONS
   ============================================ */

@media (max-width: 768px) {

    /* Optimize grid for mobile viewing */
    .videos-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 0;
    }

    /* Single column for very small screens */
    @media (max-width: 360px) {
        .videos-grid {
            grid-template-columns: 1fr;
        }
    }

    /* Video card touch optimizations */
    .video-card {
        position: relative;
        touch-action: auto;
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }

    /* Prevent context menu on video thumbnails */
    .video-thumbnail,
    .video-thumbnail img,
    .preview-container,
    .preview-video {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
        pointer-events: auto;
    }

    /* Optimize thumbnail loading */
    .video-thumbnail img {
        will-change: auto;
    }

    /* Subtle hover effects on mobile */
    .video-card:hover {
        box-shadow: 0 4px 12px rgba(255, 144, 0, 0.2);
    }

    /* Enable preview videos on mobile */
    .video-thumbnail .preview-video,
    .video-thumbnail .preview-image,
    .video-thumbnail .preview-gif,
    .hover-video-player {
        display: block !important;
        pointer-events: auto !important;
    }

    /* Ensure preview container works on mobile */
    .preview-container {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 10;
        pointer-events: none;
    }

    .preview-container video {
        width: 100%;
        height: 100%;
        object-fit: cover;
        pointer-events: none;
    }
}

/* ============================================
   MOBILE TYPOGRAPHY
   ============================================ */

@media (max-width: 768px) {

    /* Hide section title on mobile */
    .section-title {
        display: none;
    }
    
    /* Hide sort bar on mobile */
    .sort-bar {
        display: none;
    }
    
    /* Adjust section header */
    .section-header {
        margin-bottom: 10px;
    }

    /* Readable text sizes */
    .video-title {
        font-size: 13px;
        line-height: 1.3;
        max-height: 2.6em;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .video-channel {
        font-size: 11px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .video-meta {
        font-size: 10px;
    }

    /* Prevent text selection on interactive elements */
    .nav-link,
    .pagination-btn,
    .search-btn,
    .category-tag,
    .tag-item {
        -webkit-user-select: none;
        user-select: none;
    }
}

/* ============================================
   MOBILE TOUCH TARGETS
   ============================================ */

@media (max-width: 768px) {

    /* Minimum 44px touch targets (iOS guidelines) */
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .search-btn,
    .pagination-btn,
    .load-more-btn {
        min-height: 44px;
        min-width: 44px;
    }

    /* Larger tap area for video cards */
    .video-card {
        min-height: 200px;
    }

    /* Category cards */
    .category-card {
        min-height: 60px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ============================================
   MOBILE SEARCH BAR
   ============================================ */

@media (max-width: 768px) {
    .search-bar {
        width: 100%;
        margin-top: 10px;
    }

    .search-bar input {
        font-size: 16px;
        /* Prevents iOS zoom */
        padding: 12px 15px;
        border-radius: 8px;
    }

    .search-btn {
        padding: 12px 20px;
        border-radius: 8px;
        white-space: nowrap;
    }
}

/* ============================================
   MOBILE PAGINATION
   ============================================ */

@media (max-width: 768px) {
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        padding: 15px 5px;
    }

    .pagination-btn {
        padding: 8px 12px;
        min-width: 40px;
        font-size: 14px;
        border-radius: 6px;
    }

    .pagination-info {
        width: 100%;
        text-align: center;
        order: -1;
        margin-bottom: 10px;
        font-size: 12px;
    }

    /* Hide some page numbers on very small screens */
    @media (max-width: 480px) {
        .pagination-btn:not(.active):not(:first-child):not(:last-child):not(:nth-child(2)):not(:nth-last-child(2)) {
            display: none;
        }
    }
}

/* ============================================
   MOBILE LANDSCAPE MODE
   ============================================ */

@media (max-width: 768px) and (orientation: landscape) {

    /* 3 columns in landscape */
    .videos-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Adjust header for landscape */
    .header .container {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .search-bar {
        flex: 1;
        min-width: 250px;
        margin-top: 0;
    }

    /* Compact navigation */
    .nav-link {
        padding: 10px 12px;
        font-size: 12px;
    }
}

/* ============================================
   MOBILE LOADING STATES
   ============================================ */

@media (max-width: 768px) {

    /* Loading spinner */
    .loading-spinner {
        width: 30px;
        height: 30px;
        border: 3px solid #2a2a2a;
        border-top-color: #ff9000;
        border-radius: 50%;
        animation: spin 0.8s linear infinite;
    }

    @keyframes spin {
        to {
            transform: rotate(360deg);
        }
    }

    /* Skeleton loading for video cards */
    .video-card.loading {
        background: linear-gradient(90deg,
                #1a1a1a 25%,
                #2a2a2a 50%,
                #1a1a1a 75%);
        background-size: 200% 100%;
        animation: loading 1.5s ease-in-out infinite;
    }

    @keyframes loading {
        0% {
            background-position: 200% 0;
        }

        100% {
            background-position: -200% 0;
        }
    }
}

/* ============================================
   MOBILE SAFE AREAS (iPhone X+)
   ============================================ */

@media (max-width: 768px) {

    /* Support for notch devices */
    .header,
    .nav,
    .main,
    .footer {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .header {
        padding-top: env(safe-area-inset-top);
    }

    .footer {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ============================================
   MOBILE ACCESSIBILITY
   ============================================ */

@media (max-width: 768px) {

    /* Focus states for keyboard navigation */
    .video-card:focus,
    .nav-link:focus,
    .search-btn:focus,
    .pagination-btn:focus {
        outline: 2px solid #ff9000;
        outline-offset: 2px;
    }

    /* High contrast mode support */
    @media (prefers-contrast: high) {

        .video-card,
        .category-card {
            border: 2px solid #fff;
        }

        .nav-link.active {
            background: #ff9000;
            color: #000;
        }
    }

    /* Reduced motion support */
    @media (prefers-reduced-motion: reduce) {
        * {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }
}

/* ============================================
   MOBILE PULL-TO-REFRESH PREVENTION
   ============================================ */

@media (max-width: 768px) {
    body {
        overscroll-behavior-y: contain;
    }
    
    /* WATCH PAGE SCROLLING FIXES */
    .watch-container {
        touch-action: auto !important;
        -webkit-overflow-scrolling: touch !important;
        overflow-y: auto !important;
    }
    
    .watch-container * {
        touch-action: auto !important;
    }
    
    /* Video player iframe - allow its own touch handling */
    #videoIframe,
    iframe[src*="xvideos"],
    iframe[src*="embedframe"] {
        touch-action: manipulation !important;
        pointer-events: auto !important;
    }
    
    /* Related videos section */
    .related-videos,
    .related-section {
        touch-action: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* Ensure body scrolls on ALL pages */
    body {
        overflow-y: auto !important;
        position: relative !important;
        height: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* Main container */
    .main {
        overflow-y: visible !important;
        height: auto !important;
        touch-action: auto !important;
    }
}

/* ============================================
   MOBILE VIDEO QUALITY BADGES & THUMBNAILS
   ============================================ */

/* Quality badge styles for all devices */
.video-quality {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: #ff9000;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: bold;
    z-index: 15;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Thumbnail fallback for failed images */
.video-thumbnail img {
    background: #2a2a2a;
    min-height: 120px;
    object-fit: cover;
}

.video-thumbnail img[src=""],
.video-thumbnail img:not([src]),
.video-thumbnail img[src*="placeholder"] {
    background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    position: relative;
}

.video-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: bold;
    z-index: 15;
}

@media (max-width: 768px) {
    .video-quality {
        font-size: 9px;
        padding: 2px 5px;
        top: 5px;
        left: 5px;
        letter-spacing: 0.3px;
    }

    .video-duration {
        font-size: 10px;
        padding: 2px 5px;
        bottom: 5px;
        right: 5px;
    }
}

/* ============================================
   MOBILE CATEGORY PAGES
   ============================================ */

@media (max-width: 768px) {
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .category-card {
        padding: 15px 10px;
        min-height: 70px;
    }

    .category-name {
        font-size: 13px;
        text-align: center;
    }

    .category-count {
        font-size: 11px;
    }
}

/* ============================================
   MOBILE FOOTER
   ============================================ */

@media (max-width: 768px) {
    .footer {
        padding: 20px 10px;
        margin-top: 30px;
    }

    .footer p {
        font-size: 11px;
        line-height: 1.5;
    }
}

/* ============================================
   TABLET OPTIMIZATIONS (768px - 1024px)
   ============================================ */

@media (min-width: 769px) and (max-width: 1024px) {
    .videos-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }

    .categories-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }

    .container {
        padding: 0 20px;
    }

    .video-title {
        font-size: 14px;
    }

    .search-bar {
        max-width: 500px;
    }
}

/* ============================================
   VERY SMALL SCREENS (< 360px)
   ============================================ */

@media (max-width: 360px) {
    .logo-text {
        font-size: 18px;
    }

    .nav-link {
        padding: 10px;
        font-size: 11px;
    }

    .video-title {
        font-size: 12px;
    }

    .video-info {
        padding: 6px;
    }

    .section-title {
        font-size: 16px;
    }
}


/* ============================================
   NO PLAY BUTTON - PREVIEW ONLY
   ============================================ */

/* Remove play button overlay */
.video-thumbnail::before {
    display: none !important;
}