/* ============================================
   AstroPedia — Spaceflight Encyclopedia
   Design System & Styles
   ============================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Orbitron:wght@400;500;600;700;800;900&family=Share+Tech+Mono&display=swap');

/* ---- CSS Custom Properties ---- */
:root {
  /* Colors */
  --bg-primary: #00000c;
  --bg-secondary: #111827;
  --bg-surface: #1a1f35;
  --bg-card: rgba(26, 31, 53, 0.8);
  --bg-glass: rgba(17, 24, 39, 0.7);
  --bg-hover: rgba(0, 180, 216, 0.08);

  --accent-blue: #00d4ff;
  --accent-blue-light: #48cae4;
  --accent-blue-dark: #0077b6;
  --accent-gold: #ffd60a;
  --accent-gold-dark: #e6b800;
  --accent-purple: #9333ea;
  --accent-purple-light: #9d5cfa;
  --accent-red: #ef476f;
  --accent-green: #06d6a0;

  --text-primary: #dde4ef;
  --text-secondary: #7a8ba4;
  --text-muted: #6b7280;
  --text-link: #48cae4;
  --text-heading: #f0f2f5;

  --border-color: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(0, 180, 216, 0.3);

  /* Typography */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Orbitron', monospace;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Layout */
  --max-width: 1400px;
  --sidebar-width: 280px;
  --header-height: 64px;

  /* Effects */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-sm: 0 2px 8px 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 20px rgba(0, 180, 216, 0.15);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset & Base ---- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- Animated Starfield Background ---- */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(165, 243, 252, 0.6), transparent),
    radial-gradient(1px 1px at 30% 65%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1.5px 1.5px at 50% 10%, rgba(216, 180, 254, 0.7), transparent),
    radial-gradient(1px 1px at 70% 40%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1px 1px at 90% 80%, rgba(165, 243, 252, 0.5), transparent),
    radial-gradient(1.5px 1.5px at 15% 85%, rgba(255, 255, 255, 0.6), transparent),
    radial-gradient(1px 1px at 45% 50%, rgba(216, 180, 254, 0.3), transparent),
    radial-gradient(1px 1px at 80% 15%, rgba(165, 243, 252, 0.5), transparent),
    radial-gradient(1.5px 1.5px at 25% 35%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1px 1px at 60% 75%, rgba(216, 180, 254, 0.6), transparent),
    radial-gradient(1px 1px at 5% 55%, rgba(255, 255, 255, 0.3), transparent),
    radial-gradient(1.5px 1.5px at 35% 90%, rgba(165, 243, 252, 0.5), transparent),
    radial-gradient(1px 1px at 75% 60%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1px 1px at 95% 30%, rgba(216, 180, 254, 0.6), transparent),
    radial-gradient(1.5px 1.5px at 55% 45%, rgba(165, 243, 252, 0.3), transparent),
    radial-gradient(1px 1px at 20% 70%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1px 1px at 85% 95%, rgba(216, 180, 254, 0.4), transparent),
    radial-gradient(1.5px 1.5px at 40% 25%, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1px 1px at 65% 5%, rgba(165, 243, 252, 0.3), transparent),
    radial-gradient(1px 1px at 12% 48%, rgba(255, 255, 255, 0.5), transparent);
  animation: twinkle 8s ease-in-out infinite alternate;
}

@keyframes twinkle {
  0% {
    opacity: 0.7;
  }

  50% {
    opacity: 1;
  }

  100% {
    opacity: 0.8;
  }
}

/* ---- Links ---- */
a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-blue-light);
  text-decoration: underline;
}

/* ---- Header ---- */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(0, 0, 12, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  z-index: 1000;
  display: flex;
  align-items: center;
  padding: 0 var(--space-lg);
}

.header-inner {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  gap: var(--space-lg);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  flex-shrink: 0;
  text-decoration: none;
}

.logo:hover {
  text-decoration: none;
}

.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: contain;
}

.logo-text {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 1px;
}

/* ---- Navigation ---- */
.nav {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.nav-link {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  text-decoration: none;
}

.nav-link.active {
  color: var(--accent-blue);
  background: rgba(0, 180, 216, 0.12);
}

/* ---- Search ---- */
.search-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  margin-left: auto;
  min-width: 200px;
}

.search-trigger:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-glow);
}

.search-trigger kbd {
  font-family: var(--font-body);
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
  border: 1px solid var(--border-color);
}

/* Search Modal */
.search-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  justify-content: center;
  padding-top: 12vh;
}

.search-modal.active {
  display: flex;
}

