/* AgentSpot — warm, inviting, community-hub styling. Light & dark via
   [data-theme] on <html>. No inline styles anywhere (strict CSP). */

:root, :root[data-theme="light"] {
  --bg: #fdf8f2;
  --surface: #ffffff;
  --surface-2: #fbf1e6;
  --text: #2a2018;
  --muted: #5a4d40;
  --border: #ecdcc9;
  --border-strong: #e0cbb2;
  --accent: #a8460b;         /* deep amber — AA (>=4.5:1) on light + cream bg */
  --accent-soft: #f6a04d;    /* bright amber — decorative / dark bg */
  --accent-ink: #ffffff;     /* text on accent */
  --link: #a8460b;
  --chip-bg: #f3e6d6;
  --chip-text: #6a4a2a;
  --shadow: 0 1px 2px rgba(60,40,20,.06), 0 6px 20px rgba(60,40,20,.06);
  --sponsored-bg: #fff6e9;
  --sponsored-border: #f0c98a;
  --focus: #1f6feb;
}

:root[data-theme="dark"] {
  --bg: #14100c;
  --surface: #201a14;
  --surface-2: #2a2118;
  --text: #f3ebe0;
  --muted: #b6a693;
  --border: #362b20;
  --border-strong: #443729;
  --accent: #f6a04d;
  --accent-soft: #f6a04d;
  --accent-ink: #23180d;
  --link: #f6b06a;
  --chip-bg: #322618;
  --chip-text: #e8c79a;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  --sponsored-bg: #2b2013;
  --sponsored-border: #6e5124;
  --focus: #7cb0ff;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; min-height: 100vh;
}
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.site-main { flex: 1 0 auto; }
img { max-width: 100%; }

/* In-text links are underlined by default so they're distinguishable by more
   than colour (WCAG). UI chrome (nav, buttons, cards, chips) opts out below. */
a { color: var(--link); text-decoration: underline; text-underline-offset: 0.14em; text-decoration-thickness: from-font; }
.brand, .nav-link, .btn, .browse-card, .card-name a, .card-link, .tag, .tag-chip,
.breadcrumbs a, .footer-nav a, .recent-list a, .back-link a, .skip-link,
.hero-actions a, .theme-toggle, .curated-links a { text-decoration: none; }
.brand:hover, .nav-link:hover, .card-name a:hover, .card-link:hover, .recent-list a:hover,
.footer-nav a:hover, .breadcrumbs a:hover, .browse-card:hover, .back-link a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3 { line-height: 1.2; color: var(--text); }
h1 { font-size: clamp(1.7rem, 4.5vw, 2.6rem); letter-spacing: -.02em; }
h2 { font-size: clamp(1.3rem, 3vw, 1.7rem); letter-spacing: -.01em; }

.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: 8px; top: -48px; background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; border-radius: 8px; z-index: 100; transition: top .15s;
}
.skip-link:focus { top: 8px; }

/* ---------------- Header ---------------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 16px; min-height: 66px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background:
    radial-gradient(circle at 50% 50%, #ffd7a3 0 18%, transparent 19%),
    conic-gradient(from -90deg, var(--accent-soft), #e2662a, var(--accent-soft));
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 800; font-size: 1.12rem; letter-spacing: -.01em; }
.brand-tag { font-size: .74rem; color: var(--muted); }
.site-nav { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; }
.nav-link { padding: 8px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: .93rem; }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.is-active { color: var(--accent); background: var(--surface-2); }
.theme-toggle {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); cursor: pointer; font-size: 1.1rem; flex: none;
  display: grid; place-items: center;
}
.theme-toggle:hover { background: var(--surface-2); }
.theme-icon-moon { display: none; }
[data-theme="dark"] .theme-icon-sun { display: none; }
[data-theme="dark"] .theme-icon-moon { display: inline; }

/* ---------------- Hero ---------------- */
.hero { padding: 56px 20px 20px; text-align: center; max-width: 820px; }
.hero-title { margin: 0 0 14px; }
.hero-lede { font-size: 1.12rem; color: var(--muted); margin: 0 auto 12px; max-width: 660px; }
.hero-note { font-size: .98rem; color: var(--text); margin: 0 0 22px; }
.hero-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-block; background: var(--accent); color: var(--accent-ink);
  padding: 11px 20px; border-radius: 10px; font-weight: 700; border: 1px solid transparent;
}
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }

/* ---------------- Sections ---------------- */
.section { padding: 30px 0; }
.section-title { margin: 0 0 18px; }

