/* ==============================================================================
   Design System & Main Stylesheet
   Governed by Sections 41, 42, 69, 70, 71, 72, 73 of Master Specification
   Vanilla CSS with zero framework dependencies
   ============================================================================== */

:root {
  /* Color Palette - Light Mode */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --border-subtle: #f1f5f9;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  
  --brand-primary: #2563eb;
  --brand-hover: #1d4ed8;
  --brand-glow: rgba(37, 99, 235, 0.15);
  
  --accent-cyan: #0284c7;
  --accent-green: #059669;
  --accent-amber: #d97706;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  
  --transition-fast: 0.15s ease;
  --transition-smooth: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --max-width: 1200px;
}

[data-theme="dark"] {
  --bg-primary: #0b0f17;
  --bg-secondary: #111827;
  --bg-surface: #172033;
  --bg-card: #141c2e;
  --border-color: #1e293b;
  --border-subtle: #243046;
  
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  
  --brand-primary: #3b82f6;
  --brand-hover: #60a5fa;
  --brand-glow: rgba(59, 130, 246, 0.25);
  
  --accent-cyan: #38bdf8;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 20px -3px rgba(0, 0, 0, 0.5);
}

/* Base resets & typography */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-smooth), color var(--transition-smooth);
}

a {
  color: var(--brand-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--brand-hover);
}

a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* Skip to content link (Accessibility Section 70) */
.skip-to-content {
  position: absolute;
  top: -999px;
  left: 20px;
  background: var(--brand-primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  z-index: 1000;
  font-weight: 600;
}

.skip-to-content:focus {
  top: 15px;
}

/* Layout container */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* Header & Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  transition: background-color var(--transition-smooth), border-color var(--transition-smooth);
}

[data-theme="dark"] .site-header {
  background-color: rgba(11, 15, 23, 0.85);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  gap: 20px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-primary);
}

.brand-logo svg {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  list-style: none;
}

.nav-link {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.95rem;
}

.nav-link:hover, .nav-link.active {
  color: var(--brand-primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-button, .theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 0.9rem;
  gap: 8px;
  transition: all var(--transition-fast);
}

.search-button:hover, .theme-toggle:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--brand-primary);
}

/* Category Pills Bar */
.category-nav {
  padding: 16px 0;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  overflow-x: auto;
  white-space: nowrap;
}

.category-pills {
  display: flex;
  gap: 10px;
  list-style: none;
  padding-bottom: 4px;
}

.category-pill {
  display: inline-block;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.category-pill:hover, .category-pill.active {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
}

/* Hero Spotlight Section */
.hero-section {
  padding: 48px 0 32px 0;
}

.hero-card {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 32px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
  align-items: center;
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.hero-badge {
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--brand-glow);
  color: var(--brand-primary);
}

.hero-title {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.hero-excerpt {
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1.6;
  margin-bottom: 24px;
}

.hero-diagram {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Article Grid */
.section-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 48px 0 24px 0;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 28px;
  margin-bottom: 64px;
}

/* Article Card & Animations (Sections 37 & 89) */
.article-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-smooth), box-shadow var(--transition-smooth), border-color var(--transition-smooth);
}

.article-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--brand-primary);
}

.card-diagram-thumb {
  height: 180px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  overflow: hidden;
}

.card-diagram-thumb svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.card-title {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.card-excerpt {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.55;
  margin-bottom: 16px;
  flex-grow: 1;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  padding-top: 14px;
  font-size: 0.85rem;
}

.read-link {
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Site Footer */
.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 48px 0 24px 0;
  margin-top: auto;
  font-size: 0.9rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
}

.footer-col h4 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-links a {
  color: var(--text-secondary);
}

.footer-links a:hover {
  color: var(--brand-primary);
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-color);
  padding-top: 24px;
  color: var(--text-muted);
  gap: 16px;
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .hero-card {
    grid-template-columns: 1fr;
  }
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .nav-links {
    display: none;
  }
  .footer-grid {
    grid-template-columns: 1fr;
  }
  .article-grid {
    grid-template-columns: 1fr;
  }
}
