/* ============================================
   Snet Design System — Design Tokens & Base
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  /* Colors */
  --color-bg-primary: #0a0a0f;
  --color-bg-secondary: #0f0f18;
  --color-bg-tertiary: #161625;
  --color-surface: #1a1a2e;
  --color-surface-hover: #222240;
  --color-surface-active: #2a2a50;
  --color-border: #2a2a45;
  --color-border-light: #1e1e35;
  --color-text-primary: #e8e8f0;
  --color-text-secondary: #9090b0;
  --color-text-muted: #606080;
  --color-accent: #6366f1;
  --color-accent-hover: #818cf8;
  --color-accent-light: #a5b4fc;
  --color-accent-glow: rgba(99, 102, 241, 0.15);
  --color-accent-glow-strong: rgba(99, 102, 241, 0.3);
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --color-code-bg: #1a1a2e;
  --color-code-border: #2a2a45;
  --color-gradient-start: #6366f1;
  --color-gradient-mid: #8b5cf6;
  --color-gradient-end: #a855f7;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --font-cjk: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;

  /* Font Sizes (clamp for fluid typography) */
  --text-xs: clamp(0.7rem, 0.68rem + 0.1vw, 0.75rem);
  --text-sm: clamp(0.8rem, 0.77rem + 0.15vw, 0.875rem);
  --text-base: clamp(0.9rem, 0.86rem + 0.2vw, 1rem);
  --text-lg: clamp(1.05rem, 1rem + 0.25vw, 1.175rem);
  --text-xl: clamp(1.2rem, 1.12rem + 0.4vw, 1.4rem);
  --text-2xl: clamp(1.5rem, 1.38rem + 0.6vw, 1.8rem);
  --text-3xl: clamp(1.8rem, 1.6rem + 1vw, 2.4rem);
  --text-4xl: clamp(2.2rem, 1.9rem + 1.5vw, 3.2rem);
  --text-hero: clamp(2.5rem, 2rem + 3vw, 4.5rem);

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px var(--color-accent-glow);
  --shadow-glow-strong: 0 0 60px var(--color-accent-glow-strong);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;

  /* Layout */
  --header-height: 64px;
  --sidebar-width: 280px;
  --toc-width: 220px;
  --content-max-width: 1200px;
  --content-narrow: 800px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* CJK font stack */
:lang(zh) {
  font-family: var(--font-cjk), var(--font-sans);
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-accent-hover);
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-text-primary);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-code-bg);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-code-border);
}

pre {
  background: var(--color-code-bg);
  border: 1px solid var(--color-code-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  overflow-x: auto;
  position: relative;
}

pre code {
  background: none;
  padding: 0;
  border: none;
  font-size: var(--text-sm);
  line-height: 1.6;
}

img {
  max-width: 100%;
  height: auto;
}

/* --- Utilities --- */
.container {
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.container-narrow {
  max-width: var(--content-narrow);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes glow {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.animate-fade-in {
  animation: fadeIn 0.5s var(--transition-normal) forwards;
}

.animate-fade-in-scale {
  animation: fadeInScale 0.4s var(--transition-normal) forwards;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* --- Selection --- */
::selection {
  background: var(--color-accent-glow-strong);
  color: var(--color-text-primary);
}

/* --- Focus styles (interactive elements only) --- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
details:focus-visible,
[tabindex]:not([tabindex="-1"]):focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Suppress browser default focus outline on non-interactive elements
   (e.g. h1..h6, section, div — Blazor navigation may auto-focus headings with aria-labelledby) */
h1:focus, h2:focus, h3:focus, h4:focus, h5:focus, h6:focus,
p:focus, span:focus, div:focus, section:focus, header:focus, footer:focus,
main:focus, article:focus, aside:focus, nav:focus {
  outline: none;
}

/* ============================================
   Light Mode (data-theme="light")
   ============================================ */
[data-theme="light"] {
  --color-bg-primary: #f8f9fa;
  --color-bg-secondary: #ffffff;
  --color-bg-tertiary: #f0f1f3;
  --color-surface: #ffffff;
  --color-surface-hover: #f0f1f5;
  --color-surface-active: #e8e9ef;
  --color-border: #dde0e4;
  --color-border-light: #eef0f2;
  --color-text-primary: #1a1a2e;
  --color-text-secondary: #5a5a7a;
  --color-text-muted: #9090a0;
  --color-accent: #4f46e5;
  --color-accent-hover: #6366f1;
  --color-accent-light: #4338ca;
  --color-accent-glow: rgba(79, 70, 229, 0.08);
  --color-accent-glow-strong: rgba(79, 70, 229, 0.2);
  --color-code-bg: #f0f0f5;
  --color-code-border: #dde0e4;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
  --shadow-glow: 0 0 30px rgba(79, 70, 229, 0.1);
  --shadow-glow-strong: 0 0 50px rgba(79, 70, 229, 0.2);
}

[data-theme="light"] .site-header {
  background: rgba(255, 255, 255, 0.9);
  border-bottom-color: var(--color-border-light);
}

[data-theme="light"] .doc-header {
  background: rgba(255, 255, 255, 0.9);
  border-bottom-color: var(--color-border-light);
}

[data-theme="light"] .doc-sidebar {
  background: var(--color-bg-secondary);
  border-right-color: var(--color-border-light);
}

[data-theme="light"] .doc-toc {
  background: var(--color-bg-secondary);
  border-left-color: var(--color-border-light);
}

[data-theme="light"] .hero::before {
  opacity: 0.5;
}

[data-theme="light"] .hero-grid-bg {
  opacity: 0.3;
}

[data-theme="light"] .nav-links {
  background: #ffffff;
}

[data-theme="light"] .site-footer {
  background: rgba(255,255,255,0.50);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  border-top-color: rgba(0,0,0,0.06);
}

[data-theme="light"] .footer-inner a {
  color: var(--color-text-muted);
}

[data-theme="light"] .stats-section {
  background: #f0f1f3;
}

[data-theme="light"] .protocols-section {
  background: #f0f1f3;
}

[data-theme="light"] .contact-section {
  background: #f0f1f3;
}

[data-theme="light"] ::-webkit-scrollbar-track {
  background: #e8e8ee;
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: #c0c0d0;
}
