/* =========================================
   SafeW Style System & Shared Components
   ========================================= */

/* --- Design Tokens & Variables --- */
:root {
    /* Color Palette */
    --color-deep-bg: #231334;       /* 深色面：首屏、重点区 */
    --color-paper-bg: #E9E8EA;      /* 纸面：大部分内容区 */
    --color-text-main: #1C1523;     /* 正文色：标题与正文 */
    --color-brand: #7D14EB;         /* 品牌色：强调词、图标、眉标 */
    --color-accent: #EDD26E;        /* 强调色：按钮、徽标 */
    
    /* Semantic Colors (Derived for specific contexts) */
    /* Light Paper Context (Default) */
    --bg-surface: var(--color-paper-bg);
    --text-primary: var(--color-text-main);
    --text-secondary: #555555;      /* 辅助文字，基于正文色微调 */
    --brand-color: var(--color-brand);
    --accent-color: var(--color-accent);
    --border-subtle: rgba(28, 21, 35, 0.1);
    
    /* Dark Deep Context */
    .dark-surface {
        --bg-surface: var(--color-deep-bg);
        --text-primary: #FFFFFF;
        --text-secondary: #D1CDE4;
        --brand-color: var(--color-accent);
        --accent-color: var(--color-accent);
        --border-subtle: rgba(255, 255, 255, 0.15);
    }
    
    /* Card Context (Inside Dark Surface) */
    .card-light-in-dark {
        --bg-surface: #FDFBF9;
        --text-primary: var(--color-text-main);
        --text-secondary: #555555;
        --brand-color: var(--color-brand);
        --accent-color: var(--color-accent);
        border: 1px solid rgba(28, 21, 35, 0.05);
    }

    /* Structural Tokens */
    --radius-card: 20px;
    --radius-btn: 12px;
    --card-border: 0;
    --card-shadow: none;
    --section-y: clamp(3.5rem, 7vw, 6rem);
    --gap: clamp(1rem, 2vw, 1.75rem);
    --content-max: 1120px;
    
    /* Typography */
    --font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    --line-height: 1.65;
}

/* --- Global Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    line-height: var(--line-height);
    color: var(--text-primary);
    background-color: var(--bg-surface);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
a { text-decoration: none; color: inherit; transition: opacity 0.2s; }
ul, ol { list-style: none; }

/* Container */
.container {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 var(--gap);
}

/* --- Layout Rhythm --- */
.section {
    padding-top: var(--section-y);
    padding-bottom: var(--section-y);
}

.section-header {
    margin-bottom: var(--gap);
}

/* --- Typography Styles --- */
.label-tag {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--brand-color);
    display: inline-block;
    margin-bottom: 0.5rem;
}

h1 {
    font-size: clamp(2.2rem, 5vw, 4rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
}

h2 {
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: 1.5rem;
}

h3 {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.75rem;
}

p {
    font-size: 1rem; /* 16px */
    color: var(--text-primary);
    margin-bottom: 1rem;
    max-width: 38em;
}

.highlight {
    color: var(--brand-color);
}

.dark-surface .highlight {
    color: var(--accent-color);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 52px;
    padding: 0 24px;
    border-radius: var(--radius-btn);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.btn:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

.btn-primary {
    background-color: var(--accent-color);
    color: var(--color-deep-bg);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--text-primary);
    color: var(--text-primary);
}

.dark-surface .btn-outline {
    border-color: #FFFFFF;
    color: #FFFFFF;
}

/* --- Cards & Panels --- */
.card {
    background: var(--bg-surface);
    border-radius: var(--radius-card);
    border: var(--card-border);
    box-shadow: var(--card-shadow);
    padding: var(--gap);
    position: relative;
}

.panel {
    background: var(--color-deep-bg);
    border-radius: var(--radius-card);
    padding: clamp(2rem, 4vw, 3rem);
    color: #FFFFFF;
    overflow: hidden;
    position: relative;
}

/* --- Tables --- */
.data-table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-card);
    border: 1px solid var(--border-subtle);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

th, td {
    padding: 16px 24px;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}

th {
    background: rgba(0,0,0,0.03);
    font-weight: 700;
}

.dark-surface th {
    background: rgba(255,255,255,0.05);
}

tr:last-child td { border-bottom: none; }

/* --- FAQ (Details/Summary) --- */
.faq-item {
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 0;
}

details summary {
    padding: 1.25rem 0;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

details summary::-webkit-details-marker { display: none; }

details summary::after {
    content: "+";
    font-size: 1.5rem;
    font-weight: 300;
    transition: transform 0.3s;
}

details[open] summary::after {
    transform: rotate(45deg);
}

details p {
    padding-bottom: 1.25rem;
    margin-bottom: 0;
    color: var(--text-secondary);
}

/* --- Tabs (Pure CSS) --- */
.tabs-nav {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
    padding-bottom: 4px;
}

.tabs-nav input[type="radio"] {
    display: none;
}

.tabs-nav label {
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    transition: color 0.3s, border-color 0.3s;
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tabs-nav input:checked + label {
    color: var(--brand-color);
    border-bottom-color: var(--brand-color);
}

#tab1:checked ~ .tab-panel-1,
#tab2:checked ~ .tab-panel-2,
#tab3:checked ~ .tab-panel-3,
#tab4:checked ~ .tab-panel-4 {
    display: block;
}

/* --- Grid Systems --- */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
    gap: var(--gap);
}

/* --- Header & Footer --- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(233, 232, 234, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 1rem 0;
}

.dark-surface .site-header {
    background: rgba(35, 19, 52, 0.9);
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand-logo img {
    height: 32px;
    width: auto;
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-link {
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-link[aria-current="page"] {
    color: var(--brand-color);
    font-weight: 700;
}

.site-footer {
    background: var(--color-deep-bg);
    color: #FFFFFF;
    padding: 4rem 0 2rem;
    margin-top: var(--section-y);
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.footer-col h4 {
    color: var(--accent-color);
    margin-bottom: 1rem;
}

.footer-col a {
    display: block;
    color: #D1CDE4;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.footer-col a:hover {
    color: #FFFFFF;
}

.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 2rem;
    text-align: center;
    color: #777;
    font-size: 0.85rem;
}

/* --- SVG Animations --- */
@keyframes flowDash {
    to { stroke-dashoffset: -100; }
}

@keyframes floatSoft {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes pulseOpacity {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

@keyframes slideInRight {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.anim-flow {
    stroke-dasharray: 8 4;
    animation: flowDash 2s linear infinite;
}

.anim-float {
    animation: floatSoft 4s ease-in-out infinite;
}

.anim-pulse {
    animation: pulseOpacity 3s ease-in-out infinite;
}

.anim-slide {
    animation: slideInRight 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) 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;
    }
}

/* Fade In Animation Helper */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}