.search-container {
  width: 90%;
  max-width: 640px;
  max-height: 70vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: searchSlideIn 0.25s ease-out;
}

@keyframes searchSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-color);
  gap: var(--space-sm);
}

.search-input-wrapper svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text-primary);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-results {
  overflow-y: auto;
  padding: var(--space-sm);
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.search-result-item:hover {
  background: var(--bg-hover);
}

.search-result-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}

.search-result-info h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.search-result-info p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.search-empty {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---- Main Content ---- */
.main {
  position: relative;
  z-index: 1;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

.page-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
}

/* ---- Hero Section ---- */
.hero {
  text-align: center;
  padding: var(--space-3xl) var(--space-lg);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(0, 180, 216, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.hero-title {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  background: linear-gradient(135deg, #fff, var(--accent-blue-light), var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--space-md);
  line-height: 1.2;
}

.hero-subtitle {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto var(--space-xl);
  font-weight: 300;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: var(--space-2xl);
  flex-wrap: wrap;
}

.hero-stat {
  text-align: center;
}

.hero-stat-number {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-gold);
}

.hero-stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ---- Section Headers ---- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-color);
}

.section-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-heading);
  letter-spacing: 0.5px;
}

.section-link {
  font-size: 0.8rem;
  color: var(--accent-blue);
  font-weight: 500;
}

/* ---- Category Grid ---- */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-3xl);
}

.category-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  overflow: hidden;
  text-decoration: none;
}

.category-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
  opacity: 0;
  transition: opacity var(--transition);
}

.category-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-4px);
  box-shadow: var(--shadow-glow);
  text-decoration: none;
}

.category-card:hover::before {
  opacity: 1;
}

.category-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-sm);
  display: block;
}

.category-name {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-heading);
  letter-spacing: 0.5px;
  margin-bottom: var(--space-xs);
}

.category-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ---- Article Cards ---- */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-3xl);
}

.article-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  display: flex;
  flex-direction: column;
}

.article-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

.article-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: linear-gradient(135deg, rgba(0, 180, 216, 0.05), rgba(123, 47, 247, 0.05));
}

.article-card-icon {
  font-size: 2.5rem;
  flex-shrink: 0;
}

.article-card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-heading);
}

.article-card-category {
  font-size: 0.7rem;
  color: var(--accent-blue);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 500;
}

.article-card-body {
  padding: 0 var(--space-lg) var(--space-lg);
  flex: 1;
}

.article-card-summary {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-card-stats {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-lg) var(--space-md);
  flex-wrap: wrap;
}

.article-card-stat {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.article-card-stat strong {
  color: var(--text-secondary);
}

/* ---- Article Detail Page ---- */
.article-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--space-2xl);
  align-items: start;
}

.article-content {
  min-width: 0;
}

.article-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
}

.article-breadcrumb a {
  color: var(--text-muted);
}

.article-breadcrumb a:hover {
  color: var(--accent-blue);
}

.article-breadcrumb .separator {
  color: var(--text-muted);
  opacity: 0.5;
}

.article-title {
  font-family: var(--font-heading);
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: var(--space-sm);
  line-height: 1.3;
}

.article-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-xl);
  font-weight: 300;
}

.article-section {
  margin-bottom: var(--space-xl);
}

.article-section-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-blue-light);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-color);
  letter-spacing: 0.5px;
}

.article-text {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: var(--space-md);
}

/* ---- Infobox ---- */
.infobox {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: sticky;
  top: calc(var(--header-height) + var(--space-lg));
}

.infobox-header {
  background: linear-gradient(135deg, rgba(0, 180, 216, 0.15), rgba(123, 47, 247, 0.1));
  padding: var(--space-lg);
  text-align: center;
  border-bottom: 1px solid var(--border-color);
}

.infobox-icon {
  font-size: 4rem;
  margin-bottom: var(--space-sm);
  display: block;
}

.infobox-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-heading);
  letter-spacing: 0.5px;
}

.infobox-table {
  width: 100%;
}

.infobox-row {
  display: flex;
  border-bottom: 1px solid var(--border-color);
}

.infobox-row:last-child {
  border-bottom: none;
}

.infobox-label {
  flex: 0 0 120px;
  padding: var(--space-sm) var(--space-md);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(255, 255, 255, 0.02);
}

.infobox-value {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  font-size: 0.85rem;
  color: var(--text-primary);
}

/* ---- Category Listing Page ---- */
.category-header {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  margin-bottom: var(--space-2xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border-color);
}

.category-header-icon {
  font-size: 3rem;
}

.category-header-title {
  font-family: var(--font-heading);
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 700;
  color: var(--text-heading);
}

.category-header-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

