/* Selah workbench — Search tab
   Header polish, Hebrew keyboard popover, translit typing chips, rich rows.
   Split from resources/public/css/workbench.css on 2026-07-01 —
   run git log --follow to trace history through the pre-split file. */

/* ── Search tab ────────────────────────────────────────────────
   Reuses every .explore-* class for the chip rails, frow buttons,
   filter sections, header band, and bar gradients. Only the bits
   that diverge from Explore get search-* overrides here. */

/* No drill column — all controls on the left. Two-column grid:
   filter rail + results. */
.wb-profile.explore-tab.search-tab {
  grid-template-columns: 220px 1fr;
  grid-template-areas:
    "header header"
    "filter results";
}

/* Compact header — match the reader top-bar density (~36px band).
   No border on the input at all; the header band's own bottom rule
   IS the divider. Focus state shows a faint warm tint on the caret
   row instead, so we don't stack two lines next to each other. */
.search-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--wb-rule);
}
.search-input {
  flex: 1;
  background: transparent;
  color: var(--wb-ink);
  border: none;
  padding: 6px 4px;
  font-family: 'Cardo', 'EB Garamond', Georgia, var(--script-faces), serif;
  font-size: 17px;
  line-height: 1.35;
  outline: none;
}
.search-input:focus { caret-color: var(--wb-warm); }
.search-input::placeholder {
  color: var(--wb-ink-4);
  font-style: italic;
  font-size: 15px;
}

/* Result clusters live inside the standard .explore-results column.
   Section header + rows match the Explore body rhythm. */
.search-section {
  display: flex; flex-direction: column;
  margin: 0 0 22px 0;
}
.search-section-head {
  display: flex; align-items: baseline; gap: 8px;
  flex-wrap: wrap; row-gap: 4px;
  padding: 0 0 6px 0;
  border-bottom: 1px solid var(--wb-rule);
  margin-bottom: 4px;
}
.search-section-glyph {
  font-family: var(--rd-mono);
  font-size: 13px;
  color: var(--wb-warm);
  width: 16px; text-align: center;
}
.search-section-label {
  font-family: var(--rd-mono);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--wb-ink-2);
}
.search-section-count {
  font-family: var(--rd-mono);
  font-size: 10px;
  color: var(--wb-ink-3);
  font-variant-numeric: tabular-nums;
  /* Never wrap word-by-word into a tower — if the head runs out of
     room the whole pager wraps to its own row instead (flex-wrap
     on the head). */
  white-space: nowrap;
}
/* Pagination lives in the section head, right-aligned across from
 * the count so the pager and the row-list share a visual band. */
.search-section-head .explore-pagination {
  margin-left: auto;
  padding: 0;
  border-top: none;
}
.search-section-rows { display: flex; flex-direction: column; gap: 0; }

/* Stale-while-revalidate: while a new fetch is in flight, keep
 * showing the previous rows but subtly dim them to hint 'newer
 * data coming.' No layout shift, no blank flash. */
.explore-results--loading {
  opacity: 0.65;
  transition: opacity 120ms ease-in;
}

/* Hebrew keyboard toggle — small aleph button sits opposite the
 * input in the search header. */
