/* Public search page on the debug-ui design system (tokens + header, btn, pill, readout).
   Signal colors blue / amber / red only, no green. Fonts self-hosted (no third-party requests). */

@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url("/fonts/ibm-plex-sans-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url("/fonts/ibm-plex-sans-500.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap; src: url("/fonts/ibm-plex-sans-600.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap; src: url("/fonts/ibm-plex-mono-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap; src: url("/fonts/ibm-plex-mono-500.woff2") format("woff2"); }

/* ── Reset ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button, input { font-family: inherit; }
button { cursor: pointer; }

/* ── Tokens ─────────────────────────────────── */
:root {
    --sans: 'IBM Plex Sans', system-ui, sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, monospace;

    --header-h: 44px;
    --r:        5px;
    --content-w: 880px;

    --bg:       #f3f2ef;
    --surface:  #ffffff;
    --surf2:    #eeecea;
    --border:   #e3e1dc;
    --border2:  #cac7bf;
    --tx:       #18180f;
    --tx2:      #6a6760;
    --tx3:      #a09d97;

    --blue:     #2563eb;
    --blue-bg:  #eff6ff;
    --blue-dk:  #1d4ed8;
    --amber:    #b45309;
    --amber-bg: #fffbeb;
    --red:      #dc2626;
    --red-bg:   #fef2f2;
}

[data-theme="dark"] {
    --bg: #111110; --surface: #1a1918; --surf2: #222120;
    --border: #2d2b28; --border2: #3c3a36;
    --tx: #e5e2dc; --tx2: #888480; --tx3: #555250;
    --blue: #60a5fa; --blue-bg: #172036; --blue-dk: #93c5fd;
    --amber: #fbbf24; --amber-bg: #2a2210;
    --red: #f87171; --red-bg: #2a1010;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #111110; --surface: #1a1918; --surf2: #222120;
        --border: #2d2b28; --border2: #3c3a36;
        --tx: #e5e2dc; --tx2: #888480; --tx3: #555250;
        --blue: #60a5fa; --blue-bg: #172036; --blue-dk: #93c5fd;
        --amber: #fbbf24; --amber-bg: #2a2210;
        --red: #f87171; --red-bg: #2a1010;
    }
}

/* ── Base ─────────────────────────────────── */
html { font-size: 14px; }
body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--tx);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 1px solid var(--blue); outline-offset: 1px; }

.mono  { font-family: var(--mono); }
.muted { color: var(--tx3); }
.is-ok   { color: var(--blue); }
.is-warn { color: var(--amber); }
.is-bad  { color: var(--red); }

