/* Mobile First Responsive Design */

/* Extra Small Devices (phones, 576px and down) */
@media (max-width: 575.98px) {
    .hero-title {
        font-size: 1.8rem;
        line-height: 1.3;
    }
    
    .hero-description {
        font-size: 1rem;
    }
    
    .hero-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    
    .hero-buttons .btn {
        margin-bottom: 0.5rem;
        width: 100%;
    }
    
    .section-title {
        font-size: 1.8rem;
    }
    
    .size-card {
        padding: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .size-card h3 {
        font-size: 1.2rem;
    }
    
    .sidebar {
        padding-left: 0;
        margin-top: 2rem;
    }
    
    .widget {
        margin-bottom: 1.5rem;
    }
    
    .main-content {
        font-size: 1rem;
    }
    
    .main-content h2 {
        font-size: 1.5rem;
    }
    
    .main-content h3 {
        font-size: 1.3rem;
    }
    
    .table-responsive {
        font-size: 0.85rem;
    }
    
    .ad-container {
        min-height: 200px;
        margin-bottom: 1rem;
    }
    
    .navbar-brand {
        font-size: 1.2rem;
    }
    
    .footer-section {
        text-align: center;
    }
    
    .footer-section .text-end {
        text-align: center !important;
    }
    
    .size-tags {
        justify-content: center;
    }
}

/* Small Devices (landscape phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-description {
        font-size: 1.1rem;
    }
    
    .section-title {
        font-size: 2rem;
    }
    
    .size-card {
        padding: 1.75rem;
    }
    
    .sidebar {
        padding-left: 1rem;
    }
    
    .ad-container {
        min-height: 220px;
    }
}

/* Medium Devices (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .hero-title {
        font-size: 2.2rem;
    }
    
    .sidebar {
        padding-left: 1.5rem;
    }
    
    .ad-container {
        min-height: 250px;
    }
    
    .size-card {
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }
}

/* Large Devices (desktops, 992px and up) */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .container {
        max-width: 960px;
    }
    
    .sidebar {
        padding-left: 2rem;
    }
    
    .ad-container {
        min-height: 280px;
    }
}

/* Extra Large Devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
    
    .hero-title {
        font-size: 2.8rem;
    }
    
    .section-title {
        font-size: 2.8rem;
    }
}

/* Ultra-wide screens (1400px and up) */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
    
    .hero-section {
        padding: 5rem 0;
    }
    
    .content-section,
    .quick-reference-section {
        padding: 5rem 0;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .size-card:hover {
        transform: none;
        box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    }
    
    .btn:hover {
        transform: none;
    }
    
    .social-link:hover {
        transform: none;
    }
    
    .size-guide-links a:hover {
        padding-left: 0.5rem;
    }
}

/* High DPI / Retina Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .size-icon {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    .navbar-brand,
    .hero-title,
    .section-title {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Landscape Orientation for Mobile */
@media (max-width: 767.98px) and (orientation: landscape) {
    .hero-section {
        padding: 2rem 0;
    }
    
    .hero-title {
        font-size: 1.6rem;
    }
    
    .hero-description {
        font-size: 0.95rem;
        margin-bottom: 1rem;
    }
    
    .quick-reference-section {
        padding: 2rem 0;
    }
    
    .section-title {
        font-size: 1.6rem;
        margin-bottom: 2rem;
    }
    
    .size-card {
        padding: 1rem;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }
    
    .quick-reference-section,
    .content-section {
        background-color: #2d2d2d;
    }
    
    .size-card,
    .widget {
        background-color: #3a3a3a;
        border-color: #555;
        color: #e0e0e0;
    }
    
    .ad-container {
        background-color: #3a3a3a;
        border-color: #555;
    }
    
    .table {
        background-color: #3a3a3a;
        color: #e0e0e0;
    }
    
    .table-striped tbody tr:nth-of-type(odd) {
        background-color: rgba(255,255,255,0.05);
    }
    
    .form-control,
    .form-select {
        background-color: #3a3a3a;
        border-color: #555;
        color: #e0e0e0;
    }
    
    .info-box {
        background: linear-gradient(135deg, #1e3a5f 0%, #2c5aa0 100%);
        border-left-color: #4a90e2;
    }
}

/* Reduced Motion */
@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;
    }
    
    .size-card,
    .btn,
    .social-link {
        transition: none;
    }
    
    .size-card:hover {
        transform: none;
    }
}

/* Print Optimizations */
@media print {
    @page {
        margin: 1in;
    }
    
    .hero-section,
    .ad-section,
    .ad-container {
        display: none !important;
    }
    
    .quick-reference-section,
    .content-section {
        padding: 1rem 0;
        background: white !important;
        -webkit-print-color-adjust: exact;
    }
    
    .size-card {
        break-inside: avoid;
        background: white !important;
        border: 1px solid #000 !important;
        box-shadow: none !important;
    }
    
    .table {
        font-size: 10pt;
    }
    
    .table thead th {
        background: #f0f0f0 !important;
        color: #000 !important;
        -webkit-print-color-adjust: exact;
    }
}

/* Focus Styles for Accessibility */
.btn:focus,
.form-control:focus,
.form-select:focus,
.nav-link:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Skip Link for Screen Readers */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #007bff;
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1000;
}

.skip-link:focus {
    top: 6px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .btn-primary {
        background: #000;
        border-color: #000;
        color: #fff;
    }
    
    .btn-outline-primary {
        border-color: #000;
        color: #000;
    }
    
    .size-card {
        border: 2px solid #000;
    }
    
    .table {
        border: 2px solid #000;
    }
    
    .table th,
    .table td {
        border: 1px solid #000;
    }
}

/* Container Queries (Future-proofing) */
@container (max-width: 400px) {
    .size-card {
        padding: 1rem;
    }
    
    .size-card h3 {
        font-size: 1.1rem;
    }
}

/* Grid Fallback for older browsers */
@supports not (display: grid) {
    .row {
        display: flex;
        flex-wrap: wrap;
    }
    
    .col-md-6 {
        width: 50%;
    }
    
    .col-lg-3 {
        width: 25%;
    }
    
    .col-lg-4 {
        width: 33.333%;
    }
    
    .col-lg-8 {
        width: 66.666%;
    }
}
