/* =================================
   主题变量
================================= */

/* 默认深色主题 */
:root {
    --bg: #0b1020;
    --card: #141a33;
    --text: #e8ebff;
    --muted: #9aa3ff;
    --accent: #6cf2c2;
    --accent2: #7aa2ff;
    --subtitle-green: #6cf2c2;
    --container-width: 1400px; /* 添加容器最大宽度变量 */
    --container-padding: clamp(16px, 5vw, 40px); /* 响应式内边距 */
}

    /* 亮色主题 */
    :root[data-theme="light"] {
        --bg: #fdf6e3;
        --card: #ffffff;
        --text: #1b1b1b;
        --muted: #555555;
        --accent: #6cf2c2;
        --accent2: #7aa2ff;
        --subtitle-green: #007a3d;
    }

/* =================================
   全局基础样式
================================= */

* {
    box-sizing: border-box;
    transition: background-color 0.4s, color 0.4s, border-color 0.4s;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.65;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 辅助功能 */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--accent2);
    color: #0b1020;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    z-index: 101;
}

    .skip-link:focus {
        top: 6px;
    }

/* =================================
   顶部按钮
================================= */
#theme-toggle {
    position: fixed;
    top: clamp(8px, 2vh, 16px);
    right: clamp(10px, 3vw, 30px);
    padding: 8px 20px;
    border: none;
    background: rgba(11,16,32,.9);
    color: var(--text);
    font-size: clamp(12px, 2vw, 14px);
    font-weight: 600;
    cursor: pointer;
    z-index: 100;
    backdrop-filter: blur(8px);
    transition: background 0.3s, color 0.3s;
    border-radius: 6px; /* 添加圆角 */
}

:root[data-theme="light"] #theme-toggle {
    background: rgba(255,255,255,.9);
}

#theme-toggle:hover {
    background: var(--accent2);
    color: #0b1020;
}

/* =================================
   Header
================================= */
header {
    padding: clamp(30px, 6vh, 50px) var(--container-padding) clamp(20px, 4vh, 30px);
    text-align: center;
    position: relative;
    max-width: var(--container-width);
    margin: 0 auto;
    width: 100%;
}

    header h1 {
        font-size: clamp(32px, 6vw, 48px);
        margin: 0 0 12px;
        letter-spacing: 2px;
    }

    header p {
        max-width: 100%;
        margin: 0 auto;
        color: var(--muted);
        font-size: clamp(16px, 2.5vw, 18px);
    }

/* =================================
   导航
================================= */
nav {
    position: sticky;
    top: 0;
    backdrop-filter: blur(8px);
    background: rgba(11,16,32,.6);
    border-bottom: 1px solid rgba(122,162,255,.15);
    z-index: 10;
    width: 100%;
}

:root[data-theme="light"] nav {
    background: rgba(255,255,255,.8);
}

nav ul {
    display: flex;
    justify-content: center;
    gap: clamp(12px, 3vw, 30px);
    list-style: none;
    margin: 0 auto;
    padding: 12px var(--container-padding);
    flex-wrap: wrap;
    max-width: var(--container-width);
}

nav a {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: clamp(14px, 2vw, 16px);
    white-space: nowrap; /* 防止导航项换行 */
}

    nav a:hover {
        color: var(--accent);
    }

    nav a:focus, a:focus, button:focus {
        outline: 2px solid var(--accent2);
        outline-offset: 2px;
    }

/* =================================
   Section & 标题
================================= */
section {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: clamp(20px, 4vh, 40px) var(--container-padding);
    width: 100%;
}

    section h2 {
        font-size: clamp(24px, 4vw, 32px);
        margin-bottom: clamp(20px, 4vh, 30px);
        border-left: 4px solid var(--accent2);
        padding-left: 12px;
    }

/* =================================
   软件卡片
================================= */
.grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(16px, 3vw, 32px);
}

@media (max-width: 1024px) {
    .grid {
        grid-template-columns: repeat(2, 1fr); /* 保持两列 */
    }
}

@media (max-width: 768px) {
    .grid {
        grid-template-columns: 1fr; /* 小屏幕单列 */
        gap: 24px;
    }
}

@media (min-width: 1921px) {
    .grid {
        grid-template-columns: repeat(3, 1fr); /* 超大屏幕三列 */
    }
}

