/* SafeW Global Styles */

:root {
  /* Colors */
  --color-dark-bg: #231334;
  --color-paper-bg: #F5F3F7;
  --color-text-main: #1C1523;
  --color-brand: #7D14EB;
  --color-accent: #EDD26E;
  
  /* Semantic Colors (Default to Paper Face) */
  --bg-surface: var(--color-paper-bg);
  --text-primary: var(--color-text-main);
  --text-secondary: var(--color-text-main);
  --brand-color: var(--color-brand);
  --accent-color: var(--color-accent);
  --btn-text: var(--color-dark-bg);

  /* Dimensions & Radii */
  --radius-card: 20px;
  --radius-btn: 12px;
  --content-max: 1120px;
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  
  /* Borders & Shadows */
  --card-border: 2px solid var(--text-primary);
  --card-shadow: 4px 4px 0 var(--text-primary);
  
  /* Typography */
  --font-stack: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --line-height-base: 1.55;
}

/* Dark Surface Theme Override */
.dark-surface {
  --bg-surface: var(--color-dark-bg);
  --text-primary: var(--color-paper-bg);
  --text-secondary: rgba(245, 243, 247, 0.85);
  --brand-color: var(--color-accent);
  --accent-color: var(--color-accent);
  --btn-text: var(--color-dark-bg);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-stack);
  font-size: 16px;
  line-height: var(--line-height-base);
  color: var(--text-primary);
  background-color: var(--bg-surface);
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-top: 0;
  margin-bottom: var(--gap);
}

h1 {
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  text-wrap: balance;
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  margin-top: calc(var(--section-y) * 1.5);
}

h3 {
  font-size: 1.25rem;
  margin-top: 1.5rem;
}

p {
  margin-bottom: 1rem;
  max-width: 38em;
}

a {
  color: var(--brand-color);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

a:hover {
  opacity: 0.8;
}

a:focus-visible {
  outline: 2px solid var(--brand-color);
  outline-offset: 4px;
  border-radius: 4px;
}

img, svg {
  display: block;
  max-width: 100%;
}

svg {
  height: auto;
  width: 100%;
}

/* Layout Containers */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

.section-wrapper {
  padding: var(--section-y) 0;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-surface);
  border-bottom: 1px solid rgba(128, 128, 128, 0.2);
  padding: 1rem 0;
  backdrop-filter: blur(8px);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-logo img {
  height: 32px;
  width: auto;
}

nav ul {
  display: flex;
  gap: 1.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

nav a {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

nav a[aria-current="page"] {
  color: var(--brand-color);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-weight: 700;
  border-radius: var(--radius-btn);
  text-decoration: none;
  transition: transform 0.2s ease, filter 0.2s ease;
  cursor: pointer;
  border: none;
  font-size: 1rem;
}

.btn-primary {
  background-color: var(--accent-color);
  color: var(--btn-text);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.1);
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 2px solid var(--text-primary);
}

.dark-surface .btn-secondary {
  color: var(--paper-bg);
  border-color: var(--paper-bg);
}

.btn-secondary:hover {
  background-color: rgba(128, 128, 128, 0.1);
}

/* Cards */
.card {
  background-color: var(--bg-surface);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

/* 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);
}

@media (min-width: 768px) {
  .grid-2-col {
    grid-template-columns: 1fr 1fr;
    align-items: center;
  }
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

th, td {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 1px solid rgba(128, 128, 128, 0.3);
}

th {
  font-weight: 700;
}

/* FAQ */
details {
  margin-bottom: 0.75rem;
  border: 1px solid rgba(128, 128, 128, 0.3);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

summary {
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  position: relative;
  padding-right: 1.5rem;
}

summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: "+";
  position: absolute;
  right: 0;
  font-weight: 400;
}

details[open] summary::after {
  content: "-";
}

details p {
  margin-top: 0.75rem;
  margin-bottom: 0;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* Markdown Helpers */
.hl {
  color: var(--brand-color);
}

.dark-surface .hl {
  color: var(--accent-color);
}

/* SVG Animations */
@keyframes draw-line {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}

@keyframes breathe {
  0%, 100% { opacity: 0.8; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.02); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes flow {
  from { stroke-dashoffset: 10; }
  to { stroke-dashoffset: 0; }
}

.anim-draw {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: draw-line 2s ease-in-out infinite alternate;
}

.anim-breathe {
  animation: breathe 4s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

.anim-float {
  animation: float 6s ease-in-out infinite;
}

.anim-flow {
  stroke-dasharray: 2 8;
  animation: flow 1s linear infinite;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 防止布局容器与表格导致横向溢出 */
main, section, .container {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

table {
  width: 100%;
  min-width: 0;
}

.info-table-wrapper,
[style*="overflow-x: auto"] {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Footer */
.site-footer {
  background-color: var(--bg-surface);
  border-top: 1px solid rgba(128, 128, 128, 0.2);
  padding: 2rem 0;
  margin-top: var(--section-y);
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

/* Utility */
.text-center { text-align: center; }
.mb-2 { margin-bottom: 2rem; }
.mt-2 { margin-top: 2rem; }
