/* ---------------------------------------------------------------------------------------------------------------------
 * Styling follows https://vrctools.io (VRCTools/website). The brand purple (#8B5CF6) is used for the logo & solid
 * surfaces; text accents use a lighter (dark theme) or darker (light theme) shade to keep WCAG AA contrast.
 * ------------------------------------------------------------------------------------------------------------------ */
:root {
  --brand: #8b5cf6;
  --brand-ink: #ffffff;

  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 6px;
  --header-h: 56px;

  /* dark theme (default) */
  --bg: #0c0a10;
  --bg-elev: #120f18;
  --bg-code: #15111d;
  --bg-hover: #1c1726;
  --border: #272035;
  --border-strong: #3a3050;
  --text: #e7e2f0;
  --text-muted: #a29ab3;
  --text-dim: #6f6782;
  --accent: #b388ff;
  --accent-strong: #cfb3ff;
  --accent-soft: rgba(139, 92, 246, 0.14);
  --green: #7ee787;
  --selection: rgba(139, 92, 246, 0.35);
  --glow: 0 0 18px rgba(139, 92, 246, 0.35);

  --logo-a: #ffffff;

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #fbfaff;
  --bg-elev: #f4f1fb;
  --bg-code: #f3effa;
  --bg-hover: #ebe5f7;
  --border: #e1daee;
  --border-strong: #cbbfe3;
  --text: #1b1624;
  --text-muted: #57506a;
  --text-dim: #847c96;
  --accent: #6d28d9;
  --accent-strong: #5b21b6;
  --accent-soft: rgba(139, 92, 246, 0.12);
  --green: #1a7f37;
  --selection: rgba(139, 92, 246, 0.25);
  --glow: none;
  --logo-a: #0e0b14;
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #fbfaff;
    --bg-elev: #f4f1fb;
    --bg-code: #f3effa;
    --bg-hover: #ebe5f7;
    --border: #e1daee;
    --border-strong: #cbbfe3;
    --text: #1b1624;
    --text-muted: #57506a;
    --text-dim: #847c96;
    --accent: #6d28d9;
    --accent-strong: #5b21b6;
    --accent-soft: rgba(139, 92, 246, 0.12);
    --green: #1a7f37;
    --selection: rgba(139, 92, 246, 0.25);
    --glow: none;
    --logo-a: #0e0b14;
    color-scheme: light;
  }
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--selection); }

a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); text-decoration: underline; }
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 3px;
}

.dim { color: var(--text-dim); }
[hidden] { display: none !important; }

/* ---- header -------------------------------------------------------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; }
.brand a { color: var(--text); }
.brand a:hover { text-decoration: none; }
.brand-home { display: flex; align-items: center; gap: 10px; }
.brand-suffix { color: var(--text-dim); font-weight: 500; font-size: 0.9rem; }
.brand-suffix::before { content: "~/"; }

/* Logo & icons are served by vrctools.io. The logo comes in fixed-color variants per theme; icons are used as masks so
 * they follow the text color (cross-origin <use> references are blocked by browsers). */
.logo-mark { flex: none; display: block; }
.logo-light { display: none; }
:root[data-theme="light"] .logo-dark { display: none; }
:root[data-theme="light"] .logo-light { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .logo-dark { display: none; }
  :root:not([data-theme="dark"]) .logo-light { display: block; }
}

