/* =========================================
   SafeW Global Styles & Design Tokens
   ========================================= */

:root {
  /* Color Palette */
  --color-deep: #231334;
  --color-paper: #F5F3F7;
  --color-text: #1C1523;
  --color-brand: #7D14EB;
  --color-accent: #EDD26E;
  
  /* Derived Colors for Cards & Surfaces */
  --color-surface-light: #FFFFFF;
  --color-surface-dark-alt: #2A1B3B;
  --color-surface-dark-hover: #3A254D;
  
  /* Spacing & Layout */
  --section-y: clamp(5rem, 10vw, 9rem);
  --gap: clamp(1.5rem, 3vw, 2.5rem);
  --content-max: 1280px;
  
  /* Radius */
  --radius-card: 20px;
  --radius-btn: 12px;
  
  /* Typography Defaults */
  --font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  --line-height-base: 1.75;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  font-size: 16px;
  line-height: var(--line-height-base);
  color: var(--color-text);
  background-color: var(--color-paper);
  overflow-x: hidden;
}

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;
}

/* Container */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

/* Typography */
h1, h2, h3, h4 {
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(2.6rem, 6.4vw, 5rem);
  margin-bottom: var(--gap);
}

h2 {
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  margin-bottom: calc(var(--gap) * 0.8);
}

h3 {
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  margin-bottom: var(--gap);
}

p {
  margin-bottom: 1.5em;
  max-width: 38em;
}

/* Section Backgrounds */
.section-deep {
  background-color: var(--color-deep);
  color: var(--color-paper);
}

.section-paper {
  background-color: var(--color-paper);
  color: var(--color-text);
}

.section-alt-light {
  background-color: #EBE8EE; /* Slightly lighter than paper */
  color: var(--color-text);
}

/* Highlight Text */
.hl {
  color: var(--color-brand);
}

.section-deep .hl {
  color: var(--color-accent);
}

/* Header & Nav */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(245, 243, 247, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(28, 21, 35, 0.1);
  padding: 16px 0;
}

.section-deep ~ .site-header {
  background-color: rgba(35, 19, 52, 0.95);
  border-bottom-color: rgba(245, 243, 247, 0.1);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.25rem;
}

.brand img {
  height: 32px;
  width: auto;
}

nav ul {
  display: flex;
  gap: 24px;
  align-items: center;
}

nav a {
  font-size: 0.95rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius-btn);
  transition: background-color 0.2s;
}

nav a:hover, nav a[aria-current="page"] {
  background-color: rgba(125, 20, 235, 0.1);
  color: var(--color-brand);
}

.section-deep nav a:hover, .section-deep nav a[aria-current="page"] {
  background-color: rgba(237, 210, 110, 0.15);
  color: var(--color-accent);
}

/* 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, box-shadow 0.2s ease, background-color 0.2s;
  border: none;
}

.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-deep);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(237, 210, 110, 0.3);
}

.btn-secondary {
  background-color: transparent;
  color: var(--color-text);
  border: 1px solid currentColor;
}

.section-deep .btn-secondary {
  color: var(--color-paper);
  border-color: var(--color-paper);
}

.btn-secondary:hover {
  background-color: rgba(28, 21, 35, 0.05);
}

.section-deep .btn-secondary:hover {
  background-color: rgba(245, 243, 247, 0.1);
}

.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Cards */
.card {
  background-color: var(--color-surface-light);
  border-radius: var(--radius-card);
  padding: var(--gap);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  transition: transform 0.2s ease;
}

.card:hover {
  transform: translateY(-4px);
}

.card-deep {
  background-color: var(--color-surface-dark-alt);
  color: var(--color-paper);
}

.card-paper-on-deep {
  background-color: var(--color-paper);
  color: var(--color-text);
}

/* Grid Layouts */
.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-responsive {
  overflow-x: auto;
  border-radius: var(--radius-card);
  border: 1px solid rgba(28, 21, 35, 0.1);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  background-color: var(--color-surface-light);
}

th, td {
  padding: 16px 24px;
  border-bottom: 1px solid rgba(28, 21, 35, 0.08);
}

th {
  font-weight: 600;
  background-color: rgba(125, 20, 235, 0.05);
}

tr:last-child td {
  border-bottom: none;
}

/* FAQ */
.faq-item {
  border-bottom: 1px solid rgba(28, 21, 35, 0.1);
}

.faq-item summary {
  padding: 16px 0;
  cursor: pointer;
  font-weight: 600;
  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;
  font-weight: 400;
  transition: transform 0.2s;
}

.faq-item[open] summary::after {
  transform: rotate(45deg);
}

.faq-item p {
  margin-top: 12px;
  margin-bottom: 24px;
  font-size: 0.95rem;
  color: rgba(28, 21, 35, 0.8);
}

/* SVG Animation Classes */
.svg-node {
  fill: var(--color-brand);
  opacity: 0.3;
  animation: nodePulse 4s infinite alternate ease-in-out;
}

.svg-node:nth-child(odd) {
  animation-delay: 1s;
}

.svg-line {
  stroke: var(--color-accent);
  stroke-width: 2;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: dashFlow 3s linear infinite;
}

@keyframes nodePulse {
  0% { opacity: 0.3; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1.1); }
}

@keyframes dashFlow {
  0% { stroke-dashoffset: 0; }
  50% { stroke-dashoffset: -0.5; }
  100% { stroke-dashoffset: 0; }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .svg-node, .svg-line {
    animation: none;
    opacity: 1;
  }
}

/* Footer */
.site-footer {
  background-color: var(--color-deep);
  color: var(--color-paper);
  padding: var(--section-y) 0;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--gap);
}

.footer-col h4 {
  color: var(--color-accent);
  margin-bottom: 16px;
}

.footer-col a {
  display: block;
  margin-bottom: 8px;
  opacity: 0.8;
}

.footer-col a:hover {
  opacity: 1;
  color: var(--color-accent);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  h1 { font-size: clamp(2rem, 8vw, 3rem); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .header-inner nav { display: none; } /* Simplified for mobile */
  
  /* Fix horizontal overflow on narrow screens */
  body { min-width: 320px; }
  .container { width: 100%; max-width: var(--content-max); padding-left: 16px; padding-right: 16px; }
  .hero-actions { flex-direction: column; }
  .hero-actions .btn { width: 100%; box-sizing: border-box; }
  .table-responsive { -webkit-overflow-scrolling: touch; }
}

/* 兜底：裁掉横向溢出 */
body > * {
  overflow-x: clip;
}
