/* =========================================
   SafeW - Global Styles & Design Tokens
   ========================================= */

:root {
    /* 色板 */
    --bg-dark: #2D1438;
    --bg-paper: #F6F3F7;
    --text-body: #1F1523;
    --brand-color: #9E13DD;
    --accent-color: #6EEDA8;
    
    /* 派生颜色 (仅用于透明度或极微调) */
    --text-body-light: rgba(31, 21, 35, 0.7);
    --bg-paper-dark: rgba(246, 243, 247, 0.95);
    --bg-dark-overlay: rgba(45, 20, 56, 0.9);

    /* 圆角与边界 */
    --radius-card: 20px;
    --radius-btn: 12px;
    --card-border: 1px solid rgba(31, 21, 35, 0.16);
    --card-shadow: none;

    /* 间距与布局 */
    --section-y: clamp(5rem, 10vw, 9rem);
    --gap: clamp(1.5rem, 3vw, 2.5rem);
    --content-max: 1280px;
    --header-height: 64px;

    /* 字体 */
    --font-sans: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SF Mono", "Menlo", "Consolas", monospace;
}

/* =========================================
   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(--text-body);
    background-color: var(--bg-paper);
    line-height: 1.75;
    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;
}

/* =========================================
   Typography
   ========================================= */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.25;
    color: var(--text-body);
}

h1 {
    font-size: clamp(2.2rem, 5vw, 3.8rem);
    letter-spacing: -0.02em;
    line-height: 1.1;
}

h2 {
    font-size: clamp(1.6rem, 3vw, 2.4rem);
}

h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5em;
}

p {
    margin-bottom: 1em;
    max-width: 38em;
}

.hl {
    color: var(--brand-color);
}

.dark-surface .hl {
    color: var(--accent-color);
}

/* =========================================
   Layout Components
   ========================================= */
.container {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 24px;
}

.section {
    padding-top: var(--section-y);
    padding-bottom: var(--section-y);
    position: relative;
}

/* Dark Surface Variant */
.dark-surface {
    background-color: var(--bg-dark);
    color: var(--bg-paper);
}

.dark-surface h1, 
.dark-surface h2, 
.dark-surface h3, 
.dark-surface p {
    color: var(--bg-paper);
}

.dark-surface a:not(.btn):hover {
    color: var(--accent-color);
}

/* Paper Card Variant inside Dark Surface */
.paper-card {
    background-color: var(--bg-paper);
    color: var(--text-body);
    border-radius: var(--radius-card);
    border: var(--card-border);
    padding: 24px;
    box-shadow: var(--card-shadow);
}

.paper-card h1, 
.paper-card h2, 
.paper-card h3, 
.paper-card p {
    color: var(--text-body);
}

.paper-card .hl {
    color: var(--brand-color);
}

/* =========================================
   Header & Nav
   ========================================= */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--bg-paper);
    height: var(--header-height);
    border-bottom: 1px solid rgba(31, 21, 35, 0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.dark-surface .site-header {
    background-color: var(--bg-dark-overlay);
    border-bottom: 1px solid rgba(246, 243, 247, 0.1);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.2rem;
}

.brand img {
    height: 32px;
    width: auto;
}

.nav-links {
    display: flex;
    gap: 24px;
    align-items: center;
}

.nav-links a {
    font-size: 0.95rem;
    font-weight: 500;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
    opacity: 1;
    color: var(--brand-color);
}

.dark-surface .nav-links a:hover,
.dark-surface .nav-links a[aria-current="page"] {
    color: var(--accent-color);
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-body);
}

.dark-surface .menu-toggle {
    color: var(--bg-paper);
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }
    .nav-links {
        display: none;
        position: absolute;
        top: var(--header-height);
        left: 0;
        right: 0;
        background-color: var(--bg-paper);
        flex-direction: column;
        padding: 24px;
        border-bottom: 1px solid rgba(0,0,0,0.1);
        box-shadow: 0 10px 20px rgba(0,0,0,0.05);
    }
    .dark-surface .nav-links {
        background-color: var(--bg-dark);
        color: var(--bg-paper);
    }
    .nav-links.active {
        display: flex;
    }
}

