/* Responsive Design Styles */

/* Base Mobile First Approach */
.container {
    width: 100%;
    padding: 0 1rem;
    margin: 0 auto;
}

/* Extra Small Devices (phones, 640px and down) */
@media only screen and (max-width: 640px) {
    /* Typography */
    h1 {
        font-size: 1.5rem;
        color: var(--heading-color) !important;
    }
    
    h2 {
        font-size: 1.25rem;
        color: var(--heading-color) !important;
    }

    /* Ensure all headings use proper color */
    h3, h4, h5, h6 {
        color: var(--heading-color) !important;
    }

    /* Special case for hero section headings */
    .hero h1, .hero h2, .hero h3, .hero h4, .hero h5, .hero h6 {
        color: white !important;
    }

    /* Results section headings */
    #results h2, #results h3 {
        color: var(--heading-color) !important;
    }

    /* Calculator card headings */
    .calculator-card h2, .calculator-card h3 {
        color: var(--heading-color) !important;
    }

    /* Form section headings */
    .form-group h2, .form-group h3, .form-label {
        color: var(--heading-color) !important;
    }
    
    /* Navigation */
    .nav-menu {
        display: none;
    }
    
    .mobile-menu-button {
        display: block;
    }
    
    .mobile-menu {
        position: fixed;
        top: 4rem;
        left: 0;
        right: 0;
        background: white;
        padding: 1rem;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    }
    
    .mobile-menu.active {
        display: block;
    }
    
    .mobile-menu a {
        display: block;
        padding: 0.75rem 0;
        border-bottom: 1px solid #e2e8f0;
    }
    
    /* Hero Section */
    .hero {
        min-height: 400px;
        padding: 2rem 1rem;
    }
    
    .hero h1 {
        font-size: 2rem;
    }
    
    /* Calculator Cards */
    .calculator-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem;
    }
    
    /* Forms */
    .form-group {
        margin-bottom: 0.75rem;
    }
    
    .form-input {
        padding: 0.5rem;
    }
    
    /* Buttons */
    .btn {
        width: 100%;
        padding: 0.75rem;
    }
}

/* Small Devices (tablets, 768px and up) */
@media only screen and (min-width: 641px) and (max-width: 768px) {
    .container {
        max-width: 720px;
    }
    
    /* Calculator Grid */
    .calculator-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Forms */
    .form-row {
        display: flex;
        gap: 1rem;
    }
    
    .form-group {
        flex: 1;
    }
}

/* Medium Devices (laptops, 1024px and up) */
@media only screen and (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 960px;
    }
    
    /* Calculator Grid */
    .calculator-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Navigation */
    .nav-menu {
        display: flex;
    }
    
    .mobile-menu-button {
        display: none;
    }
}

/* Large Devices (desktops, 1280px and up) */
@media only screen and (min-width: 1025px) {
    .container {
        max-width: 1200px;
    }
    
    /* Hero Section */
    .hero {
        min-height: 600px;
    }
}

/* Landscape Mode */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .hero {
        min-height: 100vh;
    }
    
    .mobile-menu {
        max-height: 80vh;
        overflow-y: auto;
    }
}

/* High Resolution Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Optimize images for retina displays */
    img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #f7fafc;
        --secondary-color: #e2e8f0;
        --accent-color: #a0aec0;
        --background-color: #1a202c;
        --heading-color: #f7fafc;  /* New: Heading color for dark mode */
    }
    
    body {
        background-color: var(--background-color);
        color: var(--primary-color);
    }
    
    .calculator-card {
        background-color: #2d3748;
    }
    
    .form-input {
        background-color: #2d3748;
        border-color: #4a5568;
        color: var(--primary-color);
    }
    
    .results {
        background-color: #2d3748;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Print Styles */
@media print {
    body {
        font-size: 12pt;
    }
    
    .container {
        max-width: none;
        padding: 0;
        margin: 0;
    }
    
    .calculator-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #e2e8f0;
    }
    
    .no-print {
        display: none !important;
    }
}

/* Accessibility Improvements */
@media screen and (prefers-contrast: high) {
    :root {
        --primary-color: #000000;
        --secondary-color: #000000;
        --accent-color: #000000;
        --background-color: #ffffff;
    }
    
    .btn-primary {
        background-color: #000000;
        color: #ffffff;
        border: 2px solid #000000;
    }
    
    .form-input {
        border: 2px solid #000000;
    }
}
