/* =========================================
   SafeW 全站共享样式 (style.css)
   ========================================= */

/* --- 1. 设计变量与 Reset --- */
:root {
    /* 色板 */
    --color-bg-dark: #140E25;
    --color-bg-paper: #F5F0E5;
    --color-text-body: #191523;
    --color-text-body-rgb: 25, 21, 35;
    --color-brand: #5214EB;
    --color-accent: #C8ED6E;
    
    /* 组件 Token */
    --radius-card: 8px;
    --radius-btn: 6px;
    --card-border: 1px solid rgba(var(--color-text-body-rgb), 0.16);
    --card-shadow: none;
    
    /* 节奏与布局 */
    --section-y: clamp(5rem, 10vw, 9rem);
    --gap: clamp(1.5rem, 3vw, 2.5rem);
    --content-max: 960px;
    
    /* 字体 */
    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background-color: var(--color-bg-paper);
    color: var(--color-text-body);
    line-height: 1.75;
    font-size: 16px;
    overflow-x: hidden;
}

img, svg {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
    text-decoration: none;
}

ul, ol {
    list-style: none;
}

/* --- 2. 通用排版 --- */
.container {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 var(--gap);
}

.section {
    padding-top: var(--section-y);
    padding-bottom: var(--section-y);
    position: relative;
}

.section-header {
    margin-bottom: var(--gap);
}

.badge {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    color: var(--color-brand);
}

.dark-section .badge {
    color: var(--color-accent);
}

h1, h2, h3, h4 {
    line-height: 1.25;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--color-text-body);
}

.dark-section h1, 
.dark-section h2, 
.dark-section h3, 
.dark-section h4 {
    color: var(--color-bg-paper);
}

h1 {
    font-size: clamp(2rem, 4.6vw, 3.4rem);
    margin-bottom: 1rem;
    text-wrap: balance;
}

h2 {
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    margin-bottom: 0.75rem;
}

h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

p {
    margin-bottom: 1rem;
    max-width: 38em;
}

/* 高亮词 */
.hl {
    color: var(--color-brand);
    font-weight: 700;
}

.dark-section .hl {
    color: var(--color-accent);
}

/* --- 3. 页头与页脚 --- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--color-bg-paper);
    border-bottom: 1px solid rgba(var(--color-text-body-rgb), 0.1);
    padding: 1rem 0;
    transition: background-color 0.3s;
}

.dark-section .site-header {
    background-color: var(--color-bg-dark);
    border-bottom-color: rgba(var(--color-text-body-rgb), 0.05);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 800;
    font-size: 1.2rem;
}

.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;
    transition: opacity 0.2s;
}

nav a:hover, nav a:focus-visible {
    opacity: 0.8;
}

nav a[aria-current="page"] {
    color: var(--color-brand);
    font-weight: 700;
}

.dark-section nav a[aria-current="page"] {
    color: var(--color-accent);
}

.site-footer {
    background-color: var(--color-bg-dark);
    color: var(--color-bg-paper);
    padding: 3rem 0;
    font-size: 0.9rem;
}

.footer-inner {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
    text-align: center;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer-links a {
    color: var(--color-bg-paper);
    opacity: 0.8;
}

.footer-links a:hover {
    opacity: 1;
    text-decoration: underline;
}

/* --- 4. 按钮 --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 48px;
    padding: 0 1.5rem;
    border-radius: var(--radius-btn);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s, box-shadow 0.2s;
    border: none;
    text-decoration: none;
}

.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);
}

.btn-primary:hover {
    filter: brightness(0.95);
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--color-text-body);
    color: var(--color-text-body);
}

.dark-section .btn-secondary {
    border-color: var(--color-bg-paper);
    color: var(--color-bg-paper);
}

.btn-icon {
    width: 20px;
    height: 20px;
}

/* --- 5. 卡片与面板 --- */
.card {
    background-color: var(--color-bg-paper);
    border: var(--card-border);
    border-radius: var(--radius-card);
    padding: var(--gap);
    transition: transform 0.2s;
}

.panel {
    background-color: var(--color-bg-dark);
    border-radius: 16px;
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.panel-light {
    background-color: var(--color-bg-paper);
    border: var(--card-border);
}

/* --- 6. 表格 --- */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95rem;
    table-layout: fixed;
}

th, td {
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(var(--color-text-body-rgb), 0.1);
    overflow-wrap: break-word;
}

th {
    font-weight: 600;
    color: var(--color-brand);
}

.dark-section th {
    color: var(--color-accent);
}

tr:last-child td {
    border-bottom: none;
}

/* --- 7. FAQ (Details/Summary) --- */
.faq-item {
    border-bottom: 1px solid rgba(var(--color-text-body-rgb), 0.1);
    margin-bottom: 0.5rem;
}

.faq-item summary {
    padding: 1rem 0;
    cursor: pointer;
    font-weight: 600;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: '+';
    font-size: 1.2rem;
    transition: transform 0.2s;
}

.faq-item[open] summary::after {
    transform: rotate(45deg);
}

.faq-item p {
    margin-top: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.95rem;
    color: rgba(var(--color-text-body-rgb), 0.8);
}

/* --- 8. SVG 动效 --- */
svg {
    width: 100%;
    height: auto;
    overflow: visible;
}

/* 卡片漂浮 */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.anim-float-1 { animation: float 6s ease-in-out infinite; }
.anim-float-2 { animation: float 7s ease-in-out infinite 1s; }
.anim-float-3 { animation: float 5s ease-in-out infinite 0.5s; }

/* 描边绘制 */
@keyframes draw {
    from { stroke-dashoffset: 1; }
    to { stroke-dashoffset: 0; }
}

.anim-draw {
    path {
        stroke-dasharray: 1;
        stroke-dashoffset: 0;
    }
    &:hover path,
    &:focus path {
        animation: draw 2s ease forwards;
    }
}

/* 呼吸灯 */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.anim-pulse {
    animation: pulse 3s ease-in-out infinite;
}

/* 减少动画偏好 */
@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;
    }
    .anim-float-1, .anim-float-2, .anim-float-3 {
        animation: none;
    }
}

/* --- 9. 响应式微调 --- */
@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        gap: 1rem;
    }
    nav ul {
        flex-wrap: wrap;
        justify-content: center;
    }
    .btn {
        width: 100%;
    }
}
