:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #39d353;
  --accent-dim: #1f6b2e;
  --link: #58a6ff;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --radius: 6px;
  --radius-lg: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--font-mono); background: var(--surface-2); padding: 2px 6px; border-radius: 4px; font-size: 0.875em; }

/* ===== Layout ===== */
.site-wrapper { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* ===== Nav ===== */
.site-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
}

@media (max-width: 600px) {
  .nav-inner {
    padding: 10px 16px;
    gap: 4px;
    row-gap: 6px;
  }

  .nav-brand { flex-basis: 100%; }

  .nav-links {
    flex-wrap: wrap;
    row-gap: 4px;
  }

  .nav-links a {
    padding: 4px 8px;
    font-size: 13px;
  }
}

.nav-brand {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  display: flex;
  align-items: center;
}

.nav-brand:hover { opacity: 0.8; text-decoration: none; }

.nav-logo {
  border-radius: 50%;
  background: transparent;
  vertical-align: middle;
  margin-right: 8px;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  gap: 2px;
  list-style: none;
}

.nav-links a {
  color: var(--text-muted);
  font-size: 14px;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
  display: block;
}

.nav-links a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav-links a.active { color: var(--accent); }

/* ===== Main ===== */
main { padding: 40px 0 80px; }

/* ===== Page header ===== */
.page-header { margin-bottom: 40px; }
.page-header h1 { font-size: 2rem; font-weight: 700; margin-bottom: 8px; }
.page-header .lead { color: var(--text-muted); font-size: 1.05rem; }

/* ===== Breadcrumb ===== */
.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
  font-family: var(--font-mono);
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .sep { margin: 0 6px; opacity: 0.5; }

/* ===== Stats bar ===== */
.stats-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.stat-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent);
  line-height: 1;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

/* ===== Category strip ===== */
.category-strip {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.cat-chip {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface);
  transition: all 0.15s;
}

.cat-chip:hover { color: var(--text); border-color: var(--text-muted); text-decoration: none; }
.cat-chip.active { color: var(--accent); border-color: var(--accent-dim); background: rgba(57, 211, 83, 0.06); }

/* ===== Badge grid ===== */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

/* ===== Badge card ===== */
.badge-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  color: inherit;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.badge-card[hidden] { display: none; }

@media (hover: hover) {
  .badge-card:hover {
    border-color: var(--accent-dim);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    text-decoration: none;
  }
}

.badge-card-image {
  width: 100%;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: var(--surface-2);
}

.badge-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s;
}

@media (hover: hover) {
  .badge-card:hover .badge-card-image img { transform: scale(1.03); }
}

.badge-card-image-placeholder {
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 13px;
}

.badge-card-body {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.badge-card-title { font-size: 15px; font-weight: 600; line-height: 1.3; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.badge-card-meta { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }

.badge-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}

/* ===== Tags ===== */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  white-space: nowrap;
}