.search-header { position: relative; }
.search-kbd-toggle,
.search-translit-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  min-width: 34px;
  padding: 0 10px;
  line-height: 1;
  background: transparent;
  color: var(--wb-ink-3);
  border: 1px solid var(--wb-rule);
  border-radius: 4px;
  cursor: pointer;
  margin: 0;
  transition: color 80ms, border-color 80ms, background 80ms;
}
.search-translit-toggle {
  /* Latin fallback face for the off-state label 'ab' */
  font-family: var(--rd-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
}
.search-translit-toggle--on {
  font-family: 'SBL Hebrew', 'Cardo', var(--script-faces), serif;
  font-size: 15px;
  letter-spacing: 0;
  color: var(--wb-warm);
  border-color: var(--wb-warm);
  background: color-mix(in oklab, var(--wb-warm) 8%, transparent);
}
.search-kbd-toggle {
  font-family: var(--rd-mono);
  font-size: 16px;
}
.search-kbd-toggle:hover,
.search-translit-toggle:hover {
  color: var(--wb-ink);
  border-color: var(--wb-ink-2);
}
.search-kbd-toggle--on {
  color: var(--wb-warm);
  border-color: var(--wb-warm);
  background: color-mix(in oklab, var(--wb-warm) 8%, transparent);
}

/* Hebrew keyboard popover — appears beneath the input, RTL rows
 * of letter buttons + a final row for the divine-name shortcuts. */
.search-kbd {
  position: absolute;
  top: calc(100% + 8px);
  right: 12px;
  z-index: 40;
  background: var(--wb-bg);
  border: 1px solid var(--wb-rule);
  border-radius: 6px;
  padding: 10px 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
/* Default row direction is LEFT-TO-RIGHT, matching a physical
 * Hebrew keyboard (shin on the far left where A sits on QWERTY).
 * The .search-kbd-row--rtl modifier renders alphabetical order in
 * reading order (א on the right, tav on the left) since that's
 * how the aleph-bet is read. */
.search-kbd-row {
  display: flex;
  flex-direction: row;
  gap: 4px;
  justify-content: flex-start;
}
.search-kbd-row--rtl {
  flex-direction: row-reverse;
  justify-content: flex-end;
}
.search-kbd-key {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 42px;
  padding: 3px 6px;
  background: transparent;
  border: 1px solid var(--wb-rule);
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 60ms, background 60ms;
}
.search-kbd-key:hover {
  border-color: var(--wb-warm);
  background: color-mix(in oklab, var(--wb-warm) 8%, transparent);
}
.search-kbd-translit {
  font-family: var(--rd-mono);
  font-size: 9px;
  color: var(--wb-ink-3);
  letter-spacing: 0.05em;
  line-height: 1;
}
.search-kbd-hebrew {
  font-family: 'SBL Hebrew', 'Cardo', var(--script-faces), serif;
  font-size: 20px;
  line-height: 1;
  color: var(--wb-ink);
}
.search-kbd-sep {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: var(--wb-rule);
  margin: 0 4px;
}
.search-input--translit {
  border-color: var(--wb-warm);
  background: color-mix(in oklab, var(--wb-warm) 4%, transparent);
}
.search-kbd-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--wb-rule);
}
.search-kbd-btn {
  font-family: var(--rd-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  padding: 3px 10px;
  background: transparent;
  color: var(--wb-ink-2);
  border: 1px solid var(--wb-rule);
  border-radius: 3px;
  cursor: pointer;
}
.search-kbd-btn:hover { color: var(--wb-ink); border-color: var(--wb-ink-2); }

/* Layout toggle chips at the top of the popover. Same choice
 * writes to :palette/hebrew-kbd-layout so the setting persists
 * and matches whatever the user picked in Settings. */
.search-kbd-layout-row {
  display: flex;
  gap: 6px;
  padding-bottom: 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--wb-rule);
}
.search-kbd-layout {
  font-family: var(--rd-mono);
  font-size: 10px;
  text-transform: lowercase;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  background: transparent;
  color: var(--wb-ink-3);
  border: 1px solid var(--wb-rule);
  border-radius: 3px;
  cursor: pointer;
}
.search-kbd-layout:hover { color: var(--wb-ink-2); border-color: var(--wb-ink-2); }
.search-kbd-layout--on {
  color: var(--wb-warm);
  border-color: var(--wb-warm);
  background: color-mix(in oklab, var(--wb-warm) 8%, transparent);
}

