/* Responsive Design Styles */

/* Mobile-first approach with progressive enhancement */

/* Extra Small Devices (phones, 576px and down) */
@media (max-width: 575.98px) {
    .container {
        padding: 0 var(--space-3);
    }
    
    .hero {
        padding: var(--space-12) 0;
    }
    
    .hero-text h1 {
        font-size: var(--text-3xl);
        line-height: 1.1;
    }
    
    .hero-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    
    .hero-buttons .btn {
        justify-content: center;
    }
    
    section {
        padding: var(--space-12) 0;
    }
    
    .section-header h2 {
        font-size: var(--text-3xl);
    }
    
    .services-grid {
        grid-template-columns: 1fr;
        gap: var(--space-6);
    }
    
    .service-card {
        padding: var(--space-6);
    }
    
    .testimonials-grid {
        grid-template-columns: 1fr;
        gap: var(--space-6);
    }
    
    .about-stats {
        grid-template-columns: 1fr;
        gap: var(--space-4);
        text-align: center;
    }
    
    .contact-content {
        gap: var(--space-8);
    }
    
    .contact-item {
        flex-direction: column;
        text-align: center;
        gap: var(--space-3);
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        gap: var(--space-6);
        text-align: center;
    }
    
    .social-links {
        justify-content: center;
    }
    
    /* Blog responsive */
    .articles-grid {
        grid-template-columns: 1fr;
        gap: var(--space-6);
    }
    
    .article-card {
        margin: 0 var(--space-2);
    }
    
    .blog-header {
        padding: var(--space-12) 0;
    }
    
    .blog-header-content h1 {
        font-size: var(--text-3xl);
    }
    
    /* Blog post responsive */
    .post-header h1 {
        font-size: var(--text-3xl);
        line-height: 1.2;
    }
    
    .post-meta {
        flex-direction: column;
        gap: var(--space-2);
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    
    /* Table responsive */
    .cookie-table,
    .tax-rates-table,
    .filing-frequency-table,
    .deadline-table,
    .software-comparison {
        font-size: var(--text-sm);
    }
    
    table {
        min-width: 500px;
    }
    
    th,
    td {
        padding: var(--space-2) var(--space-3);
    }
    
    /* Form responsive */
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .newsletter-form .form-group {
        flex-direction: column;
        gap: var(--space-3);
    }
    
    .newsletter-form button {
        width: 100%;
    }
    
    /* Cookie banner responsive */
    .cookie-content {
        flex-direction: column;
        text-align: center;
    }
    
    .cookie-buttons {
        width: 100%;
        justify-content: center;
    }
    
    .cookie-buttons .btn {
        flex: 1;
        min-width: 120px;
    }
    
    /* Modal responsive */
    .modal {
        padding: var(--space-2);
    }
    
    .modal-content {
        padding: var(--space-6);
        max-height: 95vh;
    }
}

/* Small Devices (landscape phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
    .hero-text h1 {
        font-size: var(--text-4xl);
    }
    
    .services-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
    
    .about-stats {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .testimonials-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
    
    .articles-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    }
    
    .cookie-buttons {
        flex-wrap: nowrap;
    }
}

/* Medium Devices (tablets, 768px and up) */
@media (min-width: 768px) {
    /* Navigation */
    .nav-menu.active {
        display: flex;
    }
    
    /* Hero section */
    .hero-text h1 {
        font-size: var(--text-5xl);
    }
    
    /* Grid layouts */
    .services-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .testimonials-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .articles-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .footer-content {
        grid-template-columns: repeat(2, 1fr);
        text-align: left;
    }
    
    /* Cookie banner */
    .cookie-content {
        flex-direction: row;
        text-align: left;
    }
    
    .cookie-buttons {
        flex-shrink: 0;
    }
    
    /* Forms */
    .form-row {
        grid-template-columns: 1fr 1fr;
    }
    
    /* Newsletter */
    .newsletter-cta {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-10);
    }
}

/* Large Devices (desktops, 992px and up) */
@media (min-width: 992px) {
    .services-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .testimonials-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .articles-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .footer-content {
        grid-template-columns: repeat(4, 1fr);
    }
    
    /* Hero layout */
    .hero-content {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-16);
    }
    
    /* About layout */
    .about-content {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-16);
    }
    
    /* Contact layout */
    .contact-content {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-16);
    }
    
    /* Newsletter layout */
    .newsletter-cta {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-12);
    }
}

/* Extra Large Devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container {
        max-width: var(--max-width-xl);
    }
    
    .hero-text h1 {
        font-size: var(--text-6xl);
    }
    
    .section-header h2 {
        font-size: var(--text-5xl);
    }
    
    /* Increase spacing for larger screens */
    section {
        padding: var(--space-24) 0;
    }
    
    .hero {
        padding: var(--space-32) 0;
    }
}

