/* =========================================
   SafeW 全站共享样式 (style.css)
   品牌配色：靛蓝深底 + 天蓝强调 · 纯白纸面
   ========================================= */

/* --- 1. 设计变量 (Design Tokens) --- */
:root {
    /* 颜色系统 */
    --color-bg-dark: #141838;       /* 深色面 */
    --color-bg-light: #FCFCFD;      /* 纸面 */
    --color-text-body: #151723;     /* 正文色 */
    --color-brand: #142CEB;         /* 品牌色 */
    --color-accent: #6EAFED;        /* 强调色 */
    --color-white: #FFFFFF;
    --color-border: #E2E8F0;

    /* 圆角 */
    --radius-card: 8px;
    --radius-btn: 6px;
    --radius-badge: 4px;

    /* 卡片边界与阴影 */
    --card-border: 2px solid var(--color-text-body);
    --card-shadow: 4px 4px 0 var(--color-text-body);

    /* 节奏与密度 */
    --section-y: clamp(2.5rem, 5vw, 4rem);
    --gap: clamp(0.75rem, 1.5vw, 1.25rem);
    --line-height: 1.55;
    
    /* 内容宽度 */
    --content-max: 1120px;

    /* 字体 */
    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* --- 2. 基础重置与排版 --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: var(--font-sans);
    background-color: var(--color-bg-light);
    color: var(--color-text-body);
    line-height: var(--line-height);
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    max-width: 100vw;
}

img, svg {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
    text-decoration: none;
}

ul, ol {
    list-style: none;
}

/* --- 3. 通用布局 --- */
.container {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 var(--gap);
}

section {
    padding: var(--section-y) 0;
    position: relative;
}

/* 细线分节：在纸面上，区块之间用分隔线区分 */
.section-divider {
    border-top: 1px solid var(--color-border);
    margin: 0 calc(var(--gap) * -1); /* 抵消 container padding */
}

/* --- 4. 标题与眉标 --- */
.badge {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-brand);
    margin-bottom: 0.75rem;
}

.dark-surface .badge {
    color: var(--color-accent);
}

h1, h2, h3, h4 {
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.02em;
    color: var(--color-text-body);
    margin-bottom: 0.75rem;
}

.dark-surface h1, 
.dark-surface h2, 
.dark-surface h3 {
    color: var(--color-white);
}

h1 {
    font-size: clamp(2.2rem, 5vw, 3.8rem);
    margin-bottom: 1rem;
}

h2 {
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    margin-bottom: 1.5rem;
}

h3 {
    font-size: clamp(1.2rem, 2vw, 1.5rem);
    margin-bottom: 0.5rem;
}

/* 关键词高亮 */
.hl {
    color: var(--color-brand);
}

.dark-surface .hl {
    color: var(--color-accent);
}

p {
    margin-bottom: 1rem;
    max-width: 38em;
}

/* --- 5. 按钮组件 --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 48px;
    padding: 0 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-btn);
    transition: transform 0.2s ease, opacity 0.2s ease;
    cursor: pointer;
    text-align: center;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.btn-primary {
    background-color: var(--color-accent);
    color: var(--color-bg-dark);
    border: none;
}

.btn-secondary {
    background-color: transparent;
    color: var(--color-text-body);
    border: 2px solid var(--color-text-body);
}

.dark-surface .btn-secondary {
    color: var(--color-white);
    border-color: var(--color-white);
}

/* --- 6. 卡片组件 (粗描边硬阴影) --- */
.card {
    background: var(--color-white);
    border: var(--card-border);
    box-shadow: var(--card-shadow);
    border-radius: var(--radius-card);
    padding: 1.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.dark-surface .card {
    /* 深色面上的浅色卡片恢复纸面取色逻辑 */
    background: var(--color-white);
    color: var(--color-text-body);
}

/* --- 7. 表格 --- */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

th {
    background-color: #f1f5f9;
    font-weight: 600;
    white-space: nowrap;
}

tr:last-child td {
    border-bottom: none;
}

/* --- 8. FAQ (Details/Summary) --- */
details {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    margin-bottom: 0.75rem;
    padding: 1rem;
    background: var(--color-white);
}

summary {
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

summary::-webkit-details-marker {
    display: none;
}

summary::after {
    content: "+";
    font-size: 1.2rem;
    font-weight: 400;
    transition: transform 0.2s;
}

details[open] summary::after {
    transform: rotate(45deg);
}

details p {
    margin-top: 1rem;
    margin-bottom: 0;
    color: #475569;
}

/* --- 9. 页头与页脚 --- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(252, 252, 253, 0.9);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--color-border);
    padding: 0.75rem 0;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--color-text-body);
}

.brand-logo img {
    height: 32px;
    width: auto;
}

nav ul {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

nav a {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-text-body);
    transition: color 0.2s;
}

nav a:hover, nav a[aria-current="page"] {
    color: var(--color-brand);
}

.dark-surface nav a {
    color: var(--color-white);
}

.dark-surface nav a:hover, 
.dark-surface nav a[aria-current="page"] {
    color: var(--color-accent);
}

.site-footer {
    background-color: var(--color-bg-dark);
    color: var(--color-white);
    padding: 3rem 0;
    margin-top: var(--section-y);
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer-links a {
    color: #94a3b8;
    font-size: 0.9rem;
}

.footer-links a:hover {
    color: var(--color-white);
}

/* --- 10. SVG 动效关键帧 --- */

/* 网格节点依次点亮 */
@keyframes grid-glow {
    0%, 20% { fill-opacity: 0.1; }
    40%, 80% { fill-opacity: 1; }
    100% { fill-opacity: 0.1; }
}

.grid-node {
    animation: grid-glow 4s infinite ease-in-out;
}

/* 浮动效果 */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.float-anim {
    animation: float 6s infinite ease-in-out;
}

/* 呼吸效果 */
@keyframes breathe {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.breathe-anim {
    animation: breathe 3s infinite ease-in-out;
}

/* 减少动态效果偏好 */
@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;
    }
}

/* --- 11. 响应式调整 --- */
@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    nav ul {
        gap: 1rem;
    }
    
    .footer-inner {
        flex-direction: column;
        text-align: center;
    }
    
    .grid-layout {
        grid-template-columns: 1fr !important;
    }
}

/* --- 12. 辅助工具类 --- */
.text-center { text-align: center; }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.gap-1 { gap: 1rem; }
.grid-layout {
    display: grid;
    gap: var(--gap);
}
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* 杂志式长文排版 */
.magazine-layout {
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 2rem;
}
.sticky-toc {
    position: sticky;
    top: 6rem;
    font-size: 0.9rem;
    border-left: 2px solid var(--color-border);
    padding-left: 1rem;
}
.sticky-toc li {
    margin-bottom: 0.75rem;
    color: #64748b;
    cursor: pointer;
}
.sticky-toc li:hover {
    color: var(--color-brand);
}

@media (max-width: 900px) {
    .magazine-layout {
        grid-template-columns: 1fr;
    }
    .sticky-toc {
        position: static;
        border-left: none;
        border-bottom: 2px solid var(--color-border);
        padding-bottom: 1rem;
        margin-bottom: 2rem;
        display: flex;
        gap: 1rem;
        flex-wrap: wrap;
    }
}
