/* =========================================
   SafeW 全站共享样式 (Style Guide & Tokens)
   ========================================= */

/* --- 1. 设计变量 (Design Tokens) --- */
:root {
    /* 色板 */
    --color-dark: #10112D;      /* 深色面底色 */
    --color-paper: #F5F0E5;     /* 浅色纸面底色 */
    --color-text-body: #151523; /* 纸面上正文/标题色 */
    --color-brand: #1416EB;     /* 品牌色 (纸面上强调用) */
    --color-accent: #89ED6E;    /* 强调色 (按钮、深色面上强调用) */
    
    /* 派生透明度 (用于边框、阴影、背景层叠) */
    --opacity-border: 0.16;
    --opacity-subtle: 0.06;

    /* 圆角系统 */
    --radius-card: 24px;
    --radius-btn: 999px;
    --radius-badge: 8px;
    --radius-sm: 12px;

    /* 间距与节奏 */
    --section-y: clamp(3.5rem, 7vw, 6rem);
    --gap: clamp(1rem, 2vw, 1.75rem);
    --line-height-base: 1.65;
    
    /* 最大宽度 */
    --content-max: 1280px;

    /* 字体栈 */
    --font-main: "PingFang SC", "SF Pro SC", "Helvetica Neue", system-ui, sans-serif;
}

/* --- 2. 全局重置与基础排版 --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-main);
    background-color: var(--color-paper);
    color: var(--color-text-body);
    line-height: var(--line-height-base);
    font-size: 16px;
    overflow-x: hidden;
}

/* 链接通用样式 */
a {
    color: inherit;
    text-decoration: none;
    transition: opacity 0.2s ease;
}
a:hover { opacity: 0.85; }
a:focus-visible {
    outline: 2px solid var(--color-brand);
    outline-offset: 2px;
    border-radius: 2px;
}

/* 容器限制 */
.container {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 var(--gap);
}

/* 段落与文本 */
p {
    margin-bottom: 1em;
    max-width: 38em; /* 控制阅读行宽 */
}

/* 标题层级 */
h1, h2, h3, h4 {
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.25;
    color: inherit;
}

h1 {
    font-size: clamp(2rem, 4.6vw, 3.4rem);
    margin-bottom: 1.5rem;
}

h2 {
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    margin-bottom: 1.5rem;
    position: relative;
}

h3 {
    font-size: clamp(1.25rem, 2vw, 1.5rem);
    margin-bottom: 1rem;
}

/* 眉标 (Section Label) */
.section-label {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
    padding: 4px 12px;
    border-radius: var(--radius-badge);
}
/* 眉标颜色随背景变化 */
.light-paper .section-label {
    color: var(--color-brand);
    background-color: rgba(20, 22, 235, 0.08);
}
.dark-surface .section-label {
    color: var(--color-accent);
    background-color: rgba(137, 237, 110, 0.15);
}

/* 关键词高亮 */
.hl {
    /* 默认继承父级颜色，具体颜色由父级 context 决定或通过 CSS 变量覆盖 */
    font-weight: 700;
}
.light-paper .hl { color: var(--color-brand); }
.dark-surface .hl { color: var(--color-accent); }

/* --- 3. 页面布局区块 (Surface Alternation) --- */
.light-paper {
    background-color: var(--color-paper);
    color: var(--color-text-body);
}

.dark-surface {
    background-color: var(--color-dark);
    color: var(--color-paper);
}

section {
    padding-top: var(--section-y);
    padding-bottom: var(--section-y);
}

/* --- 4. 组件：按钮 (Buttons) --- */
.btn-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 24px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 52px;
    padding: 0 28px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-btn);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-2px);
    opacity: 1;
}

.btn:active {
    transform: translateY(0);
}

.btn svg {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    stroke-width: 2;
}

/* 主按钮：强调色底，深色面文字 */
.btn-primary {
    background-color: var(--color-accent);
    color: var(--color-dark);
    border: none;
}
.btn-primary:hover {
    filter: brightness(0.95);
}

/* 次按钮：描边样式 */
.btn-secondary {
    background: transparent;
    border: 1px solid currentColor;
}
/* 在深色面上，次按钮用浅色描边 */
.dark-surface .btn-secondary {
    color: var(--color-paper);
    border-color: var(--color-paper);
}
/* 在浅色面上，次按钮用深色描边 */
.light-paper .btn-secondary {
    color: var(--color-text-body);
    border-color: var(--color-text-body);
}

/* --- 5. 组件：卡片 (Cards) --- */
.card {
    background-color: var(--color-paper);
    border: var(--card-border) rgba(21, 21, 35, var(--opacity-border));
    border-radius: var(--radius-card);
    padding: 24px;
    box-shadow: var(--card-shadow);
    transition: transform 0.3s ease;
}
.dark-surface .card {
    /* 深色面上的浅色卡片，恢复纸面取色逻辑 */
    background-color: var(--color-paper);
    color: var(--color-text-body);
}

