/* ========== Design Tokens ========== */
:root {
    --primary: #1e3a5f;
    --primary-dark: #152a45;
    --primary-light: #2a5080;
    --accent: #e8491d;
    --accent-hover: #ff5722;
    --bg: #f4f6f9;
    --surface: #ffffff;
    --text: #2c3e50;
    --text-light: #6c757d;
    --text-muted: #95a5a6;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,.1);
    --shadow-lg: 0 8px 30px rgba(0,0,0,.12);
    --radius: 10px;
    --radius-sm: 6px;
    --transition: .3s cubic-bezier(.4,0,.2,1);
    --max-width: 1200px;
    --nav-height: 64px;
    --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, "Microsoft YaHei", "微软雅黑", Roboto, Arial, sans-serif;
}

/* ========== Reset & Base ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

/* ========== Site Header / Navigation ========== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--primary);
    box-shadow: var(--shadow-md);
}

.nav-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--nav-height);
}

.nav-brand {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    letter-spacing: .5px;
    white-space: nowrap;
    transition: opacity var(--transition);
}
.nav-brand:hover { opacity: .85; color: #fff; }

.nav-links {
    display: flex;
    list-style: none;
    gap: 2px;
    align-items: center;
}
.nav-links li a {
    display: block;
    padding: 8px 16px;
    color: rgba(255,255,255,.8);
    font-size: 15px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    text-decoration: none;
}
.nav-links li a:hover,
.nav-links li.active a {
    background: rgba(255,255,255,.15);
    color: #fff;
}

.lang-switch-nav {
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid rgba(255,255,255,.25);
}
.lang-switch-nav a {
    font-size: 13px;
    color: rgba(255,255,255,.6);
    padding: 4px 10px;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 20px;
    transition: all var(--transition);
}
.lang-switch-nav a:hover {
    background: rgba(255,255,255,.15);
    color: #fff;
    border-color: rgba(255,255,255,.5);
}

/* Hamburger */
.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}
.nav-toggle span {
    width: 24px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: all var(--transition);
}
.nav-toggle.open span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ========== Hero / Banner ========== */
.hero-banner {
    width: 100%;
    overflow: hidden;
    position: relative;
}
.hero-banner img {
    width: 100%;
    display: block;
    object-fit: cover;
    max-height: 360px;
}
.hero-banner::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(transparent, rgba(0,0,0,.15));
}

.banner-logo {
    position: absolute;
    top: 50%;
    left: calc(max((100% - var(--max-width)) / 2, 0px) + 24px);
    transform: translateY(-50%);
    z-index: 2;
}
.banner-logo img {
    width: 289px;
    height: 289px;
    display: block;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,.3));
}

/* ========== Main Content ========== */
.content-wrapper {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 30px 20px;
    min-height: calc(100vh - var(--nav-height) - 200px);
}

/* ========== Page Title ========== */
.page-title {
    font-size: 30px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 30px;
    padding-bottom: 14px;
    border-bottom: 3px solid var(--accent);
    position: relative;
}

/* ========== Home Grid ========== */
.home-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 30px;
    align-items: start;
}

.home-cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* ========== Home Card ========== */
.home-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--border);
}
.home-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
    color: inherit;
    text-decoration: none;
    border-color: var(--accent);
}
.home-card img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
}
.home-card .card-label {
    padding: 12px 8px;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

/* ========== News Sidebar ========== */
.news-sidebar {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}
.news-sidebar .news-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    padding: 14px 20px;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: .5px;
    display: flex;
    align-items: center;
}
.news-sidebar .news-header a {
    margin-left: auto;
    color: rgba(255,255,255,.85);
    font-size: 13px;
    font-weight: 400;
    text-decoration: none;
    transition: color var(--transition);
}
.news-sidebar .news-header a:hover { color: #fff; text-decoration: underline; }
.news-sidebar .news-text {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========== News Grid Page ========== */
.news-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}
.news-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    transition: all var(--transition);
}
.news-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent);
}
.news-card-date {
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.news-card-content {
    font-size: 14px;
    color: var(--text);
    line-height: 1.7;
    flex: 1;
}
.news-sidebar .news-item {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    line-height: 1.7;
    color: var(--text);
    transition: background var(--transition);
}
.news-sidebar .news-item:hover { background: #f8fafc; }
.news-sidebar .news-item:last-child { border-bottom: none; }
.news-sidebar .news-date {
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 4px;
    font-weight: 500;
}

/* ========== Software Card ========== */
.software-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: all var(--transition);
}
.software-card:hover { box-shadow: var(--shadow-md); border-color: var(--accent); }
.software-card .software-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 14px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(59,130,246,.08), rgba(59,130,246,.03));
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--accent);
}
.software-card .software-img img {
    height: 200px;
    width: auto;
    object-fit: contain;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: opacity var(--transition);
}
.software-card .software-img a { display: inline-block; }
.software-card .software-img a:hover img { opacity: .85; }
.software-card .software-intro {
    font-size: 15px;
    line-height: 1.8;
    color: var(--text-light);
    margin-bottom: 14px;
}
.software-card .software-info {
    margin-bottom: 6px;
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-light);
}
.software-card .software-info strong { color: var(--text); margin-right: 8px; }
.software-card .btn-download { margin-top: 14px; }

