/* AI Agent Finder — shared shell.
   Night is the default; WWTheme stores the choice under ww_agents_theme.
   Token names mirror the other weienwong.online services so the look carries
   across subdomains without importing the hub stylesheet.

   Layout rule used throughout: siblings are spaced with flex/grid `gap`, never
   per-element margins, so nothing collapses or doubles when blocks are
   reordered at a breakpoint. */

:root {
  --bg: #0b0f14;
  --bg-elevated: #111823;
  --card: #131b26;
  --card-hover: #182231;
  --border: #223044;
  --border-light: #2c3d54;
  --text: #e8eef6;
  --text-secondary: #b4c2d4;
  --muted: #8095ad;
  --accent: #3ba88f;
  --accent-bright: #4fd0b0;
  --accent-dim: #17493d;
  --danger: #e0685f;
  --warn: #d9a441;
  --new: #6fb2f0;
  --new-dim: #16304a;

  --radius: 10px;
  --radius-lg: 14px;
  --max-width: 1180px;
  --nav-height: 60px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

:root[data-theme="day"] {
  --bg: #f4f7fa;
  --bg-elevated: #ffffff;
  --card: #ffffff;
  --card-hover: #eef3f8;
  --border: #dbe3ec;
  --border-light: #c3d0de;
  --text: #101820;
  --text-secondary: #38495c;
  --muted: #5d7089;
  --accent: #14705a;
  --accent-bright: #0d5943;
  --accent-dim: #d5ece4;
  --danger: #b3352c;
  --warn: #8a6410;
  --new: #1a5fa0;
  --new-dim: #dcebfa;
}

* { box-sizing: border-box; }

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

/* Sticky footer: body is the column, main takes the slack. Without this a
   short page leaves the footer floating mid-screen, and a long one lets the
   last card sit flush against the footer rule. */
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

a { color: var(--accent-bright); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; border-radius: 4px; }

img { max-width: 100%; height: auto; }

.container { width: 100%; max-width: var(--max-width); margin: 0 auto; padding: 0 1.25rem; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 50;
  background: var(--accent); color: #04120e; padding: 0.6rem 1rem; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ------------------------------------------------------------------ header */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  min-height: var(--nav-height);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.5rem 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  font-size: 1rem;
  white-space: nowrap;
}

.brand img { border-radius: 7px; flex: none; }

.header-spacer { margin-left: auto; }

.header-links { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }

.header-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
}
.header-links a:hover { background: var(--card-hover); color: var(--text); }

/* Minimum 44px targets: these are tapped on phones. */
.btn {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 0.9rem;
  border-radius: 9px;
  border: 1px solid var(--border-light);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.btn:hover:not(:disabled) { background: var(--card-hover); }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #04120e;
  font-weight: 650;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-bright); }

.btn-sm { min-height: 36px; padding: 0.3rem 0.65rem; font-size: 0.82rem; }

/* -------------------------------------------------------------------- main */

main {
  flex: 1 0 auto;
  padding: 2rem 0 4rem;
  display: flex;
  flex-direction: column;
  gap: 2.25rem;
}

h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); line-height: 1.12; margin: 0; text-wrap: balance; }
h2 { font-size: clamp(1.05rem, 2.2vw, 1.25rem); margin: 0; text-wrap: balance; }
h3 { font-size: 1rem; margin: 0; }

.lede { color: var(--text-secondary); margin: 0; max-width: 60ch; font-size: 1.02rem; }

.section { display: flex; flex-direction: column; gap: 1rem; }

.section-head { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }
.section-head .muted { margin-left: auto; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem;
}

.muted { color: var(--muted); font-size: 0.86rem; }