.search-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  background: transparent;
  border: none;
  color: var(--wb-ink);
  text-align: left;
  padding: 6px 10px 6px 8px;
  font-family: 'Cardo', 'EB Garamond', Georgia, var(--script-faces), serif;
  font-size: 14px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: color 0.1s ease, border-color 0.1s ease, background 80ms ease;
  line-height: 1.45;
  width: 100%;
}
.search-row:hover {
  color: var(--wb-warm);
  border-left-color: var(--wb-warm);
  background: color-mix(in srgb, var(--wb-warm) 6%, transparent);
}
/* Per-kind row pieces */
.search-row-label { color: inherit; }
.search-row-hb {
  font-family: 'SBL Hebrew', 'Cardo', 'EB Garamond', var(--script-faces), serif;
  font-size: 16px;
  color: var(--wb-ink);
  min-width: 64px;
}
.search-row-translit {
  font-family: 'Cardo', 'EB Garamond', Georgia, var(--script-faces), serif;
  font-style: italic;
  color: var(--wb-ink-2);
  font-size: 13px;
}
.search-row-strongs {
  font-family: var(--rd-mono);
  font-size: 10px;
  color: var(--wb-ink-3);
  letter-spacing: 0.06em;
}
.search-row-gloss {
  color: var(--wb-ink-2);
  font-size: 13px;
  flex: 1; min-width: 0;
}
/* Right-side badges — POS + frequency. Both pushed to the trailing
 * edge of the row so the eye can scan them as one column. */
.search-row-pos {
  font-family: var(--rd-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--wb-ink-3);
  padding: 1px 5px;
  border: 1px solid var(--wb-rule);
  border-radius: 3px;
  opacity: 0.75;
  white-space: nowrap;
}
.search-row-pos--proper-noun { color: var(--wb-warm); border-color: var(--wb-warm); }
.search-row-pos--verb        { color: var(--wb-warm); border-color: var(--wb-warm); }
.search-row-freq {
  font-family: var(--rd-mono);
  font-size: 10px;
  color: var(--wb-ink-3);
  font-variant-numeric: tabular-nums;
  min-width: 40px; text-align: right;
  opacity: 0.75;
}
.search-row-ref {
  font-family: var(--rd-mono);
  font-size: 11px;
  color: var(--wb-warm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  min-width: 110px;
}
.search-row-text {
  color: var(--wb-ink-2);
  font-size: 13px;
  flex: 1; min-width: 0;
}
.search-mark {
  background: color-mix(in srgb, var(--wb-warm) 30%, transparent);
  color: var(--wb-ink);
  padding: 0 2px;
  border-radius: 1px;
}
.search-row-sub {
  font-family: var(--rd-mono);
  font-size: 10px;
  color: var(--wb-ink-3);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

/* Center column gets generous padding so the result list breathes
   without consuming the whole tab. */
.search-tab .explore-results {
  padding: 18px 28px 24px;
  overflow-y: auto;
  display: flex; flex-direction: column;
  min-height: 0;
}

/* Histogram rows in the Search tab — inset the right-side count a
   few pixels from the row's right edge so the bar (which spans the
   button's full background width) extends past the count text. */
.search-tab .explore-frow { padding-right: 10px; }

.search-banner {
  padding: 32px 16px;
  text-align: center;
  color: var(--wb-ink-3);
  font-family: 'Cardo', 'EB Garamond', Georgia, var(--script-faces), serif;
  font-size: 14px;
  font-style: italic;
}

.search-load-more {
  padding-top: 6px;
  display: flex; justify-content: center;
}
.search-load-more-btn {
  background: transparent;
  color: var(--wb-ink-3);
  border: 1px solid var(--wb-rule);
  padding: 4px 12px;
  border-radius: 3px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  font-family: var(--rd-mono);
}
.search-load-more-btn:hover {
  color: var(--wb-warm);
  border-color: var(--wb-warm);
}


/* ── Mobile ───────────────────────────────────────────────────
   The single-column collapse lives in explore.css @700px, but this
   file loads AFTER explore.css in the bundle, so our base
   220px 1fr grid was overriding it (equal specificity, later
   source wins — media queries add no specificity). Restate the
   collapse here so the search tab actually folds on phones. */
@media (max-width: 700px) {
  .wb-profile.explore-tab.search-tab {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
      "header"
      "filter"
      "results";
  }
  /* Verse rows: keep ref + excerpt readable at full width */
  .search-row { gap: 8px; }
}
