:root {
  color-scheme: dark;
  --bg: #08111f;
  --panel: rgba(12, 24, 43, 0.88);
  --panel-strong: rgba(16, 35, 63, 0.95);
  --border: rgba(150, 187, 255, 0.18);
  --border-strong: rgba(150, 187, 255, 0.32);
  --text: #ebf2ff;
  --muted: #9db3d4;
  --accent: #8dc2ff;
  --success: #66d19e;
  --success-soft: rgba(102, 209, 158, 0.14);
  --warning: #ffd26a;
  --warning-soft: rgba(255, 210, 106, 0.14);
  --danger: #ff9d9d;
  --featured: #d5b7ff;
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

/* Accessibility: skip-to-content link */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  border-radius: 0 0 12px 12px;
  background: var(--accent);
  color: #04101d;
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus {
  top: 0;
}

/* Text selection */
::selection {
  background: rgba(141, 194, 255, 0.3);
  color: var(--text);
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  background:
    radial-gradient(circle at top, rgba(78, 159, 255, 0.22), transparent 30%),
    linear-gradient(180deg, #09101d 0%, #08111f 100%);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.75), transparent 92%);
}

/* ── Full-width shell ──────────────────────────────────────────────── */

.shell {
  width: calc(100% - 3rem);
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.hero,
.panel,
.footer {
  position: relative;
  z-index: 1;
}

/* ── Hero ──────────────────────────────────────────────────────────── */

.hero {
  padding: 3rem;
  border: 1px solid var(--border);
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(16, 35, 63, 0.96), rgba(10, 20, 37, 0.96));
  box-shadow: var(--shadow);
}

.hero-topline {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.eyebrow {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.05);
}

.live-pill::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: currentColor;
}

.live-pill.is-live {
  color: var(--success);
  border-color: rgba(102, 209, 158, 0.28);
  background: var(--success-soft);
}

.live-pill.is-fallback {
  color: var(--warning);
  border-color: rgba(255, 210, 106, 0.26);
  background: var(--warning-soft);
}

/* ── Typography ────────────────────────────────────────────────────── */

h1,
h2,
h3,
p,
dl {
  margin-top: 0;
}

h1 {
  margin: 1rem 0;
  font-size: clamp(2.35rem, 4vw, 4.25rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
}

h2 {
  font-size: clamp(1.55rem, 2.3vw, 2rem);
  margin-bottom: 0.6rem;
}

.hero-copy,
#intro-copy,
.section-heading p,
.repo-summary,
.results-summary,
.footer,
.callout p,
.meta-row,
.field span,
.empty-state p,
.repo-kicker,
.snapshot-copy {
  color: var(--muted);
}

.hero-copy,
#intro-copy {
  font-size: 1.08rem;
  max-width: 70ch;
}

/* ── Hero actions ──────────────────────────────────────────────────── */

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin: 1.75rem 0 2rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.8rem;
  padding: 0.72rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-decoration: none;
  font-weight: 700;
  font: inherit;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.button:hover,
.button:focus-visible {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.button.primary {
  color: #04101d;
  background: linear-gradient(135deg, var(--accent), #d2e9ff);
}

.button.secondary,
.button.tertiary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

/* ── Grids ─────────────────────────────────────────────────────────── */

.stats,
.snapshot-grid,
.repo-grid {
  display: grid;
  gap: 1rem;
}

.stats,
.snapshot-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.repo-grid {
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
}

/* ── Cards (stat / snapshot / repo) ────────────────────────────────── */

.stat-card,
.snapshot-card,
.repo-card {
  border-radius: 20px;
  border: 1px solid var(--border);
}

.stat-card,
.snapshot-card {
  margin: 0;
  padding: 1rem 1.1rem;
  background: rgba(255, 255, 255, 0.03);
}

.stat-card dt {
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.stat-card dd {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
}

/* ── Panels ────────────────────────────────────────────────────────── */

.panel {
  margin-top: 1.5rem;
  padding: 1.75rem;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.intro-panel {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 1.25rem;
}

.intro-copy-block {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  justify-content: space-between;
}

.legend-row,
.badges,
.topics,
.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.callout {
  padding: 1rem 1.1rem;
  border-radius: 18px;
  border: 1px solid rgba(102, 209, 158, 0.25);
  background: rgba(102, 209, 158, 0.08);
}

.callout strong {
  display: block;
  margin-bottom: 0.5rem;
}

.section-heading {
  margin-bottom: 1.25rem;
}

.snapshot-card {
  background: linear-gradient(180deg, rgba(16, 35, 63, 0.86), rgba(8, 17, 31, 0.92));
}

.snapshot-value {
  margin: 0 0 0.35rem;
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  font-weight: 800;
}

.snapshot-copy {
  margin-bottom: 0;
  line-height: 1.55;
}

/* ── Filters ───────────────────────────────────────────────────────── */

.filters {
  display: grid;
  grid-template-columns: minmax(0, 2fr) repeat(4, minmax(140px, 1fr)) 120px;
  gap: 1rem;
  margin-bottom: 1rem;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

input,
select {
  width: 100%;
  min-height: 2.9rem;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(5, 11, 20, 0.9);
  color: var(--text);
  font: inherit;
}

input::placeholder {
  color: rgba(157, 179, 212, 0.82);
}

input:focus,
select:focus,
.button:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(141, 194, 255, 0.32);
  outline-offset: 2px;
}

.results-summary {
  margin-bottom: 0.85rem;
}

.active-filters {
  margin-bottom: 1rem;
}

/* ── Badges / chips / topics ───────────────────────────────────────── */

.filter-chip,
.badge,
.topic {
  display: inline-flex;
  align-items: center;
  min-height: 1.9rem;
  padding: 0.22rem 0.58rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.filter-chip,
.badge {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.badge.status-active {
  color: #071913;
  background: var(--success);
}

.badge.status-featured,
.badge.priority-badge {
  color: #1c1031;
  background: var(--featured);
}

.badge.status-experimental,
.badge.status-watch {
  color: #2f2100;
  background: var(--warning);
}

.badge.status-archived {
  color: #301414;
  background: var(--danger);
}

.badge.kind-original {
  background: rgba(141, 194, 255, 0.12);
  border-color: rgba(141, 194, 255, 0.2);
}

.badge.kind-fork {
  background: rgba(255, 210, 106, 0.12);
  border-color: rgba(255, 210, 106, 0.2);
}

.topic {
  color: var(--accent);
  background: rgba(141, 194, 255, 0.08);
  border: 1px solid rgba(141, 194, 255, 0.14);
}

/* ── Catalog container (holds group sections) ──────────────────────── */

.catalog-container {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

/* ── Group sections ────────────────────────────────────────────────── */

.group-section {
  /* each group is a self-contained block */
}

.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.group-header-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.group-header-text h3 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}

.group-header-text p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.group-count {
  flex-shrink: 0;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Repo cards ────────────────────────────────────────────────────── */

.repo-card {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-height: 100%;
  padding: 1.25rem;
  background: linear-gradient(180deg, rgba(16, 35, 63, 0.88), rgba(8, 17, 31, 0.94));
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.repo-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
}

.repo-card.featured {
  border-color: rgba(213, 183, 255, 0.34);
  background: linear-gradient(180deg, rgba(33, 43, 88, 0.94), rgba(12, 24, 43, 0.97));
}

.repo-card-header {
  /* wrapper for kicker + title */
}

.repo-kicker {
  margin-bottom: 0.25rem;
  font-size: 0.8rem;
}

.repo-title {
  margin: 0;
  font-size: 1.12rem;
}

.repo-title a {
  text-decoration: none;
  color: var(--text);
}

.repo-title a:hover {
  color: var(--accent);
}

.repo-summary {
  flex: 1;
  margin-bottom: 0;
  line-height: 1.58;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1rem;
  font-size: 0.92rem;
  color: var(--muted);
}

/* ── Repo action buttons ───────────────────────────────────────────── */

.repo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(150, 187, 255, 0.08);
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.38rem 0.8rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.action-btn:hover {
  transform: translateY(-1px);
}

.btn-repo {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
}

.btn-repo:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: var(--border-strong);
}

.btn-pages {
  color: var(--success);
  background: rgba(102, 209, 158, 0.08);
  border: 1px solid rgba(102, 209, 158, 0.22);
}

.btn-pages:hover {
  background: rgba(102, 209, 158, 0.2);
  border-color: rgba(102, 209, 158, 0.4);
}

.btn-parent {
  color: var(--featured);
  background: rgba(213, 183, 255, 0.08);
  border: 1px solid rgba(213, 183, 255, 0.22);
}

.btn-parent:hover {
  background: rgba(213, 183, 255, 0.2);
  border-color: rgba(213, 183, 255, 0.4);
}

/* ── Empty state ───────────────────────────────────────────────────── */

.empty-state {
  padding: 2rem;
  border: 1px dashed var(--border);
  border-radius: 20px;
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
}

/* ── Footer ────────────────────────────────────────────────────────── */

.footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.95rem;
}

.footer .copyright {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  opacity: 0.6;
}

code {
  padding: 0.15rem 0.35rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.hidden {
  display: none;
}

/* ── Reduced motion ────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Medium screens ────────────────────────────────────────────────── */

@media (max-width: 1120px) {
  .filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .snapshot-grid,
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .intro-panel {
    grid-template-columns: 1fr;
  }
}

/* ── Small screens ─────────────────────────────────────────────────── */

@media (max-width: 720px) {
  .shell {
    width: calc(100% - 1rem);
    padding-top: 1rem;
  }

  .hero,
  .panel {
    padding: 1.2rem;
    border-radius: 20px;
  }

  .filters,
  .snapshot-grid,
  .stats {
    grid-template-columns: 1fr;
  }

  .repo-grid {
    grid-template-columns: 1fr;
  }

  .group-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}