/* ------------------------------------------------------------------- stats */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stat .n {
  font-family: var(--mono);
  font-size: clamp(1.35rem, 3vw, 1.7rem);
  font-weight: 600;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.stat .k {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}

.stat-new .n { color: var(--new); }
.stat-accent .n { color: var(--accent-bright); }

/* ------------------------------------------------------------------ search */

.search-box { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.search-box input {
  flex: 1 1 20rem;
  min-width: 0;
  font: inherit;
  font-size: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border-light);
  background: var(--bg-elevated);
  color: var(--text);
  min-height: 48px;
}

.search-box input::placeholder { color: var(--muted); }

.chips { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }

.chip {
  font: inherit;
  font-size: 0.81rem;
  padding: 0.34rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  min-height: 34px;
}
.chip:hover { background: var(--card-hover); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--accent-dim); border-color: var(--accent); color: var(--accent-bright); }

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

.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 1.75rem; align-items: start; }

.filters { display: flex; flex-direction: column; gap: 1.1rem; position: sticky; top: calc(var(--nav-height) + 1rem); }

.filter-group { display: flex; flex-direction: column; gap: 0.35rem; }
.filter-group h3 {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--muted); font-weight: 600; margin: 0;
}
.filter-group label { display: flex; align-items: center; gap: 0.45rem; font-size: 0.87rem; color: var(--text-secondary); cursor: pointer; min-height: 28px; }
.filter-group input { accent-color: var(--accent); flex: none; }

/* ------------------------------------------------------------------- cards */

.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0.85rem; }

.results-list { display: flex; flex-direction: column; gap: 0.75rem; }

.agent {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.agent:hover { background: var(--card-hover); border-color: var(--border-light); }

.agent-head { display: flex; justify-content: space-between; gap: 0.75rem; align-items: baseline; flex-wrap: wrap; }
.agent-name { font-size: 1.02rem; font-weight: 650; margin: 0; }
.agent-name a { color: var(--text); text-decoration: none; }
.agent-name a:hover { color: var(--accent-bright); text-decoration: underline; }
.agent-meta { color: var(--muted); font-size: 0.82rem; margin: 0; }
.agent-desc { margin: 0; color: var(--text-secondary); font-size: 0.91rem; }

.score { font-family: var(--mono); font-size: 0.8rem; color: var(--accent-bright); white-space: nowrap; }

.pill {
  display: inline-block;
  font-size: 0.71rem;
  font-family: var(--mono);
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  white-space: nowrap;
}

.pill-accent { background: var(--accent-dim); border-color: var(--accent); color: var(--accent-bright); }
.pill-new { background: var(--new-dim); border-color: var(--new); color: var(--new); font-weight: 650; }
.pill-warn { color: var(--warn); border-color: var(--warn); }
.pill-danger { color: var(--danger); border-color: var(--danger); }

.matched { color: var(--muted); font-size: 0.77rem; margin: 0; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }

.notice {
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent);
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  color: var(--text-secondary);
}
.notice-error { border-left-color: var(--danger); }

/* ------------------------------------------------------------------ tables */

.table-wrap { border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: 0.73rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: var(--card-hover); }

/* margin-top keeps the rule clear of the last card; the old 4rem of main
   padding alone read as cramped once cards ran to the bottom of the page. */
.site-footer {
  flex: none;
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  padding: 1.75rem 0 2rem;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ------------------------------------------------------------- breakpoints */

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 1.25rem; }

  /* The sidebar becomes a horizontal band above the results: sticky filters
     that eat half a phone screen are worse than no filters. */
  .filters { position: static; flex-direction: row; flex-wrap: wrap; gap: 1.25rem; }
  .filter-group { flex: 1 1 9rem; }
}

