/* =========================================
   SafeW Global Styles & Design Tokens
   ========================================= */

:root {
    /* Colors */
    --color-dark: #231334;
    --color-paper: #F5F3F7;
    --color-text: #1C1523;
    --color-brand: #7D14EB;
    --color-accent: #EDD26E;
    
    /* UI Tokens */
    --radius-card: 20px;
    --radius-btn: 12px;
    --card-border: 2px solid var(--color-text);
    --card-shadow: 4px 4px 0 var(--color-text);
    --section-y: clamp(2.5rem, 5vw, 4rem);
    --gap: clamp(0.75rem, 1.5vw, 1.25rem);
    --content-max: 1280px;
    
    /* Typography */
    --font-sans: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    background-color: var(--color-paper);
    color: var(--color-text);
    line-height: 1.55;
    font-size: 16px;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; transition: color 0.2s ease; }
ul, ol { list-style: none; }

/* Focus */
:focus-visible { outline: 3px solid var(--color-brand); outline-offset: 2px; border-radius: 4px; }

/* Container */
.container {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 var(--gap);
}

/* =========================================
   Header & Navigation
   ========================================= */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: rgba(245, 243, 247, 0.9);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(28, 21, 35, 0.1);
    padding: var(--gap) 0;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

.brand img { width: 32px; height: 32px; object-fit: contain; }

.nav-links {
    display: flex;
    gap: 24px;
    align-items: center;
}

.nav-link {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--color-text);
    position: relative;
}

.nav-link:hover, .nav-link[aria-current="page"] {
    color: var(--color-brand);
}

.nav-link[aria-current="page"]::after {
    content: "";
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--color-brand);
}

/* =========================================
   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: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.btn:active { transform: translateY(2px); }

.btn-primary {
    background-color: var(--color-accent);
    color: var(--color-dark);
    border: none;
}

.btn-primary:hover { opacity: 0.9; }

.btn-secondary {
    background-color: transparent;
    color: var(--color-text);
    border: 2px solid var(--color-text);
}

.btn-secondary:hover {
    background-color: var(--color-text);
    color: var(--color-paper);
}

/* Dark mode buttons (inverted logic handled by specific classes if needed, but usually accent stays accent) */
.btn-on-dark {
    background-color: var(--color-accent);
    color: var(--color-dark);
    border: none;
}

.btn-on-dark:hover { opacity: 0.9; }

/* =========================================
   Typography Utilities
   ========================================= */
.section-label {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 16px;
    color: var(--color-brand);
}

.dark-section .section-label { color: var(--color-accent); }

.text-hl { color: var(--color-brand); font-weight: 800; }
.dark-section .text-hl { color: var(--color-accent); }

h1, h2, h3, h4 {
    font-weight: 500;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--color-text);
}

.dark-section h1, .dark-section h2, .dark-section h3, .dark-section h4 { color: var(--color-paper); }

h1 { font-size: clamp(2.6rem, 6.4vw, 5rem); margin-bottom: 24px; }
h2 { font-size: clamp(1.8rem, 3.5vw, 2.8rem); margin-bottom: 32px; }
h3 { font-size: 1.4rem; margin-bottom: 16px; }

p { margin-bottom: 16px; max-width: 38em; }

/* =========================================
   Layout Sections
   ========================================= */
.section-hero {
    background-color: var(--color-dark);
    padding-top: calc(var(--section-y) * 1.5);
    padding-bottom: calc(var(--section-y) * 1.5);
    color: var(--color-paper);
}

.dark-section { background-color: var(--color-dark); color: var(--color-paper); }
.paper-section { background-color: var(--color-paper); color: var(--color-text); }

.section-padding { padding-top: var(--section-y); padding-bottom: var(--section-y); }

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: var(--gap);
    align-items: center;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: var(--gap);
}

@media (min-width: 900px) {
    .grid-2 { grid-template-columns: 1fr 1fr; }
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
}

/* =========================================
   Cards & Panels
   ========================================= */
.card {
    background-color: var(--color-paper);
    border: var(--card-border);
    box-shadow: var(--card-shadow);
    border-radius: var(--radius-card);
    padding: 32px;
    transition: transform 0.2s ease;
}

.dark-section .card {
    background-color: var(--color-paper);
    color: var(--color-text);
    border-color: var(--color-text);
}

.card:hover { transform: translateY(-4px); }

.panel {
    background-color: var(--color-dark);
    border-radius: var(--radius-card);
    padding: 24px;
    overflow: hidden;
    position: relative;
}

.dark-section .panel {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* =========================================
   Tables
   ========================================= */
.table-container {
    overflow-x: auto;
    border: var(--card-border);
    border-radius: var(--radius-card);
    background: var(--color-paper);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th, td {
    padding: 16px 24px;
    border-bottom: 2px solid var(--color-text);
}

th {
    background-color: rgba(125, 20, 235, 0.1);
    font-weight: 700;
}

tr:last-child td { border-bottom: none; }

/* =========================================
   FAQ
   ========================================= */
.faq-item {
    border: var(--card-border);
    border-radius: var(--radius-card);
    margin-bottom: 16px;
    background: var(--color-paper);
}

.faq-item summary {
    padding: 20px 24px;
    cursor: pointer;
    font-weight: 700;
    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;
    color: var(--color-brand);
    transition: transform 0.2s;
}

.faq-item[open] summary::after { transform: rotate(45deg); }

.faq-item p {
    padding: 0 24px 24px;
    margin-bottom: 0;
    color: var(--color-text);
    opacity: 0.85;
}

/* =========================================
   SVG Animations
   ========================================= */
/* Grid Nodes Animation */
@keyframes gridLight {
    0%, 100% { fill-opacity: 0.2; }
    50% { fill-opacity: 1; }
}

.node-light {
    animation: gridLight 4s infinite ease-in-out;
}

/* Staggered delays for grid nodes */
.delay-1 { animation-delay: 0.2s; }
.delay-2 { animation-delay: 0.4s; }
.delay-3 { animation-delay: 0.6s; }
.delay-4 { animation-delay: 0.8s; }
.delay-5 { animation-delay: 1.0s; }

/* Float Animation */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.float-anim { animation: float 6s infinite ease-in-out; }

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Footer */
.site-footer {
    background-color: var(--color-dark);
    color: var(--color-paper);
    padding: 64px 0;
    margin-top: var(--section-y);
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 48px;
}

.footer-col h4 { color: var(--color-accent); margin-bottom: 24px; font-size: 1.1rem; }
.footer-col a { display: block; margin-bottom: 12px; opacity: 0.8; font-size: 0.95rem; }
.footer-col a:hover { opacity: 1; color: var(--color-accent); }

.copyright {
    text-align: center;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.9rem;
    opacity: 0.6;
}
