:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --warn-bg: #3d2d00;
  --warn-text: #e3b341;
  --radius: 10px;
  --gap: 1rem;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family:
    system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--accent);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 10;
  background: var(--accent);
  color: #000;
  padding: 0.5rem 1rem;
  border-radius: 0 0 var(--radius) 0;
}

.skip-link:focus {
  left: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Header / profile */
.site-header {
  padding: clamp(1.25rem, 4vw, 2.5rem) clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #12182100, #0d1117);
}

.profile {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.profile__avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex: 0 0 auto;
}

.profile__body {
  min-width: 0;
}

.profile__name {
  margin: 0;
  font-size: clamp(1.3rem, 3vw, 1.9rem);
}

.profile__bio {
  margin: 0.25rem 0;
  color: var(--text);
}

.profile__facts,
.profile__links {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.profile__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: center;
}

.profile__link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

/* Main */
.site-main {
  padding: clamp(1rem, 4vw, 2.5rem);
  max-width: 1200px;
  margin: 0 auto;
}

.section-title {
  font-size: 1.25rem;
  margin: 0 0 0.75rem;
}

/* Controls */
.controls {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: end;
  margin-bottom: 0.75rem;
}

.controls__field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.controls__field--search {
  flex: 1 1 260px;
}

.controls__field--sort {
  flex: 0 0 auto;
  min-width: 190px;
}

.controls__input,
.controls__select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.55rem 0.75rem;
  font-size: 1rem;
  width: 100%;
  min-height: 44px;
}

/* Safari ignores min-height/padding on native selects; strip the native
   appearance so the select matches the search input height, and supply our own
   dropdown chevron. */
.controls__select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 2.1rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%238b949e'%3E%3Cpath d='M4.22 6.22a.75.75 0 0 1 1.06 0L8 8.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L4.22 7.28a.75.75 0 0 1 0-1.06Z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 0.85rem;
}

.result-count {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.view-toggle__group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.view-toggle__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 38px;
  padding: 0.35rem 0.6rem;
  background: var(--surface);
  color: var(--muted);
  border: 0;
  cursor: pointer;
}

.view-toggle__btn + .view-toggle__btn {
  border-left: 1px solid var(--border);
}

.view-toggle__btn:hover {
  color: var(--text);
}

.view-toggle__btn[aria-pressed="true"] {
  background: var(--accent);
  color: #041018;
}

/* Grid + cards */
.repo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--gap);
}

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

.repo-grid--list .repo-card {
  padding: 0.9rem 1.2rem;
}

/* In list view, lay the footer stats out inline (the inline grid-area on the
   cells is ignored once the container is flex rather than grid). */
.repo-grid--list .repo-card__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 1.5rem;
  row-gap: 0.4rem;
}

.repo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.repo-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.repo-card__name {
  margin: 0;
  font-size: 1.05rem;
  word-break: break-word;
}

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

.repo-card__name a:hover {
  text-decoration: underline;
}

.fork-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 0.4rem;
  color: var(--muted);
  vertical-align: middle;
}

.repo-card__desc {
  margin: 0;
  color: var(--text);
}

.repo-card__topics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.topic {
  font-size: 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
}

.badge-unmanaged {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--warn-bg);
  color: var(--warn-text);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  white-space: nowrap;
}

.repo-card__foot {
  margin-top: auto;
  padding-top: 0.95rem;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: auto auto;
  justify-content: start;
  column-gap: 1.4rem;
  row-gap: 0.6rem;
  font-size: 0.8rem;
}

.stat {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  color: var(--muted);
  white-space: nowrap;
}

.stat--link {
  text-decoration: none;
}

.stat--link:hover {
  text-decoration: underline;
}

.stat--primary {
  color: var(--accent);
  font-weight: 600;
}

.lang-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
}

.icon {
  vertical-align: middle;
}

/* States */
.state {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
  grid-column: 1 / -1;
}

.state--error {
  color: var(--warn-text);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem clamp(1rem, 4vw, 3rem);
}

.build-info {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.commit-link {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.noscript {
  text-align: center;
  color: var(--warn-text);
  padding: 1rem;
}

@media (max-width: 480px) {
  .profile {
    justify-content: center;
    text-align: center;
  }

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

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
