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

:root {
  --bg: #0c1322;
  --bg2: #121a2d;
  --bg3: #1a2540;
  --bg4: #243354;
  --border: rgba(255, 255, 255, 0.08);
  --border2: rgba(255, 255, 255, 0.18);
  --text: #ebf0fa;
  --muted: #92a0bb;
  --accent: #59c1ff;
  --accent2: #ff8f5a;
  --accent3: #67d7a5;
  --hero-glow: rgba(89, 193, 255, 0.22);
  --mono: 'JetBrains Mono', 'Cascadia Code', monospace;
  --sans: 'Inter', system-ui, sans-serif;
  --display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(89, 193, 255, 0.2), transparent 28%),
    radial-gradient(circle at top right, rgba(103, 215, 165, 0.12), transparent 24%),
    linear-gradient(180deg, #0b1220 0%, #0c1322 40%, #10192e 100%);
  color: var(--text);
  font-family: var(--sans);
}

.index-shell {
  width: min(1240px, calc(100% - 48px));
  margin: 0 auto;
  padding: 36px 0 64px;
}

.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 18px;
  padding: 36px;
  border-radius: 28px;
  border: 1px solid rgba(89, 193, 255, 0.18);
  background:
    linear-gradient(135deg, rgba(89, 193, 255, 0.1), rgba(255, 143, 90, 0.06)),
    rgba(18, 26, 45, 0.92);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.28);
}

.hero::after {
  content: '';
  position: absolute;
  inset: auto -120px -140px auto;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--hero-glow), transparent 68%);
  pointer-events: none;
}

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent3);
}

.hero h1 {
  max-width: 820px;
  font-family: var(--display);
  font-size: clamp(2.5rem, 5vw, 4.7rem);
  line-height: 0.94;
  letter-spacing: -0.05em;
}

.hero-copy {
  max-width: 720px;
  font-size: 16px;
  line-height: 1.7;
  color: var(--muted);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border2);
  background: rgba(255, 255, 255, 0.04);
  font-size: 13px;
  color: var(--text);
}

.hero-pill strong {
  color: var(--accent);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin: 32px 0 22px;
}

.section-head h2 {
  font-family: var(--display);
  font-size: 1.6rem;
  letter-spacing: -0.04em;
}

.section-head p {
  max-width: 640px;
  color: var(--muted);
  line-height: 1.6;
}

.topic-filter-bar {
  display: grid;
  gap: 12px;
  margin: 0 0 22px;
}

.topic-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.topic-filter-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topic-filter-count {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.topic-filter-clear {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, opacity 0.18s ease;
}

.topic-filter-clear:hover:not(:disabled) {
  border-color: rgba(89, 193, 255, 0.32);
  background: rgba(89, 193, 255, 0.08);
}

.topic-filter-clear:disabled {
  opacity: 0.45;
  cursor: default;
}

.topic-filter {
  appearance: none;
  border: 1px solid rgba(89, 193, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.topic-filter:hover {
  color: var(--text);
  border-color: rgba(89, 193, 255, 0.38);
  transform: translateY(-1px);
}

.topic-filter.is-active {
  color: var(--text);
  border-color: rgba(89, 193, 255, 0.5);
  background: linear-gradient(135deg, rgba(89, 193, 255, 0.2), rgba(103, 215, 165, 0.12));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.handbook-card {
  position: relative;
  display: grid;
  min-height: 320px;
  grid-template-rows: 172px 1fr auto;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(18, 26, 45, 0.96), rgba(16, 25, 46, 0.98));
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.22);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.handbook-card:hover {
  transform: translateY(-4px);
  border-color: rgba(89, 193, 255, 0.34);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.3);
}

.handbook-card.is-hidden {
  display: none;
}

.handbook-art {
  position: relative;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(89, 193, 255, 0.2), transparent 32%),
    linear-gradient(135deg, rgba(103, 215, 165, 0.08), rgba(255, 143, 90, 0.12));
}

.handbook-art::after {
  content: '';
  position: absolute;
  inset: auto 18px 18px auto;
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  filter: blur(2px);
}

.handbook-art svg {
  width: min(100%, 180px);
  height: auto;
}

.handbook-copy {
  display: grid;
  gap: 10px;
  padding: 20px 20px 16px;
}

.card-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent3);
}

.handbook-copy h3 {
  font-size: 19px;
  line-height: 1.2;
}

.handbook-copy p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 0 20px 20px;
}

.card-file {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.card-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  border: 1px solid rgba(89, 193, 255, 0.22);
  background: rgba(89, 193, 255, 0.08);
  transition: background 0.18s ease, border-color 0.18s ease;
}

.card-link:hover {
  background: rgba(89, 193, 255, 0.16);
  border-color: rgba(89, 193, 255, 0.42);
}

.card-link svg {
  width: 16px;
  height: 16px;
}

.footer-note {
  margin-top: 28px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

html[data-theme="light"] body {
  background:
    radial-gradient(circle at top left, rgba(89, 193, 255, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(103, 215, 165, 0.12), transparent 24%),
    linear-gradient(180deg, #f6f9fc 0%, #edf3f9 100%);
}

html[data-theme="light"] .hero,
html[data-theme="light"] .handbook-card {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
}

html[data-theme="light"] .hero-pill,
html[data-theme="light"] .topic-filter,
html[data-theme="light"] .topic-filter-clear,
html[data-theme="light"] .card-link {
  background: rgba(15, 23, 42, 0.04);
}

html[data-theme="light"] .topic-filter.is-active {
  background: linear-gradient(135deg, rgba(89, 193, 255, 0.14), rgba(103, 215, 165, 0.12));
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

html[data-theme="light"] .handbook-art {
  background:
    radial-gradient(circle at top left, rgba(89, 193, 255, 0.14), transparent 32%),
    linear-gradient(135deg, rgba(103, 215, 165, 0.08), rgba(255, 143, 90, 0.08));
}

@media (max-width: 900px) {
  .index-shell {
    width: min(100% - 28px, 1240px);
  }

  .section-head {
    align-items: start;
    flex-direction: column;
  }

  .topic-filter-bar {
    margin-bottom: 18px;
  }

  .card-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .card-link {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .index-shell {
    width: calc(100% - 24px);
    padding-top: 88px;
  }

  .hero {
    padding: 24px;
    border-radius: 24px;
  }

  .hero-meta {
    flex-direction: column;
    align-items: start;
  }

  .handbook-card {
    min-height: 0;
  }
}