/* --- 6. 组件：表格 (Table) --- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-card);
    border: var(--card-border) rgba(21, 21, 35, var(--opacity-border));
    background-color: rgba(255, 255, 255, 0.5);
}
table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* 防止手机上挤压过甚 */
}
th, td {
    padding: 16px 24px;
    text-align: left;
    border-bottom: 1px solid rgba(21, 21, 35, 0.08);
}
th {
    font-weight: 700;
    background-color: rgba(21, 21, 35, 0.03);
}
tr:last-child td {
    border-bottom: none;
}
td strong {
    font-weight: 600;
}

/* --- 7. 组件：FAQ (Details/Summary) --- */
.faq-list {
    display: grid;
    gap: 16px;
}
.faq-item {
    border: var(--card-border) rgba(21, 21, 35, var(--opacity-border));
    border-radius: var(--radius-card);
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.6);
}
.faq-item summary {
    padding: 20px 24px;
    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.5rem;
    font-weight: 300;
    transition: transform 0.3s ease;
}
.faq-item[open] summary::after {
    transform: rotate(45deg);
}
.faq-item .faq-answer {
    padding: 0 24px 24px 24px;
    color: var(--color-text-body);
    opacity: 0.9;
}

/* --- 8. 页头与页脚 (Header & Footer) --- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: rgba(245, 240, 229, 0.85); /* 默认纸面半透明 */
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(21, 21, 35, 0.05);
    height: 72px;
    display: flex;
    align-items: center;
}
.dark-surface .site-header {
    background-color: rgba(16, 17, 45, 0.85);
    border-bottom: 1px solid rgba(245, 240, 229, 0.1);
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-links {
    display: flex;
    gap: 32px;
}
.nav-links a {
    font-size: 0.95rem;
    font-weight: 500;
    opacity: 0.7;
}
.nav-links a:hover, .nav-links a[aria-current="page"] {
    opacity: 1;
}
.nav-links a[aria-current="page"] {
    color: var(--color-brand);
    font-weight: 700;
}
.dark-surface .nav-links a[aria-current="page"] {
    color: var(--color-accent);
}

.site-footer {
    padding: 64px 0 32px;
    background-color: var(--color-dark);
    color: var(--color-paper);
    font-size: 0.9rem;
}
.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 48px;
    margin-bottom: 48px;
}
.footer-col h4 {
    color: var(--color-accent);
    margin-bottom: 16px;
    font-size: 1rem;
}
.footer-col ul {
    list-style: none;
}
.footer-col li {
    margin-bottom: 10px;
}
.footer-col a:hover {
    text-decoration: underline;
}
.copyright {
    border-top: 1px solid rgba(245, 240, 229, 0.1);
    padding-top: 32px;
    text-align: center;
    opacity: 0.6;
}

/* --- 9. SVG 动效方向 (Animations) --- */
/* 
   原则：
   1. 仅动画 transform, opacity, stroke-dashoffset
   2. pathLength="1", stroke-dasharray: 1, offset 从 1 -> 0
   3. 默认状态即最终可见状态，动画围绕默认状态循环或回到默认状态
   4. 尊重 prefers-reduced-motion
*/

@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;
    }
}

/* 路径描边流动 */
@keyframes draw-line {
    0% { stroke-dashoffset: 1; }
    50% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: 1; }
}
.path-flow {
    pathLength: 1;
    stroke-dasharray: 1;
    stroke-dashoffset: 0;
    animation: draw-line 3s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

/* 气泡漂浮与浮现 */
@keyframes float-up {
    0%, 100% { transform: translateY(0); opacity: 0.8; }
    50% { transform: translateY(-8px); opacity: 1; }
}
.bubble-float {
    animation: float-up 4s ease-in-out infinite;
}
.bubble-delay-1 { animation-delay: 0.5s; }
.bubble-delay-2 { animation-delay: 1.2s; }

/* 输入框呼吸点 */
@keyframes breathe {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}
.input-dot {
    animation: breathe 2s ease-in-out infinite;
}
.dot-1 { animation-delay: 0s; }
.dot-2 { animation-delay: 0.2s; }
.dot-3 { animation-delay: 0.4s; }

/* 通知卡片滑入 */
@keyframes slide-in-right {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
.notify-slide {
    animation: slide-in-right 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* 数据流小点流动 */
@keyframes flow-dot {
    0% { stroke-dashoffset: 1; }
    100% { stroke-dashoffset: 0; }
}
.data-flow {
    pathLength: 1;
    stroke-dasharray: 1;
    stroke-dashoffset: 0;
    animation: flow-dot 2s linear infinite;
}

/* --- 10. 响应式适配 (Responsive) --- */
@media (max-width: 768px) {
    .nav-links { display: none; } /* 简化版：移动端隐藏导航，仅留按钮 */
    .hero-layout {
        flex-direction: column-reverse;
    }
    .feature-row {
        flex-direction: column;
    }
    .scenario-grid {
        grid-template-columns: 1fr;
    }
    h1 { font-size: 2.2rem; }
}

/* 防止横向溢出 */
img, svg {
    max-width: 100%;
    height: auto;
}
.long-text {
    overflow-wrap: anywhere;
}

/* 修复 flex 子项最小宽度导致的横向溢出 */
.hero-layout > div,
.feature-row > div {
    min-width: 0;
}

/* 兜底：裁掉横向溢出 */
body > * {
  overflow-x: clip;
}