.visually-hidden {
    position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* ── Header ─────────────────────────────────── */
.site-header {
    height: var(--header-h);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.site-header__left  { display: flex; align-items: center; gap: 8px; min-width: 0; }
.site-header__right { display: flex; align-items: center; gap: 8px; }
.site-header__wordmark { font-size: 13px; font-weight: 600; letter-spacing: -0.02em; color: var(--tx); }
.site-header__wordmark:hover { text-decoration: none; }
.site-header__sep { font-size: 12px; color: var(--tx3); }
.site-header__section {
    font-family: var(--mono); font-size: 11px; font-weight: 500;
    text-transform: uppercase; letter-spacing: 0.07em; color: var(--tx3);
}

.icon-btn {
    width: 30px; height: 30px;
    display: grid; place-items: center;
    background: transparent; color: var(--tx2);
    border: 1px solid var(--border); border-radius: var(--r);
    transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { background: var(--surf2); color: var(--tx); }
.icon { width: 13px; height: 13px; display: block; }
.icon--moon { display: none; }
[data-theme="dark"] .icon--sun  { display: none; }
[data-theme="dark"] .icon--moon { display: block; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .icon--sun  { display: none; }
    :root:not([data-theme="light"]) .icon--moon { display: block; }
}

/* ── Search bar (sticky below header) ─────────────────────────────────── */
.bar {
    position: sticky; top: 0; z-index: 50;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.bar__inner {
    max-width: var(--content-w); margin: 0 auto;
    display: flex; flex-direction: column; gap: 10px;
    padding: 12px 16px;
}

.search { position: relative; display: block; }
.search__input {
    width: 100%; height: 36px; padding: 0 36px 0 10px;
    font-size: 14px; color: var(--tx);
    background: var(--bg);
    border: 1px solid var(--border2); border-radius: var(--r);
    transition: border-color 0.1s, background 0.1s;
}
.search__input::placeholder { color: var(--tx3); }
.search__input:focus { outline: none; border-color: var(--blue); background: var(--surface); }
.search__hint {
    position: absolute; right: 8px; top: 50%; translate: 0 -50%;
    padding: 0 6px;
    font-family: var(--mono); font-size: 10.5px; line-height: 18px; color: var(--tx3);
    border: 1px solid var(--border2); border-radius: 3px;
    pointer-events: none;
}
.search__input:focus ~ .search__hint,
.search__input:not(:placeholder-shown) ~ .search__hint { display: none; }

/* loading: thin progress line under the bar */
.bar::after {
    content: ''; display: block; height: 2px; margin-bottom: -2px;
    background: var(--blue); transform-origin: left;
    transform: scaleX(0); opacity: 0;
}
.loading .bar::after { opacity: 1; animation: progress 1.2s ease-out infinite; }
@keyframes progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ── Tabs (category toggles) ─────────────────────────────────── */
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tabs .btn { flex: none; display: inline-flex; align-items: center; gap: 6px; }
.tabs__count { font-family: var(--mono); font-size: 10.5px; font-variant-numeric: tabular-nums; color: var(--tx3); }
.btn--active .tabs__count { color: inherit; }

/* ── Buttons ─────────────────────────────────── */
.btn-row { display: flex; gap: 6px; }
.btn {
    height: 28px; padding: 0 10px;
    display: inline-flex; align-items: center;
    font-size: 12px; font-weight: 500; white-space: nowrap;
    border: 1px solid transparent; border-radius: var(--r);
    transition: background 0.1s, color 0.1s, border-color 0.1s;
}
a.btn:hover { text-decoration: none; }
.btn--outline { background: transparent; color: var(--tx); border-color: var(--border2); }
.btn--outline:hover { background: var(--surf2); }
.btn--ghost   { background: var(--surf2); color: var(--tx); border-color: var(--border); }
.btn--ghost:hover { background: var(--border); }
.btn--active  { background: var(--blue-bg); color: var(--blue); border-color: var(--blue); }

/* ── Pills (state / language); square like the rest ─────────────────────────────────── */
.pill {
    padding: 0 6px;
    font-family: var(--mono); font-size: 10px; line-height: 16px; letter-spacing: 0.04em; white-space: nowrap;
    text-transform: none;
    color: var(--tx2); background: var(--surf2);
    border: 1px solid var(--border2); border-radius: 3px;
}
.pill--ok   { color: var(--blue);  background: var(--blue-bg);  border-color: var(--blue); }
.pill--warn { color: var(--amber); background: var(--amber-bg); border-color: var(--amber); }
.pill--bad  { color: var(--red);   background: var(--red-bg);   border-color: var(--red); }

/* ── Page ─────────────────────────────────── */
.page { max-width: var(--content-w); margin: 0 auto; padding: 16px; }

.readout { min-height: 18px; margin-bottom: 8px; font-family: var(--mono); font-size: 11.5px; color: var(--tx2); }

.intro { padding: 40px 0; }
.intro h1 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.intro__hint { font-size: 13px; color: var(--tx2); }
.intro__examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }

/* ── Hits ─────────────────────────────────── */
.hits {
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--r);
}
.hits:empty { display: none; }

.hit {
    position: relative;
    display: flex; gap: 16px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}
.hit:last-child { border-bottom: none; }
.hit--link:hover { background: var(--surf2); }
.hit__body { flex: 1; min-width: 0; }

.hit__kicker {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px;
    margin-bottom: 3px;
    font-family: var(--mono); font-size: 10.5px; font-weight: 500;
    text-transform: uppercase; letter-spacing: 0.08em; color: var(--tx2);
}
.hit__sep { color: var(--tx3); }
.hit__crumb { font-weight: 400; color: var(--tx2); }
.hit__kicker .pill:first-of-type { margin-left: 4px; }
.hit__track { display: inline-flex; align-items: center; gap: 5px; }
.hit__swatch { width: 8px; height: 8px; border-radius: 1px; background: var(--tx3); }

.hit__title { font-size: 15px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.hit__title a { color: var(--tx); }
/* the title link covers the whole hit; tags and buttons sit above it */
.hit__title a::after { content: ''; position: absolute; inset: 0; }
.hit__title a:hover { text-decoration: none; }
.hit--link:hover .hit__title a { color: var(--blue); }
.tag, .hit .btn { position: relative; z-index: 1; }

.hit__meta { display: flex; flex-wrap: wrap; gap: 2px 18px; margin-top: 6px; font-size: 12.5px; }
.hit__meta > div { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.hit__meta dt {
    font-family: var(--mono); font-size: 10px; font-weight: 500;
    text-transform: uppercase; letter-spacing: 0.07em; color: var(--tx2);
}
.hit__meta dd { overflow-wrap: anywhere; }
.hit__meta dd.mono { font-size: 12px; font-variant-numeric: tabular-nums; }

.hit__snippet {
    margin-top: 6px;
    font-size: 12.5px; line-height: 1.55; color: var(--tx2);
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

mark { color: var(--tx); background: var(--blue-bg); box-shadow: inset 0 -1px var(--blue); }

.hit__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.hit__tags { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; }
.hit__foot .btn-row { margin-left: auto; }

.tag {
    height: 22px; padding: 0 6px;
    font-family: var(--mono); font-size: 10.5px; color: var(--tx2);
    background: var(--surf2);
    border: 1px solid var(--border); border-radius: 3px;
    transition: border-color 0.1s, color 0.1s;
}
.tag:hover { color: var(--tx); border-color: var(--border2); }

.hit__thumb {
    flex: none; align-self: flex-start;
    width: 112px; aspect-ratio: 4 / 3; object-fit: cover;
    background: var(--surf2);
    border: 1px solid var(--border); border-radius: var(--r);
}

@media (max-width: 720px) {
    .bar__inner { padding: 10px 12px; }
    .page { padding: 12px; }
    .hit { padding: 12px; gap: 12px; }
    .hit__thumb { width: 64px; }
}

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