/* ===== Antigravity Kit Book - "Mission Control" Design System ===== */
/* Inspired by: Space Tech (#89) + HUD/Sci-Fi (#51) + Developer Tool (#87) */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  /* Deep space palette */
  --bg-void: #050510;
  --bg-panel: #0c0f1a;
  --bg-console: #111628;
  --bg-raised: #161d33;

  /* HUD Cyan - chủ đạo */
  --cyan: #00e5ff;
  --cyan-dim: #0097a7;
  --cyan-glow: rgba(0,229,255,0.10);
  --cyan-border: rgba(0,229,255,0.18);

  /* Amber - alerts, warnings, interactive */
  --amber: #ffb300;
  --amber-glow: rgba(255,179,0,0.10);

  /* Emerald - success, active */
  --emerald: #00e676;
  --emerald-glow: rgba(0,230,118,0.10);

  /* Gold - author branding */
  --gold: #fbbf24;
  --gold-glow: rgba(251,191,36,0.12);

  /* Text - indigo-tinted grays */
  --text-bright: #e8eaf6;
  --text-mid: #9fa8da;
  --text-dim: #5c6bc0;
  --text-muted: #3949ab;

  /* Borders */
  --border: rgba(92,107,192,0.12);
  --border-cyan: rgba(0,229,255,0.20);

  /* Layout */
  --sidebar-w: 280px;
  --header-h: 56px;
  --radius: 4px;

  /* Fonts */
  --font-heading: 'Space Grotesk', 'Inter', sans-serif;
  --font-body: 'IBM Plex Sans', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Motion */
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition: all 0.2s var(--ease);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font-body);
  background: var(--bg-void);
  color: var(--text-bright);
  line-height: 1.75;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== CONSTELLATION BACKGROUND ===== */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(0,229,255,0.15) 0%, transparent 100%),
    radial-gradient(1px 1px at 30% 70%, rgba(0,229,255,0.08) 0%, transparent 100%),
    radial-gradient(1px 1px at 55% 15%, rgba(255,179,0,0.10) 0%, transparent 100%),
    radial-gradient(1px 1px at 80% 55%, rgba(0,229,255,0.12) 0%, transparent 100%),
    radial-gradient(1px 1px at 90% 85%, rgba(0,230,118,0.08) 0%, transparent 100%),
    radial-gradient(1px 1px at 15% 90%, rgba(0,229,255,0.06) 0%, transparent 100%),
    radial-gradient(1px 1px at 45% 45%, rgba(255,179,0,0.06) 0%, transparent 100%),
    radial-gradient(1px 1px at 70% 30%, rgba(0,229,255,0.10) 0%, transparent 100%),
    radial-gradient(0.5px 0.5px at 25% 40%, rgba(232,234,246,0.08) 0%, transparent 100%),
    radial-gradient(0.5px 0.5px at 65% 60%, rgba(232,234,246,0.06) 0%, transparent 100%),
    radial-gradient(0.5px 0.5px at 35% 80%, rgba(232,234,246,0.05) 0%, transparent 100%),
    radial-gradient(0.5px 0.5px at 85% 10%, rgba(232,234,246,0.07) 0%, transparent 100%);
  pointer-events: none;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto; z-index: 100;
  padding: 20px 0;
  transition: transform 0.35s var(--ease);
}
.sidebar::before {
  content: '';
  position: absolute; top: 0; right: 0;
  width: 1px; height: 100%;
  background: linear-gradient(to bottom, var(--cyan-border), transparent 30%, var(--cyan-border) 50%, transparent 70%, var(--cyan-border));
}

.sidebar-logo {
  padding: 0 20px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.sidebar-logo h2 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cyan);
  text-shadow: 0 0 20px rgba(0,229,255,0.3);
}
.sidebar-logo .sub {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 4px;
  letter-spacing: 0.04em;
}

.sidebar nav { padding: 0 10px; }
.sidebar nav a {
  display: block;
  padding: 7px 12px;
  margin: 1px 0;
  font-size: 0.8rem;
  color: var(--text-mid);
  text-decoration: none;
  border-radius: var(--radius);
  transition: var(--transition);
  cursor: pointer;
  border-left: 2px solid transparent;
  font-family: var(--font-body);
}
.sidebar nav a:hover {
  background: var(--cyan-glow);
  color: var(--text-bright);
}
.sidebar nav a.active {
  background: var(--cyan-glow);
  color: var(--cyan);
  border-left-color: var(--cyan);
  font-weight: 500;
}
.sidebar nav a.chapter-link {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--text-bright);
  margin-top: 10px;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}
.sidebar nav a.section-link {
  padding-left: 26px;
  font-size: 0.75rem;
}