/* Mobile Navigation */
@media (max-width: 767.98px) {
    .nav-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: hsl(var(--surface));
        border-top: 1px solid hsl(var(--gray-200));
        box-shadow: var(--shadow-lg);
        flex-direction: column;
        padding: var(--space-4);
        gap: var(--space-4);
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all var(--transition-normal);
        z-index: 40;
    }
    
    .nav-menu.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }
    
    .nav-link {
        padding: var(--space-3) 0;
        border-bottom: 1px solid hsl(var(--gray-100));
    }
    
    .nav-link:last-child {
        border-bottom: none;
    }
    
    /* Mobile toggle animation */
    .nav-toggle.active .bar:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .nav-toggle.active .bar:nth-child(2) {
        opacity: 0;
    }
    
    .nav-toggle.active .bar:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }
}

/* Tablet specific adjustments */
@media (min-width: 768px) and (max-width: 1023.98px) {
    .hero-content {
        gap: var(--space-8);
    }
    
    .about-content {
        gap: var(--space-8);
    }
    
    .contact-content {
        gap: var(--space-10);
    }
    
    .newsletter-cta {
        gap: var(--space-8);
    }
    
    /* Adjust font sizes for tablets */
    .hero-text h1 {
        font-size: var(--text-4xl);
    }
    
    .section-header h2 {
        font-size: var(--text-3xl);
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Ensure crisp rendering on high DPI displays */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    .logo-icon,
    .service-icon,
    .contact-icon {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Print styles */
@media print {
    * {
        background: transparent !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
    }
    
    h1, h2, h3 {
        page-break-after: avoid;
        color: black !important;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
    
    .btn {
        border: 1px solid black;
        background: transparent;
        color: black;
    }
    
    a {
        color: black;
        text-decoration: underline;
    }
    
    a[href^="http"]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
    }
    
    .header,
    .footer,
    .cookie-banner,
    .modal,
    .social-links,
    .nav-toggle {
        display: none !important;
    }
    
    .hero,
    .services,
    .about,
    .testimonials,
    .contact {
        page-break-inside: avoid;
    }
    
    table {
        border-collapse: collapse;
        border: 1px solid black;
    }
    
    th, td {
        border: 1px solid black;
        padding: 0.25em;
    }
    
    thead {
        display: table-header-group;
    }
    
    tbody {
        display: table-row-group;
    }
}

/* 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;
    }
    
    .hero-image svg,
    .service-card,
    .testimonial-card,
    .article-card {
        transform: none !important;
    }
}

/* Dark mode support (if user prefers dark mode) */
@media (prefers-color-scheme: dark) {
    /* Note: This is a basic dark mode setup */
    /* In a production environment, you'd want more comprehensive dark mode support */
    
    :root {
        --background: 220 39% 11%;
        --surface: 217 33% 17%;
        --gray-50: 215 25% 20%;
        --gray-100: 214 13% 29%;
    }
    
    body {
        background-color: hsl(var(--background));
        color: hsl(var(--gray-100));
    }
    
    .header {
        background-color: hsl(var(--surface));
        border-bottom-color: hsl(var(--gray-700));
    }
    
    .service-card,
    .testimonial-card,
    .article-card {
        background-color: hsl(var(--surface));
    }
}

/* Focus visible for better accessibility */
@supports selector(:focus-visible) {
    *:focus {
        outline: none;
    }
    
    *:focus-visible {
        outline: 2px solid hsl(var(--primary));
        outline-offset: 2px;
    }
}

/* Container queries (progressive enhancement) */
@supports (container-type: inline-size) {
    .services-grid {
        container-type: inline-size;
    }
    
    @container (min-width: 600px) {
        .service-card {
            display: flex;
            flex-direction: column;
            justify-content: space-between;
        }
    }
}

/* Aspect ratio support */
@supports (aspect-ratio: 1) {
    .hero-image,
    .about-image,
    .newsletter-image {
        aspect-ratio: 16 / 9;
    }
    
    .article-image {
        aspect-ratio: 2 / 1;
    }
}

/* Scroll behavior */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* Hover support detection */
@media (hover: hover) {
    .service-card:hover,
    .testimonial-card:hover,
    .article-card:hover {
        transform: translateY(-4px);
        box-shadow: var(--shadow-lg);
    }
    
    .btn:hover {
        transform: translateY(-1px);
    }
    
    .social-links a:hover {
        transform: translateY(-2px);
    }
}

@media (hover: none) {
    .service-card,
    .testimonial-card,
    .article-card,
    .btn,
    .social-links a {
        transform: none !important;
    }
}
