/* ─── Design Tokens ──────────────────────────────────────── */
:root {
  /* Colors */
  --bg-primary:       #000000;
  --bg-secondary:     #0a0a0a;
  --bg-tertiary:      #111111;
  --bg-card:          rgba(255, 255, 255, 0.05);
  --bg-card-hover:    rgba(255, 255, 255, 0.08);
  --glass-border:     rgba(255, 255, 255, 0.12);
  --glass-border-hover: rgba(255, 255, 255, 0.22);

  /* Text */
  --text-primary:     #f5f5f7;
  --text-secondary:   #86868b;
  --text-tertiary:    #6e6e73;

  /* Accent */
  --accent-blue:      #0071e3;
  --accent-blue-hover: #0077ed;
  --accent-blue-dim:  rgba(0, 113, 227, 0.15);
  --accent-green:     #30d158;
  --accent-green-dim: rgba(48, 209, 88, 0.15);
  --accent-red:       #ff453a;
  --accent-red-dim:   rgba(255, 69, 58, 0.15);
  --accent-yellow:    #ffd60a;
  --accent-purple:    #bf5af2;

  /* Gradients */
  --gradient-hero:    linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  --gradient-blue:    linear-gradient(135deg, #0071e3, #40a9ff);
  --gradient-card:    linear-gradient(145deg, rgba(255,255,255,0.07), rgba(255,255,255,0.02));

  /* Typography */
  --font-system:      -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
                      "PingFang TC", "Heiti TC", "Microsoft JhengHei", sans-serif;
  --font-mono:        "SF Mono", "Monaco", "Inconsolata", monospace;

  /* Spacing */
  --space-xs:   4px;
  --space-sm:   8px;
  --space-md:   16px;
  --space-lg:   24px;
  --space-xl:   40px;
  --space-2xl:  64px;
  --space-3xl:  96px;

  /* Border Radius */
  --radius-sm:  8px;
  --radius-md:  18px;
  --radius-lg:  24px;
  --radius-xl:  32px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md:  0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg:  0 20px 60px rgba(0, 0, 0, 0.5);
  --shadow-glow-blue: 0 0 30px rgba(0, 113, 227, 0.25);

  /* Transitions */
  --transition-fast:   0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow:   0.4s cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --max-width:  1200px;
  --nav-height: 64px;
}

/* ─── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-system);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* overflow-x on html instead of body to avoid iOS fixed-element bugs */
html { overflow-x: hidden; }

/* ─── Typography ─────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.5rem); }
h3 { font-size: clamp(1.2rem, 2.5vw, 1.75rem); }
h4 { font-size: 1.25rem; }

p { color: var(--text-secondary); line-height: 1.7; }

a {
  color: var(--accent-blue);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--accent-blue-hover); }

/* ─── Layout Utilities ───────────────────────────────────── */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-lg); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-lg); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-lg); }

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .container { padding: 0 var(--space-md); }
}
@media (max-width: 1024px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }
.hidden { display: none !important; }

/* ─── Navigation ─────────────────────────────────────────── */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--glass-border);
  z-index: 1000;
  display: flex;
  align-items: center;
}

@media (max-width: 768px) {
  .navbar {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(0, 0, 0, 0.97);
  }
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.nav-logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  list-style: none;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--transition-fast);
}
.nav-links a:hover { color: var(--text-primary); }

.nav-actions { display: flex; gap: var(--space-sm); align-items: center; }

/* Hamburger */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
  margin-left: var(--space-sm);
}
.nav-hamburger span {
  display: block;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all 0.25s ease;
}

@media (max-width: 768px) {
  .nav-hamburger { display: flex; }

  .nav-links {
    display: none;
    position: fixed;
    top: var(--nav-height);
    left: 0; right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: #000;
    border-bottom: 1px solid var(--glass-border);
    padding: var(--space-md) 0;
    z-index: 999;
  }
  .nav-links.open { display: flex; }
  .nav-links li { width: 100%; }
  .nav-links a {
    display: block;
    padding: var(--space-md) var(--space-lg);
    font-size: 1rem;
    color: var(--text-primary);
  }

  .page-content {
    padding-top: calc(var(--nav-height) + var(--space-lg));
  }

  .container { padding: 0 var(--space-md); }

  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  .toast-container {
    left: var(--space-md);
    right: var(--space-md);
    bottom: var(--space-md);
  }
  .toast { min-width: unset; max-width: 100%; }
}

/* Page content offset for fixed navbar */
.page-content {
  padding-top: calc(var(--nav-height) + var(--space-xl));
}

/* ─── Section Spacing ────────────────────────────────────── */
.section {
  padding: var(--space-3xl) 0;
}

/* ─── Loading State ──────────────────────────────────────── */
.loading-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--glass-border);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

@media (max-width: 768px) {
  .loading-overlay {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(0, 0, 0, 0.85);
  }
}

/* ─── Toast Notifications ────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  backdrop-filter: blur(20px);
  min-width: 240px;
  max-width: 380px;
  font-size: 0.9rem;
  animation: slideInRight 0.3s ease;
}

.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error   { border-left: 3px solid var(--accent-red); }
.toast.info    { border-left: 3px solid var(--accent-blue); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }
