/* =========================================
   SafeW 全站共享样式 (Shared Stylesheet)
   ========================================= */

/* --- 1. 设计变量 (Design Tokens) --- */
:root {
    /* 颜色系统 (Color System) */
    --color-dark-bg: #1B1231;
    --color-paper-bg: #DBD4ED;
    --color-text: #191523;
    --color-brand: #5214EB;
    --color-accent: #9977EE;
    
    /* 派生颜色 (Derived Colors) */
    --color-dark-text: #DBD4ED; /* 深色面上的文字 */
    --color-dark-accent: #C3B1F9; /* 深色面上的强调色变体（用于悬停或次要元素） */
    --color-border: rgba(25, 21, 35, 0.1);
    --color-dark-border: rgba(219, 212, 237, 0.15);

    /* 圆角 (Radius) */
    --radius-card: 24px;
    --radius-btn: 999px;
    --radius-sm: 8px;
    --radius-md: 12px;

    /* 阴影与边框 (Shadow & Border) */
    --card-border: 0;
    --card-shadow: none;
    --btn-shadow: 0 4px 12px rgba(82, 20, 235, 0.2);
    --focus-ring: 0 0 0 3px var(--color-brand), 0 0 0 5px var(--color-paper-bg);
    --dark-focus-ring: 0 0 0 3px var(--color-accent), 0 0 0 5px var(--color-dark-bg);

    /* 间距与布局 (Spacing & Layout) */
    --section-y: clamp(5rem, 10vw, 9rem);
    --gap: clamp(1.5rem, 3vw, 2.5rem);
    --content-max: 960px;
    --header-height: 72px;

    /* 字体 (Typography) */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    --line-height-tight: 1.2;
    --line-height-normal: 1.75;
}

/* --- 2. 基础重置与排版 (Reset & Base) --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    color: var(--color-text);
    background-color: var(--color-paper-bg);
    line-height: var(--line-height-normal);
    overflow-x: hidden;
}

img, svg {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

ul, ol {
    list-style: none;
}

/* --- 3. 容器与网格 (Layout) --- */
.container {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 var(--gap);
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
    gap: var(--gap);
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: var(--gap);
}

/* --- 4. 组件：按钮 (Buttons) --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 52px;
    padding: 0 32px;
    border-radius: var(--radius-btn);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    border: none;
    text-align: center;
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.btn-primary {
    background-color: var(--color-accent);
    color: var(--color-dark-bg);
    box-shadow: var(--btn-shadow);
}

.btn-primary:hover {
    background-color: #8866DD;
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: transparent;
    color: var(--color-text);
    border: 2px solid var(--color-text);
}

.btn-secondary:hover {
    background-color: rgba(25, 21, 35, 0.05);
    transform: translateY(-2px);
}

.dark .btn-secondary {
    color: var(--color-dark-text);
    border-color: var(--color-dark-text);
}

.dark .btn-secondary:hover {
    background-color: rgba(219, 212, 237, 0.1);
}

/* --- 5. 组件：卡片 (Cards) --- */
.card {
    background-color: rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-card);
    padding: var(--gap);
    border: var(--card-border);
    box-shadow: var(--card-shadow);
    transition: transform 0.3s ease, background-color 0.3s ease;
}

.dark .card {
    background-color: rgba(219, 212, 237, 0.08);
}

.card:hover {
    transform: translateY(-4px);
    background-color: rgba(255, 255, 255, 0.6);
}

.dark .card:hover {
    background-color: rgba(219, 212, 237, 0.12);
}

/* --- 6. 组件：表格 (Tables) --- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-card);
    border: 1px solid var(--color-border);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    background: rgba(255, 255, 255, 0.5);
}

.dark table {
    background: rgba(219, 212, 237, 0.05);
}

th, td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--color-border);
}

.dark th, .dark td {
    border-bottom-color: var(--color-dark-border);
}

th {
    font-weight: 700;
    background-color: rgba(255, 255, 255, 0.3);
    white-space: nowrap;
}

.dark th {
    background-color: rgba(219, 212, 237, 0.1);
}

tr:last-child td {
    border-bottom: none;
}

/* --- 7. 组件：眉标 (Labels/Badges) --- */
.label {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 16px;
    color: var(--color-brand);
}

