/* ============================================
   RESPONSIVE DESIGN SYSTEM
   ============================================ */

/* Breakpoints */
/* xs: 0-575px, sm: 576-767px, md: 768-991px, lg: 992-1199px, xl: 1200px+ */

/* ============================================
   MOBILE FIRST - EXTRA SMALL DEVICES
   ============================================ */

/* Navigation adjustments for mobile */
@media (max-width: 767px) {
    /* Hide desktop navigation, show mobile */
    .navbar-collapse {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--bg-primary);
        overflow-y: auto;
        z-index: var(--z-fixed);
        transform: translateX(-100%);
        transition: transform var(--transition-base);
    }
    
    .navbar-collapse.show {
        transform: translateX(0);
    }
    
    /* Bottom Navigation Bar */
    .bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-primary);
        border-top: 1px solid var(--border-color);
        display: flex;
        justify-content: space-around;
        padding: var(--spacing-sm) 0;
        z-index: var(--z-sticky);
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
    
    .bottom-nav__item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
        padding: var(--spacing-sm);
        color: var(--text-secondary);
        font-size: 0.75rem;
        text-decoration: none;
        transition: color var(--transition-base);
        min-width: 60px;
    }
    
    .bottom-nav__item.active,
    .bottom-nav__item:hover {
        color: var(--primary);
    }
    
    .bottom-nav__icon {
        font-size: 1.25rem;
    }
    
    /* Add padding to body to account for bottom nav */
    body {
        padding-bottom: 70px;
    }
}

/* ============================================
   TABLET DEVICES (768px - 991px)
   ============================================ */

@media (min-width: 768px) and (max-width: 991px) {
    .container-modern {
        max-width: 720px;
    }
    
    .news-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .article-header__title {
        font-size: 2rem;
    }
}

/* ============================================
   DESKTOP DEVICES (992px+)
   ============================================ */

@media (min-width: 992px) {
    .container-modern {
        max-width: 960px;
    }
    
    /* Two Column Layout */
    .main-content-wrapper {
        display: grid;
        grid-template-columns: 1fr 320px;
        gap: var(--spacing-xl);
        align-items: start;
    }
    
    .sidebar {
        position: sticky;
        top: 80px;
    }
}

/* ============================================
   LARGE DESKTOP (1200px+)
   ============================================ */

@media (min-width: 1200px) {
    .container-modern {
        max-width: 1140px;
    }
    
    .news-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Article with sidebar layout */
    .article-wrapper {
        display: grid;
        grid-template-columns: 80px 1fr 280px;
        gap: var(--spacing-xl);
        max-width: 1400px;
        margin: 0 auto;
    }
    
    .article-content {
        max-width: 800px;
    }
}

/* ============================================
   MOBILE OPTIMIZATIONS
   ============================================ */

@media (max-width: 767px) {
    /* Typography adjustments */
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.125rem; }
    
    /* Reduce spacing on mobile */
    :root {
        --spacing-lg: 1rem;
        --spacing-xl: 1.5rem;
        --spacing-2xl: 2rem;
    }
    
    /* Card adjustments */
    .news-card {
        border-radius: var(--border-radius);
    }
    
    .news-card__content {
        padding: var(--spacing-md);
    }
    
    /* Make buttons full width on mobile */
    .btn-modern {
        width: 100%;
        justify-content: center;
    }
    
    /* Stack elements vertically */
    .article-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
    }
    
    .article-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .article-actions__left,
    .article-actions__right {
        width: 100%;
        justify-content: space-between;
    }
    
    /* Adjust image galleries */
    .media-gallery__grid {
        grid-template-columns: 1fr;
    }
    
    /* Hide sidebar on mobile */
    .sidebar {
        display: none;
    }
    
    /* Full width containers */
    .container-modern {
        padding: 0 var(--spacing-sm);
    }
    
    /* Touch-friendly targets */
    .comment-action-btn,
    .share-button {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ============================================
   LANDSCAPE MOBILE
   ============================================ */

@media (max-width: 767px) and (orientation: landscape) {
    .news-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .no-print,
    .bottom-nav,
    .share-sidebar,
    .comment-form,
    .comment-card__actions,
    .article-actions,
    .navbar {
        display: none !important;
    }
    
    .article-container,
    .article-body {
        max-width: 100%;
        box-shadow: none;
        padding: 0;
    }
    
    .article-body {
        font-size: 12pt;
        line-height: 1.5;
    }
    
    a {
        text-decoration: underline;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 10pt;
        color: var(--text-secondary);
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000;
    }
    
    .news-card,
    .comment-card {
        border-width: 2px;
    }
}

/* ============================================
   SWIPE GESTURES (Mobile)
   ============================================ */

@media (max-width: 767px) {
    .swipeable {
        touch-action: pan-y;
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Horizontal scrolling containers */
    .horizontal-scroll {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: var(--spacing-md);
        padding: var(--spacing-md) 0;
    }
    
    .horizontal-scroll::-webkit-scrollbar {
        display: none;
    }
    
    .horizontal-scroll > * {
        scroll-snap-align: start;
        flex-shrink: 0;
    }
}
