/* =========================================
   SafeW Global Styles & Design System
   ========================================= */

/* --- Variables & Reset --- */
:root {
  /* Color Palette */
  --color-bg-dark: #2D1438;
  --color-bg-paper: #F6F3F7;
  --color-text-main: #1F1523;
  --color-brand: #9E13DD;
  --color-accent: #6EEDA8;
  
  /* Derived Colors for Contrast */
  --color-paper-on-dark: #F6F3F7;
  --color-accent-on-dark: rgba(110, 237, 168, 0.15);
  
  /* Spacing & Layout */
  --content-max: 1280px;
  --section-y: clamp(5rem, 10vw, 9rem);
  --gap: clamp(1.5rem, 3vw, 2.5rem);
  
  /* Component Shapes */
  --radius-card: 20px;
  --radius-btn: 12px;
  --card-border: 1px solid rgba(31, 21, 35, 0.16);
  --card-shadow: none;
  
  /* Typography */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  color: var(--color-text-main);
  background-color: var(--color-bg-paper);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

/* --- Layout Utilities --- */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

.section {
  padding-top: var(--section-y);
  padding-bottom: var(--section-y);
}

.bg-paper {
  background-color: var(--color-bg-paper);
}

.bg-dark {
  background-color: var(--color-bg-dark);
  color: var(--color-paper-on-dark);
}

/* --- Typography --- */
h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4.6vw, 3.4rem);
  margin-bottom: 1rem;
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  margin-bottom: 0.5em;
}

h3 {
  font-size: 1.25rem;
  margin-bottom: 0.75em;
}

p {
  margin-bottom: 1em;
  max-width: 38em;
}

/* Highlight Span */
.hl {
  color: var(--color-brand);
}

.bg-dark .hl {
  color: var(--color-accent);
}

/* Section Label (眉标) */
.section-label {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
  color: var(--color-brand);
}

.bg-dark .section-label {
  color: var(--color-accent);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 48px;
  padding: 0 24px;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
}

.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 4px;
}

.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-bg-dark);
}

.btn-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn-secondary {
  background-color: transparent;
  border: 1px solid currentColor;
  color: var(--color-text-main);
}

.bg-dark .btn-secondary {
  color: var(--color-paper-on-dark);
}

.btn-secondary:hover {
  transform: translateY(-1px);
  background-color: rgba(0,0,0,0.05);
}

.bg-dark .btn-secondary:hover {
  background-color: rgba(255,255,255,0.05);
}

/* --- Header & Nav --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(246, 243, 247, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(31, 21, 35, 0.08);
  padding: 16px 0;
}

.bg-dark ~ .site-header, 
.site-header.dark-mode {
  background-color: rgba(45, 20, 56, 0.9);
  border-bottom-color: rgba(246, 243, 247, 0.1);
}

.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.2rem;
}

.logo img {
  height: 32px;
  width: auto;
}

nav ul {
  display: flex;
  gap: 24px;
}

nav a {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text-main);
  transition: color 0.2s;
}

nav a:hover, nav a[aria-current="page"] {
  color: var(--color-brand);
}

.bg-dark nav a {
  color: var(--color-paper-on-dark);
}

.bg-dark nav a:hover, .bg-dark nav a[aria-current="page"] {
  color: var(--color-accent);
}

/* --- Footer --- */
.site-footer {
  padding: 48px 0;
  border-top: 1px solid rgba(31, 21, 35, 0.1);
  font-size: 0.9rem;
}

.bg-dark .site-footer {
  border-top-color: rgba(246, 243, 247, 0.1);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 24px;
}

.footer-links {
  display: flex;
  gap: 24px;
}

/* --- Cards & Grid --- */
.card {
  background-color: #fff;
  border: var(--card-border);
  border-radius: var(--radius-card);
  padding: 24px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.bg-dark .card {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.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-wrapper {
  overflow-x: auto;
  border: var(--card-border);
  border-radius: var(--radius-card);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th, td {
  padding: 16px 24px;
  border-bottom: 1px solid rgba(31, 21, 35, 0.08);
}

th {
  background-color: rgba(0,0,0,0.03);
  font-weight: 600;
}

.bg-dark 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;
}

summary {
  padding: 20px 24px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: "+";
  font-size: 1.2rem;
  font-weight: 400;
}

details[open] summary::after {
  content: "−";
}

details p {
  padding: 0 24px 20px 24px;
  margin-bottom: 0;
  color: var(--color-text-main);
}

.bg-dark details {
  background-color: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.1);
}

.bg-dark details p {
  color: var(--color-paper-on-dark);
}

/* --- Timeline --- */
.timeline {
  position: relative;
  padding-left: 24px;
  border-left: 2px solid var(--color-brand);
}

.bg-dark .timeline {
  border-left-color: var(--color-accent);
}

.timeline-item {
  position: relative;
  margin-bottom: 32px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -29px;
  top: 6px;
  width: 10px;
  height: 10px;
  background-color: var(--color-brand);
  border-radius: 50%;
}

.bg-dark .timeline-item::before {
  background-color: var(--color-accent);
}

.time-badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-brand);
  margin-bottom: 4px;
}

.bg-dark .time-badge {
  color: var(--color-accent);
}

/* --- SVG Animation Base --- */
.svg-anim-container {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Keyframes for flowing dots/lines */
@keyframes flowDash {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}

@keyframes floatY {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes pulseOpacity {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* Animation Classes */
.anim-flow {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: flowDash 3s linear infinite;
}

.anim-float {
  animation: floatY 4s ease-in-out infinite;
}

.anim-pulse {
  animation: pulseOpacity 3s ease-in-out infinite;
}

/* Transform origin for sub-elements */
.anim-rotate, .anim-scale {
  transform-box: fill-box;
  transform-origin: center;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 兜底：裁掉横向溢出 */
body > * {
  overflow-x: clip;
}
