/* =========================================
   SafeW Global Styles
   Design System & Animation Definitions
   ========================================= */

:root {
  /* --- Color Palette --- */
  --color-bg-dark: #10112D;
  --color-bg-paper: #F5F0E5;
  --color-text-body: #151523;
  --color-brand: #1416EB;
  --color-accent: #89ED6E;

  /* --- Design Tokens --- */
  --radius-card: 24px;
  --radius-btn: 999px;
  
  --card-border: 0;
  --card-shadow: 0 10px 28px -14px rgba(21, 21, 35, 0.3);
  
  --section-y: clamp(5rem, 10vw, 9rem);
  --gap: clamp(1.5rem, 3vw, 2.5rem);
  
  --content-max: 1280px;
  
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* =========================================
   Base & Reset
   ========================================= */
*, *::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-sans);
  font-size: 16px;
  line-height: 1.75;
  color: var(--color-text-body);
  background-color: var(--color-bg-paper);
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

/* =========================================
   Typography & Layout
   ========================================= */
.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);
}

/* Metadata Label (眉标) */
.meta-label {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

/* Headings */
h1, h2, h3 {
  font-weight: 500;
  line-height: 1.15;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.6rem, 6.4vw, 5rem);
  margin-bottom: 1.5rem;
}

h2 {
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  margin-bottom: 1.25rem;
}

h3 {
  font-size: clamp(1.3rem, 2.5vw, 1.75rem);
  margin-bottom: 1rem;
}

p {
  margin-bottom: 1.25rem;
  max-width: 38em;
}

/* Highlighted Keywords */
.hl {
  /* Default to body color, overridden by context if needed, 
     but usually keywords take brand/accent color via parent class logic or explicit spans */
}

/* =========================================
   Surface Themes
   ========================================= */
.surface-dark {
  background-color: var(--color-bg-dark);
  color: var(--color-bg-paper);
}

.surface-dark .meta-label {
  color: var(--color-accent);
}

.surface-dark h2 .hl, 
.surface-dark h3 .hl {
  color: var(--color-accent);
}