.browse-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.browse-card {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 22px; box-shadow: var(--shadow); color: var(--text);
  transition: transform .12s ease, border-color .12s ease;
}
.browse-card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--accent-soft); }
.browse-card h3 { margin: 0 0 6px; font-size: 1.25rem; }
.browse-blurb { color: var(--muted); margin: 0 0 14px; font-size: .95rem; }
.browse-count { color: var(--accent); font-weight: 700; margin: 0; }

.recent-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.recent-list li { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.recent-list a { font-weight: 600; }
.recent-cat { display: block; font-size: .78rem; color: var(--muted); }

/* ---------------- FAQ ---------------- */
.faq { max-width: 820px; }
.faq-item { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 4px 18px; margin-bottom: 10px; }
.faq-item summary { cursor: pointer; font-weight: 700; padding: 12px 0; font-size: 1.03rem; }
.faq-item summary::-webkit-details-marker { color: var(--accent); }
.faq-item p { margin: 0 0 14px; color: var(--muted); }
.faq-more { color: var(--muted); }

/* ---------------- Breadcrumbs ---------------- */
.breadcrumbs { margin: 20px 0 8px; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; font-size: .86rem; color: var(--muted); }
.breadcrumbs li + li::before { content: "/"; margin-right: 6px; color: var(--border-strong); }

/* ---------------- Category header + controls ---------------- */
.cat-header { padding: 8px 0 8px; }
.cat-header h1 { margin: 0 0 6px; }
.cat-blurb { color: var(--muted); margin: 0 0 6px; font-size: 1.05rem; }
.cat-count { color: var(--muted); margin: 0; font-size: .92rem; }

.controls { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin: 18px 0 22px; }
.controls-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.search-field { flex: 1 1 260px; }
.search-field input {
  width: 100%; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-size: 1rem;
}
.sort-field { display: flex; align-items: center; gap: 8px; }
.sort-label { font-size: .88rem; color: var(--muted); font-weight: 600; }
.sort-field select {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-size: .95rem;
}
.fastgrow-field { display: flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--muted); }
.fastgrow-field input { width: 17px; height: 17px; accent-color: var(--accent); }

.tag-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.tag-chip {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--chip-text);
  padding: 6px 12px; border-radius: 999px; font-size: .82rem; cursor: pointer; font-weight: 600;
}
.tag-chip:hover { border-color: var(--accent-soft); }
.tag-chip.is-active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.controls-status { margin: 12px 0 0; font-size: .85rem; color: var(--muted); min-height: 1em; }

/* ---------------- Cards ---------------- */
.card-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px;
}
.card-head { display: flex; gap: 12px; align-items: flex-start; }
.card-title { min-width: 0; }
.card-name { margin: 0; font-size: 1.12rem; }
.card-name a { color: var(--text); }
.card-name a:hover { color: var(--accent); }
.card-license { margin: 2px 0 0; font-size: .76rem; color: var(--muted); }
.card-desc { margin: 0; color: var(--muted); font-size: .93rem; flex: 1 0 auto; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.card-links { display: flex; gap: 14px; margin-top: 2px; }
.card-link { font-size: .86rem; font-weight: 600; }

.avatar {
  width: 44px; height: 44px; flex: none; border-radius: 11px; display: grid; place-items: center;
  font-weight: 800; font-size: .95rem; letter-spacing: .02em;
  background: hsl(var(--h, 30) 60% 90%); color: hsl(var(--h, 30) 55% 26%);
}
[data-theme="dark"] .avatar { background: hsl(var(--h, 30) 32% 24%); color: hsl(var(--h, 30) 75% 80%); }
.av-h0{--h:0}.av-h1{--h:30}.av-h2{--h:60}.av-h3{--h:90}.av-h4{--h:120}.av-h5{--h:150}
.av-h6{--h:180}.av-h7{--h:210}.av-h8{--h:240}.av-h9{--h:270}.av-h10{--h:300}.av-h11{--h:330}

.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; font-weight: 700;
  padding: 4px 9px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}
