/**
 * Responsive Design Styles
 * Mobile-first approach with progressive enhancement
 */

/* Mobile First Base Styles (320px+) */
@media (max-width: 480px) {
    /* Typography adjustments for small screens */
    html {
        font-size: 14px;
    }

    h1 {
        font-size: 1.75rem;
        line-height: 1.3;
    }

    h2 {
        font-size: 1.5rem;
        margin-top: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
        margin-top: 1.25rem;
    }

    .lead {
        font-size: 1rem;
    }

    /* Container and spacing */
    .container {
        padding: 0 1rem;
    }

    /* Hero section mobile optimization */
    .hero {
        padding: 2rem 0;
        text-align: center;
    }

    .hero-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .hero-title {
        font-size: 1.75rem;
        margin-bottom: 1rem;
    }

    .featured-snippet {
        padding: 1rem;
        margin: 1rem 0;
    }

    .featured-stats {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .stat {
        padding: 0.5rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    /* CTA buttons mobile */
    .hero-cta {
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
    }

    .cta-button {
        width: 100%;
        justify-content: center;
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }

    /* Trust signals mobile */
    .trust-signals {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }

    /* Quick answer mobile */
    .quick-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .quick-summary {
        font-size: 1rem;
        text-align: left;
    }

    .key-takeaways {
        padding: 1rem;
    }

    .takeaways-list {
        padding-left: 0;
    }

    .takeaway-item {
        padding-left: 1.25rem;
    }

    /* Process diagram mobile */
    .diagram-container {
        gap: 0.5rem;
        padding: 1rem;
    }

    .diagram-step {
        width: 90px;
        height: 90px;
        padding: 0.75rem;
    }

    .step-number {
        font-size: 1.125rem;
    }

    .step-title {
        font-size: 0.7rem;
        margin: 0.25rem 0;
    }

    .step-desc {
        font-size: 0.6rem;
    }

    .diagram-arrow {
        font-size: 1.25rem;
        transform: rotate(90deg);
        margin: 0.5rem 0;
    }

    /* Navigation mobile */
    .nav-toggle {
        display: flex;
    }

    .nav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e5e7eb;
        padding: 1rem;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        z-index: 1000;
    }

    body.dark-mode .nav-menu {
        background: #1a1a1a;
        border-top-color: #374151;
    }

    .nav-menu.show {
        display: block;
    }

    .nav-list {
        flex-direction: column;
        gap: 0;
    }

    .nav-link {
        display: block;
        padding: 0.75rem 0;
        border-bottom: 1px solid #e5e7eb;
        font-size: 1rem;
    }

    body.dark-mode .nav-link {
        border-bottom-color: #374151;
    }

    /* TOC Sidebar mobile */
    .toc-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: white;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        border-radius: 0;
        max-height: none;
        overflow-y: auto;
    }

    body.dark-mode .toc-sidebar {
        background: #1a1a1a;
    }

    .toc-sidebar.show-mobile {
        transform: translateX(0);
    }

    .toc-container {
        padding: 5rem 1.5rem 1.5rem;
    }

    /* Main content mobile */
    .main {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0 0.5rem;
    }

    /* Section spacing mobile */
    .content-section {
        margin-bottom: 2rem;
        padding: 0 0.5rem;
    }

    .section-header {
        margin-bottom: 1.5rem;
        padding-bottom: 0.75rem;
    }

    .section-title {
        font-size: 1.5rem;
    }

    .section-meta {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    /* Benefits grid mobile */
    .benefits-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .benefit-card {
        padding: 1rem;
    }

    .benefit-icon {
        width: 40px;
        height: 40px;
    }

    /* Comparison tables mobile */
    .comparison-table {
        margin: 1rem 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        font-size: 0.75rem;
        min-width: 600px;
    }

    .data-table th,
    .data-table td {
        padding: 0.5rem;
        white-space: nowrap;
    }

    /* Code blocks mobile */
    .code-block {
        padding: 0.75rem;
        font-size: 0.8rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .code-block pre {
        font-size: 0.8rem;
        line-height: 1.4;
    }

    .copy-button {
        top: 0.25rem;
        right: 0.25rem;
        padding: 0.375rem;
        font-size: 0.7rem;
    }

    /* Use cases mobile */
    .use-cases {
        margin: 1.5rem 0;
    }

    .use-case {
        padding: 1rem;
        margin-bottom: 0.75rem;
    }

    /* Expert quotes mobile */
    .expert-quote {
        padding: 1rem;
        margin: 1.5rem 0;
        font-size: 0.9rem;
    }

    .quote-author {
        font-size: 0.875rem;
    }

    /* CTA sections mobile */
    .cta-section {
        padding: 2rem 0;
        text-align: center;
    }

    .cta-title {
        font-size: 1.75rem;
        margin-bottom: 0.75rem;
    }

    .cta-description {
        font-size: 1rem;
        margin-bottom: 1.5rem;
        padding: 0 1rem;
    }

    .cta-benefits {
        flex-direction: column;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }

    .benefit {
        font-size: 0.9rem;
    }

    .cta-actions {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
        padding: 0 1rem;
    }

    .cta-button {
        width: 100%;
        max-width: none;
        padding: 1rem;
        font-size: 1rem;
        justify-content: center;
    }

    /* Newsletter signup mobile */
    .newsletter-signup {
        padding: 1rem;
    }

    .newsletter-form {
        flex-direction: column;
        gap: 0.75rem;
    }

    .newsletter-input,
    .newsletter-button {
        width: 100%;
        padding: 0.875rem;
        font-size: 1rem;
    }

    /* Related articles mobile */
    .related-articles {
        padding: 2rem 0;
    }

    .related-title {
        font-size: 1.5rem;
        margin-bottom: 2rem;
    }

    .related-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .related-card {
        max-width: 100%;
    }

    .related-image img {
        height: 180px;
    }

    .related-content {
        padding: 1rem;
    }

    /* Author section mobile */
    .author-section {
        padding: 2rem 0;
    }

    .author-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }

    .author-info {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .author-details h3 {
        font-size: 1.25rem;
    }

    .author-credentials {
        justify-content: center;
        gap: 1rem;
    }

    .credential {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .credential strong {
        font-size: 1rem;
    }

    .author-social {
        justify-content: center;
    }

    .expertise-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .expertise-item h5 {
        font-size: 0.9rem;
    }

    .expertise-item p {
        font-size: 0.8rem;
    }

    /* Footer mobile */
    .footer {
        padding: 2rem 0 1rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        text-align: center;
    }

    .footer-section h3,
    .footer-section h4 {
        font-size: 1.125rem;
    }

    .footer-title {
        font-size: 1.125rem;
    }

    .footer-description {
        font-size: 0.8rem;
    }

    .footer-links {
        font-size: 0.8rem;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }

    .footer-legal,
    .footer-meta {
        font-size: 0.75rem;
    }

    /* Back to top mobile */
    .back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 45px;
        height: 45px;
    }

    /* Modal mobile */
    .modal-content {
        margin: 1rem;
        max-width: calc(100vw - 2rem);
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    /* Form mobile */
    .form-group {
        margin-bottom: 1rem;
    }

    input,
    textarea,
    select {
        padding: 0.875rem;
        font-size: 1rem;
        border-radius: 6px;
    }

    /* Utility classes mobile */
    .text-center {
        text-align: center;
    }

    .text-left {
        text-align: left;
    }

    .hidden-mobile {
        display: none;
    }

    .show-mobile {
        display: block;
    }
}

/* Small tablets (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    /* Typography */
    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.75rem;
    }

    /* Hero improvements */
    .hero-title {
        font-size: 2rem;
    }

    .hero-cta {
        justify-content: center;
        gap: 1rem;
    }

    .cta-button {
        min-width: 200px;
    }

    /* Quick answer */
    .quick-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    /* Benefits grid */
    .benefits-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }

    /* Tables */
    .data-table {
        font-size: 0.8rem;
    }

    /* Related articles */
    .related-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    /* Author section */
    .author-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .expertise-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Footer */
    .footer-content {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }
}