/* ===== AUTHOR BAR ===== */
.author-bar {
  position: fixed; top: 0; right: 0;
  left: var(--sidebar-w);
  height: var(--header-h);
  background: rgba(5,5,16,0.80);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 28px;
  z-index: 90;
}
.author-link {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none;
  padding: 7px 16px;
  border-radius: 4px;
  background: var(--gold-glow);
  border: 1px solid rgba(251,191,36,0.25);
  transition: var(--transition);
  cursor: pointer;
}
.author-link:hover {
  background: rgba(251,191,36,0.20);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(251,191,36,0.15);
}
.author-link span {
  color: var(--gold);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  position: relative; z-index: 1;
  margin-left: var(--sidebar-w);
  padding: calc(var(--header-h) + 36px) 48px 80px;
  max-width: 920px;
}

/* ===== HERO ===== */
.hero {
  text-align: center;
  padding: 48px 0 44px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 48px;
  position: relative;
}

/* Scanline effect */
.hero::after {
  content: '';
  position: absolute;
  left: 10%; right: 10%;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  box-shadow: 0 0 8px var(--cyan-glow);
}

.hero h1 {
  font-family: var(--font-heading);
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #e8eaf6 0%, var(--cyan) 45%, var(--emerald) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.15;
  margin-bottom: 12px;
}
.hero .subtitle {
  font-family: var(--font-body);
  color: var(--text-mid);
  font-size: 1.05rem;
  font-weight: 300;
  margin-bottom: 6px;
}
.hero .meta {
  font-family: var(--font-mono);
  color: var(--text-dim);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}
.hero .meta strong {
  color: var(--text-bright);
}
.github-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-mid);
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--bg-console);
  transition: var(--transition);
  cursor: pointer;
}
.github-link:hover {
  border-color: var(--cyan-border);
  color: var(--cyan);
  box-shadow: 0 0 12px rgba(0,229,255,0.08);
}
.github-link svg { flex-shrink: 0; }

/* HUD Stats */
.hero .stats {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 28px;
  flex-wrap: wrap;
}
.hero .stat {
  text-align: center;
  padding: 14px 22px;
  background: var(--bg-console);
  border: 1px solid var(--border-cyan);
  position: relative;
}
/* HUD corner markers */
.hero .stat::before,
.hero .stat::after {
  content: '';
  position: absolute;
  width: 8px; height: 8px;
  border-color: var(--cyan);
  border-style: solid;
}
.hero .stat::before {
  top: -1px; left: -1px;
  border-width: 1px 0 0 1px;
}
.hero .stat::after {
  bottom: -1px; right: -1px;
  border-width: 0 1px 1px 0;
}
.hero .stat .num {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(0,229,255,0.25);
  line-height: 1.2;
}
.hero .stat .label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 4px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ===== CHAPTER & SECTIONS ===== */
.chapter {
  margin-bottom: 56px;
  scroll-margin-top: calc(var(--header-h) + 20px);
  animation: fadeIn 0.4s ease-out forwards;
}
.chapter > h2 {
  font-family: var(--font-heading);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text-bright);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--cyan-border);
  margin-bottom: 24px;
  scroll-margin-top: calc(var(--header-h) + 20px);
  letter-spacing: 0.01em;
  position: relative;
}
.chapter > h2::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0;
  width: 60px; height: 2px;
  background: var(--cyan);
  box-shadow: 0 0 6px rgba(0,229,255,0.4);
}

.chapter h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-bright);
  margin: 28px 0 12px;
  scroll-margin-top: calc(var(--header-h) + 20px);
}
.chapter h4 {
  font-family: var(--font-heading);
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--cyan);
  margin: 20px 0 8px;
  letter-spacing: 0.02em;
}
.chapter p {
  margin-bottom: 14px;
  color: var(--text-mid);
  font-weight: 400;
}
.chapter ul, .chapter ol {
  padding-left: 22px;
  margin-bottom: 14px;
}
.chapter li {
  margin-bottom: 5px;
  color: var(--text-mid);
}
.chapter li strong { color: var(--text-bright); }
.chapter strong { color: var(--text-bright); }
.chapter hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 36px 0;
}

/* ===== BLOCKQUOTE ===== */
blockquote {
  margin: 18px 0;
  padding: 14px 18px;
  border-left: 2px solid var(--cyan);
  background: var(--cyan-glow);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
  color: var(--text-mid);
  font-size: 0.92rem;
}

/* ===== TABLES ===== */
.table-wrap {
  overflow-x: auto;
  margin: 14px 0;
  border: 1px solid var(--border-cyan);
  position: relative;
}
/* HUD corners on tables */
.table-wrap::before,
.table-wrap::after {
  content: '';
  position: absolute;
  width: 10px; height: 10px;
  border-color: var(--cyan);
  border-style: solid;
  z-index: 1;
}
.table-wrap::before {
  top: -1px; left: -1px;
  border-width: 2px 0 0 2px;
}
.table-wrap::after {
  bottom: -1px; right: -1px;
  border-width: 0 2px 2px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}
th {
  background: var(--bg-raised);
  color: var(--cyan);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.78rem;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--cyan-border);
}
td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-mid);
  font-size: 0.82rem;
}
tr:hover td {
  background: rgba(0,229,255,0.03);
}

