/* ===================================
   RESPONSIVE DESIGN
   =================================== */

/* Tablette (max 1024px) */
@media (max-width: 1024px) {
    :root {
        --text-5xl: 2.5rem;
        --text-4xl: 2rem;
        --text-3xl: 1.75rem;
    }
    
    .blog-layout {
        grid-template-columns: 240px 1fr;
        gap: var(--spacing-lg);
    }
    
    .article-layout {
        grid-template-columns: 1fr 240px;
        gap: var(--spacing-lg);
    }
    
    .footer-content {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .posts-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

/* Tablette portrait et mobile paysage (max 768px) */
@media (max-width: 768px) {
    :root {
        --text-5xl: 2rem;
        --text-4xl: 1.75rem;
        --text-3xl: 1.5rem;
        --text-2xl: 1.25rem;
        --spacing-3xl: 2.5rem;
        --spacing-2xl: 2rem;
    }
    
    .container {
        padding: 0 var(--spacing-md);
    }
    
    /* Header */
    .main-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: var(--color-bg);
        border-bottom: 1px solid var(--color-border);
        padding: var(--spacing-lg);
        box-shadow: var(--shadow-lg);
    }
    
    .main-nav.active {
        display: block;
    }
    
    .main-nav ul {
        flex-direction: column;
        gap: var(--spacing-md);
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    /* Hero */
    .hero {
        padding: var(--spacing-2xl) 0;
    }
    
    .hero-title {
        font-size: var(--text-3xl);
    }
    
    .hero-description {
        font-size: var(--text-base);
    }
    
    /* Sections */
    .featured-posts,
    .recent-posts,
    .categories-section {
        padding: var(--spacing-2xl) 0;
    }
    
    /* Posts Grid */
    .posts-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
    
    /* Blog Layout */
    .blog-layout {
        grid-template-columns: 1fr;
    }
    
    .blog-sidebar {
        position: static;
        order: -1;
    }
    
    .sidebar-section {
        margin-bottom: var(--spacing-md);
    }
    
    /* Article Layout */
    .article-layout {
        grid-template-columns: 1fr;
    }
    
    .article-sidebar {
        display: none;
    }
    
    .article-title {
        font-size: var(--text-3xl);
    }
    
    .article-image {
        height: 250px;
    }
    
    .article-body {
        font-size: var(--text-base);
    }
    
    /* Post List Item */
    .post-list-item {
        flex-direction: column;
    }
    
    .post-list-image {
        width: 100%;
        height: 200px;
    }
    
    /* Categories Grid */
    .categories-grid {
        grid-template-columns: 1fr;
    }
    
    /* Newsletter */
    .newsletter-form {
        flex-direction: column;
    }
    
    /* Footer */
    .footer-content {
        grid-template-columns: 1fr;
        gap: var(--spacing-xl);
    }
    
    /* Share Buttons */
    .share-buttons {
        flex-direction: column;
    }
    
    .share-btn {
        width: 100%;
        text-align: center;
    }
    
    /* Search Modal */
    .search-modal-content {
        width: 95%;
        padding: var(--spacing-lg);
    }
}

/* Mobile (max 480px) */
@media (max-width: 480px) {
    :root {
        --text-5xl: 1.75rem;
        --text-4xl: 1.5rem;
        --text-3xl: 1.25rem;
        --text-2xl: 1.125rem;
        --spacing-3xl: 2rem;
        --spacing-2xl: 1.5rem;
        --spacing-xl: 1.25rem;
    }
    
    .container {
        padding: 0 var(--spacing-sm);
    }
    
    .logo-text {
        display: none;
    }
    
    .header-actions {
        gap: var(--spacing-sm);
    }
    
    .theme-toggle,
    .search-toggle,
    .mobile-menu-toggle {
        width: 36px;
        height: 36px;
    }
    
    .hero {
        padding: var(--spacing-xl) 0;
    }
    
    .section-title {
        font-size: var(--text-2xl);
    }
    
    .post-card-content {
        padding: var(--spacing-md);
    }
    
    .post-card-title {
        font-size: var(--text-lg);
    }
    
    .article-header {
        margin-bottom: var(--spacing-xl);
    }
    
    .article-meta {
        flex-wrap: wrap;
    }
    
    .article-image {
        height: 200px;
    }
    
    .pagination-btn {
        width: 36px;
        height: 36px;
        font-size: var(--text-sm);
    }
}

/* Mode paysage mobile */
@media (max-height: 600px) and (orientation: landscape) {
    .hero {
        padding: var(--spacing-lg) 0;
    }
    
    .search-modal {
        padding-top: 5vh;
    }
    
    .search-modal-content {
        max-height: 90vh;
    }
}

/* Très grands écrans (min 1440px) */
@media (min-width: 1440px) {
    :root {
        --container-max-width: 1400px;
    }
    
    .posts-grid {
        grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    }
}

/* Préférence réduite de mouvement */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Impression */
@media print {
    .site-header,
    .search-modal,
    .article-sidebar,
    .article-share,
    .related-posts,
    .comments-section,
    .site-footer,
    .newsletter {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
        color: #000;
        background: #fff;
    }
    
    .article-content {
        max-width: 100%;
    }
    
    a {
        text-decoration: underline;
        color: #000;
    }
    
    .article-image {
        max-height: 400px;
        page-break-inside: avoid;
    }
    
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }
    
    p, ul, ol {
        orphans: 3;
        widows: 3;
    }
}

/* Touch devices */
@media (hover: none) and (pointer: coarse) {
    .post-card:hover,
    .category-card:hover,
    .btn:hover {
        transform: none;
    }
    
    .link:hover::after {
        width: 0;
    }
    
    /* Augmenter les zones de touche */
    .btn,
    .link,
    .theme-toggle,
    .search-toggle,
    .mobile-menu-toggle {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Dark mode préféré par le système */
@media (prefers-color-scheme: dark) {
    [data-theme="auto"] {
        --color-bg: rgba(26, 17, 16, 0.95);
        --color-surface: rgba(26, 17, 16, 0.7);
        --color-text: #F8F9FB;
        --color-text-secondary: rgba(248, 249, 251, 0.85);
        --color-border: rgba(255, 255, 255, 0.1);
        
        --klein-blue: #0047C8;
        --klein-light: #5A8BFF;
        --cosmic-purple: #7B1FA2;
        --cosmic-pink: #FF4081;
    }
}

/* Amélioration pour écrans haute résolution */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .article-image,
    .post-card-image,
    .post-list-image {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* iPad Pro et grandes tablettes */
@media (min-width: 769px) and (max-width: 1024px) {
    .posts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Navigation sticky améliorée pour mobile */
@media (max-width: 768px) {
    .site-header {
        position: fixed;
        width: 100%;
    }
    
    .main-content {
        margin-top: 70px;
    }
}

/* Accessibilité - Focus visible */
@media (prefers-contrast: high) {
    *:focus {
        outline: 3px solid var(--color-primary);
        outline-offset: 2px;
    }
}

/* Optimisation pour petits écrans en hauteur */
@media (max-height: 700px) {
    .hero {
        padding: var(--spacing-xl) 0;
    }
    
    .featured-posts,
    .recent-posts,
    .categories-section {
        padding: var(--spacing-xl) 0;
    }
}
