/* =========================================================
   八年七班学生网站 · 公共样式 common.css
   供 index.html 与 file 目录页（含子目录页）共同引用
   ========================================================= */

/* ---------- 设计变量 ---------- */
:root {
    --bg: #f5f5f7;
    --card: #ffffff;
    --surface: rgba(255, 255, 255, 0.82);
    --nav-bg: rgba(251, 251, 253, 0.72);
    --text: #1d1d1f;
    --text-2: #6e6e73;
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --accent-soft: rgba(0, 113, 227, 0.10);
    --border: rgba(0, 0, 0, 0.08);
    --shadow: 0 6px 28px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.14);
    --danger: #dc2626;
    --toast-bg: #1d1d1f;
    --toast-text: #f5f5f7;
    --thumb-bg: #e8e8ed;
    --scrollbar: #c7c7cc;
}
[data-theme="dark"] {
    --bg: #0b0b0f;
    --card: #1d1d1f;
    --surface: rgba(29, 29, 31, 0.72);
    --nav-bg: rgba(16, 16, 20, 0.72);
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --accent: #2997ff;
    --accent-hover: #66bbff;
    --accent-soft: rgba(41, 151, 255, 0.14);
    --border: rgba(255, 255, 255, 0.12);
    --shadow: 0 6px 28px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.55);
    --danger: #ff453a;
    --toast-bg: #f5f5f7;
    --toast-text: #1d1d1f;
    --thumb-bg: #2c2c2e;
    --scrollbar: #48484a;
}

/* ---------- 基础 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
        "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    line-height: 1.6;
    transition: background 0.4s ease, color 0.3s ease;
}
body.modal-open { overflow: hidden; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 12px; }

/* ---------- 图标尺寸 ---------- */
.icon-24 { width: 22px; height: 22px; }
.icon-16 { width: 16px; height: 16px; }

/* ---------- 吸顶导航 ---------- */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    background: var(--nav-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
    transition: background 0.3s ease, border-color 0.3s ease;
}
.nav-inner {
    max-width: 1080px;
    margin: 0 auto;
    height: 52px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.nav-links { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 980px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text-2);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}
.nav-link:hover { background: var(--border); color: var(--text); }
.nav-link.active { color: var(--text); font-weight: 600; }
.nav-trick { border: 1px solid var(--border); }
.nav-trick:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: none;
    color: var(--text-2);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.25s ease, color 0.25s ease, transform 0.2s ease;
}
.theme-toggle:hover { background: var(--border); color: var(--text); transform: scale(1.05); }
.theme-toggle svg { width: 17px; height: 17px; }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border-radius: 980px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent);
    background: transparent;
    border: 1px solid var(--accent);
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.25s ease, color 0.25s ease, transform 0.15s ease, box-shadow 0.25s ease;
}
.btn:hover { background: var(--accent-soft); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    box-shadow: 0 6px 20px rgba(0, 113, 227, 0.3);
}
.btn.copied { background: #34c759; border-color: #34c759; color: #fff; }
.btn .icon-16 { flex-shrink: 0; }

/* ---------- 弹窗 ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.modal[hidden] { display: none; }
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.modal-panel {
    position: relative;
    width: 100%;
    max-width: 760px;
    max-height: min(680px, 84vh);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(18px) scale(0.98); }
    to { opacity: 1; transform: none; }
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 24px 26px 10px; }
.modal-head h3 { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.01em; }
.modal-head p { font-size: 0.88rem; color: var(--text-2); margin-top: 3px; }
.modal-close {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: var(--thumb-bg);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.2s ease;
}
.modal-close:hover { transform: scale(1.08); }
.modal-body { padding: 8px 26px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 26px 20px; border-top: 1px solid var(--border); text-align: right; }
.modal-foot a { color: var(--accent); text-decoration: none; font-size: 0.9rem; font-weight: 500; }
.modal-foot a:hover { text-decoration: underline; }
.modal-text { color: var(--text-2); font-size: 0.98rem; line-height: 1.8; padding: 4px 26px 8px; }
.modal-btn-wrap { padding: 16px 26px 26px; text-align: right; }

/* ---------- 文件网格 ---------- */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}
.file-item {
    display: block;
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    background: var(--card);
    text-decoration: none;
    color: inherit;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.file-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(0, 113, 227, 0.4);
}
.file-thumb { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--thumb-bg); }
.file-video {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}
.file-video .play-badge {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease, background 0.25s ease;
}
.file-item:hover .play-badge { transform: scale(1.1); background: rgba(255, 255, 255, 0.34); }
.file-folder {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: var(--accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}
.file-item .meta { padding: 9px 11px 11px; }
.file-item .name { font-size: 0.82rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-item .size { font-size: 0.74rem; color: var(--text-2); margin-top: 1px; }
.file-empty { padding: 40px 20px; text-align: center; color: var(--text-2); font-size: 0.95rem; }

/* ---------- 公共响应式 ---------- */
@media (max-width: 820px) {
    .nav-links { gap: 2px; }
    .nav-link { padding: 7px 10px; font-size: 0.88rem; }
}
@media (max-width: 520px) {
    .file-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
}