.category-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-lg);
}

/* ---- Did You Know Section ---- */
.dyk-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
  margin-bottom: var(--space-3xl);
}

.dyk-list {
  list-style: none;
}

.dyk-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}

.dyk-item:last-child {
  border-bottom: none;
}

.dyk-item::before {
  content: '🚀';
  flex-shrink: 0;
}

.dyk-item a {
  color: var(--text-link);
  font-weight: 500;
}

/* ---- Related Articles ---- */
.related-section {
  margin-top: var(--space-xl);
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: var(--space-md);
}

.related-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.related-card:hover {
  border-color: var(--border-accent);
  background: var(--bg-hover);
  text-decoration: none;
}

.related-card-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
}

.related-card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-heading);
}

.related-card-cat {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ---- Table of Contents ---- */
.toc {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-xl);
}

.toc-title {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: var(--space-sm);
}

.toc-list {
  list-style: none;
}

.toc-item {
  padding: 4px 0;
}

.toc-link {
  font-size: 0.82rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  transition: color var(--transition);
}

.toc-link::before {
  content: '›';
  color: var(--accent-blue);
  font-weight: 700;
}

.toc-link:hover {
  color: var(--accent-blue);
  text-decoration: none;
}

/* ---- Footer ---- */
.footer {
  position: relative;
  z-index: 1;
  margin-top: var(--space-3xl);
  padding: var(--space-xl) var(--space-lg);
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.footer-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
  margin-top: var(--space-sm);
}

.footer-link {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ---- Mobile Nav Toggle ---- */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--space-sm);
}

/* ---- Category Badge ---- */
.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  border-radius: 100px;
  background: rgba(0, 180, 216, 0.12);
  color: var(--accent-blue);
}

.badge.rockets {
  background: rgba(239, 71, 111, 0.12);
  color: var(--accent-red);
}

.badge.people {
  background: rgba(6, 214, 160, 0.12);
  color: var(--accent-green);
}

.badge.agencies {
  background: rgba(123, 47, 247, 0.12);
  color: var(--accent-purple);
}

.badge.concepts {
  background: rgba(255, 214, 10, 0.12);
  color: var(--accent-gold);
}

.badge.components {
  background: rgba(0, 180, 216, 0.12);
  color: var(--accent-blue);
}

.badge.missions {
  background: rgba(239, 71, 111, 0.12);
  color: var(--accent-red);
}

.badge.spacecraft {
  background: rgba(6, 214, 160, 0.12);
  color: var(--accent-green);
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .article-layout {
    grid-template-columns: 1fr;
  }

  .infobox {
    position: static;
    margin-bottom: var(--space-xl);
    order: -1;
  }
}

@media (max-width: 768px) {
  .nav {
    display: none;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-direction: column;
    padding: var(--space-md);
  }

  .nav.open {
    display: flex;
  }

  .nav-toggle {
    display: block;
  }

  .search-trigger {
    min-width: 120px;
  }

  .search-trigger span {
    display: none;
  }

  .hero {
    padding: var(--space-2xl) var(--space-md);
  }

  .articles-grid {
    grid-template-columns: 1fr;
  }

  .category-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .category-list {
    grid-template-columns: 1fr;
  }

  .related-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- Animations & Polish ---- */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes starPass {
  from {
    background-position: 0 0;
  }

  to {
    background-position: 0 1000px;
  }
}

/* Background Movement */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 200%;
  pointer-events: none;
  z-index: -2;
  /* Stars behind glow */
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(165, 243, 252, 0.6), transparent),
    radial-gradient(1px 1px at 30% 60%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(2px 2px at 50% 10%, rgba(216, 180, 254, 0.7), transparent),
    radial-gradient(1px 1px at 70% 80%, rgba(165, 243, 252, 0.6), transparent),
    radial-gradient(2px 2px at 90% 40%, rgba(255, 255, 255, 0.8), transparent);
  /* Repeat pattern */
  background-size: 800px 800px;
  animation: starPass 150s linear infinite;
}

/* Shining Light / Nebula Effect */
body::after {
  content: '';
  position: fixed;
  top: 50%;
  left: 50%;
  width: 150vw;
  height: 150vh;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at center, rgba(0, 180, 216, 0.08), rgba(123, 47, 247, 0.05), transparent 70%);
  z-index: -1;
  pointer-events: none;
  animation: cosmicGlow 20s ease-in-out infinite alternate;
  filter: blur(60px);
}