.badge-star { color: #7a5300; }
[data-theme="dark"] .badge-star { color: #ecc06b; }
.badge-src { font-weight: 500; color: var(--muted); }
.badge-growth.is-fast { background: color-mix(in srgb, var(--accent-soft) 22%, var(--surface-2)); border-color: var(--accent-soft); }
.badge-unranked { color: var(--muted); }

.tag {
  font-size: .76rem; background: var(--chip-bg); color: var(--chip-text);
  padding: 3px 9px; border-radius: 999px; font-weight: 600;
}
.tag:hover { text-decoration: none; filter: brightness(.97); }

/* ---------------- Sponsored slot ---------------- */
.sponsored-slot { margin: 6px 0 26px; }
.slot-heading { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 0 0 10px; }
.slot-sub { text-transform: none; letter-spacing: 0; font-weight: 500; }
.card-sponsored { background: var(--sponsored-bg); border-color: var(--sponsored-border); }
.sponsored-label {
  align-self: flex-start; font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
  color: #8a5a12; background: #ffe9c9; border: 1px solid var(--sponsored-border);
  padding: 2px 8px; border-radius: 6px; margin: 0;
}
[data-theme="dark"] .sponsored-label { color: #ffd79b; background: #4a370f; }

/* ---------------- Ad slot ---------------- */
.ad-slot { margin: 24px 0; padding: 14px; border: 1px dashed var(--border-strong); border-radius: 12px; text-align: center; }
.ad-slot:empty { display: none; }
.ad-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 8px; }

/* ---------------- Listing page ---------------- */
.listing-page { padding-bottom: 30px; }
.listing { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 26px; box-shadow: var(--shadow); margin-top: 6px; }
.listing-header { display: flex; gap: 16px; align-items: center; }
.listing-header .avatar { width: 60px; height: 60px; font-size: 1.2rem; border-radius: 14px; }
.listing-eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .74rem; color: var(--accent); font-weight: 800; margin: 0 0 2px; }
.listing-header h1 { margin: 0; }
.listing-license { margin: 4px 0 0; font-size: .85rem; color: var(--muted); }
.listing-desc { font-size: 1.12rem; color: var(--text); margin: 20px 0; }
.listing-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin: 0 0 20px; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.stat dt { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.stat dd { margin: 6px 0 0; font-size: 1.4rem; font-weight: 800; }
.stat-sub { font-size: .82rem; font-weight: 500; color: var(--muted); }
.stat-pending { font-size: .88rem; font-weight: 500; color: var(--muted); }

.listing-tags { margin: 8px 0 18px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tags-label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.source-note { font-size: .82rem; color: var(--muted); border-top: 1px solid var(--border); padding-top: 16px; }
.listing-disclaimer { font-size: .88rem; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.back-link { margin-top: 20px; }

/* ---------------- Prose / content pages ---------------- */
.prose { max-width: 780px; padding-bottom: 40px; }
.prose h1 { margin: 8px 0 8px; }
.prose h2 { margin: 32px 0 10px; }
.prose p, .prose li { color: var(--muted); }
.prose .lead { font-size: 1.15rem; color: var(--text); }
.prose a { font-weight: 600; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin: 6px 0; }
.callout { background: var(--sponsored-bg); border: 1px solid var(--sponsored-border); border-radius: 12px; padding: 16px 18px; color: var(--text) !important; }
.formula { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 16px; overflow-x: auto; }
.formula code { font: .9rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--text); }
.threshold-box { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; padding: 20px 22px; box-shadow: var(--shadow); }
.threshold-box h2 { margin-top: 0; }
.threshold-note { font-size: .85rem; }
.cta-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 18px 0; }
.stub-badge, .soon { font-size: .78rem; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); padding: 3px 9px; border-radius: 999px; font-weight: 600; }
.soon { color: var(--accent); }
.fineprint { font-size: .84rem; }
.api-table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.api-table th, .api-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: .92rem; }
.api-table code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }
.curated-links { }

.empty-state { text-align: center; color: var(--muted); padding: 40px 20px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 12px; }

/* ---------------- Footer ---------------- */
.site-footer { background: var(--surface-2); border-top: 1px solid var(--border); margin-top: 40px; padding: 28px 0 40px; }
.footer-disclaimer { font-size: .88rem; color: var(--muted); max-width: 900px; margin: 0 0 18px; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 16px; }
.footer-nav a { font-size: .88rem; color: var(--muted); font-weight: 600; }
.footer-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .82rem; color: var(--muted); align-items: center; }
.footer-policy strong { color: var(--accent); }

/* ---------------- Responsive ---------------- */
@media (max-width: 640px) {
  .header-inner { min-height: 58px; }
  .brand-tag { display: none; }
  .site-nav { order: 3; width: 100%; margin-left: 0; overflow-x: auto; padding-bottom: 4px; flex-wrap: nowrap; }
  .theme-toggle { margin-left: auto; }
  .hero { padding-top: 36px; }
  .card-grid, .browse-grid { grid-template-columns: 1fr; }
  .controls-row { flex-direction: column; align-items: stretch; }
  .search-field { flex: 0 0 auto; }
  .sort-field { justify-content: space-between; }
  .sort-field select { flex: 1 1 auto; }
  .fastgrow-field { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