.tag-type-badge     { border-color: #1d4ed8; color: #60a5fa; background: #0c1a3a; }
.tag-type-sao       { border-color: #6d28d9; color: #a78bfa; background: #1a0e3a; }
.tag-type-minibadge { border-color: #0f766e; color: #2dd4bf; background: #0a2926; }
.tag-type-standalone{ border-color: #92400e; color: #fbbf24; background: #2a1a05; }
.tag-type-entry     { border-color: #1f6b2e; color: #39d353; background: #0a1f0d; }
.tag-type-other     { border-color: var(--border); color: var(--text-muted); }
.tag-con-defcon     { border-color: #dc2626; color: #f87171; background: #2a0a0a; }
.tag-con-saintcon   { border-color: #0369a1; color: #38bdf8; background: #061827; }
.tag-status-stub    { border-color: #78350f; color: #d97706; background: #1c1007; }
.tag-status-complete{ border-color: #166534; color: #4ade80; background: #0a1f0d; }
.tag-credit          { border-color: #86198f; color: #e879f9; background: #2a0a2e; }

a.tag { text-decoration: none; }
a.tag:hover { opacity: 0.75; }

.badge-card-meta .card-facet-link { cursor: pointer; }
.badge-card-meta .card-facet-link:hover { text-decoration: underline; }
.badge-tags .card-facet-link { cursor: pointer; }
.badge-tags .card-facet-link:hover { opacity: 0.75; }

/* ===== Badge ID chip — card overlay and detail tag ===== */
.badge-card-image { position: relative; }
.badge-card-image-placeholder { position: relative; }
.badge-id-chip {
  font-family: var(--font-mono);
  font-size: 20px; font-weight: 700;
  background: var(--surface-2);
  color: var(--accent);
  padding: 4px 8px;
  border-radius: 4px;
  letter-spacing: 0.08em;
  line-height: 1;
  flex-shrink: 0;
  user-select: none;
}
.badge-id-chip--missing { color: #f87171; }

/* ===== Badge detail ===== */
.badge-detail-header { margin-bottom: 32px; }
.badge-detail-header h1 { font-size: 1.8rem; font-weight: 700; margin-bottom: 12px; }
.badge-detail-meta-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tag-edit { margin-left: auto; text-decoration: none; border-color: var(--border); color: var(--text-muted); }
.tag-edit:hover { color: var(--text); border-color: var(--text-muted); }

.badge-detail-body {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 40px;
  align-items: start;
}

@media (max-width: 800px) {
  .badge-detail-body { grid-template-columns: 1fr; }
}

/* Image gallery */
.badge-gallery { display: flex; flex-direction: column; gap: 12px; }

.gallery-main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-main img { max-width: 100%; max-height: 100%; object-fit: contain; }

.gallery-main-placeholder {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 14px;
}

.gallery-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }

.gallery-thumb {
  width: 72px;
  height: 72px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s;
}

.gallery-thumb:hover,
.gallery-thumb.active { border-color: var(--accent); }

.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* Badge videos — short looping clips (e.g. a badge slowly rotating),
   converted to small muted MP4s by the admin app's ffmpeg pipeline */
.badge-videos { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }

.badge-video {
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
  display: block;
}

.badge-video-caption {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: -6px;
}

/* YouTube embeds */
.badge-youtube { margin-top: 12px; }
.badge-youtube iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: none;
  border-radius: var(--radius-lg);
  display: block;
}

/* Badge links */
.badge-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.source-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface-2);
  transition: all 0.15s;
}

.source-link:hover { border-color: var(--link); color: var(--link); text-decoration: none; }

/* Specs table */
.badge-specs {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.specs-header {
  padding: 10px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-muted);
}

.spec-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  border-bottom: 1px solid var(--border);
}

.spec-row:last-child { border-bottom: none; }

.spec-label {
  padding: 10px 16px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--surface-2);
  display: flex;
  align-items: flex-start;
  padding-top: 12px;
}

.spec-value {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

/* Badge notes */
.badge-notes {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.badge-notes h2 {
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.badge-notes-content { color: var(--text); line-height: 1.75; }
.badge-notes-content p { margin-bottom: 12px; }
.badge-notes-content h2,
.badge-notes-content h3 { margin: 24px 0 8px; font-size: 1rem; }
.badge-notes-content ul,
.badge-notes-content ol { padding-left: 20px; margin-bottom: 12px; }
.badge-notes-content li { margin-bottom: 4px; }

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 16px; }
.empty-state p { margin-bottom: 8px; }

/* ===== Footer ===== */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ===== Filter bar ===== */
button.cat-chip {
  cursor: pointer;
  font-family: var(--font-sans);
}

.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-input {
  flex: 1;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-sans);
  padding: 6px 12px;
  transition: border-color 0.15s;
}

.filter-input::placeholder { color: var(--text-muted); }
.filter-input:focus { outline: none; border-color: var(--accent-dim); }

.filter-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-mono);
  padding: 6px 28px 6px 10px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b949e'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.15s;
}

.filter-select:focus { outline: none; border-color: var(--accent-dim); }

.filter-results {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  padding: 0 4px;
}

.filter-clear {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-mono);
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.filter-clear:hover { border-color: var(--text-muted); color: var(--text); }

/* ===== Advanced parametric filter ===== */
.filter-advanced { position: relative; }

.filter-advanced-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  font-family: var(--font-sans);
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-advanced-toggle:hover,
.filter-advanced-toggle.active { color: var(--text); border-color: var(--text-muted); }
.filter-advanced-toggle.has-active { color: var(--accent); border-color: var(--accent-dim); }

.advanced-count-badge {
  background: var(--accent-dim);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 20px;
}

/* Full-width parametric search strip, docked between the filter bar and the
   grid (Digikey-style) rather than a floating dropdown — each facet gets its
   own always-visible, independently-scrolling column. */
.filter-advanced-panel {
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.filter-advanced-panel[hidden] { display: none; }

.filter-advanced-panel-inner {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
}

.facet-column {
  flex: 1 0 200px;
  max-width: 260px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 10px 14px;
  border-right: 1px solid var(--border);
}
.facet-column:last-child { border-right: none; }

.facet-column-header {
  font-size: 12px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.facet-column-search {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
  font-family: var(--font-sans);
  padding: 4px 8px;
  margin-bottom: 8px;
}
.facet-column-search::placeholder { color: var(--text-muted); }
.facet-column-search:focus { outline: none; border-color: var(--accent-dim); }

.facet-options {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
}

.facet-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 3px 4px;
  border-radius: 4px;
  cursor: pointer;
}

.facet-option:hover { background: var(--surface-2); }
.facet-option-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facet-option-count { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.facet-option-zero { opacity: 0.4; }

/* ===== View toggle (grid / table) ===== */
.view-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

.view-btn {
  background: var(--surface);
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-family: var(--font-sans);
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.view-btn + .view-btn { border-left: 1px solid var(--border); }
.view-btn:hover { color: var(--text); }
.view-btn.active { color: var(--accent); background: rgba(57, 211, 83, 0.06); }

.columns-wrap { position: relative; }

.columns-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.columns-panel[hidden] { display: none; }

.columns-option { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }

/* ===== Badge table view ===== */
.badge-grid[hidden],
.badge-table-wrap[hidden] { display: none; }

.badge-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}

.badge-table { width: 100%; border-collapse: collapse; font-size: 13px; }

.badge-table th {
  text-align: left;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  white-space: nowrap;
}

.badge-table th.sortable { cursor: pointer; }
.badge-table th.sortable:hover { color: var(--text); }

.badge-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.badge-table tr:last-child td { border-bottom: none; }
.badge-table tbody tr { cursor: pointer; transition: background 0.15s; }
.badge-table tbody tr:hover { background: var(--surface-2); }

.badge-table .table-col-con,
.badge-table .table-col-type,
.badge-table .table-col-status,
.badge-table .table-col-edition,
.badge-table .table-col-rarity,
.badge-table .table-col-display { text-transform: capitalize; }

/* ===== Utility ===== */
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.font-mono { font-family: var(--font-mono); }