/* Tablets (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Main layout */
    .main {
        grid-template-columns: 1fr 250px;
        gap: 1.5rem;
    }

    .toc-sidebar {
        width: 250px;
        margin-left: -210px;
    }

    .toc-sidebar:hover {
        margin-left: 0;
    }

    /* Hero */
    .hero-content {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }

    /* Benefits grid */
    .benefits-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Related articles */
    .related-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Author section */
    .author-content {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }

    /* Footer */
    .footer-content {
        grid-template-columns: 2fr 1fr 1fr 1fr;
        gap: 1.5rem;
    }
}

/* Large tablets and small desktops (1025px - 1200px) */
@media (min-width: 1025px) and (max-width: 1200px) {
    /* Main layout */
    .main {
        grid-template-columns: 1fr 280px;
        gap: 2rem;
    }

    /* Hero */
    .hero-content {
        grid-template-columns: 1fr 1fr;
        gap: 3rem;
    }

    /* Benefits grid */
    .benefits-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Related articles */
    .related-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Desktop (1201px+) */
@media (min-width: 1201px) {
    /* Enhanced desktop layout */
    .main {
        grid-template-columns: 1fr 300px;
        gap: 3rem;
        max-width: 1400px;
    }

    .toc-sidebar {
        width: 300px;
        margin-left: -260px;
    }

    /* Hero enhancements */
    .hero {
        padding: 5rem 0;
    }

    .hero-content {
        grid-template-columns: 1fr 1fr;
        gap: 4rem;
        align-items: center;
    }

    .hero-title {
        font-size: 2rem;
    }

    .hero-cta {
        justify-content: center;
    }

    .cta-button {
        width: 100%;
        justify-content: center;
        max-width: 300px;
    }

    /* Video containers mobile */
    .video-container-local {
        max-width: 100%;
        border-radius: 12px;
    }

    .hero-video-player {
        height: auto;
        border-radius: 12px;
    }

    .video-container {
        max-width: 100%;
        height: auto;
        aspect-ratio: 16/9;
    }

    .video-container iframe {
        border-radius: 12px;
    }

    /* Enhanced hover effects */
    .benefit-card:hover {
        transform: translateY(-8px);
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    }

    body.dark-mode .benefit-card:hover {
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    }

    .related-card:hover {
        transform: translateY(-8px);
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    }

    body.dark-mode .related-card:hover {
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    }
}

/* Ultra-wide screens (1401px+) */
@media (min-width: 1401px) {
    .container {
        max-width: 1400px;
    }

    .main {
        max-width: 1600px;
    }

    /* Enhanced spacing for ultra-wide */
    .hero {
        padding: 6rem 0;
    }

    .hero-content {
        gap: 5rem;
    }

    .hero-title {
        font-size: 3.5rem;
    }

    /* More columns for large screens */
    .benefits-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2rem;
    }

    .related-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2rem;
    }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Enhanced image quality */
    .hero-image,
    .related-image img,
    .author-avatar img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }

    /* Sharper borders */
    .benefit-card,
    .related-card,
    .data-table,
    .code-block {
        border-width: 0.5px;
    }
}