/* =========================================
   Buttons
   ========================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 48px;
    padding: 0 24px;
    border-radius: var(--radius-btn);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease, background-color 0.2s ease;
    border: none;
    text-decoration: none;
}

.btn:focus-visible {
    outline: 2px solid var(--brand-color);
    outline-offset: 2px;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn-primary {
    background-color: var(--accent-color);
    color: var(--bg-dark);
}

.btn-primary:hover {
    filter: brightness(0.95);
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-body);
    border: 1px solid var(--text-body);
}

.dark-surface .btn-secondary {
    color: var(--bg-paper);
    border-color: var(--bg-paper);
}

.btn-secondary:hover {
    background-color: rgba(31, 21, 35, 0.05);
}

.dark-surface .btn-secondary:hover {
    background-color: rgba(246, 243, 247, 0.1);
}

.btn-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

/* =========================================
   Feature Blocks & Grid
   ========================================= */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--gap);
    margin-top: var(--gap);
}

.feature-card {
    background-color: var(--bg-paper);
    border: var(--card-border);
    border-radius: var(--radius-card);
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: transform 0.2s ease;
}

.feature-card:hover {
    transform: translateY(-4px);
}

.dark-surface .feature-card {
    background-color: var(--bg-dark);
    border-color: rgba(246, 243, 247, 0.1);
    color: var(--bg-paper);
}

.dark-surface .feature-card h3 {
    color: var(--bg-paper);
}

.icon-box {
    width: 48px;
    height: 48px;
    background-color: rgba(158, 19, 221, 0.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-color);
}

.dark-surface .icon-box {
    background-color: rgba(110, 237, 168, 0.1);
    color: var(--accent-color);
}

/* Zig-Zag Layout for Core Features */
.zigzag-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--gap);
    margin-bottom: calc(var(--section-y) * 2);
}

.zigzag-row:last-child {
    margin-bottom: 0;
}

.zigzag-text {
    flex: 1;
    min-width: 300px;
}

.zigzag-visual {
    flex: 1;
    min-width: 300px;
    background-color: var(--bg-dark);
    border-radius: var(--radius-card);
    padding: 32px;
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.dark-surface .zigzag-visual {
    background-color: rgba(246, 243, 247, 0.05);
}

@media (max-width: 768px) {
    .zigzag-row.reverse {
        flex-direction: column-reverse;
    }
}

/* =========================================
   Timeline (One Day Usage)
   ========================================= */
.timeline {
    position: relative;
    padding-left: 32px;
    border-left: 2px solid rgba(158, 19, 221, 0.2);
    margin-top: 48px;
}

.timeline-item {
    position: relative;
    margin-bottom: 48px;
    padding-left: 24px;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-marker {
    position: absolute;
    left: -39px;
    top: 0;
    width: 16px;
    height: 16px;
    background-color: var(--brand-color);
    border: 3px solid var(--bg-paper);
    border-radius: 50%;
    z-index: 2;
}

.dark-surface .timeline-marker {
    background-color: var(--accent-color);
    border-color: var(--bg-dark);
}

.timeline-time {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--brand-color);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
    display: block;
}

.dark-surface .timeline-time {
    color: var(--accent-color);
}

/* =========================================
   Tables
   ========================================= */
.table-wrapper {
    overflow-x: auto;
    border: var(--card-border);
    border-radius: var(--radius-card);
    margin-top: 24px;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th, td {
    padding: 16px 24px;
    border-bottom: 1px solid rgba(31, 21, 35, 0.08);
}

.dark-surface th, 
.dark-surface td {
    border-bottom-color: rgba(246, 243, 247, 0.08);
}

th {
    font-weight: 600;
    background-color: rgba(31, 21, 35, 0.03);
    color: var(--text-body);
}

.dark-surface th {
    background-color: rgba(246, 243, 247, 0.05);
    color: var(--bg-paper);
}

tr:last-child th, 
tr:last-child td {
    border-bottom: none;
}

/* =========================================
   FAQ Details/Summary
   ========================================= */
.faq-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 32px;
}

details {
    border: var(--card-border);
    border-radius: var(--radius-btn);
    padding: 16px 24px;
    background-color: var(--bg-paper);
    transition: all 0.2s ease;
}

.dark-surface details {
    background-color: rgba(246, 243, 247, 0.05);
    border-color: rgba(246, 243, 247, 0.1);
}

summary {
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1rem;
}

summary::-webkit-details-marker {
    display: none;
}

summary::after {
    content: "+";
    font-size: 1.5rem;
    font-weight: 400;
    transition: transform 0.2s ease;
}

details[open] summary::after {
    transform: rotate(45deg);
}

details p {
    margin-top: 16px;
    color: var(--text-body-light);
}

.dark-surface details p {
    color: rgba(246, 243, 247, 0.8);
}

/* =========================================
   News Cards
   ========================================= */
.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--gap);
    margin-top: 32px;
}

