/* ============================================
   SafeW — Shared Design System & Utilities
   ============================================ */

/* ---------- Design Tokens ---------- */
:root {
  --color-dark: #231334;
  --color-paper: #E9E8EA;
  --color-text: #1C1523;
  --color-brand: #7D14EB;
  --color-accent: #EDD26E;

  --radius-card: 20px;
  --radius-btn: 12px;

  --card-border: 2px solid var(--color-text);
  --card-shadow: 4px 4px 0 var(--color-text);

  --section-y: clamp(5rem, 10vw, 9rem);
  --gap: clamp(1.5rem, 3vw, 2.5rem);

  --content-max: 1280px;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.75;
  color: var(--color-text);
  background-color: var(--color-paper);
  overflow-x: hidden;
  min-width: 0;
  word-break: break-word;
}

img, svg { display: block; max-width: 100%; height: auto; }

a {
  color: inherit;
  text-decoration: none;
}

ul, ol { list-style: none; }

/* ---------- Typography ---------- */
h1, h2, h3, h4 {
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.4rem, 6vw, 4.5rem);
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  line-height: 1.25;
}

h3 {
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  line-height: 1.25;
}

p, li {
  font-size: clamp(1rem, 1.1vw, 1.125rem);
  line-height: 1.75;
  max-width: 38em;
}

small {
  font-size: 0.8rem;
  line-height: 1.6;
}

/* ---------- Layout Containers ---------- */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

.section {
  padding-block: var(--section-y);
}

.section--dark {
  background-color: var(--color-dark);
  color: var(--color-paper);
}

/* Dark surface overrides for text variables */
.section--dark .text-body,
.section--dark p,
.section--dark li {
  color: var(--color-paper);
}

.section--dark .text-heading,
.section--dark h1,
.section--dark h2,
.section--dark h3,
.section--dark h4 {
  color: var(--color-paper);
}

/* Card inside dark section reverts to paper palette */
.card--light-on-dark {
  background-color: var(--color-paper);
  color: var(--color-text);
}

.card--light-on-dark .text-body,
.card--light-on-dark p,
.card--light-on-dark li {
  color: var(--color-text);
}

.card--light-on-dark .text-heading,
.card--light-on-dark h1,
.card--light-on-dark h2,
.card--light-on-dark h3,
.card--light-on-dark h4 {
  color: var(--color-text);
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(233, 232, 234, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(28, 21, 35, 0.08);
  transition: border-color 0.3s ease;
}

.site-header.scrolled {
  border-bottom-color: rgba(28, 21, 35, 0.16);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-logo img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.site-logo span {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.site-nav a {
  font-size: 0.9rem;
  font-weight: 600;
  padding: 4px 0;
  position: relative;
  transition: color 0.2s ease;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--color-brand);
}

.site-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--color-brand);
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Footer ---------- */
.site-footer {
  background-color: var(--color-dark);
  color: var(--color-paper);
  padding: 48px 0 32px;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  text-align: center;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 24px;
}

.footer-links a {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-accent);
  transition: opacity 0.2s ease;
}

.footer-links a:hover {
  opacity: 0.8;
}

.footer-copy {
  font-size: 0.75rem;
  opacity: 0.6;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 52px;
  padding: 0 24px;
  font-size: 1rem;
  font-weight: 700;
  border-radius: var(--radius-btn);
  cursor: pointer;
  border: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

.btn--primary {
  background-color: var(--color-accent);
  color: var(--color-dark);
}

.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: 2px solid var(--color-text);
}

.section--dark .btn--secondary {
  color: var(--color-paper);
  border-color: var(--color-paper);
}

.btn--secondary:hover {
  transform: translateY(-2px);
  background-color: rgba(28, 21, 35, 0.06);
}

.section--dark .btn--secondary:hover {
  background-color: rgba(233, 232, 234, 0.08);
}

.btn svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

/* ---------- Cards ---------- */
.card {
  background-color: var(--color-paper);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: var(--gap);
  transition: transform 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: var(--gap);
}

/* ---------- Tables ---------- */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(28, 21, 35, 0.12);
}

.data-table th {
  font-weight: 700;
}

.section--dark .data-table th,
.section--dark .data-table td {
  border-bottom-color: rgba(233, 232, 234, 0.12);
}

/* ---------- FAQ ---------- */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.faq-item summary {
  font-weight: 700;
  font-size: 1.05rem;
  padding: 16px 20px;
  background-color: var(--color-paper);
  border: var(--card-border);
  border-radius: var(--radius-card);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background-color 0.2s ease;
}

