/* ========================================
   TheBitcoinIndex.com - Responsive Styles
   ======================================== */

/* Mobile First Approach - Base styles are for mobile */

/* Small Mobile Devices (320px - 479px) */
@media (max-width: 479px) {
    .container {
        padding: 0 16px;
    }
    
    .hero h1 {
        font-size: 32px;
        line-height: 1.1;
    }
    
    .hero .subtitle {
        font-size: 16px;
    }
    
    .hero-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .cta-button, .secondary-button {
        width: 100%;
        max-width: 280px;
        margin: 8px 0;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .stat-item {
        padding: 16px;
    }
    
    .stat-value {
        font-size: 28px;
    }
    
    .indices-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .index-card {
        padding: 20px;
    }
    
    .index-stats {
        flex-direction: column;
        gap: 8px;
    }
    
    .table-header,
    .table-row {
        grid-template-columns: 1fr;
        gap: 8px;
        text-align: center;
    }
    
    .table-header > div,
    .table-row > div {
        padding: 4px 0;
    }
    
    .table-header > div:first-child,
    .table-row > div:first-child {
        font-weight: 600;
        border-bottom: 1px solid #f2f4f7;
        margin-bottom: 8px;
        padding-bottom: 8px;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        gap: 24px;
        text-align: center;
    }
    
    .footer-bottom {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
}

/* Mobile Devices (480px - 767px) */
@media (min-width: 480px) and (max-width: 767px) {
    .container {
        padding: 0 20px;
    }
    
    .hero h1 {
        font-size: 36px;
    }
    
    .hero .subtitle {
        font-size: 18px;
    }
    
    .hero-actions {
        flex-direction: row;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .cta-button, .secondary-button {
        min-width: 140px;
        margin: 8px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }
    
    .indices-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .table-header,
    .table-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .table-header > div:not(:first-child),
    .table-row > div:not(:first-child) {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .table-header > div:not(:first-child)::before,
    .table-row > div:not(:first-child)::before {
        content: attr(data-label);
        font-weight: 500;
        color: #475467;
    }
    
    .footer-content {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }
}

/* Tablet Devices (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .container {
        padding: 0 24px;
    }
    
    .hero h1 {
        font-size: 42px;
    }
    
    .hero .subtitle {
        font-size: 20px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 32px;
    }
    
    .indices-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }
    
    .table-header,
    .table-row {
        grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
        gap: 16px;
    }
    
    .footer-content {
        grid-template-columns: repeat(3, 1fr);
        gap: 32px;
    }
}

/* Desktop Devices (1024px - 1279px) */
@media (min-width: 1024px) and (max-width: 1279px) {
    .container {
        padding: 0 24px;
    }
    
    .hero h1 {
        font-size: 48px;
    }
    
    .hero .subtitle {
        font-size: 20px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 32px;
    }
    
    .indices-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 32px;
    }
    
    .table-header,
    .table-row {
        grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
        gap: 24px;
    }
    
    .footer-content {
        grid-template-columns: repeat(4, 1fr);
        gap: 32px;
    }
}

/* Large Desktop Devices (1280px+) */
@media (min-width: 1280px) {
    .container {
        padding: 0 24px;
    }
    
    .hero h1 {
        font-size: 48px;
    }
    
    .hero .subtitle {
        font-size: 20px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 40px;
    }
    
    .indices-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 24px;
    }
    
    .table-header,
    .table-row {
        grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
        gap: 24px;
    }
    
    .footer-content {
        grid-template-columns: repeat(4, 1fr);
        gap: 40px;
    }
}

/* Mobile Navigation */
@media (max-width: 767px) {
    header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background-color: #ffffff;
        border-bottom: 1px solid #e4e7ec;
        box-shadow: 0 2px 8px rgba(16, 24, 40, 0.1);
        height: 64px;
    }
    
    .header-content {
        padding: 12px 24px;
        position: relative;
        height: 64px;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    
    .main-nav {
        position: fixed;
        top: 64px;
        left: 0;
        right: 0;
        background-color: #ffffff;
        border-bottom: 1px solid #e4e7ec;
        box-shadow: 0 4px 12px rgba(16, 24, 40, 0.15);
        transform: translateY(-100%);
        transition: transform 0.3s ease;
        z-index: 999;
        max-height: calc(100vh - 64px);
        overflow-y: auto;
        display: block !important;
    }
    
    .main-nav.mobile-open {
        transform: translateY(0);
    }
    
    .nav-list {
        flex-direction: column;
        gap: 0;
        padding: 8px 0;
        list-style: none;
        margin: 0;
    }
    
    .nav-link {
        display: block !important;
        padding: 16px 24px; 
        border-bottom: 1px solid #f2f4f7;
        font-size: 16px;
        color: #344054 !important;
        text-decoration: none;
        transition: all 0.2s ease;
        position: relative;
    }
    
    .nav-link:hover {
        background-color: #f9fafb;
        color: #f79009 !important;
    }
    
    .nav-link:last-child {
        border-bottom: none;
    }
    
    .nav-link.active {
        background-color: #fef7ed;
        color: #f79009 !important;
        font-weight: 600;
    }
    
    .nav-link.active::after {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: flex !important;
        background: none;
        border: none;
        cursor: pointer;
        padding: 8px;
        border-radius: 4px;
    }
    
    .mobile-menu-toggle:hover {
        background-color: #f9fafb;
    }
    
    body {
        padding-top: 64px;
        overflow-x: hidden;
    }
    
    .hero {
        margin-top: 0;
        padding-top: calc(80px + 64px);
    }
}

/* Small Mobile Devices (320px - 479px) */
@media (max-width: 479px) {
    header {
        height: 56px;
    }
    
    .header-content {
        padding: 8px 0;
        height: 56px;
    }
    
    .logo {
        font-size: 18px;
    }
    
    .bitcoin-icon {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    .main-nav {
        top: 56px;
        max-height: calc(100vh - 56px);
    }
    
    body {
        padding-top: 56px;
    }
    
    .hero {
        margin-top: -56px;
        padding-top: calc(60px + 56px);
    }
    
    .hero h1 {
        font-size: 28px;
    }
}

/* Tablet Navigation */
@media (min-width: 768px) and (max-width: 1023px) {
    header {
        position: sticky;
        height: auto;
    }
    
    .header-content {
        padding: 16px 0;
        height: auto;
    }
    
    .main-nav {
        position: static;
        transform: none;
        box-shadow: none;
        background-color: transparent;
        border-bottom: none;
        max-height: none;
        overflow: visible;
    }
    
    .nav-list {
        gap: 24px;
        flex-direction: row;
        padding: 0;
    }
    
    .nav-link {
        font-size: 14px;
        padding: 0;
        border-bottom: none;
        display: inline;
    }
    
    .mobile-menu-toggle {
        display: none !important;
    }
    
    body {
        padding-top: 0;
    }
    
    .hero {
        margin-top: 0;
        padding-top: 80px;
    }
}

/* Desktop Navigation */
@media (min-width: 1024px) {
    header {
        position: sticky;
        height: auto;
    }
    
    .header-content {
        padding: 16px 0;
        height: auto;
    }
    
    .main-nav {
        position: static;
        transform: none;
        box-shadow: none;
        background-color: transparent;
        border-bottom: none;
        max-height: none;
        overflow: visible;
    }
    
    .nav-list {
        gap: 32px;
        flex-direction: row;
        padding: 0;
    }
    
    .nav-link {
        font-size: 14px;
        padding: 0;
        border-bottom: none;
        display: inline;
    }
    
    .mobile-menu-toggle {
        display: none !important;
    }
    
    body {
        padding-top: 0;
    }
    
    .hero {
        margin-top: 0;
        padding-top: 80px;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .bitcoin-icon,
    .index-icon {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .spinner {
        animation: none;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #f9fafb;
        --text-secondary: #d1d5db;
        --text-muted: #9ca3af;
        --background-primary: #111827;
        --background-secondary: #1f2937;
        --background-tertiary: #0f172a;
        --border-color: #374151;
        --border-light: #4b5563;
        --secondary-color: #d1d5db;
    }
    
    .card,
    .index-card,
    .comparison-table,
    .modal-content {
        background-color: var(--background-primary);
        border-color: var(--border-color);
    }
    
    .table-header {
        background-color: var(--background-secondary);
    }
    
    .table-row:hover {
        background-color: var(--background-secondary);
    }
    
    .form-input,
    .form-select,
    .form-textarea,
    .search-input {
        background-color: var(--background-primary);
        border-color: var(--border-color);
        color: var(--text-primary);
    }
    
    .form-input::placeholder {
        color: var(--text-muted);
    }
}

/* Print Styles */
@media print {
    .header,
    .footer,
    .btn,
    .mobile-menu-toggle {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
        color: #000;
        background: #fff;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
    
    .hero {
        padding: 20pt 0;
        background: #fff;
        border: none;
    }
    
    .hero h1 {
        font-size: 24pt;
        color: #000;
    }
    
    .hero .subtitle {
        font-size: 14pt;
        color: #333;
    }
    
    .section-title {
        font-size: 18pt;
        color: #000;
    }
    
    .index-card {
        break-inside: avoid;
        border: 1px solid #ccc;
        background: #fff;
    }
    
    .table {
        border-collapse: collapse;
        width: 100%;
    }
    
    .table th,
    .table td {
        border: 1px solid #ccc;
        padding: 8pt;
        text-align: left;
    }
    
    .table th {
        background: #f5f5f5;
        font-weight: bold;
    }
    
    .stats-grid {
        display: block;
    }
    
    .stat-item {
        display: inline-block;
        width: 45%;
        margin: 5pt;
        padding: 10pt;
        border: 1px solid #ccc;
        background: #fff;
    }
    
    .indices-grid {
        display: block;
    }
    
    .index-card {
        display: block;
        width: 100%;
        margin-bottom: 20pt;
        padding: 15pt;
        border: 1px solid #ccc;
        background: #fff;
    }
    
    a {
        color: #000;
        text-decoration: underline;
    }
    
    .badge {
        border: 1px solid #ccc;
        background: #f5f5f5;
        color: #000;
    }
}

/* Landscape Orientation */
@media (orientation: landscape) and (max-height: 500px) {
    .hero {
        padding: 32px 0;
    }
    
    .hero h1 {
        font-size: 32px;
    }
    
    .hero .subtitle {
        font-size: 16px;
    }
}

/* Portrait Orientation */
@media (orientation: portrait) and (max-width: 767px) {
    .hero-actions {
        flex-direction: column;
    }
    
    .cta-button, .secondary-button {
        width: 100%;
    }
}

/* Accessibility Improvements */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000;
        --text-secondary: #000;
        --text-muted: #333;
    }
    
    .cta-button {
        background-color: #000;
        color: #fff;
        border: 2px solid #000;
    }
    
    .secondary-button {
        background-color: #fff;
        color: #000;
        border: 2px solid #000;
    }
    
    .card,
    .index-card {
        border: 2px solid #000;
    }
}

/* Focus Visible for Keyboard Navigation */
@media (prefers-reduced-motion: no-preference) {
    *:focus-visible {
        outline: 3px solid #f79009;
        outline-offset: 2px;
    }
}
