/* ── D4 · Search existing entities (/dossiers) ──────────────────────────────
   Uses the SAME public-shell tokens as the D3 Dossier reader — `--pub-w-wide`
   for the measure and `--pub-gutter` for the responsive inset — so the finder
   and the record it links to share one geometry instead of two hand-tuned
   layouts that drift at the next viewport change.

   No colour, radius or type size is literal here: every value is a token, so
   a palette change lands on this page without touching this file.
   ──────────────────────────────────────────────────────────────────────── */

.esr {
  max-width: var(--pub-w-wide);
  margin-inline: auto;
  padding-inline: var(--pub-gutter);
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  padding-block: var(--space-xl) var(--space-3xl);
}

/* ── Heading ─────────────────────────────────────────────────────────────── */

.esr-head { display: flex; flex-direction: column; gap: var(--space-sm); }
.esr-head__h { font-size: var(--fs-xl); line-height: 1.15; margin: 0; }
.esr-head__sub {
  margin: 0;
  max-width: 62ch;
  color: var(--text-secondary);
  font-size: var(--fs-card-body);
  line-height: 1.55;
}

/* ── Search form ─────────────────────────────────────────────────────────── */

.esr-form { display: flex; flex-direction: column; gap: var(--space-xs); }
.esr-form__label {
  font-size: var(--fs-card-label);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.esr-form__row { display: flex; gap: var(--space-sm); align-items: stretch; }
.esr-form__in {
  flex: 1 1 auto;
  min-width: 0;                    /* never let a long value push the button out */
  padding: var(--space-sm) var(--space-md);
  font: inherit;
  font-size: var(--fs-card-body);
  color: var(--text-primary);
  background: var(--bg-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xs);
}
.esr-form__in::placeholder { color: var(--text-tertiary); }
.esr-form__in:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 1px; }
.esr-form__go {
  flex: none;
  padding: var(--space-sm) var(--space-lg);
  font: inherit;
  font-size: var(--fs-card-body);
  color: var(--bg-0);
  background: var(--brand-500);
  border: 1px solid var(--brand-500);
  border-radius: var(--r-xs);
  cursor: pointer;
}
.esr-form__go:hover { filter: brightness(1.08); }
.esr-form__go:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 2px; }

/* ── Type filters ────────────────────────────────────────────────────────── */

.esr-kinds { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.esr-kind {
  font-size: var(--fs-card-chip);
  line-height: 1;
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xs);
  color: var(--text-secondary);
  background: var(--bg-1);
  text-decoration: none;
  white-space: nowrap;
}
.esr-kind:hover { border-color: var(--border-strong); color: var(--text-primary); }
.esr-kind.is-on {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--bg-2);
}
.esr-kind:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 1px; }

/* ── State line + empty state ────────────────────────────────────────────── */

.esr-state {
  margin: 0;
  font-size: var(--fs-card-label);
  color: var(--text-tertiary);
}
.esr-empty {
  display: flex; flex-direction: column; gap: var(--space-sm);
  padding: var(--space-lg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  background: var(--bg-1);
  max-width: 62ch;
}
.esr-empty p { margin: 0; color: var(--text-secondary); line-height: 1.55; }
.esr-empty__try { color: var(--text-tertiary) !important; }
.esr-empty code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-primary);
}

/* ── Results ─────────────────────────────────────────────────────────────── */

.esr-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.esr-row { border-top: 1px solid var(--border-subtle); }
.esr-row:last-child { border-bottom: 1px solid var(--border-subtle); }

.esr-row__link {
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
  padding: var(--space-md) var(--space-xs);
  text-decoration: none;
  color: inherit;
}
.esr-row__link:hover { background: var(--bg-1); }
.esr-row__link:focus-visible { outline: 2px solid var(--brand-500); outline-offset: -2px; }

.esr-row__fig { flex: none; width: 48px; height: 48px; }
.esr-row__fig img {
  width: 48px; height: 48px; object-fit: cover;
  border-radius: var(--r-xs); border: 1px solid var(--border-subtle);
}
.esr-row__mono {
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 48px;
  border-radius: var(--r-xs);
  border: 1px solid var(--border-subtle);
  background: var(--bg-2);
  color: var(--text-tertiary);
  font-size: var(--fs-card-label);
  letter-spacing: 0.04em;
}

.esr-row__main {
  min-width: 0;                    /* the reason long names wrap instead of clipping */
  display: flex; flex-direction: column; gap: var(--space-2xs);
}
.esr-row__name {
  font-size: var(--fs-card-title);
  color: var(--text-primary);
  overflow-wrap: anywhere;
}
.esr-row__desc {
  font-size: var(--fs-card-meta);
  color: var(--text-secondary);
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.esr-row__meta {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: var(--space-xs) var(--space-sm);
  margin-top: var(--space-2xs);
}

.esr-chip {
  display: inline-flex; align-items: center; gap: var(--space-xs);
  font-size: var(--fs-card-chip); line-height: 1;
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xs);
  color: var(--text-secondary);
  background: var(--bg-1);
  white-space: nowrap;
}
.esr-chip__dot {
  width: 6px; height: 6px; border-radius: 50%; flex: none;
  background: var(--_accent, var(--text-tertiary));
}
.esr-row__qid,
.esr-row__reports {
  font-size: var(--fs-card-chip);
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* ── Mobile ──────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .esr-form__row { flex-direction: column; }
  .esr-form__go { width: 100%; }
  .esr-row__fig,
  .esr-row__fig img,
  .esr-row__mono { width: 40px; height: 40px; }
}

/* ── Degraded-index notice ─────────────────────────────────────────────────
   Shown when the relevance engine did not answer and Postgres served the
   results instead. It sits ABOVE `.esr-state` because it changes how the
   sentence below it must be read: with the index degraded, "nothing found"
   describes this search, not the archive. */
.esr-degraded {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0 0 10px;
  padding: 11px 14px;
  border-radius: var(--r-sm);
  border: 1px solid color-mix(in oklch, var(--brand-500) 30%, transparent);
  background: color-mix(in oklch, var(--brand-500) 8%, transparent);
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  line-height: 1.5;
}
.esr-degraded__dot {
  flex: none;
  width: 7px;
  height: 7px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--brand-500);
}