.faq-item summary::-webkit-details-marker { display: none; }

.faq-item summary::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  flex-shrink: 0;
}

.faq-item[open] summary::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cpath d='M5 12h14'/%3E%3C/svg%3E");
}

.faq-item summary:hover {
  background-color: rgba(28, 21, 35, 0.04);
}

.faq-item .faq-answer {
  padding: 16px 20px 20px 48px;
  font-size: 0.95rem;
  line-height: 1.75;
}

.section--dark .faq-item summary {
  background-color: rgba(233, 232, 234, 0.08);
  border-color: rgba(233, 232, 234, 0.2);
  color: var(--color-paper);
}

.section--dark .faq-item summary:hover {
  background-color: rgba(233, 232, 234, 0.12);
}

.section--dark .faq-item .faq-answer {
  color: var(--color-paper);
}

/* ---------- Badge / Eyebrow ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 16px;
}

.badge--brand {
  color: var(--color-brand);
}

.section--dark .badge--accent {
  color: var(--color-accent);
}

.badge--accent {
  color: var(--color-accent);
}

/* ---------- Highlight ---------- */
.hl {
  color: var(--color-brand);
}

.section--dark .hl {
  color: var(--color-accent);
}

/* ---------- Steps ---------- */
.steps-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.step-item {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.step-number {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-accent);
  color: var(--color-dark);
  font-weight: 800;
  font-size: 0.95rem;
  border-radius: 10px;
}

.step-content h3 {
  margin-bottom: 4px;
}

.step-content p {
  font-size: 0.95rem;
  opacity: 0.85;
}

/* ---------- Comparison Table ---------- */
.comparison-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: var(--gap);
}

.comparison-col {
  padding: var(--gap);
  border-radius: var(--radius-card);
  border: var(--card-border);
}

.comparison-col--old {
  background-color: rgba(28, 21, 35, 0.03);
}

.comparison-col--new {
  background-color: rgba(125, 20, 235, 0.06);
  border-color: var(--color-brand);
}

.comparison-col h3 {
  margin-bottom: 16px;
  font-size: 1.1rem;
}

.comparison-col ul {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comparison-col li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.95rem;
  line-height: 1.65;
}

.comparison-col li svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  stroke-width: 2;
  margin-top: 2px;
}

/* ---------- News Cards ---------- */
.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: var(--gap);
}

.news-card {
  background-color: var(--color-paper);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-card);
  padding: var(--gap);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.2s ease;
}

.news-card:hover {
  transform: translateY(-2px);
}

.news-card time {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-brand);
}

.section--dark .news-card time {
  color: var(--color-accent);
}

.news-card article {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.news-card h3 {
  font-size: 1.05rem;
  line-height: 1.35;
}

.news-card p {
  font-size: 0.9rem;
  line-height: 1.65;
  opacity: 0.8;
}

/* ---------- Two Column Layout ---------- */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  align-items: center;
}

@media (max-width: 768px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

/* ---------- Hero ---------- */
.hero {
  background-color: var(--color-dark);
  color: var(--color-paper);
  padding-block: var(--section-y);
}

.hero-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  align-items: center;
}

@media (max-width: 768px) {
  .hero-inner {
    grid-template-columns: 1fr;
  }
}

.hero-text {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.hero-text h1 {
  color: var(--color-paper);
}

.hero-text .hero-desc {
  font-size: clamp(1rem, 1.2vw, 1.15rem);
  line-height: 1.75;
  max-width: 36em;
  opacity: 0.9;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.hero-fact {
  font-size: 0.8rem;
  opacity: 0.6;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hero-visual {
  position: relative;
  aspect-ratio: 4 / 3;
  max-width: 560px;
  margin: 0 auto;
}

/* ---------- Feature Row (alternating) ---------- */
.feature-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  align-items: center;
  margin-bottom: var(--section-y);
}

.feature-row:last-child {
  margin-bottom: 0;
}

@media (max-width: 768px) {
  .feature-row {
    grid-template-columns: 1fr;
  }
  .feature-row.reverse {
    direction: ltr;
  }
}

.feature-panel {
  background-color: var(--color-dark);
  border-radius: var(--radius-card);
  padding: 24px;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.feature-panel svg {
  width: 100%;
  height: 100%;
}

/* ---------- Scenario Walkthrough ---------- */
.scenario-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}

@media (max-width: 768px) {
  .scenario-grid {
    grid-template-columns: 1fr;
  }
}

.scenario-card {
  padding: var(--gap);
  border-radius: var(--radius-card);
  border: var(--card-border);
  background-color: rgba(28, 21, 35, 0.03);
}

.scenario-card h3 {
  margin-bottom: 12px;
}

.scenario-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0;
}

.scenario-step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.95rem;
}

