/* ============================================================================
   GitHubDB · css/base.css — GLOBALE BASIS & SHARED PRIMITIVES
   ----------------------------------------------------------------------------
   Zuständig für: Reset, Dokument-/Textstile, Scrollbar, ::selection,
   :focus-visible-Ring, Links/Code, .container, Seiten-Titel,
   SHARED PRIMITIVES (von JEDER Seite genutzt — andere Dateien dürfen diese
   NICHT neu definieren):
     .btn(.btn-primary/.btn-ghost), .input/select.input/textarea.input,
     .segmented, .badge(+Modifier), .repo-table(+Spalten/.repo-row/.repo-cell
     /.repo-name/.repo-desc/.repo-avatar/.lang-dot), .panel(.panel-wide),
     .section-grid, .notice, .status(.error), .spinner, .skeleton,
     .controls/.control-group/.control-meta, .checklist(+States),
   sowie Utilities (.muted, .accent, .num-green, .mono, .flex, .flex-between,
   .grid-basic, .sr-only, .hidden, .grow, .skip-link) und den
   Reduced-Motion-Kill-Switch.
   ========================================================================== */

/* ---------- Reset ---------- */
*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-base);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Auswahl & Scrollbar ---------- */
::selection { background: var(--accent-muted); color: var(--text-1); }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Fokus (a11y) ---------- */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ---------- Headings ---------- */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-1);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-md);
}

/* ---------- Links ---------- */
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Code / KBD / Pre (mono) ---------- */
code, kbd {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-1);
}
pre {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: var(--leading-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  overflow: auto;
  color: var(--text-1);
}

/* ---------- Layout ---------- */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-7);
  min-height: 70vh;
}

.page-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.01em;
}

/* ============================================================================
   SHARED PRIMITIVES
   ========================================================================== */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-1);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--transition-fast) var(--ease-out),
              border-color var(--transition-fast) var(--ease-out),
              color var(--transition-fast) var(--ease-out);
}
.btn:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--text-1);
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--accent-contrast);
}
.btn-primary:hover {
  background: var(--accent-strong-hover);
  border-color: var(--accent-strong-hover);
  color: var(--accent-contrast);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-1);
}

/* ---------- Inputs ---------- */
.input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-1);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: var(--text-sm);
  line-height: 1.4;
  min-height: 28px;
}
.input::placeholder { color: var(--text-3); }
.input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring-soft);
}
select.input { cursor: pointer; }
textarea.input { resize: vertical; }
.search-input { width: 100%; }

/* ---------- Segmented Control (Filter-Umschalter) ---------- */
.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
}
.segmented button {
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text-2);
  padding: 5px 12px;
  font-size: var(--text-xs);
  font-family: inherit;
  font-weight: var(--weight-medium);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--transition-fast) var(--ease-out),
              color var(--transition-fast) var(--ease-out);
}
.segmented button:last-child { border-right: none; }
.segmented button:hover { color: var(--text-1); background: var(--surface-2); }
.segmented button.active { background: var(--accent-muted); color: var(--accent); }

/* ---------- Badges / Pills ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 1px 9px;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-2);
  white-space: nowrap;
}
.badge a { color: inherit; }
.badge a:hover { color: var(--accent); }
.badge-open {
  color: var(--success);
  border-color: var(--accent-border);
  background: rgba(63, 185, 80, 0.08);
}
.badge-closed {
  color: var(--danger);
  border-color: rgba(248, 81, 73, 0.4);
  background: rgba(248, 81, 73, 0.08);
}
.badge-pr {
  color: var(--info);
  border-color: rgba(68, 147, 248, 0.4);
  background: rgba(68, 147, 248, 0.08);
}
.badge-sev-high {
  color: #f0883e;
  border-color: rgba(240, 136, 62, 0.45);
  background: rgba(240, 136, 62, 0.1);
}
.badge-sev-med {
  color: var(--warning);
  border-color: rgba(210, 153, 34, 0.45);
  background: rgba(210, 153, 34, 0.1);
}

/* ---------- Datentabelle (gemeinsames Gerüst) ---------- */
.repo-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.repo-table th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.repo-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.repo-table tbody tr:last-child td { border-bottom: none; }

.repo-row { cursor: pointer; }
.repo-row:hover { background: var(--surface-2); }
.repo-row:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}

.col-rank {
  width: 44px;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.col-num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.col-date { white-space: nowrap; color: var(--text-3); font-size: var(--text-xs); }
.col-lang { white-space: nowrap; }

.repo-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.repo-avatar { border-radius: var(--radius-sm); flex-shrink: 0; }
.repo-name { font-weight: var(--weight-semibold); }
.repo-desc {
  color: var(--text-2);
  font-size: var(--text-xs);
  line-height: var(--leading-xs);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.lang-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--text-3);
  vertical-align: baseline;
}

/* ---------- Panels & Grids ---------- */
.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  min-width: 0;
}
.panel-wide { grid-column: 1 / -1; }
.panel h2 {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-3);
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: var(--space-4);
}

.notice {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  max-width: 640px;
}
.notice h2 { margin-bottom: var(--space-2); }
.notice p { color: var(--text-2); }

/* ---------- Status / Laden / Skeleton ---------- */
.status { padding: 32px; text-align: center; color: var(--text-2); }
.status:empty { display: none; }
.status.error { color: var(--danger); }

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  display: block;
  height: 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
@keyframes skeleton-shimmer { to { background-position: -200% 0; } }

/* ---------- Filter-Leisten ---------- */
.controls {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.control-group { display: flex; flex-direction: column; gap: 4px; }
.control-group.grow { flex: 1; min-width: 240px; }
.control-meta {
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--text-3);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- Checklisten (Community-Profil, Lizenzen, Meta) ---------- */
.checklist { list-style: none; font-size: var(--text-sm); }
.checklist li { padding: 3px 0; }
.check-ok { color: var(--success); }
.check-no { color: var(--danger); }
.check-warn { color: var(--warning); }
.health { margin-bottom: var(--space-2); }

/* ---------- Utilities ---------- */
.muted { color: var(--text-3); }
.accent { color: var(--accent); }
.num-green { color: var(--success); font-weight: var(--weight-semibold); }
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.flex { display: flex; align-items: center; gap: var(--space-2); }
.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.grid-basic {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.grow { flex: 1; min-width: 0; }

/* ---------- Skip-Link (a11y) ---------- */
.skip-link {
  position: absolute;
  top: -48px;
  left: var(--space-3);
  z-index: calc(var(--z-nav) + 10);
  background: var(--surface-3);
  color: var(--text-1);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: top var(--transition-fast) var(--ease-out);
}
.skip-link:focus-visible { top: var(--space-2); }

/* ============================================================================
   REDUCED MOTION — Kill-Switch (a11y)
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .spinner { animation: none; border-top-color: var(--border); }
  .skeleton { animation: none; background: var(--surface-2); }
}

/* ---------- Responsive Basis ---------- */
@media (max-width: 720px) {
  .container { padding-top: var(--space-4); }
  .section-grid { grid-template-columns: 1fr; }
}