@media (max-width: 620px) {
  :root { --nav-height: 54px; }
  .container { padding: 0 1rem; }
  main { padding: 1.5rem 0 3rem; gap: 1.75rem; }
  .header-links a { padding: 0.4rem 0.45rem; font-size: 0.84rem; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .agent-grid { grid-template-columns: 1fr; }
  .search-box input { flex-basis: 100%; }
  .search-box .btn { flex: 1 1 auto; }
  .section-head .muted { margin-left: 0; flex-basis: 100%; }
}

@media (max-width: 380px) {
  .stats { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ------------------------------------------------------- scrollbars (shared)
   Default scrollbars are a light-grey chrome widget that sits badly on a dark
   panel and changes width between platforms, which shifts layout. These are
   theme-aware, overlay-thin, and sized identically everywhere.

   Two mechanisms, both needed:
     * scrollbar-width / scrollbar-color — the standard, Firefox and modern
       Chromium. Only accepts a thumb and track colour, nothing else.
     * ::-webkit-scrollbar-* — Chromium and Safari, where the finer control is.
   Colours come from existing theme variables, with literal fallbacks so this
   block still works when pasted into a page that has no token layer.

   Scroll containers also get overscroll-behavior so a table that reaches its
   end stops rather than scrolling the page behind it, and a momentum flag for
   iOS. */

:root {
  --sb-size: 10px;
  --sb-thumb: color-mix(in srgb, currentColor 26%, transparent);
  --sb-thumb-hover: color-mix(in srgb, currentColor 45%, transparent);
  --sb-track: transparent;
}

/* color-mix is widely supported but not universal; these fall back to fixed
   translucent values where it is missing. */
@supports not (color: color-mix(in srgb, red 50%, transparent)) {
  :root {
    --sb-thumb: rgba(128, 149, 173, 0.42);
    --sb-thumb-hover: rgba(128, 149, 173, 0.68);
  }
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--sb-thumb) var(--sb-track);
}

*::-webkit-scrollbar {
  width: var(--sb-size);
  height: var(--sb-size);
}

*::-webkit-scrollbar-track {
  background: var(--sb-track);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  background: var(--sb-thumb);
  border-radius: 999px;
  /* A transparent border with background-clip gives the thumb breathing room
     inside the gutter, so it reads as a floating pill rather than a bar
     welded to the edge. */
  border: 2px solid transparent;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--sb-thumb-hover);
  background-clip: padding-box;
}

*::-webkit-scrollbar-corner { background: transparent; }

/* Any element that scrolls: keep the gesture contained and smooth. */
.table-wrap,
.scroll-x,
.scroll-y,
pre,
textarea {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Horizontal scroll container that hints there is more to the right. The
   gradient is painted on the container background and pinned with
   background-attachment: local, so it appears only when content overflows and
   fades out as the user reaches each end. */
.scroll-x,
.table-wrap {
  overflow-x: auto;
  background:
    linear-gradient(to right, var(--bg-elevated, #fff) 30%, rgba(0, 0, 0, 0)) left center,
    linear-gradient(to left, var(--bg-elevated, #fff) 30%, rgba(0, 0, 0, 0)) right center,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0)) left center,
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0)) right center;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}

/* Vertical scroll container with a capped height — used for any table or list
   that would otherwise run past the fold. */
.scroll-y {
  overflow-y: auto;
  max-height: min(70vh, 640px);
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* -------------------------------------------------------------- pagination */

.pager {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-top: 0.25rem;
}

.pager[hidden] { display: none; }

.pager-info {
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pager-pages { display: flex; gap: 0.3rem; flex-wrap: wrap; }

.pager-num {
  font: inherit;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  min-width: 36px;
  min-height: 36px;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.pager-num:hover:not(:disabled) { background: var(--card-hover); color: var(--text); }
.pager-num[aria-current="page"] {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-bright);
  font-weight: 650;
}
.pager-num:disabled { opacity: 0.4; cursor: default; }

.pager-size { margin-left: auto; display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: var(--muted); }
.pager-size select {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.3rem 0.45rem;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  background: var(--bg-elevated);
  color: var(--text);
  min-height: 34px;
}

@media (max-width: 620px) {
  .pager-size { margin-left: 0; flex-basis: 100%; }
  .pager-info { flex-basis: 100%; }
}