.icon {
  flex: none; display: block;
  width: 18px; height: 18px;
  background-color: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.i-github { --icon: url(https://vrctools.io/assets/icons/github.svg); }
.i-sun { --icon: url(https://vrctools.io/assets/icons/sun.svg); }
.i-moon { --icon: url(https://vrctools.io/assets/icons/moon.svg); }

.wordmark { font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; }
.wordmark .wm-a { color: var(--logo-a); }
.wordmark .wm-b, .wordmark .wm-cursor { color: var(--brand); }
.wordmark .wm-cursor { animation: blink 1.1s steps(1) infinite; }

@keyframes blink { 50% { opacity: 0; } }

.header-links { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.header-link { padding: 0 10px; font-size: 0.9rem; color: var(--text-muted); }
.header-link:hover { color: var(--accent); text-decoration: none; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: 1px solid transparent; border-radius: var(--radius);
  background: none; color: var(--text-muted); cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--bg-hover); border-color: var(--border); text-decoration: none; }

.theme-toggle .i-sun { display: none; }
:root[data-theme="light"] .theme-toggle .i-sun { display: block; }
:root[data-theme="light"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="dark"]) .theme-toggle .i-moon { display: none; }
}

/* ---- hero ---------------------------------------------------------------------------------------------------------- */
.home { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px 72px; }

.hero { max-width: 760px; padding: 64px 0 24px; }
.hero h1 { margin: 0 0 12px; font-size: clamp(1.6rem, 4vw, 2.4rem); line-height: 1.15; letter-spacing: -0.03em; }
.hero-sub { margin: 0 0 24px; color: var(--text-muted); font-size: 1.05rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }

.listing-url, .search {
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 6px 0 12px;
  background: var(--bg-code);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--glow);
}
.listing-url input, .search input {
  flex: 1; min-width: 0;
  font: inherit; font-size: 0.85rem;
  color: var(--text); background: none; border: 0; outline: none;
}
.prompt { color: var(--green); font-size: 0.85rem; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  font: inherit; font-weight: 700; font-size: 0.9rem;
  border: 1px solid var(--brand); border-radius: var(--radius);
  background: var(--brand); color: var(--brand-ink);
  cursor: pointer;
}
.btn:hover { text-decoration: none; color: var(--brand-ink); filter: brightness(1.1); box-shadow: var(--glow); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { color: var(--accent-strong); background: var(--accent-soft); }

.copy-btn {
  font: inherit; font-size: 0.72rem;
  padding: 2px 8px;
  color: var(--text-muted); background: none;
  border: 1px solid var(--border); border-radius: 4px; cursor: pointer;
}
.copy-btn:hover { color: var(--text); border-color: var(--border-strong); }
.copy-btn.copied { color: var(--green); border-color: var(--green); }

.help { margin-top: 28px; font-size: 0.88rem; color: var(--text-muted); }
.help summary { cursor: pointer; color: var(--text-dim); }
.help summary:hover { color: var(--accent); }
.help[open] {
  padding: 14px 18px; border-left: 2px solid var(--brand);
  background: linear-gradient(90deg, var(--accent-soft), transparent 70%);
}
.help ol { padding-left: 1.4em; }
.help strong { color: var(--text); }
.help pre {
  margin: 0; padding: 10px 14px; overflow-x: auto;
  font: inherit; font-size: 0.8rem; color: var(--text);
  background: var(--bg-code); border: 1px solid var(--border); border-radius: var(--radius);
}
.t-p { color: var(--green); }
.t-a { color: var(--accent); }

/* ---- packages ------------------------------------------------------------------------------------------------------ */
.home-section { margin-top: 48px; }
.section-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 24px; margin-bottom: 18px; }
.section-head h2 { margin: 0; font-size: 1.3rem; }
.section-head h2::before { content: "## "; color: var(--brand); }
.search { width: min(360px, 100%); height: 36px; box-shadow: none; background: var(--bg-elev); border-color: var(--border); }
.search:focus-within { border-color: var(--border-strong); }
.search .prompt { color: var(--accent); }

.pkg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.pkg-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 20px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-elev);
  transition: border-color 0.15s ease;
}
.pkg-card:hover { border-color: var(--brand); }
.pkg-card p { margin: 0; color: var(--text-muted); font-size: 0.88rem; }
.pkg-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; }
.pkg-name { font-weight: 800; font-size: 1.1rem; color: var(--accent); }
.pkg-id { font-size: 0.78rem; color: var(--text-dim); }

.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badges:empty { display: none; }
.badge {
  display: inline-block;
  padding: 0 8px;
  font-size: 0.74rem; line-height: 1.75;
  border: 1px solid var(--border-strong); border-radius: 4px;
  color: var(--text-muted);
}
.badge::before { content: "["; color: var(--text-dim); margin-right: 2px; }
.badge::after { content: "]"; color: var(--text-dim); margin-left: 2px; }

.pkg-deps { margin: 0; padding: 0; list-style: none; font-size: 0.78rem; color: var(--text-muted); }
.pkg-deps:not(:has(li)) { display: none; }
.pkg-deps li::before { content: "↳ "; color: var(--text-dim); }

.pkg-actions { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-top: auto; font-size: 0.85rem; white-space: nowrap; }
.pkg-actions .dim-link { margin-left: auto; color: var(--text-dim); }
.pkg-actions .dim-link:hover { color: var(--accent); }

.empty { color: var(--text-dim); font-size: 0.88rem; }

/* ---- footer -------------------------------------------------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  font-size: 0.8rem; color: var(--text-dim);
}
.footer-inner { max-width: 1120px; margin: 0 auto; padding: 24px 20px 32px; }
.footer-brand { display: flex; align-items: center; gap: 10px; color: var(--text-muted); }
.site-footer p { margin: 8px 0 0; }
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--accent); }

/* ---- responsive ---------------------------------------------------------------------------------------------------- */
@media (max-width: 520px) {
  .site-header { gap: 8px; padding: 0 10px; }
  .home { padding: 0 16px 48px; }
  .hero { padding-top: 40px; }
  .pkg-grid { grid-template-columns: minmax(0, 1fr); }
}

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