.card {
    background: linear-gradient(180deg, #1a2044, var(--card));
    border: 1px solid rgba(122,162,255,.18);
    border-radius: clamp(12px, 2vw, 20px);
    padding: clamp(16px, 3vw, 24px);
    box-shadow: 0 10px 30px rgba(0,0,0,.25);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform .25s ease, box-shadow .25s ease;
    height: 100%; /* 确保卡片高度一致 */
}

    .card:hover {
        transform: translateY(-4px);
        box-shadow: 0 20px 40px rgba(0,0,0,.3);
    }

:root[data-theme="light"] .card {
    background: linear-gradient(180deg, #e6ebf5, var(--card));
    border: 1px solid rgba(122,162,255,.2);
}

    :root[data-theme="light"] .card:hover {
        box-shadow: 0 16px 32px rgba(0,0,0,.15);
    }

.card h3 {
    margin-top: 0;
    font-size: clamp(18px, 3vw, 22px);
    word-break: break-word; /* 防止长标题溢出 */
}

.card-subtitle {
    color: var(--subtitle-green);
    font-size: clamp(13px, 2vw, 15px);
    margin-bottom: 12px;
}

:root[data-theme="light"] .card-subtitle {
    color: var(--subtitle-green);
}

.card p {
    color: var(--muted);
    font-size: clamp(14px, 2vw, 16px);
    margin-bottom: 16px;
    line-height: 1.6;
    flex-grow: 1; /* 让p元素占据剩余空间 */
}

.tags {
    margin-bottom: 16px;
}

.tag {
    display: inline-block;
    background: rgba(108,242,194,.15);
    color: var(--subtitle-green);
    padding: 4px 12px;
    border-radius: 999px;
    font-size: clamp(11px, 1.5vw, 13px);
    margin: 0 6px 6px 0;
}

:root[data-theme="light"] .tag {
    background: rgba(0,122,61,.15);
}

.btn {
    display: inline-block;
    text-align: center;
    padding: 8px 16px;
    border-radius: 30px;
    margin: 8px 8px 0 0;
    background: linear-gradient(90deg, var(--accent2) 0%, var(--accent) 100%);
    box-shadow: 0 6px 18px rgba(108,242,194,.25);
    color: #0b1020;
    text-decoration: none;
    font-weight: 600;
    transition: opacity 0.3s, transform 0.2s;
    font-size: clamp(13px, 2vw, 15px);
    border: none;
    cursor: pointer;
}

:root[data-theme="light"] .btn {
    box-shadow: 0 4px 12px rgba(0,122,61,.2);
}

.btn.disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

.btn.secondary {
    background: transparent;
    border: 1px solid rgba(122,162,255,.4);
    color: var(--text);
}

.btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

/* 按钮容器 */
.card .buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
}

/* =================================
   关于布局
================================= */
.about {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(20px, 4vw, 40px);
}

    .about p {
        color: var(--muted);
        font-size: clamp(15px, 2.2vw, 17px);
        line-height: 1.7;
    }

@media (max-width: 640px) {
    .about {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}

/* =================================
   Footer
================================= */
footer {
    text-align: center;
    padding: clamp(24px, 5vh, 40px) var(--container-padding);
    color: var(--muted);
    border-top: 1px solid rgba(122,162,255,.15);
    background: rgba(11,16,32,.6);
    margin-top: auto; /* 将footer推到底部 */
    width: 100%;
}

:root[data-theme="light"] footer {
    background: rgba(255,255,255,.8);
}

footer a {
    color: var(--accent2);
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 500;
    transition: color 0.3s, text-decoration 0.3s;
}

:root[data-theme="light"] footer a {
    color: #0056b3;
}

footer a:hover {
    color: var(--accent);
    text-decoration: none;
}

footer a:visited {
    color: var(--muted);
    opacity: 0.85;
}

:root[data-theme="light"] footer a:visited {
    color: #6c757d;
}

footer a.footer-highlight {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

    footer a.footer-highlight:hover {
        text-decoration: underline;
    }

:root[data-theme="light"] footer a.footer-highlight {
    color: #007a3d;
}

/* =================================
   打印优化
================================= */
@media print {
    nav, footer, .btn, #theme-toggle, .skip-link, #stars {
        display: none !important;
    }

    body {
        background: white !important;
        color: black !important;
    }

    section {
        max-width: 100%;
        padding: 1cm;
    }

    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
        background: white !important;
    }

        .card h3, .card p, .card-subtitle {
            color: black !important;
        }

    .tag {
        border: 1px solid #ccc;
        background: #f5f5f5 !important;
        color: black !important;
    }
}

/* =================================
   星空背景 & 动态星星
================================= */
#stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    transition: background 0.5s ease;
    pointer-events: none; /* 确保不干扰点击 */
}

.star {
    position: absolute;
    border-radius: 50%;
    opacity: 0.8;
    animation: twinkle 4s infinite alternate;
}

@keyframes twinkle {
    from {
        opacity: 0.3;
        transform: scale(1);
    }

    to {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* 星空背景颜色根据主题 */
:root[data-theme='dark'] #stars {
    background: var(--bg);
}

:root[data-theme='light'] #stars {
    background: var(--bg);
}

/* 针对超小屏幕的优化 */
@media (max-width: 480px) {
    nav ul {
        gap: 8px;
    }

    nav a {
        font-size: 14px;
        padding: 4px 6px;
    }

    .btn {
        width: 100%; /* 小屏幕按钮全宽 */
        margin: 4px 0;
    }

    .card .buttons {
        flex-direction: column;
    }
}

/* 针对超宽屏幕的优化 */
@media (min-width: 2560px) {
    :root {
        --container-width: 1800px;
    }

    body {
        font-size: 18px;
    }

    .card {
        padding: 32px;
    }
}
