/* Tokens ------------------------------------------------------------------ */

:root {
  color-scheme: light dark;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --ink: #171a20;
  --ink-2: #565d69;
  --ink-3: #8a919c;
  --line: #dfe3e9;
  --line-2: #cbd1d9;
  --focus: #2563eb;

  --skill: #2563eb;
  --agent: #7c3aed;
  --command: #0891b2;
  --hook: #db2777;
  --plugin: #059669;

  --sans:
    ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --radius: 6px;
  --gutter: 16px;
  --measure: 68ch;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1c21;
    --surface: #202329;
    --surface-2: #2a2e35;
    --ink: #eceef1;
    --ink-2: #a9b0ba;
    --ink-3: #7b828d;
    --line: #33373f;
    --line-2: #444952;
    --focus: #60a5fa;

    --skill: #60a5fa;
    --agent: #a78bfa;
    --command: #22d3ee;
    --hook: #f472b6;
    --plugin: #34d399;
  }
}

:root[data-theme="dark"] {
  --bg: #1a1c21;
  --surface: #202329;
  --surface-2: #2a2e35;
  --ink: #eceef1;
  --ink-2: #a9b0ba;
  --ink-3: #7b828d;
  --line: #33373f;
  --line-2: #444952;
  --focus: #60a5fa;

  --skill: #60a5fa;
  --agent: #a78bfa;
  --command: #22d3ee;
  --hook: #f472b6;
  --plugin: #34d399;
}

/* Base -------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

code,
kbd {
  font-family: var(--mono);
  font-size: 0.92em;
}

p code,
dd code,
li code {
  background: var(--surface-2);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

button {
  font: inherit;
  color: inherit;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -40px;
  background: var(--surface);
  padding: 6px 10px;
  border-radius: var(--radius);
  z-index: 10;
}

.skip:focus {
  top: 8px;
}

/* Type colours ------------------------------------------------------------- */

[data-type="skill"] {
  --type: var(--skill);
}
[data-type="agent"] {
  --type: var(--agent);
}
[data-type="command"] {
  --type: var(--command);
}
[data-type="hook"] {
  --type: var(--hook);
}
[data-type="plugin"] {
  --type: var(--plugin);
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--type, var(--ink-3));
  margin-right: 8px;
  vertical-align: 0;
}

/* Masthead ------------------------------------------------------------------ */

.masthead {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.masthead-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 var(--gutter);
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-weight: 600;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 20px;
  height: 20px;
  border-radius: 5px;
}

.masthead-nav {
  display: flex;
  gap: 4px;
}

.masthead-nav a {
  text-decoration: none;
  color: var(--ink-2);
  padding: 6px 10px;
  border-radius: var(--radius);
}

.masthead-nav a:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.masthead-nav a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
}

/* Page ----------------------------------------------------------------------- */

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px var(--gutter) 64px;
}

.intro h1 {
  font-size: clamp(26px, 3.4vw, 36px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}

.lede,
.section-lede {
  color: var(--ink-2);
  margin: 0;
  font-size: 16px;
}

.section-lede {
  max-width: var(--measure);
}

.counts {
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.counts a {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  text-decoration: none;
  padding: 6px 12px 6px 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--type);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-2);
}

.counts a:hover {
  border-color: var(--line-2);
  border-left-color: var(--type);
  color: var(--ink);
}

.counts strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* Catalog layout ------------------------------------------------------------- */

.catalog {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 40px;
  margin-top: 40px;
}

@media (max-width: 800px) {
  .catalog {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    margin-top: 32px;
  }
}

/* Filters ---------------------------------------------------------------------- */

.filters {
  position: sticky;
  top: 16px;
  align-self: start;
}

@media (max-width: 800px) {
  .filters {
    position: static;
  }
}

.search {
  position: relative;
  display: block;
}

.search input {
  width: 100%;
  font: inherit;
  padding: 9px 36px 9px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.search input::placeholder {
  color: var(--ink-3);
}

.search input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 6px;
  line-height: 18px;
  background: var(--surface-2);
}

.search input:focus + kbd {
  display: none;
}

.filter-group {
  margin-top: 24px;
}

.filter-group h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin: 0 0 8px;
}

.chips {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

@media (max-width: 800px) {
  .chips {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }
}

.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  cursor: pointer;
  color: var(--ink-2);
}

@media (max-width: 800px) {
  .chip {
    width: auto;
    border-color: var(--line);
    background: var(--surface);
  }
}

.chip:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.chip[aria-pressed="true"] {
  background: var(--surface);
  border-color: var(--line-2);
  color: var(--ink);
  font-weight: 600;
}

.chip .label {
  flex: 1;
}

.chip .n {
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 400;
}

.chip .dot {
  margin-right: 0;
}

.clear {
  margin-top: 20px;
  background: none;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 6px 10px;
  cursor: pointer;
  color: var(--ink-2);
}