/* ========== Contest Grid ========== */
.contest-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
}
.contest-grid-item {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: all var(--transition);
    text-decoration: none;
    color: inherit;
}
.contest-grid-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent);
    color: inherit;
    text-decoration: none;
}
.contest-grid-item img {
    width: 100%;
    aspect-ratio: 16/10;
    object-fit: cover;
}
.contest-grid-item .contest-title {
    text-align: center;
    padding: 14px 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

/* ========== Contest Detail ========== */
.contest-detail {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: var(--shadow-sm);
    line-height: 1.9;
}
.contest-detail h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--accent);
}
.contest-detail img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }

/* ========== Breadcrumb ========== */
.breadcrumb-custom {
    padding: 10px 0;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 20px;
}
.breadcrumb-custom a { color: var(--accent); font-weight: 500; }
.breadcrumb-custom a:hover { text-decoration: underline; }

/* ========== About Page ========== */
.about-content {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: var(--shadow-sm);
    line-height: 2;
    font-size: 15px;
}
.about-content img { max-width: 100%; height: auto; border-radius: var(--radius-sm); display: inline-block; }
.contest-detail img { display: inline-block; }

/* ========== Buttons ========== */
.btn {
    display: inline-block;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    text-align: center;
}
.btn-danger {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #fff;
}
.btn-danger:hover {
    background: linear-gradient(135deg, #c62828, var(--accent));
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(232,73,29,.35);
}

/* ========== Site Footer ========== */
.site-footer {
    background: var(--primary-dark);
    color: rgba(255,255,255,.6);
    padding: 28px 20px;
    text-align: center;
    font-size: 13px;
    margin-top: 40px;
}
.site-footer p { margin-bottom: 4px; }
.site-footer p:last-child { margin-bottom: 0; }

/* ========== Back to Top ========== */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 44px;
    height: 44px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    line-height: 44px;
    text-align: center;
    cursor: pointer;
    display: none;
    z-index: 999;
    box-shadow: 0 3px 12px rgba(232,73,29,.4);
    transition: all var(--transition);
    opacity: 0;
}
.back-to-top.visible { display: block; opacity: 1; }
.back-to-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(232,73,29,.5);
}

/* ========== Utility ========== */
.text-muted { color: var(--text-muted); }
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 16px;
}

/* ========== Responsive ========== */
@media (max-width: 992px) {
    .home-layout {
        grid-template-columns: 1fr;
    }
    .home-cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    :root { --nav-height: 56px; }

    .nav-toggle { display: flex; }

    .nav-links {
        display: none;
        position: absolute;
        top: var(--nav-height);
        left: 0;
        right: 0;
        background: var(--primary-dark);
        flex-direction: column;
        padding: 10px 0;
        gap: 0;
        box-shadow: var(--shadow-lg);
    }
    .nav-links.open { display: flex; }
    .nav-links li a {
        padding: 12px 24px;
        border-radius: 0;
        font-size: 16px;
    }
    .lang-switch-nav {
        margin: 8px 20px;
        padding-left: 0;
        border-left: none;
        border-top: 1px solid rgba(255,255,255,.15);
        padding-top: 8px;
    }

    .hero-banner img { max-height: 220px; }
    .banner-logo img { width: 180px; height: 180px; }
    .content-wrapper { padding: 20px 16px; }
    .page-title { font-size: 22px; margin-bottom: 20px; }

    .home-cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .hide-mobile { display: none; }
    .home-card .card-label { font-size: 13px; padding: 8px 4px; }

    .contest-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
    .news-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }

    .software-card { padding: 20px; }
    .software-card .software-name { font-size: 20px; }
    .contest-detail { padding: 20px; }
    .contest-detail h2 { font-size: 22px; }
    .about-content { padding: 20px; }

    .back-to-top { bottom: 20px; right: 20px; width: 40px; height: 40px; line-height: 40px; font-size: 18px; }
}

@media (max-width: 480px) {
    .nav-brand { font-size: 16px; }
    .banner-logo { left: 16px; }
    .banner-logo img { width: 120px; height: 120px; }
    .home-cards-grid { grid-template-columns: repeat(2, 1fr); }
    .contest-grid { grid-template-columns: 1fr; }
    .news-grid { grid-template-columns: 1fr; }
}
