/* Responsive Enhancements for DigitalHub Theme */

/* Mobile First Approach - Base styles for mobile devices */
@media screen and (max-width: 639px) {
    /* Header adjustments */
    .hero-title {
        font-size: 2rem !important;
        line-height: 1.1 !important;
    }
    
    .hero-subtitle {
        font-size: 1rem !important;
        line-height: 1.4 !important;
    }
    
    /* Navigation improvements */
    .mobile-nav-item {
        padding: 0.75rem 1rem;
        border-bottom: 1px solid #f1f5f9;
    }
    
    .mobile-nav-item:last-child {
        border-bottom: none;
    }
    
    /* Article spacing */
    .article-content {
        font-size: 1rem;
        line-height: 1.6;
    }
    
    .article-content h2 {
        font-size: 1.5rem !important;
        margin-top: 2rem;
        margin-bottom: 1rem;
    }
    
    .article-content h3 {
        font-size: 1.25rem !important;
        margin-top: 1.5rem;
        margin-bottom: 0.75rem;
    }
    
    /* Card spacing */
    .card-grid {
        gap: 1rem !important;
    }
    
    /* Button adjustments */
    .btn-primary,
    .btn-secondary {
        padding: 0.75rem 1.5rem;
        font-size: 0.875rem;
        width: 100%;
        text-align: center;
    }
    
    /* Newsletter form */
    .newsletter-form {
        flex-direction: column !important;
        gap: 1rem;
    }
    
    .newsletter-input {
        width: 100% !important;
    }
}

/* Tablet Portrait */
@media screen and (min-width: 640px) and (max-width: 767px) {
    .hero-title {
        font-size: 2.5rem !important;
    }
    
    .grid-cols-tablet-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .featured-article-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

/* Tablet Landscape / Small Desktop */
@media screen and (min-width: 768px) and (max-width: 1023px) {
    .hero-title {
        font-size: 3rem !important;
    }
    
    .featured-article-grid {
        grid-template-columns: 1.5fr 1fr;
        gap: 2rem;
    }
    
    .category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }
    
    .article-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }
}

/* Desktop */
@media screen and (min-width: 1024px) {
    .hero-title {
        font-size: 3.5rem !important;
    }
    
    .featured-article-grid {
        grid-template-columns: 1.5fr 1fr;
        gap: 3rem;
    }
    
    .category-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2rem;
    }
    
    .article-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2rem;
    }
    
    /* Hover effects for desktop */
    .desktop-hover:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    }
}

/* Large Desktop */
@media screen and (min-width: 1280px) {
    .hero-title {
        font-size: 4rem !important;
    }
    
    .container-xl {
        max-width: 1280px;
        margin: 0 auto;
        padding: 0 2rem;
    }
}

/* Ultra Wide Screens */
@media screen and (min-width: 1536px) {
    .hero-title {
        font-size: 4.5rem !important;
    }
    
    .container-2xl {
        max-width: 1536px;
        margin: 0 auto;
        padding: 0 2rem;
    }
}

/* High DPI / Retina Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Optimize for high-resolution displays */
    .logo-icon,
    .category-icon {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Landscape Orientation for Mobile */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .hero-section {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    .hero-title {
        font-size: 2rem !important;
    }
    
    .mobile-menu {
        max-height: 200px;
        overflow-y: auto;
    }
}

/* Print Styles */
@media print {
    /* Hide navigation and interactive elements */
    .no-print,
    header nav,
    .newsletter-section,
    .social-share,
    .mobile-menu-button,
    .search-button {
        display: none !important;
    }
    
    /* Optimize text for printing */
    body {
        font-size: 12pt;
        line-height: 1.4;
        color: #000 !important;
        background: #fff !important;
    }
    
    .article-content {
        font-size: 11pt;
        line-height: 1.5;
    }
    
    .article-title {
        font-size: 18pt;
        font-weight: bold;
        margin-bottom: 12pt;
    }
    
    /* Page breaks */
    .article-section {
        page-break-inside: avoid;
    }
    
    .article-title {
        page-break-after: avoid;
    }
    
    /* Links */
    a[href^="http"]:after {
        content: " (" attr(href) ")";
        font-size: 9pt;
        color: #666;
    }
}

/* Reduced Motion Preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .parallax-element {
        transform: none !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .bg-gradient-to-br,
    .bg-gradient-to-r {
        background: #fff !important;
        color: #000 !important;
        border: 2px solid #000 !important;
    }
    
    .text-brand-600,
    .text-accent-600 {
        color: #000 !important;
    }
    
    .bg-brand-600,
    .bg-accent-600 {
        background: #000 !important;
        color: #fff !important;
    }
}

/* WordPress Admin Bar Compatibility */
.admin-bar {
    margin-top: 32px;
}

@media screen and (max-width: 782px) {
    .admin-bar {
        margin-top: 46px;
    }
}

/* WordPress Editor Styles */
.wp-block {
    max-width: 100%;
}

.wp-block-group {
    margin-bottom: 1.5rem;
}

.wp-block-image {
    margin-bottom: 1.5rem;
}

.wp-block-image img {
    border-radius: 0.5rem;
}

.wp-block-quote {
    border-left: 4px solid #0ea5e9;
    padding-left: 1rem;
    margin: 2rem 0;
    font-style: italic;
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: 0.5rem;
}

.wp-block-code {
    background: #f1f5f9;
    padding: 1rem;
    border-radius: 0.5rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    overflow-x: auto;
}

/* WordPress Gallery Styles */
.wp-block-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.wp-block-gallery .wp-block-image {
    margin-bottom: 0;
}

/* WordPress Video Styles */
.wp-block-video {
    margin: 2rem 0;
}

.wp-block-video video {
    width: 100%;
    border-radius: 0.5rem;
}

/* Accessibility Improvements */
.focus-visible {
    outline: 3px solid #0ea5e9;
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Keyboard Navigation Enhancements */
.keyboard-navigation *:focus {
    outline: 2px solid #0ea5e9;
    outline-offset: 2px;
}

/* Loading States */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Error States */
.error-state {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 0.5rem;
    padding: 1rem;
    color: #dc2626;
}

.error-state .error-icon {
    color: #dc2626;
    margin-right: 0.5rem;
}

/* Success States */
.success-state {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 0.5rem;
    padding: 1rem;
    color: #16a34a;
}

.success-state .success-icon {
    color: #16a34a;
    margin-right: 0.5rem;
}

/* Performance Optimizations */
.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Dark Mode Preparation */
@media (prefers-color-scheme: dark) {
    .dark-mode-ready {
        --bg-primary: #1f2937;
        --bg-secondary: #374151;
        --text-primary: #f9fafb;
        --text-secondary: #d1d5db;
        --border-color: #4b5563;
    }
    
    .dark-mode-ready body {
        background-color: var(--bg-primary);
        color: var(--text-primary);
    }
    
    .dark-mode-ready .bg-white {
        background-color: var(--bg-secondary);
    }
    
    .dark-mode-ready .text-gray-900 {
        color: var(--text-primary);
    }
    
    .dark-mode-ready .text-gray-600 {
        color: var(--text-secondary);
    }
    
    .dark-mode-ready .border-gray-200 {
        border-color: var(--border-color);
    }
}