/* Responsive Styles for VideoHub Theme */

/* Header Responsive */
/* Flex row already follows the document direction; reversing it mirrors RTL twice. */
[dir="rtl"] .site-header .header-container,
[dir="rtl"] .site-header .header-left,
[dir="rtl"] .site-header .header-right {
    flex-direction: row;
}
@media (min-width: 768px) {
    [dir="rtl"] .site-header .nav-menu { flex-direction: row; }
}

@media (max-width: 1024px) {
    .header-container {
        padding: 12px 16px;
    }
    
    .header-center {
        max-width: 400px;
    }
}

@media (max-width: 767px) {
    .site-header {
        position: sticky;
        top: 0;
        z-index: 1000;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border-color);
    }
    
    .header-container {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 12px;
        position: relative;
    }
    
    .header-left {
        min-width: 0;
        order: 1;
        display: flex;
        align-items: center;
        gap: 12px;
    }
    
    .header-center {
        grid-column: 1 / -1;
        width: 100%;
        order: 3;
        max-width: 100%;
    }
    
    .header-right {
        width: auto;
        order: 2;
        margin-left: auto;
        display: flex;
        align-items: center;
        gap: 8px;
    }
    
    .site-title {
        font-size: 18px;
    }

    .site-branding { min-width: 0; }
    .site-title { margin: 0; overflow-wrap: anywhere; }
    .custom-logo { max-height: 44px; width: auto; max-width: 100%; object-fit: contain; }
    .header-right { flex-wrap: wrap; justify-content: flex-end; max-width: 48vw; }
    .btn, .user-avatar, .menu-toggle, .search-submit { min-height: 44px; }
    .btn-icon, .menu-toggle, .user-avatar { min-width: 44px; }
    .header-right .btn { padding: 8px 12px; }
    .search-form, .search-wrapper { width: 100%; min-width: 0; }
    .search-field { font-size: 16px; }
    .video-actions { display: flex; flex-wrap: wrap; gap: 8px; }
    .tag-archive-navigation-link { white-space: normal; overflow-wrap: anywhere; max-width: 100%; min-height: 44px; display: inline-flex; align-items: center; }
    .site-main.tag-archive-page { padding-top: 0; }
    
    .search-form {
        margin: 0;
    }
    
    /* Ensure buttons are clickable */
    .header-right .btn,
    .header-right .user-avatar,
    .header-right .upload-btn {
        position: relative;
        z-index: 10;
    }
}

/* Grid Responsive */
@media (max-width: 1440px) {
    .videos-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 18px;
    }
}

@media (max-width: 1024px) {
    .videos-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .container {
        padding: 0 16px;
    }
}

@media (max-width: 767px) {
    .videos-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .videos-toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
}

/* Video Card Responsive */
@media (max-width: 480px) {
    .video-card {
        border-radius: var(--radius-sm);
    }
    
    .video-info {
        padding: 10px 12px;
    }
    
    .video-title {
        font-size: 14px;
    }
    
    .video-meta {
        font-size: 12px;
    }
}

/* Footer Responsive */
@media (max-width: 1024px) {
    .footer-columns {
        grid-template-columns: repeat(2, 1fr);
        gap: 32px;
    }
}

@media (max-width: 767px) {
    .footer-columns {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .footer-bottom-content {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .footer-menu {
        flex-direction: column;
        gap: 12px;
    }
}

/* Navigation Responsive */
@media (max-width: 767px) {
    .main-navigation {
        position: absolute;
        top: 100%;
        bottom: auto;
        left: 0;
        width: min(85vw, 320px);
        max-height: 65vh;
        max-height: 65dvh;
        background: var(--bg-card);
        box-shadow: var(--shadow-lg);
        border-right: 1px solid var(--border-color);
        transform: translateX(-110%);
        transition: transform var(--transition-normal), visibility var(--transition-normal);
        z-index: var(--z-fixed);
        padding: 8px 12px;
        overflow-y: auto;
        visibility: hidden;
        pointer-events: none;
    }
    
    .main-navigation.active {
        transform: translateX(0);
        visibility: visible;
        pointer-events: auto;
    }
    
    .nav-menu {
        flex-direction: column;
        gap: 0;
        padding: 8px 0;
    }
    
    .nav-menu li {
        border-bottom: 1px solid var(--border-color);
    }
    
    .nav-menu li:last-child {
        border-bottom: none;
    }
    
    .nav-menu a {
        display: block;
        padding: 16px 20px;
    }
    
    .nav-menu a::after {
        display: none;
    }
    
    .menu-toggle {
        display: block;
    }

    body.mobile-navigation-open {
        overflow: hidden;
    }

    [dir="rtl"] .main-navigation {
        left: auto;
        right: 0;
        border-right: 0;
        border-left: 1px solid var(--border-color);
        transform: translateX(110%);
    }

    [dir="rtl"] .main-navigation.active {
        transform: translateX(0);
    }

    [dir="rtl"] .nav-menu {
        flex-direction: column;
    }

    [dir="rtl"] .site-header .header-left,
    [dir="rtl"] .site-header .header-right {
        flex-direction: row;
        margin: 0;
    }
    [dir="rtl"] .site-header .menu-toggle { margin: 0; }
    .site-header .main-navigation .nav-menu li { margin: 0; }
}

:is(a, button, input, select, textarea):focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .main-navigation, .menu-icon span, .btn { transition: none; }
}

/* Pagination Responsive */
@media (max-width: 767px) {
    .pagination-wrapper {
        font-size: 14px;
    }
    
    .pagination .page-numbers {
        padding: 8px 12px;
    }
}

/* Utility Classes for Responsive */
@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }
    
    .show-mobile-only {
        display: block !important;
    }
}

@media (min-width: 768px) {
    .show-mobile-only {
        display: none !important;
    }
}

/* Typography Responsive */
@media (max-width: 767px) {
    body {
        font-size: 14px;
    }
    
    h1 {
        font-size: 24px;
    }
    
    h2 {
        font-size: 20px;
    }
    
    h3 {
        font-size: 18px;
    }
    
    .page-title {
        font-size: 20px;
    }
}

/* Spacing Responsive */
@media (max-width: 767px) {
    .site-main {
        padding: 24px 0;
    }
    
    .mb-xl {
        margin-bottom: 24px;
    }
    
    .mb-lg {
        margin-bottom: 16px;
    }
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    z-index: var(--z-sticky);
    transition: all var(--transition-fast);
}

.back-to-top:hover {
    background: var(--accent-hover);
    transform: translateY(-4px);
}

@media (max-width: 767px) {
    .back-to-top {
        bottom: 16px;
        right: 16px;
        width: 40px;
        height: 40px;
    }
}

/* Print Styles */
@media print {
    .site-header,
    .site-footer,
    .video-actions,
    .back-to-top,
    .no-print {
        display: none !important;
    }
    
    .video-player-wrap {
        border: 1px solid #000;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
        color: #000;
        background: #fff;
    }
}