/* Landscape mobile orientation */
@media (max-width: 768px) and (orientation: landscape) {
    .hero {
        padding: 1.5rem 0;
    }

    .hero-title {
        font-size: 1.5rem;
        margin-bottom: 0.75rem;
    }

    .featured-snippet {
        padding: 0.75rem;
        margin: 0.75rem 0;
    }

    .toc-sidebar {
        height: 80vh;
        top: 10vh;
    }

    .toc-container {
        padding: 1rem;
    }
}

/* Print media queries */
@media print {
    /* Hide interactive elements */
    .nav-toggle,
    .nav-menu,
    .theme-toggle,
    .toc-sidebar,
    .back-to-top,
    .cta-section,
    .related-articles,
    .author-section,
    .footer {
        display: none !important;
    }

    /* Optimize layout for print */
    .main {
        grid-template-columns: 1fr;
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .hero {
        background: none !important;
        color: #000 !important;
        padding: 1rem 0;
        page-break-after: avoid;
    }

    .hero-title {
        color: #000 !important;
        font-size: 2rem !important;
    }

    /* Code blocks for print */
    .code-block {
        background: #f5f5f5 !important;
        border: 1px solid #ccc !important;
        page-break-inside: avoid;
    }

    .code-block pre {
        color: #000 !important;
        font-size: 10pt !important;
    }

    /* Tables for print */
    .data-table {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        page-break-inside: avoid;
    }

    .data-table th {
        background: #f5f5f5 !important;
        color: #000 !important;
    }

    /* Links for print */
    a {
        color: #000 !important;
        text-decoration: underline !important;
    }

    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    /* Page breaks */
    .content-section {
        page-break-after: always;
    }

    .content-section:last-child {
        page-break-after: avoid;
    }

    h2, h3 {
        page-break-after: avoid;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .benefit-card:hover,
    .related-card:hover,
    .tool-card:hover {
        transform: none !important;
    }

    .back-to-top {
        transition: none !important;
    }

    .diagram-step {
        animation: none !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    /* Enhanced contrast for all elements */
    .hero {
        background: #000 !important;
        color: #fff !important;
    }

    .featured-snippet {
        background: rgba(255, 255, 255, 0.3) !important;
        border: 2px solid rgba(255, 255, 255, 0.8) !important;
    }

    .cta-button {
        border: 2px solid currentColor !important;
        background: transparent !important;
    }

    .cta-primary {
        background: #000 !important;
        color: #fff !important;
        border-color: #fff !important;
    }

    .data-table th {
        background: #000 !important;
        color: #fff !important;
        border: 1px solid #fff !important;
    }

    .data-table td {
        border: 1px solid #000 !important;
    }

    .benefit-card,
    .related-card {
        border: 2px solid #000 !important;
    }

    body.dark-mode .benefit-card,
    body.dark-mode .related-card {
        border-color: #fff !important;
    }
}

/* Dark mode responsive adjustments */
@media (max-width: 768px) {
    body.dark-mode .nav-menu {
        background: #1a1a1a !important;
        border-top: 1px solid #374151 !important;
    }

    body.dark-mode .nav-link {
        border-bottom: 1px solid #374151 !important;
        color: #d1d5db !important;
    }

    body.dark-mode .toc-sidebar {
        background: #1a1a1a !important;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5) !important;
    }
}

/* Focus management for mobile */
@media (max-width: 768px) {
    /* Enhanced focus indicators for touch devices */
    button:focus,
    a:focus,
    input:focus,
    textarea:focus,
    select:focus {
        outline: 3px solid #2563eb;
        outline-offset: 3px;
    }

    /* Larger touch targets */
    .nav-link,
    .toc-link,
    .cta-button,
    .copy-button {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Improved mobile navigation */
    .nav-menu.show {
        animation: slideDown 0.3s ease;
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* Container queries for modern browsers */
@container (max-width: 800px) {
    .benefits-grid {
        grid-template-columns: 1fr;
    }

    .related-grid {
        grid-template-columns: 1fr;
    }
}

@container (min-width: 801px) and (max-width: 1200px) {
    .benefits-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .related-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@container (min-width: 1201px) {
    .benefits-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .related-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