.clear:hover {
  color: var(--ink);
  background: var(--surface-2);
}

/* Results ------------------------------------------------------------------------ */

.results-summary {
  margin: 0 0 12px;
  color: var(--ink-3);
  font-size: 13px;
  min-height: 20px;
}

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.row + .row {
  border-top: 1px solid var(--line);
}

.row-link {
  display: flex;
  text-decoration: none;
  min-height: 60px;
}

.row-link:hover {
  background: var(--surface-2);
}

.row-link:focus-visible {
  outline-offset: -2px;
}

.row-rail {
  flex: 0 0 3px;
  background: var(--type);
}

.row-main {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.row-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.row-name {
  font-weight: 600;
  font-size: 14px;
}

.row-type {
  color: var(--type);
  font-size: 13px;
}

.row-category {
  color: var(--ink-3);
  font-size: 13px;
}

.row-desc {
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: var(--measure);
}

.row-desc mark,
.row-name mark {
  background: none;
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--focus);
  text-underline-offset: 2px;
}

.empty {
  color: var(--ink-2);
  padding: 32px 0;
  text-align: center;
}

/* Command blocks ---------------------------------------------------------------------- */

.command-block {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.command-block code {
  flex: 1;
  padding: 9px 12px;
  font-size: 13px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.copy {
  flex: 0 0 auto;
  border: 0;
  border-left: 1px solid var(--line-2);
  background: var(--surface-2);
  padding: 0 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink-2);
  min-width: 64px;
}

.copy:hover {
  color: var(--ink);
}

.copy[data-done] {
  color: var(--plugin);
}

/* Plugins view --------------------------------------------------------------------- */

.plugins {
  margin-top: 40px;
}

.plugins .command-block {
  margin: 16px 0 24px;
  max-width: var(--measure);
}

.plugin-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.plugin {
  border: 1px solid var(--line);
  border-left: 3px solid var(--plugin);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px 18px;
  display: grid;
  gap: 10px;
}

.plugin-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.plugin-name {
  font-weight: 600;
  font-size: 15px;
}

.plugin-summary {
  color: var(--ink-3);
  font-size: 13px;
}

.plugin-desc {
  margin: 0;
  color: var(--ink-2);
  max-width: var(--measure);
}

.plugin-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.plugin-items a {
  text-decoration: none;
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 2px 8px 2px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.plugin-items a:hover {
  color: var(--ink);
  border-color: var(--line-2);
}

.plugin-items .dot {
  width: 7px;
  height: 7px;
  margin: 0;
}

/* Install view ---------------------------------------------------------------------- */

.install {
  margin-top: 40px;
  max-width: 960px;
}

.install h2 {
  font-size: 20px;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
}

.install-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 32px;
}

.install h2 + .install-cols {
  margin-bottom: 48px;
}

.install h3 {
  font-size: 16px;
  margin: 0 0 8px;
}

.install p {
  margin: 0 0 12px;
  color: var(--ink-2);
  max-width: var(--measure);
}

.install .command-block {
  margin-bottom: 10px;
}

.types-dl {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px 32px;
}

.types-dl dt {
  font-weight: 600;
  margin-bottom: 4px;
}

.types-dl dd {
  margin: 0;
  color: var(--ink-2);
}

/* Detail panel ------------------------------------------------------------------------- */

.detail-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, 0.35);
  z-index: 20;
}

.detail {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--line);
  z-index: 21;
  overflow-y: auto;
  animation: slide-in 180ms ease-out;
}

@keyframes slide-in {
  from {
    transform: translateX(100%);
  }
  to {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .detail {
    animation: none;
  }
}

.detail-inner {
  padding: 24px 28px 40px;
}

.detail-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.detail-kind {
  color: var(--type);
  font-size: 13px;
  margin: 0 0 6px;
}

.detail-kind .row-category {
  color: var(--ink-3);
}

.detail h2 {
  margin: 0;
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  word-break: break-word;
}

.detail-title {
  color: var(--ink-3);
  margin: 2px 0 0;
  font-size: 14px;
}

.close {
  flex: 0 0 auto;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--ink-2);
}

.close:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.detail-desc {
  margin: 20px 0 0;
  color: var(--ink);
}

.detail h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin: 28px 0 8px;
}

.detail h3 + p {
  margin: 0 0 8px;
  color: var(--ink-2);
  font-size: 14px;
}

.detail .command-block + .command-block {
  margin-top: 8px;
}

.targets {
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-2);
  display: grid;
  gap: 4px;
}

.detail-links {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 16px;
  font-size: 14px;
}

.detail-note {
  color: var(--ink-3);
  font-size: 13px;
}

/* Footer / misc --------------------------------------------------------------------------- */

.footer {
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 13px;
}

.footer-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px var(--gutter);
}

.load-error {
  color: var(--ink-2);
  padding: 40px 0;
}

/* Last so it beats every component display rule of equal specificity. */
[hidden] {
  display: none;
}
