/* SafeW Global Styles */

:root {
  /* Color Palette */
  --color-dark: #19102D;
  --color-paper: #F4F3F7;
  --color-text: #191523;
  --color-brand: #5214EB;
  --color-accent: #D66EED;
  
  /* Derived Colors for specific contexts */
  --color-dark-bg: var(--color-dark);
  --color-dark-text: var(--color-paper);
  --color-dark-accent: var(--color-accent);
  
  --color-paper-bg: var(--color-paper);
  --color-paper-text: var(--color-text);
  --color-paper-brand: var(--color-brand);

  /* Layout Tokens */
  --radius-card: 0;
  --radius-btn: 0;
  
  --card-border: 0;
  --card-shadow: none;
  
  --section-y: clamp(5rem, 10vw, 9rem);
  --gap: clamp(1.5rem, 3vw, 2.5rem);
  
  --content-max: 1120px;
  
  /* Typography */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  color: var(--color-text);
  background-color: var(--color-paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

/* Utility Classes */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

.section-padding {
  padding-top: var(--section-y);
  padding-bottom: var(--section-y);
}

/* Theme Contexts */
.theme-dark {
  background-color: var(--color-dark-bg);
  color: var(--color-dark-text);
}
.theme-dark .theme-text-accent {
  color: var(--color-dark-accent);
}
.theme-dark .theme-link {
  color: var(--color-accent);
}
.theme-dark .theme-link:hover {
  color: #e8b4f8;
}

.theme-paper {
  background-color: var(--color-paper-bg);
  color: var(--color-paper-text);
}
.theme-paper .theme-text-accent {
  color: var(--color-brand);
}
.theme-paper .theme-link {
  color: var(--color-brand);
}
.theme-paper .theme-link:hover {
  color: #3a0db3;
}

/* Cards in Dark Context */
.card-dark {
  background-color: rgba(255, 255, 255, 0.05);
  border: var(--card-border) solid transparent;
  box-shadow: var(--card-shadow);
  padding: var(--gap);
}
.card-dark .theme-text-accent {
  color: var(--color-dark-accent);
}
.card-dark .theme-link {
  color: var(--color-accent);
}

/* Cards in Paper Context */
.card-paper {
  background-color: #ffffff;
  border: var(--card-border) solid transparent;
  box-shadow: var(--card-shadow);
  padding: var(--gap);
}
.card-paper .theme-text-accent {
  color: var(--color-brand);
}
.card-paper .theme-link {
  color: var(--color-brand);
}

/* Typography Components */
.section-label {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.section-label::before {
  content: '';
  display: block;
  width: 16px;
  height: 2px;
  background-color: currentColor;
}

h1 {
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
  text-wrap: balance;
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-bottom: 2rem;
  position: relative;
  padding-left: 1rem;
}
h2::before {
  content: attr(data-number);
  position: absolute;
  left: -1rem;
  top: 0;
  font-size: 0.6em;
  font-weight: 700;
  opacity: 0.3;
  color: currentColor;
}

h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

p {
  margin-bottom: 1rem;
  max-width: 38em;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  height: 48px;
  padding: 0 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-dark);
}
.btn-primary:hover {
  transform: translateY(-2px);
  background-color: #e08bf4;
}
.btn-primary:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

.btn-secondary {
  background-color: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-text);
}
.theme-dark .btn-secondary {
  color: var(--color-paper);
  border-color: var(--color-paper);
}
.btn-secondary:hover {
  transform: translateY(-2px);
  background-color: rgba(0,0,0,0.05);
}
.theme-dark .btn-secondary:hover {
  background-color: rgba(255,255,255,0.1);
}
.btn-secondary:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(244, 243, 247, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  padding: 1rem 0;
}
.theme-dark .site-header {
  background-color: rgba(25, 16, 45, 0.9);
  border-bottom-color: rgba(255,255,255,0.1);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 800;
  font-size: 1.25rem;
}
.logo img {
  height: 32px;
  width: auto;
}

.nav-links {
  display: flex;
  gap: 2rem;
  align-items: center;
}
.nav-links a {
  font-weight: 500;
  font-size: 0.95rem;
  position: relative;
}
.nav-links a:hover {
  color: var(--color-brand);
}
.theme-dark .nav-links a:hover {
  color: var(--color-accent);
}
.nav-links a[aria-current="page"] {
  color: var(--color-brand);
  font-weight: 700;
}
.theme-dark .nav-links a[aria-current="page"] {
  color: var(--color-accent);
}

/* Footer */
.site-footer {
  background-color: var(--color-dark);
  color: var(--color-paper);
  padding: 4rem 0 2rem;
  margin-top: auto;
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--gap);
  margin-bottom: 3rem;
}
.footer-col h4 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--color-accent);
}
.footer-col ul li {
  margin-bottom: 0.5rem;
}
.footer-col a {
  font-size: 0.9rem;
  opacity: 0.8;
  transition: opacity 0.2s;
}
.footer-col a:hover {
  opacity: 1;
}
.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 2rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.85rem;
  opacity: 0.6;
}

