/* =========================================
   SafeW Global Styles & Design Tokens
   ========================================= */

:root {
    /* Color Palette */
    --color-dark-surface: #1B1231;
    --color-paper-surface: #F4F3F7;
    --color-text-body: #191523;
    --color-brand: #5214EB;
    --color-accent: #9977EE;

    /* Semantic Colors (Default to Paper Surface context) */
    --bg-page: var(--color-paper-surface);
    --bg-section: var(--color-paper-surface);
    --text-main: var(--color-text-body);
    --text-heading: var(--color-text-body);
    --text-muted: #5A5668; /* Derived from body for readability, slightly lighter */
    --link-color: var(--color-brand);
    --accent-highlight: var(--color-brand);
    --border-color: rgba(25, 21, 35, 0.1);

    /* Design Tokens */
    --radius-card: 24px;
    --radius-btn: 999px;
    --card-border: 2px solid var(--text-main);
    --card-shadow: 4px 4px 0 var(--text-main);
    
    --section-y: clamp(3.5rem, 7vw, 6rem);
    --gap: clamp(1rem, 2vw, 1.75rem);
    
    --content-max: 1120px;
    
    /* Typography */
    --font-family: "PingFang SC", "Noto Sans SC", system-ui, -apple-system, sans-serif;
    --line-height-base: 1.65;
}

/* Dark Surface Context Override */
.dark-surface {
    --bg-section: var(--color-dark-surface);
    --text-main: var(--color-paper-surface);
    --text-heading: var(--color-paper-surface);
    --text-muted: #C4C0D6;
    --link-color: var(--color-accent);
    --accent-highlight: var(--color-accent);
    --border-color: rgba(244, 243, 247, 0.15);
    --card-border: 2px solid rgba(244, 243, 247, 0.3);
    --card-shadow: none; /* Hard shadow looks weird on dark, switch to subtle border or none */
}

/* Paper Card inside Dark Surface (Inverted context) */
.paper-card-in-dark {
    background-color: var(--color-paper-surface);
    color: var(--color-text-body);
    border: var(--card-border);
    box-shadow: var(--card-shadow);
    border-radius: var(--radius-card);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    font-size: 16px;
    line-height: var(--line-height-base);
    color: var(--text-main);
    background-color: var(--bg-page);
    overflow-x: hidden;
    text-rendering: optimizeLegibility;
}

img, svg {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
    text-decoration: none;
}

ul, ol {
    padding-left: 0;
    list-style: none;
}

/* Layout Utilities */
.container {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 var(--gap);
}

.section-wrapper {
    padding-top: var(--section-y);
    padding-bottom: var(--section-y);
    background-color: var(--bg-section);
}

/* Typography */
h1, h2, h3, h4 {
    font-weight: 500;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--text-heading);
    margin-top: 0;
    margin-bottom: 0.6em;
}

h1 {
    font-size: clamp(2.6rem, 6.4vw, 5rem);
    margin-bottom: 1.2em;
}

h2 {
    font-size: clamp(1.8rem, 3.5vw, 2.8rem);
    margin-bottom: 0.8em;
    position: relative;
    padding-left: var(--gap);
}

h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.25em;
    bottom: 0.25em;
    width: 4px;
    background-color: var(--accent-highlight);
    border-radius: 2px;
}

h3 {
    font-size: clamp(1.3rem, 2vw, 1.6rem);
    margin-bottom: 0.5em;
}

p {
    margin-bottom: 1em;
    max-width: 38em;
}

.text-highlight {
    color: var(--accent-highlight);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 48px;
    padding: 0 24px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-btn);
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease, background-color 0.2s ease;
    text-decoration: none;
    border: none;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:focus-visible {
    outline: 3px solid var(--accent-highlight);
    outline-offset: 2px;
}

.btn-primary {
    background-color: var(--accent-highlight);
    color: var(--color-dark-surface); /* Always dark text on accent button */
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-main);
    border: 2px solid var(--text-main);
}

.dark-surface .btn-primary {
    color: var(--color-dark-surface);
}

/* Cards */
.card {
    background-color: var(--bg-section);
    border: var(--card-border);
    box-shadow: var(--card-shadow);
    border-radius: var(--radius-card);
    padding: var(--gap);
    transition: transform 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-4px);
}

/* Grid Systems */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: var(--gap);
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: var(--gap);
}

/* Tables */
.table-container {
    overflow-x: auto;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

th, td {
    padding: 16px 24px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-weight: 600;
    background-color: rgba(0,0,0,0.03);
}

.dark-surface th {
    background-color: rgba(255,255,255,0.05);
}

tr:last-child td {
    border-bottom: none;
}

/* FAQ Details */
details {
    border: var(--card-border);
    border-radius: var(--radius-card);
    margin-bottom: 12px;
    overflow: hidden;
    background-color: var(--bg-section);
    transition: background-color 0.2s;
}

details[open] {
    background-color: rgba(0,0,0,0.02);
}

.dark-surface details[open] {
    background-color: rgba(255,255,255,0.05);
}

summary {
    padding: 20px 24px;
    cursor: pointer;
    font-weight: 600;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

summary::-webkit-details-marker {
    display: none;
}

summary::after {
    content: '+';
    font-size: 1.5rem;
    font-weight: 400;
    transition: transform 0.2s;
}

details[open] summary::after {
    transform: rotate(45deg);
}

details > div {
    padding: 0 24px 24px 24px;
    color: var(--text-main);
}

/* Header & Nav */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--bg-page);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 0;
    transition: background-color 0.3s;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.25rem;
}

.logo img {
    height: 32px;
    width: auto;
}

nav ul {
    display: flex;
    gap: 24px;
    align-items: center;
}

nav a {
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.2s;
}

nav a:hover, nav a[aria-current="page"] {
    color: var(--accent-highlight);
}

@media (max-width: 768px) {
    nav ul {
        display: none; /* Simplified for mobile, usually burger menu needed but keeping it clean */
    }
    .header-btn {
        display: none;
    }
}

/* Footer */
.site-footer {
    background-color: var(--color-dark-surface);
    color: var(--color-paper-surface);
    padding: 64px 0 32px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 48px;
    margin-bottom: 48px;
}

.footer-col h4 {
    color: var(--color-paper-surface);
    font-size: 1rem;
    margin-bottom: 16px;
}

.footer-col ul li {
    margin-bottom: 12px;
}

.footer-col a {
    color: #C4C0D6;
    font-size: 0.9rem;
}

.footer-col a:hover {
    color: var(--color-accent);
}

.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 32px;
    text-align: center;
    color: #8A869E;
    font-size: 0.85rem;
}

/* SVG Animations */
svg {
    width: 100%;
    height: auto;
}

.anim-float-1 {
    animation: float1 6s ease-in-out infinite;
}
.anim-float-2 {
    animation: float2 7s ease-in-out infinite;
}
.anim-float-3 {
    animation: float3 5s ease-in-out infinite;
}

@keyframes float1 {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

@keyframes float2 {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes float3 {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-16px); }
}

/* 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;
    }
    .anim-float-1, .anim-float-2, .anim-float-3 {
        animation: none;
        transform: none;
    }
}

/* Responsive Adjustments */
@media (max-width: 900px) {
    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 600px) {
    .footer-grid {
        grid-template-columns: 1fr;
    }
    h1 {
        font-size: 2.4rem;
    }
    h2 {
        font-size: 1.6rem;
    }
}

/* 兜底：裁掉横向溢出 */
body > * {
  overflow-x: clip;
}