.surface-dark a:not(.btn) {
  color: var(--color-accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.surface-paper {
  background-color: var(--color-bg-paper);
  color: var(--color-text-body);
}

.surface-paper .meta-label {
  color: var(--color-brand);
}

.surface-paper h2 .hl, 
.surface-paper h3 .hl {
  color: var(--color-brand);
}

.surface-paper a:not(.btn) {
  color: var(--color-brand);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

/* =========================================
   Buttons
   ========================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  height: 52px;
  padding: 0 2rem;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
  border: none;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 4px;
}

.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-bg-dark);
}

.btn-primary:hover {
  transform: translateY(-2px);
  opacity: 0.9;
}

.btn-secondary {
  background-color: transparent;
  border: 2px solid currentColor;
}

.surface-dark .btn-secondary {
  color: var(--color-bg-paper);
}

.surface-paper .btn-secondary {
  color: var(--color-text-body);
}

.btn-secondary:hover {
  transform: translateY(-2px);
  opacity: 0.85;
}

.btn-icon {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.download-platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.surface-dark .btn-secondary {
  border-color: var(--color-bg-paper);
  color: var(--color-bg-paper);
}

.surface-dark .btn-secondary:hover {
  background-color: var(--color-bg-paper);
  color: var(--color-bg-dark);
}

.surface-dark-btn {
  border-color: var(--color-bg-paper);
  color: var(--color-bg-paper);
}

.surface-dark-btn:hover {
  background-color: var(--color-bg-paper);
  color: var(--color-bg-dark);
}

/* =========================================
   Cards & Panels
   ========================================= */
.card {
  background-color: var(--color-bg-paper);
  border-radius: var(--radius-card);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  padding: 2rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.surface-dark .card {
  /* Cards inside dark surfaces revert to paper colors */
  background-color: var(--color-bg-paper);
  color: var(--color-text-body);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 32px -12px rgba(21, 21, 35, 0.4);
}

.visual-panel {
  background-color: var(--color-bg-dark);
  border-radius: var(--radius-card);
  padding: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  min-height: 320px;
}

.surface-paper .visual-panel {
  /* Panels in paper sections can be brand color or dark */
  background-color: var(--color-brand);
}

/* =========================================
   Navigation (Header/Footer)
   ========================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--color-bg-paper);
  border-bottom: 1px solid rgba(21, 21, 35, 0.08);
  padding: 1rem 0;
  backdrop-filter: blur(8px);
  background-color: rgba(245, 240, 229, 0.9);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.25rem;
}

.brand-logo img {
  height: 32px;
  width: auto;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.nav-link {
  font-weight: 500;
  font-size: 0.95rem;
  position: relative;
}

.nav-link[aria-current="page"] {
  color: var(--color-brand);
  font-weight: 700;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--color-brand);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s ease;
}

.nav-link:hover::after,
.nav-link[aria-current="page"]::after {
  transform: scaleX(1);
  transform-origin: left;
}

.site-footer {
  background-color: var(--color-bg-dark);
  color: var(--color-bg-paper);
  padding: 4rem 0 2rem;
  border-top-left-radius: 48px;
  border-top-right-radius: 48px;
  margin-top: auto;
}

.footer-inner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 3rem;
  margin-bottom: 3rem;
}

.footer-col h4 {
  color: var(--color-accent);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1.25rem;
}

.footer-col ul li {
  margin-bottom: 0.75rem;
}

.footer-col a {
  opacity: 0.8;
  transition: opacity 0.2s;
}

.footer-col a:hover {
  opacity: 1;
}

.footer-bottom {
  border-top: 1px solid rgba(245, 240, 229, 0.1);
  padding-top: 2rem;
  text-align: center;
  font-size: 0.85rem;
  opacity: 0.6;
}

/* =========================================
   Component: FAQ (Details/Summary)
   ========================================= */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

details {
  background-color: rgba(21, 21, 35, 0.03);
  border-radius: var(--radius-card);
  overflow: hidden;
  transition: background-color 0.2s;
}

details[open] {
  background-color: rgba(21, 21, 35, 0.06);
}

summary {
  padding: 1.25rem 1.5rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 1.1rem;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: '+';
  font-size: 1.5rem;
  font-weight: 300;
  transition: transform 0.3s ease;
}

details[open] summary::after {
  transform: rotate(45deg);
}

.details-content {
  padding: 0 1.5rem 1.5rem;
  color: var(--color-text-body);
  opacity: 0.9;
  line-height: 1.8;
}

/* Dark surface overrides for FAQ */
.surface-dark details {
  background-color: rgba(245, 240, 229, 0.05);
}
.surface-dark details[open] {
  background-color: rgba(245, 240, 229, 0.08);
}
.surface-dark summary {
  color: var(--color-bg-paper);
}
.surface-dark .details-content {
  color: rgba(245, 240, 229, 0.85);
}

/* =========================================
   Component: Tables
   ========================================= */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-card);
  border: 1px solid rgba(21, 21, 35, 0.08);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.95rem;
}

th, td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(21, 21, 35, 0.06);
}

th {
  font-weight: 700;
  background-color: rgba(21, 21, 35, 0.03);
  width: 35%;
}

tr:last-child td {
  border-bottom: none;
}

/* =========================================
   Component: Grid & Flex Utilities
   ========================================= */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--gap);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--gap);
}

.flex-row {
  display: flex;
  align-items: center;
  gap: var(--gap);
}

.flex-row.reverse {
  flex-direction: row-reverse;
}

@media (max-width: 768px) {
  .flex-row, .flex-row.reverse {
    flex-direction: column;
  }
  .nav-links {
    display: none; /* Simplified for this static output, ideally hamburger */
  }
  /* Basic mobile nav fallback */
  .header-inner::after {
    content: 'Menu';
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-brand);
  }
}

/* =========================================
   SVG Animations
   ========================================= */
.svg-container {
  width: 100%;
  height: auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Grid Node Lighting Effect */
@keyframes grid-light {
  0%, 100% { opacity: 0.15; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

.node {
  fill: currentColor;
  transform-box: fill-box;
  transform-origin: center;
  animation: grid-light 4s ease-in-out infinite;
}

/* Staggered delays for nodes */
.node:nth-child(1) { animation-delay: 0.0s; }
.node:nth-child(2) { animation-delay: 0.4s; }
.node:nth-child(3) { animation-delay: 0.8s; }
.node:nth-child(4) { animation-delay: 1.2s; }
.node:nth-child(5) { animation-delay: 1.6s; }
.node:nth-child(6) { animation-delay: 2.0s; }
.node:nth-child(7) { animation-delay: 2.4s; }
.node:nth-child(8) { animation-delay: 2.8s; }
.node:nth-child(9) { animation-delay: 3.2s; }

/* Bubble Float Effect */
@keyframes float-bubble {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.bubble {
  animation: float-bubble 5s ease-in-out infinite;
}

.bubble-delay-1 { animation-delay: 0.5s; }
.bubble-delay-2 { animation-delay: 1.0s; }

/* Stroke Draw Effect */
@keyframes draw-stroke {
  0% { stroke-dashoffset: 1; }
  50%, 100% { stroke-dashoffset: 0; }
}

.draw-path {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: draw-stroke 3s ease-in-out 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;
    scroll-behavior: auto !important;
  }
}