/* Grid Layouts */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--gap);
  overflow-x: auto;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--gap);
  overflow-x: auto;
}

/* Specific Components */
.feature-list-item {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.feature-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  stroke: currentColor;
}

.step-list {
  counter-reset: step;
}
.step-item {
  position: relative;
  padding-left: 3rem;
  margin-bottom: 2rem;
}
.step-item::before {
  counter-increment: step;
  content: "0" counter(step);
  position: absolute;
  left: 0;
  top: 0;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-brand);
  opacity: 0.5;
}
.theme-dark .step-item::before {
  color: var(--color-accent);
}

.news-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.news-date {
  font-size: 0.85rem;
  opacity: 0.7;
  margin-bottom: 0.5rem;
}
.news-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  line-height: 1.3;
}
.news-excerpt {
  font-size: 0.95rem;
  opacity: 0.85;
  flex-grow: 1;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  font-size: 0.95rem;
}
th, td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(0,0,0,0.1);
}
.theme-dark th, .theme-dark td {
  border-bottom-color: rgba(255,255,255,0.1);
}
th {
  font-weight: 700;
  background-color: rgba(0,0,0,0.02);
}
.theme-dark th {
  background-color: rgba(255,255,255,0.05);
}

details {
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(0,0,0,0.1);
  padding-bottom: 1rem;
}
.theme-dark details {
  border-bottom-color: rgba(255,255,255,0.1);
}
summary {
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
summary::-webkit-details-marker {
  display: none;
}
summary::after {
  content: '+';
  font-size: 1.25rem;
  font-weight: 300;
}
details[open] summary::after {
  content: '-';
}
details p {
  margin-top: 1rem;
  font-size: 0.95rem;
  opacity: 0.9;
}

/* SVG Animation Classes */
.draw-path {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: drawLine 4s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate;
}
.bubble-float {
  animation: floatBubble 6s ease-in-out infinite;
}
.bubble-float-delayed {
  animation: floatBubble 6s ease-in-out infinite;
  animation-delay: 2s;
}
.pulse-opacity {
  animation: pulseOpacity 3s ease-in-out infinite;
}
.line-flow {
  stroke-dasharray: 4 4;
  animation: flowDash 1s linear infinite;
}

@keyframes drawLine {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}
@keyframes floatBubble {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes pulseOpacity {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.8; }
}
@keyframes flowDash {
  to { stroke-dashoffset: -8; }
}

/* 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;
  }
  .draw-path, .bubble-float, .bubble-float-delayed, .pulse-opacity, .line-flow {
    animation: none;
    stroke-dashoffset: 0;
    opacity: 1;
  }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .nav-links {
    display: none; /* Simple hide for this static demo, ideally a hamburger menu */
  }
  .header-inner {
    justify-content: space-between;
  }
  h1 {
    font-size: 2.5rem;
  }
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* 兜底：裁掉横向溢出 */
body > * {
  overflow-x: clip;
}
