/* Contributor — Linear-inspired dark theme.
   One indigo accent (--accent) is reserved for primary actions and focus; green is only used for match checkmarks. */
:root {
  --bg: #08090a;
  --bg-panel: #0f1011;
  --bg-surface: #191a1b;
  --bg-elevated: #28282c;
  --text-primary: #f7f8f8;
  --text-secondary: #d0d6e0;
  --text-muted: #8a8f98;
  --text-subtle: #62666d;
  --accent: #5e6ad2;
  --accent-bright: #7170ff;
  --accent-hover: #828fff;
  --border: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.05);
  --green: #27a644;
  --amber: #f2b24a;
  --danger: #f08a85;
  --radius: 10px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  color-scheme: dark;
  font-family: var(--font);
  font-feature-settings: 'cv01', 'ss03';
  background: var(--bg);
  color: var(--text-secondary);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--bg); font-size: 14px; font-weight: 400; line-height: 1.6; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; font-feature-settings: inherit; }
h1, h2, h3 { font-family: var(--font); color: var(--text-primary); margin: 0; }
:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }

.shell { max-width: 1120px; padding: 0 32px; margin: auto; }
section[id] { scroll-margin-top: 72px; }

/* Header */
.topbar {
  height: 64px;
  display: flex;
  gap: 32px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}
.brand { font-size: 17px; font-weight: 600; letter-spacing: -0.2px; color: var(--text-primary); display: flex; align-items: center; gap: 10px; }
.brandmark {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 600;
}
.branddot, .footer-name span { color: var(--accent-bright); }
.branddot { margin-left: -10px; }
.nav { display: flex; gap: 28px; margin-right: auto; margin-left: 24px; font-size: 13px; font-weight: 500; color: var(--text-muted); }
.nav a { padding: 6px 0; transition: color 0.15s ease; }
.nav a:hover { color: var(--text-primary); }
.top-status {
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border); color: var(--text-muted); border-radius: 999px;
  padding: 6px 12px; font-size: 11px; font-weight: 500; white-space: nowrap;
}

.top-right { display: flex; align-items: center; gap: 14px; }
.auth[hidden], .btn-signin[hidden], .auth-user[hidden] { display: none; }
.btn.btn-signin { background: rgba(255, 255, 255, 0.04); color: var(--text-secondary); border-color: var(--border); font-size: 13px; padding: 8px 14px; gap: 8px; white-space: nowrap; }
.btn.btn-signin:hover { background: rgba(255, 255, 255, 0.08); }
.auth-user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-secondary); }
.auth-user img { width: 28px; height: 28px; border-radius: 50%; background: var(--bg-surface); }
.auth-name { font-weight: 500; color: var(--text-primary); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-signout { color: var(--text-muted); padding: 4px 0; }
.auth-signout:hover { color: var(--text-primary); text-decoration: underline; }

/* Eyebrow labels */
.eyebrow { color: var(--text-muted); font-size: 12px; letter-spacing: 0.05em; font-weight: 500; margin: 0; text-transform: uppercase; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; cursor: pointer; font-size: 14px; font-weight: 500;
  border-radius: 8px; padding: 10px 20px; transition: all 0.15s ease;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-text { background: rgba(255, 255, 255, 0.04); color: var(--text-secondary); border-color: var(--border); }
.btn-text:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.12); color: var(--text-primary); }
.btn:disabled { opacity: 0.6; cursor: wait; }

/* Hero */
.hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 112px 0 120px; }
.hero h1 { font-size: 56px; font-weight: 600; letter-spacing: -1.2px; line-height: 1.05; color: var(--text-primary); max-width: 760px; margin: 0; }
.nowrap { white-space: nowrap; }
.hero h1 { text-wrap: balance; }
.hero-sub { color: var(--text-secondary); font-size: 16px; line-height: 1.6; max-width: 520px; margin: 24px 0 0; }
.hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin: 32px 0 28px; }
.hero-pills { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0; padding: 0; }
.hero-pills li { border: 1px solid var(--border); background: rgba(255, 255, 255, 0.03); color: var(--text-muted); border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 500; }

/* Discover */
.finder { padding: 96px 0; }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 40px; }
.section-head h2 { font-size: clamp(26px, 4vw, 32px); font-weight: 600; letter-spacing: -0.5px; line-height: 1.15; margin: 12px 0; }
.section-head p:not(.eyebrow) { color: var(--text-secondary); font-size: 14px; margin: 0; }
.read-only { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border); color: var(--text-muted); border-radius: 999px; padding: 6px 12px; font-weight: 500; font-size: 11px; white-space: nowrap; }