.news-card {
    background-color: var(--bg-paper);
    border: var(--card-border);
    border-radius: var(--radius-card);
    padding: 24px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.dark-surface .news-card {
    background-color: rgba(246, 243, 247, 0.05);
    border-color: rgba(246, 243, 247, 0.1);
}

.news-date {
    font-size: 0.8rem;
    color: var(--brand-color);
    margin-bottom: 12px;
    font-weight: 600;
}

.dark-surface .news-date {
    color: var(--accent-color);
}

.news-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 12px;
    line-height: 1.4;
}

.news-excerpt {
    font-size: 0.95rem;
    color: var(--text-body-light);
    flex-grow: 1;
}

.dark-surface .news-excerpt {
    color: rgba(246, 243, 247, 0.7);
}

/* =========================================
   Footer
   ========================================= */
.site-footer {
    background-color: var(--bg-dark);
    color: var(--bg-paper);
    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(--bg-paper);
    margin-bottom: 24px;
    font-size: 1rem;
}

.footer-col ul li {
    margin-bottom: 12px;
}

.footer-col a {
    color: rgba(246, 243, 247, 0.7);
    font-size: 0.9rem;
}

.footer-col a:hover {
    color: var(--accent-color);
}

.footer-bottom {
    border-top: 1px solid rgba(246, 243, 247, 0.1);
    padding-top: 32px;
    text-align: center;
    color: rgba(246, 243, 247, 0.5);
    font-size: 0.85rem;
}

/* =========================================
   SVG Animations
   ========================================= */
.svg-container {
    width: 100%;
    height: auto;
    max-width: 100%;
}

/* Grid Node Animation */
@keyframes nodePulse {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 1; }
}

.node {
    animation: nodePulse 3s infinite ease-in-out;
}

.node:nth-child(odd) {
    animation-delay: 0.5s;
}

.node:nth-child(even) {
    animation-delay: 1.5s;
}

/* Draw Line Animation */
@keyframes drawLine {
    from { stroke-dashoffset: 1; }
    to { stroke-dashoffset: 0; }
}

.draw-line {
    stroke-dasharray: 1;
    stroke-dashoffset: 0;
    animation: drawLine 2s ease forwards;
}

/* Float Animation */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.float-anim {
    animation: float 4s ease-in-out infinite;
}

/* Slide In Animation */
@keyframes slideIn {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.slide-in {
    animation: slideIn 0.8s ease forwards;
}

/* 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;
    }
    .node, .draw-line, .float-anim, .slide-in {
        opacity: 1 !important;
        transform: none !important;
    }
}