/* ===== CODE ===== */
code {
  font-family: var(--font-mono);
  font-size: 0.83em;
  background: var(--bg-console);
  color: var(--cyan);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
}
pre {
  background: var(--bg-console);
  border: 1px solid var(--border-cyan);
  padding: 18px;
  overflow-x: auto;
  margin: 14px 0;
  position: relative;
}
/* HUD corner on code blocks */
pre::before {
  content: '';
  position: absolute;
  top: -1px; left: -1px;
  width: 8px; height: 8px;
  border-top: 2px solid var(--emerald);
  border-left: 2px solid var(--emerald);
}
pre::after {
  content: '>';
  position: absolute;
  top: 8px; left: 10px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--emerald);
  opacity: 0.4;
}
pre code {
  background: transparent;
  padding: 0;
  color: #c5cae9;
  font-size: 0.8rem;
  line-height: 1.65;
  border: none;
}

/* ===== AGENT CARDS ===== */
.agent-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  padding: 22px;
  margin: 18px 0;
  transition: var(--transition);
  position: relative;
}
/* HUD corner markers */
.agent-card::before,
.agent-card::after {
  content: '';
  position: absolute;
  width: 10px; height: 10px;
  border-color: var(--cyan-dim);
  border-style: solid;
  transition: var(--transition);
}
.agent-card::before {
  top: -1px; left: -1px;
  border-width: 2px 0 0 2px;
}
.agent-card::after {
  bottom: -1px; right: -1px;
  border-width: 0 2px 2px 0;
}
.agent-card:hover {
  border-color: var(--cyan-border);
  box-shadow: 0 0 24px rgba(0,229,255,0.06), inset 0 0 30px rgba(0,229,255,0.02);
}
.agent-card:hover::before,
.agent-card:hover::after {
  border-color: var(--cyan);
  width: 14px; height: 14px;
}
.agent-card h4 {
  margin-top: 0;
  color: var(--cyan);
}

/* Status dot - mission control indicator */
.status-dot {
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--emerald);
  border-radius: 50%;
  margin-right: 8px;
  box-shadow: 0 0 6px var(--emerald);
  animation: pulse 2s infinite;
  vertical-align: middle;
}
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--emerald); }
  50% { opacity: 0.5; box-shadow: 0 0 2px var(--emerald); }
}

/* ===== BADGE ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  background: var(--cyan-glow);
  color: var(--cyan);
  border: 1px solid var(--cyan-border);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge.green {
  background: var(--emerald-glow);
  color: var(--emerald);
  border-color: rgba(0,230,118,0.25);
}
.badge.orange {
  background: var(--amber-glow);
  color: var(--amber);
  border-color: rgba(255,179,0,0.25);
}

/* ===== JUMP TO TOP ===== */
#jump-top {
  position: fixed;
  bottom: 24px; right: 24px;
  width: 40px; height: 40px;
  background: var(--bg-panel);
  color: var(--cyan);
  border: 1px solid var(--cyan-border);
  font-family: var(--font-mono);
  font-size: 1rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 200;
}
#jump-top:hover {
  background: var(--cyan-glow);
  border-color: var(--cyan);
  box-shadow: 0 0 16px rgba(0,229,255,0.2);
  transform: translateY(-2px);
}
#jump-top.visible { display: flex; }

/* ===== HAMBURGER (mobile) ===== */
.hamburger {
  display: none;
  position: fixed;
  top: 10px; left: 10px;
  width: 44px; height: 44px;
  z-index: 200;
  background: var(--bg-panel);
  border: 1px solid var(--border-cyan);
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.hamburger span {
  display: block;
  width: 18px; height: 1.5px;
  background: var(--cyan);
  transition: var(--transition);
}
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(5,5,16,0.75);
  z-index: 90;
  backdrop-filter: blur(4px);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 800px) {
  .sidebar {
    transform: translateX(-100%);
    width: 260px;
    z-index: 150;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .hamburger { display: flex; }
  .author-bar {
    left: 0;
    padding: 0 14px;
    justify-content: center;
  }
  .main-content {
    margin-left: 0;
    padding: calc(var(--header-h) + 16px) 16px 60px;
  }
  .hero h1 { font-size: 1.8rem; }
  .hero .stats { gap: 10px; }
  .hero .stat { padding: 10px 14px; }
  .hero .stat .num { font-size: 1.3rem; }
  table { font-size: 0.76rem; }
  th, td { padding: 7px 10px; }
  #jump-top { bottom: 16px; right: 16px; }
  .chapter > h2 { font-size: 1.4rem; }
  .agent-card { padding: 16px; }
}
@media (max-width: 375px) {
  .main-content { padding-left: 12px; padding-right: 12px; }
  .hero h1 { font-size: 1.5rem; }
  .hero .stat { padding: 8px 10px; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-cyan);
  border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover { background: var(--cyan-dim); }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== SELECTION ===== */
::selection {
  background: rgba(0,229,255,0.25);
  color: var(--text-bright);
}
