/* 增强响应式设计 */
@media (max-width: 992px) {
    .container {
        width: 95%;
    }
    
    h1 {
        font-size: 2.2rem;
    }
}

@media (max-width: 768px) {
    .container {
        width: 100%;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.2rem;
    }
    
    header {
        padding: 0.8rem 0;
    }
    
    nav ul {
        flex-direction: column;
    }
    
    .section h2 {
        padding: 1rem;
    }
    
    .content {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.3rem;
    }
    
    h3 {
        font-size: 1.1rem;
    }
    
    ol, ul {
        margin-left: 1.5rem;
    }
    
    .section {
        border-radius: 5px;
    }
    
    .back-to-top {
        width: 40px;
        height: 40px;
        bottom: 1rem;
        right: 1rem;
    }
}

/* 触摸设备优化 */
@media (hover: none) {
    nav a {
        padding: 0.7rem 0;
    }
    
    nav a::after {
        display: none;
    }
    
    .section:hover {
        transform: none;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    }
}

/* 平板设备优化 */
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
    body {
        font-size: 16px;
    }
    
    .container {
        width: 90%;
    }
    
    nav ul {
        flex-wrap: wrap;
    }
    
    nav li {
        margin-bottom: 0.3rem;
    }
}

/* 横屏模式优化 */
@media (orientation: landscape) and (max-height: 500px) {
    header {
        position: relative;
    }
    
    nav ul {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    nav li {
        margin-right: 1rem;
        margin-bottom: 0.3rem;
    }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    body {
        font-weight: 300;
    }
    
    h1, h2, h3, h4, h5, h6 {
        font-weight: 600;
    }
}

/* 暗黑模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #5c6bc0;
        --secondary-color: #ff4081;
        --background-color: #121212;
        --text-color: #e0e0e0;
        --heading-color: #bbdefb;
        --link-color: #90caf9;
        --link-hover-color: #ff4081;
        --section-bg: #1e1e1e;
        --border-color: #424242;
        --footer-bg: #0d1921;
        --footer-text: #e0e0e0;
    }
    
    .section {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    }
    
    .section h2 {
        background-color: rgba(92, 107, 192, 0.15);
    }
}

/* 无障碍优化 */
:focus {
    outline: 3px solid var(--secondary-color);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .section:hover {
        transform: none;
    }
}

/* 打印优化 */
@media print {
    @page {
        margin: 2cm;
    }
    
    body {
        font-size: 12pt;
    }
    
    h1 {
        font-size: 24pt;
    }
    
    h2 {
        font-size: 18pt;
    }
    
    h3 {
        font-size: 14pt;
    }
    
    a::after {
        content: " (" attr(href) ")";
        font-size: 90%;
        color: #666;
    }
}