.scenario-step-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-brand);
  color: var(--color-paper);
  font-weight: 700;
  font-size: 0.75rem;
  border-radius: 6px;
}

.scenario-result {
  margin-top: 12px;
  padding: 12px 16px;
  background-color: rgba(125, 20, 235, 0.08);
  border-left: 3px solid var(--color-brand);
  border-radius: 0 8px 8px 0;
  font-size: 0.9rem;
  font-weight: 600;
}

/* ---------- Deep Dive ---------- */
.deep-dive h3 {
  margin-top: 32px;
  margin-bottom: 12px;
}

.deep-dive p {
  margin-bottom: 16px;
}

/* ---------- Section Eyebrow ---------- */
.section-header {
  margin-bottom: var(--gap);
}

.section-header h2 {
  margin-bottom: 12px;
}

/* ---------- Focus Styles ---------- */
*:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

/* ============================================
   SVG Animation Keyframes
   ============================================ */

/* Grid nodes lighting up sequentially */
@keyframes grid-node-pulse {
  0%, 100% { opacity: 0.15; }
  20% { opacity: 1; }
  40% { opacity: 0.15; }
}

.grid-node {
  animation: grid-node-pulse 6s ease-in-out infinite;
}

.grid-node:nth-child(1) { animation-delay: 0s; }
.grid-node:nth-child(2) { animation-delay: 0.6s; }
.grid-node:nth-child(3) { animation-delay: 1.2s; }
.grid-node:nth-child(4) { animation-delay: 1.8s; }
.grid-node:nth-child(5) { animation-delay: 2.4s; }
.grid-node:nth-child(6) { animation-delay: 3.0s; }
.grid-node:nth-child(7) { animation-delay: 3.6s; }
.grid-node:nth-child(8) { animation-delay: 4.2s; }
.grid-node:nth-child(9) { animation-delay: 4.8s; }

/* Chat bubble float */
@keyframes chat-bubble-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.chat-bubble {
  animation: chat-bubble-float 4s ease-in-out infinite;
}

.chat-bubble:nth-child(odd) {
  animation-delay: 0.5s;
}

/* Typing dots breathing */
@keyframes typing-dot {
  0%, 60%, 100% { opacity: 0.2; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

.typing-dot {
  animation: typing-dot 2s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.3s; }
.typing-dot:nth-child(3) { animation-delay: 0.6s; }

/* Notification card slide in */
@keyframes notif-slide-in {
  0%, 100% { transform: translateX(0); opacity: 0.7; }
  15% { transform: translateX(-8px); opacity: 1; }
  85% { transform: translateX(-8px); opacity: 1; }
}

.notif-card {
  animation: notif-slide-in 8s ease-in-out infinite;
}

/* Connection line dash flow */
@keyframes dash-flow {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}

.dash-flow {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: dash-flow 4s linear infinite;
}

/* Panel gentle hover */
@keyframes panel-gentle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.panel-float {
  animation: panel-gentle 6s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

/* Toggle switch pulse */
@keyframes toggle-pulse {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(12px); }
}

.toggle-active {
  animation: toggle-pulse 5s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

/* File list row highlight */
@keyframes row-highlight {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.row-highlight {
  animation: row-highlight 7s ease-in-out infinite;
}

/* Message queue indicator */
@keyframes queue-dot {
  0%, 100% { r: 3; opacity: 0.3; }
  50% { r: 5; opacity: 1; }
}

.queue-dot {
  animation: queue-dot 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;
    animation: none !important;
  }
}

/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 768px) {
  .site-nav {
    gap: 16px;
  }
  .site-nav a {
    font-size: 0.8rem;
  }
  .hero-actions {
    flex-direction: column;
    align-items: flex-start;
  }
  .comparison-grid {
    grid-template-columns: 1fr;
  }
  .news-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .header-inner {
    height: 56px;
  }
  .site-nav {
    gap: 12px;
  }
  .btn {
    height: 48px;
    font-size: 0.9rem;
    padding: 0 16px;
  }
}