@keyframes cosmicGlow {
  0% {
    transform: translate(-50%, -50%) scale(0.8) rotate(0deg);
    opacity: 0.6;
  }

  50% {
    opacity: 0.9;
  }

  100% {
    transform: translate(-50%, -50%) scale(1.2) rotate(5deg);
    opacity: 0.6;
  }
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.8;
    transform: scale(0.95);
  }
}

/* Additional Floating Movement for Cards */
.card:hover,
.article-card:hover,
.related-card:hover {
  animation: float 3s ease-in-out infinite;
}


/* Scroll Reveal Base Class */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.reveal.active {
  opacity: 1;
  transform: translateY(0);
}

/* Interactive Hover Effects */
.card,
.article-card,
.related-card {
  transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.card:hover,
.article-card:hover,
.related-card:hover {
  transform: translateY(-8px) scale(1.01);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 30px rgba(0, 180, 216, 0.1);
  border-color: var(--accent-blue);
  z-index: 10;
}

.category-card {
  transition: all 0.3s ease;
}

.category-card:hover {
  transform: translateY(-5px);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--text-link);
}

.category-card:hover .category-icon {
  transform: scale(1.2) rotate(5deg);
  transition: transform 0.3s ease;
}

.btn-primary,
.btn-secondary {
  transition: all 0.3s ease;
}

.btn-primary:active,
.btn-secondary:active {
  transform: translateY(1px) scale(0.98);
}

/* Hero Animations */
.hero-title {
  opacity: 0;
  animation: fadeUp 1s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.hero-subtitle {
  opacity: 0;
  animation: fadeUp 1s cubic-bezier(0.2, 0.8, 0.2, 1) 0.2s forwards;
}

/* Hero Stats Float + Fade */
.hero-stats {
  opacity: 0;
  animation: fadeUp 1s cubic-bezier(0.2, 0.8, 0.2, 1) 0.4s forwards, float 6s ease-in-out infinite 1.4s;
}

/* Header Glass Effect Enhancement */
.header {
  transition: background 0.3s ease, padding 0.3s ease;
}

/* Category Icon Float */
.category-header-icon {
  display: inline-block;
  animation: float 5s ease-in-out infinite;
}

/* Text Glow */
h1 {
  text-shadow: 0 0 20px rgba(0, 180, 216, 0.5);
}

/* More Light for Active Nav */
.nav-link.active {
  color: var(--accent-gold);
  text-shadow: 0 0 10px rgba(255, 214, 10, 0.6);
}

/* ---- Custom Dark Scrollbar ---- */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 180, 216, 0.25) rgba(0, 0, 12, 0.5);
}
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 12, 0.5);
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 180, 216, 0.25);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 180, 216, 0.4);
}

/* ---- Touch Target Improvements ---- */
@media (pointer: coarse) {
  .nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  .search-trigger {
    min-height: 44px;
  }
  .nav-toggle {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .category-card {
    min-height: 44px;
  }
  .article-card {
    min-height: 44px;
  }
  .search-result-item {
    min-height: 44px;
  }
  .related-card {
    min-height: 44px;
  }
  .toc-link {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  .footer-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}

/* ---- Prefers 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;
  }
  html {
    scroll-behavior: auto;
  }
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .hero-title,
  .hero-subtitle,
  .hero-stats {
    opacity: 1;
    animation: none;
  }
  .card:hover,
  .article-card:hover,
  .related-card:hover {
    animation: none;
    transform: none;
  }
  body::before,
  body::after {
    animation: none;
  }
}

/* ---- Nebula Blobs ---- */
.nebula-blob {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(80px);
  opacity: 0.18;
  z-index: 0;
  animation: nebulaFloat 20s ease-in-out infinite alternate;
}
.nebula-blob.nb1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #00d4ff 0%, transparent 70%);
  top: -10%; left: -5%;
}
.nebula-blob.nb2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #9333ea 0%, transparent 70%);
  bottom: -10%; right: -5%;
  animation-delay: -10s;
}
.nebula-blob.nb3 {
  width: 350px; height: 350px;
  background: radial-gradient(circle, #00d4ff 0%, #9333ea 50%, transparent 70%);
  top: 40%; left: 60%;
  animation-delay: -5s;
  opacity: 0.1;
}
@keyframes nebulaFloat {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(30px, -20px) scale(1.1); }
  100% { transform: translate(-20px, 15px) scale(0.95); }
}

/* ---- Scanlines Overlay ---- */
.scanlines-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 9998;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 212, 255, 0.008) 2px,
    rgba(0, 212, 255, 0.008) 4px
  );
  opacity: 0.5;
}

/* ---- Grid Overlay ---- */
.grid-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(0, 212, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 212, 255, 0.02) 1px, transparent 1px);
  background-size: 60px 60px;
}