.dark .label {
    color: var(--color-accent);
}

/* --- 8. 组件：FAQ (Details/Summary) --- */
.faq-item {
    border-bottom: 1px solid var(--color-border);
}

.dark .faq-item {
    border-bottom-color: var(--color-dark-border);
}

.faq-item summary {
    padding: 24px 0;
    cursor: pointer;
    font-weight: 600;
    font-size: 1.1rem;
    list-style: none;
    position: relative;
    padding-right: 40px;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: "+";
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5rem;
    font-weight: 300;
    color: var(--color-brand);
}

.dark .faq-item summary::after {
    color: var(--color-accent);
}

.faq-item[open] summary::after {
    content: "-";
}

.faq-item p {
    padding-bottom: 24px;
    color: var(--color-text);
    opacity: 0.85;
}

.dark .faq-item p {
    color: var(--color-dark-text);
}

/* --- 9. 页头与页脚 (Header & Footer) --- */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    z-index: 1000;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.site-header.scrolled {
    background-color: rgba(219, 212, 237, 0.9);
    backdrop-filter: blur(10px);
    box-shadow: 0 1px 0 var(--color-border);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    font-size: 1.2rem;
}

.logo img {
    height: 32px;
    width: auto;
}

.nav-links {
    display: flex;
    gap: 32px;
}

.nav-links a {
    font-weight: 500;
    font-size: 0.95rem;
    position: relative;
}

.nav-links a:hover, .nav-links a[aria-current="page"] {
    color: var(--color-brand);
}

.dark .nav-links a:hover, .dark .nav-links a[aria-current="page"] {
    color: var(--color-accent);
}

.site-footer {
    background-color: var(--color-dark-bg);
    color: var(--color-dark-text);
    padding: 64px 0 32px;
}

.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: 24px;
    font-size: 1rem;
}

.footer-col ul li {
    margin-bottom: 12px;
}

.footer-col ul li a {
    opacity: 0.7;
    font-size: 0.9rem;
}

.footer-col ul li a:hover {
    opacity: 1;
    color: var(--color-accent);
}

.footer-bottom {
    border-top: 1px solid var(--color-dark-border);
    padding-top: 32px;
    text-align: center;
    font-size: 0.85rem;
    opacity: 0.6;
}

/* --- 10. SVG 动效关键帧 (Keyframes) --- */

/* 星点明灭 */
@keyframes twinkle {
    0%, 100% { opacity: 0.2; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* 修复 SVG 溢出：确保变换不导致元素超出容器边界 */
.anim-star, .anim-float, .anim-breathe {
    transform-origin: center center;
}

/* 防止 SVG 动画导致的横向溢出 */
svg {
    display: block;
    max-width: 100%;
}

/* 连线流动 */
@keyframes flow-line {
    0% { stroke-dashoffset: 1; }
    100% { stroke-dashoffset: 0; }
}

/* 气泡浮动 */
@keyframes float-bubble {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* 输入框呼吸 */
@keyframes breathe-input {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* 滑入通知 */
@keyframes slide-in {
    0% { transform: translateX(20px); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

/* 应用动画的类 (Utility Classes for Animation) */
.anim-star {
    animation: twinkle 4s ease-in-out infinite alternate;
}
.anim-star.delay-1 { animation-delay: 1s; }
.anim-star.delay-2 { animation-delay: 2s; }

.anim-flow {
    stroke-dasharray: 1;
    stroke-dashoffset: 0;
    animation: flow-line 3s linear infinite;
}

.anim-float {
    animation: float-bubble 6s ease-in-out infinite;
}

.anim-breathe {
    animation: breathe-input 2s ease-in-out infinite;
}

.anim-slide {
    animation: slide-in 1s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* --- 11. 响应式媒体查询 (Media Queries) --- */
@media (max-width: 768px) {
    .nav-links { display: none; } /* 移动端简化导航 */
    :root { --section-y: 4rem; }
}

/* 减少动态效果偏好 */
@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;
    }
}

/* 兜底：裁掉横向溢出 */
body > * {
  overflow-x: clip;
}
