/* ============ 响应式设计 ============ */

/* 大屏设备 (1200px 及以上) */
@media (min-width: 1200px) {
    .container {
        max-width: 1200px;
    }

    .news-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .nav-links {
        gap: 2.5rem;
    }
}

/* 中等屏幕 (768px - 1199px) */
@media (min-width: 768px) and (max-width: 1199px) {
    .container {
        max-width: 960px;
    }

    .news-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .nav-links {
        gap: 1.5rem;
    }

    .news-card {
        margin-bottom: 10px;
    }
}

/* 小屏幕 (576px - 767px) */
@media (max-width: 767px) {
    .container {
        max-width: 540px;
        padding: 0 15px;
    }

    .content-wrapper {
        grid-template-columns: 1fr;
    }

    .sidebar-ads {
        position: static;
        margin-top: 30px;
    }

    .navbar .container {
        flex-wrap: wrap;
        gap: 15px;
    }

    .logo-text {
        font-size: 20px;
    }

    .nav-links {
        flex-basis: 100%;
        gap: 0.8rem;
        margin-left: 0;
        font-size: 14px;
    }

    .user-section {
        flex-basis: 100%;
        justify-content: center;
        gap: 0.5rem;
    }

    .news-card {
        height: auto;
        grid-template-columns: 1fr;
    }

    .news-image {
        height: 150px;
    }

    .banner-container {
        height: 220px;
    }

    .section-header {
        gap: 10px;
        margin-bottom: 20px;
    }

    .section-header h2 {
        font-size: 24px;
    }

    .section-icon {
        font-size: 28px;
    }

    .modal-content {
        max-width: 95%;
        padding: 20px;
    }

    .article-header {
        padding: 20px;
    }

    .article-header h1 {
        font-size: 20px;
    }

    .article-content {
        padding: 20px;
    }
}

/* 超小屏幕 (480px 及以下) */
@media (max-width: 480px) {
    .container {
        max-width: 100%;
        padding: 0 10px;
    }

    .navbar .container {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .logo-text {
        font-size: 18px;
    }

    .nav-links {
        flex-wrap: wrap;
        gap: 0.5rem;
        font-size: 12px;
    }

    .nav-links a {
        padding: 4px 8px;
    }

    .user-section {
        width: 100%;
        justify-content: flex-start;
        gap: 0.5rem;
        font-size: 12px;
    }

    .btn-login,
    .btn-register,
    .btn-logout {
        padding: 6px 12px;
        font-size: 12px;
    }

    .news-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .banner-container {
        height: 180px;
    }

    .banner-btn {
        padding: 8px 12px;
        font-size: 16px;
    }

    .section-category {
        margin-bottom: 30px;
    }

    .section-header {
        gap: 8px;
        margin-bottom: 15px;
    }

    .section-header h2 {
        font-size: 20px;
    }

    .section-icon {
        font-size: 24px;
    }

    .news-image {
        height: 150px;
        font-size: 32px;
    }

    .news-body {
        padding: 15px;
    }

    .news-title {
        font-size: 16px;
        margin-bottom: 10px;
    }

    .news-excerpt {
        font-size: 13px;
        margin-bottom: 10px;
    }

    .modal-content {
        max-width: 90%;
        padding: 15px;
        border-radius: 6px;
    }

    .article-header {
        padding: 15px;
    }

    .article-header h1 {
        font-size: 18px;
        margin-bottom: 10px;
    }

    .article-content {
        padding: 15px;
        font-size: 14px;
        line-height: 1.6;
    }

    .article-footer {
        flex-direction: column;
        gap: 10px;
        padding: 15px;
    }

    .btn-secondary {
        width: 100%;
    }

    .footer {
        padding: 20px 0;
    }

    .footer p {
        font-size: 12px;
        margin: 5px 0;
    }
}

/* ============ 触摸设备优化 ============ */
@media (hover: none) and (pointer: coarse) {
    .news-card,
    .btn-login,
    .btn-register,
    .btn-primary,
    .btn-secondary,
    .banner-btn,
    .nav-links a {
        -webkit-tap-highlight-color: transparent;
    }

    .news-card {
        transform: none;
    }

    .news-card:active {
        transform: scale(0.98);
    }
}

/* ============ 高分辨率屏幕优化 ============ */
@media (min-width: 1920px) {
    .container {
        max-width: 1400px;
    }

    .news-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .section-header h2 {
        font-size: 32px;
    }

    .news-title {
        font-size: 20px;
    }
}

/* ============ 暗黑模式支持 ============ */
@media (prefers-color-scheme: dark) {
    :root {
        --light-gray: #2a2a2a;
    }

    body {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }

    .modal-content,
    .news-card {
        background-color: #2d2d2d;
        color: #e0e0e0;
    }

    .form-group input {
        background-color: #3a3a3a;
        color: #e0e0e0;
        border-color: #4a4a4a;
    }

    .form-group label {
        color: #b0b0b0;
    }

    .article-content {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }

    .article-footer {
        background-color: #252525;
        border-top-color: #4a4a4a;
    }
}

/* ============ 打印优化 ============ */
@media print {
    .navbar,
    .banner,
    .footer,
    .modal,
    .close {
        display: none !important;
    }

    body {
        background-color: white;
    }

    .news-card {
        page-break-inside: avoid;
        box-shadow: 0 1px 3px rgba(0,0,0,0.12);
        border: 1px solid #ddd;
        margin-bottom: 20px;
    }

    .section-category {
        page-break-inside: avoid;
    }

    .section-header {
        color: #000;
        border-color: #000;
    }
}

/* ============ 高对比度模式 ============ */
@media (prefers-contrast: more) {
    :root {
        --primary-color: #000;
        --secondary-color: #0000ee;
        --accent-color: #ee0000;
    }

    .navbar {
        background: #000;
    }

    .news-card {
        border: 2px solid #000;
    }

    .btn-primary,
    .btn-login,
    .btn-register {
        border: 2px solid currentColor;
    }
}

/* ============ 减少动画模式 ============ */
@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;
    }
}