.filter-panel {
  display: grid; grid-template-columns: 1fr 1.5fr 1fr 1fr; gap: 20px;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px; padding: 28px;
}
.field { display: flex; flex-direction: column; gap: 8px; }
.field-wide { grid-column: span 1; }
.field label, .mode-field legend { font-size: 11px; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }
.field input, .field select {
  background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; outline: none; width: 100%; font-size: 14px; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus, .field select:focus { border-color: var(--accent-bright); box-shadow: 0 0 0 3px rgba(113, 112, 255, 0.2); }
.field input::placeholder { color: var(--text-subtle); }
.field select option { background: var(--bg-surface); color: var(--text-primary); }
.mode-field { border: 0; padding: 0; margin: 0; grid-column: span 4; }
.modes { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.modes label { cursor: pointer; }
.modes input { position: absolute; opacity: 0; }
.modes span { display: block; border: 1px solid var(--border); background: var(--bg-surface); color: var(--text-secondary); border-radius: 999px; padding: 7px 16px; font-size: 13px; font-weight: 500; transition: all 0.15s ease; }
.modes label:hover span { border-color: rgba(255, 255, 255, 0.16); }
.modes input:checked + span { border-color: var(--accent); background: var(--accent); color: #fff; }
.modes input:focus-visible + span { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
/* Example searches: pre-fill the form and submit in one click. */
.examples { grid-column: span 4; display: flex; flex-direction: column; gap: 8px; }
.examples-label { font-size: 11px; color: var(--text-subtle); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-muted); font-size: 12px; border-radius: 999px; padding: 5px 14px; cursor: pointer; transition: background 0.15s ease; }
.chip:hover { background: var(--bg-elevated); }
.form-footer { grid-column: span 4; display: flex; justify-content: space-between; align-items: center; gap: 16px; border-top: 1px solid var(--border-subtle); padding-top: 20px; }
.local-memory { font-size: 13px; color: var(--text-muted); display: flex; gap: 10px; align-items: center; cursor: pointer; }
.local-memory input { accent-color: var(--accent); inline-size: 16px; block-size: 16px; }

.status-info { margin: 24px 0; color: var(--text-muted); font-size: 13px; min-height: 22px; }

/* Saved bar */
.saved-bar { display: flex; gap: 12px; align-items: center; margin: 0 0 20px; }
.saved-bar button { border: 1px solid var(--border); border-radius: 8px; background: rgba(255, 255, 255, 0.04); color: var(--text-secondary); font-size: 13px; font-weight: 500; padding: 7px 14px; cursor: pointer; transition: all 0.15s ease; }
.saved-bar button:hover { background: rgba(255, 255, 255, 0.08); color: var(--text-primary); }
.saved-bar button[hidden] { display: none; }
#clear-saved { color: var(--danger); }

/* Results */
.results { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.result-card {
  background: rgba(255, 255, 255, 0.02); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 10px;
  padding: 20px; cursor: pointer; display: flex; flex-direction: column; min-height: 280px; transition: all 0.15s ease;
}
.result-card:hover { background: rgba(255, 255, 255, 0.04); border-color: rgba(255, 255, 255, 0.12); }
.result-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.result-kind { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; color: var(--accent-hover); background: rgba(113, 112, 255, 0.12); border-radius: 999px; padding: 3px 9px; }
.match { display: inline-flex; align-items: baseline; gap: 3px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); color: var(--text-secondary); border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.result-card h3 {
  font-size: 15px; font-weight: 500; letter-spacing: -0.1px; line-height: 1.4; overflow-wrap: anywhere; margin: 14px 0 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.repo-name { font-size: 12px; font-weight: 500; color: var(--text-muted); margin: 0; overflow-wrap: anywhere; }
.result-desc {
  font-size: 13px; color: var(--text-muted); line-height: 1.55; overflow-wrap: anywhere; margin: 10px 0 0;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.reasons { list-style: none; padding: 0; margin: 14px 0 16px; display: grid; gap: 4px; }
.reasons li { font-size: 12px; color: var(--text-secondary); }
.reasons li::before { content: '✓'; margin-right: 8px; color: var(--green); font-weight: 700; }
.card-spacer { flex: 1; }
.result-bottom { border-top: 1px solid var(--border-subtle); padding-top: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.result-bottom a, .result-bottom button { font-size: 12px; font-weight: 500; background: none; border: 0; cursor: pointer; padding: 4px 0; color: var(--text-muted); transition: color 0.15s ease; }
.result-bottom a { color: var(--accent-hover); margin-right: auto; }
.result-bottom a:hover, .result-bottom button:hover { color: var(--text-primary); text-decoration: underline; }
/* Card CTAs: Copy AI prompt is the primary action; View on GitHub is the ghost secondary. */
.result-bottom .btn { font-size: 13px; font-weight: 500; padding: 8px 16px; border: 1px solid transparent; border-radius: 8px; }
.result-bottom .btn-primary { background: var(--accent); color: #fff; }
.result-bottom .btn-primary:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }
.result-bottom .btn-ghost { background: transparent; border-color: var(--border); color: var(--text-secondary); margin-right: 0; }
.result-bottom .btn-ghost:hover { background: rgba(255, 255, 255, 0.06); color: var(--text-primary); text-decoration: none; }
/* Tooltip: pure CSS, text comes from data-tooltip. Shown above the button on hover and keyboard focus. */
.result-bottom .copy-prompt { position: relative; }
.copy-prompt[data-tooltip]::after {
  content: attr(data-tooltip); position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 10;
  width: max-content; max-width: 220px; padding: 6px 10px; border-radius: 6px;
  background: var(--bg-elevated); color: var(--text-secondary); font-size: 11px; font-weight: 400; line-height: 1.4; text-align: left; white-space: normal;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.15s ease;
}
.copy-prompt[data-tooltip]:hover::after, .copy-prompt[data-tooltip]:focus-visible::after { opacity: 1; visibility: visible; }
.save-toggle[aria-pressed="true"] { color: var(--text-primary); }
.remove-saved { color: var(--danger) !important; }
.stale-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 6px; vertical-align: middle; }
.stale-closed { background: #ef4444; }
.stale-stale { background: #f59e0b; }
.card-warning { margin: 12px 0 0; font-size: 12px; line-height: 1.5; color: var(--amber); }
.byok-note { margin: 10px 0 0; font-size: 11px; line-height: 1.5; color: var(--text-subtle); }
.empty { grid-column: 1 / -1; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); padding: 56px 24px; color: var(--text-muted); }
.empty a { color: var(--accent-hover); font-weight: 500; }
/* Rate-limit nudge shown to anonymous users. */
.nudge { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; }
.nudge-icon { font-size: 24px; line-height: 1; flex: none; }
.nudge-copy { flex: 1; min-width: 0; }
.nudge-copy h3 { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.nudge-copy p { margin: 0; font-size: 13px; color: var(--text-muted); }
.nudge .btn { white-space: nowrap; }

/* Detail panel */
.panel-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); opacity: 0; transition: opacity 0.2s ease; z-index: 40; }
.panel-backdrop[hidden] { display: none; }
.panel-backdrop.open { opacity: 1; }
.detail-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 100%; z-index: 50;
  background: var(--bg-panel); border-left: 1px solid var(--border); overflow-y: auto; overscroll-behavior: contain;
  transform: translateX(100%); visibility: hidden; transition: transform 0.2s ease, visibility 0s linear 0.2s; outline: none;
}
.detail-panel.open { transform: translateX(0); visibility: visible; transition: transform 0.2s ease, visibility 0s; }
.panel-close {
  position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04); color: var(--text-secondary); font-size: 20px; line-height: 1; cursor: pointer; transition: all 0.15s ease;
}
.panel-close:hover { background: rgba(255, 255, 255, 0.08); color: var(--text-primary); }
.panel-body { padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.panel-head { display: flex; align-items: center; gap: 12px; padding-right: 40px; }
.panel-head img { width: 40px; height: 40px; border-radius: 10px; background: var(--bg-surface); flex: none; }
.panel-owner { margin: 0; font-size: 12px; font-weight: 500; color: var(--text-muted); overflow-wrap: anywhere; }
.panel-repo { margin: 0; font-size: 15px; font-weight: 500; color: var(--text-primary); overflow-wrap: anywhere; }
.panel-title { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.2px; line-height: 1.35; overflow-wrap: anywhere; }
.panel-kind { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-stats { margin: 0; font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.panel-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; font-weight: 500; color: var(--text-muted); }
.badge { border: 1px solid var(--border); background: rgba(255, 255, 255, 0.04); color: var(--text-secondary); border-radius: 999px; padding: 2px 10px; font-size: 11px; font-weight: 500; }
.panel-section h4 { margin: 0 0 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
.panel-section p { margin: 0; font-size: 14px; line-height: 1.6; color: var(--text-secondary); overflow-wrap: anywhere; }
.panel-section .reasons { margin: 0; }
.panel-section .reasons li { font-size: 13px; }
.labels { display: flex; flex-wrap: wrap; gap: 6px; }
.panel-warning { border: 1px solid rgba(242, 178, 74, 0.35); background: rgba(242, 178, 74, 0.08); border-radius: 8px; padding: 12px 14px; color: var(--amber); font-size: 13px; line-height: 1.5; }
.panel-warning strong { display: block; margin-bottom: 4px; font-weight: 600; }
.panel-note { margin: 0; font-size: 12px; line-height: 1.5; color: var(--text-muted); }
.panel-similar h4 { font-size: 12px; color: var(--text-muted); }
.similar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.similar-list a { display: block; font-size: 12px; line-height: 1.5; color: var(--text-secondary); overflow-wrap: anywhere; }
.similar-list a:hover { color: var(--text-primary); text-decoration: underline; }
.similar-repo { color: var(--text-muted); font-weight: 500; }
.panel-actions { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.panel-actions .btn { width: 100%; }
body.panel-open { overflow: hidden; }

/* How it works */
.how { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 16px; padding: 64px 48px; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.steps article { padding: 24px 20px; background: rgba(255, 255, 255, 0.02); border: 1px solid var(--border); border-radius: var(--radius); }
.steps article span { color: var(--accent-bright); font-size: 12px; font-weight: 600; }
.steps article h3 { font-size: 15px; font-weight: 500; margin: 14px 0 8px; }
.steps article p { font-size: 13px; line-height: 1.6; color: var(--text-muted); margin: 0; }

/* Bottom CTA */
.bottom-cta { background: var(--bg-panel); border: 1px solid var(--border); color: var(--text-primary); padding: 48px; border-radius: 16px; display: flex; justify-content: space-between; align-items: center; gap: 28px; margin: 96px 0; }
.bottom-cta h2 { color: var(--text-primary); font-size: 32px; font-weight: 600; letter-spacing: -0.5px; margin: 8px 0; }
.bottom-cta p:not(.eyebrow) { color: var(--text-secondary); font-size: 14px; margin: 0; }
.bottom-cta .btn { white-space: nowrap; }

footer { border-top: 1px solid var(--border-subtle); min-height: 88px; display: flex; align-items: center; justify-content: space-between; gap: 20px; color: var(--text-muted); font-size: 12px; }
.footer-name { font-size: 15px; font-weight: 600; color: var(--text-primary); }
footer p { margin: 0; }

@media (max-width: 1000px) {
  .shell { padding: 0 24px; }
  .hero { padding: 80px 0 88px; }
  .hero h1 { font-size: 44px; }
  .filter-panel { grid-template-columns: 1fr 1fr; padding: 24px; }
  .field-wide { grid-column: span 1; }
  .mode-field, .examples, .form-footer { grid-column: span 2; }
  .results { grid-template-columns: repeat(2, 1fr); }
  .steps { grid-template-columns: repeat(2, 1fr); }
  .top-status { display: none; }
}

@media (max-width: 620px) {
  .shell { padding: 0 16px; }
  .topbar { gap: 12px; }
  .nav { display: none; }
  .top-right { margin-left: auto; }
  .auth-name { display: none; }
  .signin-long { display: none; }
  .hero { padding: 56px 0 64px; }
  .hero h1 { font-size: 36px; letter-spacing: -0.8px; }
  .hero-actions { flex-direction: column; align-items: stretch; width: 100%; }
  .filter-panel { grid-template-columns: 1fr; padding: 20px; }
  .field-wide, .mode-field, .examples, .form-footer { grid-column: 1; }
  .form-footer { align-items: stretch; flex-direction: column; }
  .nudge { flex-direction: column; align-items: flex-start; }
  .results, .steps { grid-template-columns: 1fr; }
  .finder { padding: 64px 0; }
  .how { padding: 40px 20px; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .read-only { white-space: normal; }
  .detail-panel { width: 100%; border-left: 0; }
  .bottom-cta { align-items: flex-start; flex-direction: column; padding: 28px; margin: 64px 0; }
  footer { align-items: flex-start; flex-direction: column; justify-content: center; padding: 24px 0; }
}

/* Motion. Everything here is opt-in via no-preference, so reduced-motion users see the static page. */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: no-preference) {
  .hero h1      { animation: fadeUp 0.5s ease both; animation-delay: 0.05s; }
  .hero-sub     { animation: fadeUp 0.5s ease both; animation-delay: 0.15s; }
  .hero-actions { animation: fadeUp 0.5s ease both; animation-delay: 0.25s; }
  .hero-pills   { animation: fadeUp 0.5s ease both; animation-delay: 0.35s; }
  /* Spring-like slide; visibility flips only after the slide-out finishes. */
  .detail-panel { transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s linear 0.35s; }
  .detail-panel.open { transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s; }
  .panel-backdrop { transition: opacity 0.25s ease; }
  /* Click ripple. The host clips it instead of the button, so the Copy AI prompt tooltip is not cut off. */
  .btn-primary { position: relative; }
  .btn-ripple-host { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; pointer-events: none; }
  .btn-ripple { position: absolute; border-radius: 50%; background: rgba(255, 255, 255, 0.2); transform: scale(0); animation: ripple 0.5s ease-out forwards; pointer-events: none; }
}
@keyframes ripple { to { transform: scale(4); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn, .result-card, .detail-panel, .panel-backdrop { transition: none; }
}
