/**
 * @file
 * Meridian styling for Scolta's result cards and search-as-you-type dropdown.
 *
 * Loaded after the module's scolta.css, which is never edited. Two techniques
 * only: override the documented custom properties, and style the theme's own
 * meridian-* classes on the markup its renderers emit. No selector here is
 * more specific than one class.
 *
 * The card deliberately keeps Scolta's scolta-result-card, scolta-result-title
 * and scolta-result-excerpt classes, so everything meridian.css already gives
 * a result — the panel, the hover lift, the serif title, the amber highlight
 * on <mark> — still applies, and this file adds only the layout the thumbnail
 * and badges need.
 */

/* The seven documented search-as-you-type knobs, nothing more. scolta.css
   declares these on :root; this file loads after it, so a same-specificity
   redeclaration is all it takes. */
:root {
  --scolta-sayt-bg: var(--white);
  --scolta-sayt-border: var(--border);
  --scolta-sayt-shadow: 0 8px 24px rgba(26, 39, 68, 0.14);
  --scolta-sayt-radius: 8px;
  --scolta-sayt-max-height: 24rem;
  --scolta-sayt-active-bg: var(--amber-muted);
  --scolta-sayt-z-index: 60;
}

/* --------------------------------------------------------------------------
 * Result card
 *
 * Emitted by js/scolta-rich-results.js for every result. One without a lead
 * image gets the same card minus the thumbnail, not Scolta's built-in one.
 * ----------------------------------------------------------------------- */

.meridian-result {
  display: flex;
  gap: 1.1rem;
  align-items: flex-start;
}

/* Fixed box, so the card's height is settled before the image arrives and
   nothing below it moves when it does. */
.meridian-result__thumb {
  flex: 0 0 auto;
  display: block;
  width: 110px;
  height: 110px;
  overflow: hidden;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: var(--bg-subtle);
}

.meridian-result__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* A thumbnail that fails to load takes its own box with it rather than leaving
   a hole; the rest of the card is already laid out as text, so nothing else
   moves. Two of this corpus's images are still remote, so this path is real. */
.meridian-result--thumb-failed .meridian-result__thumb {
  display: none;
}

.meridian-result__body {
  min-width: 0;
  flex: 1 1 auto;
}

.meridian-result__title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-clamp: 2;
  overflow: hidden;
}

.meridian-result__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0.35rem 0 0.45rem;
}

.meridian-result__date {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--slate-light);
}

.meridian-result__badge {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.16rem 0.5rem;
  border: 1px solid rgba(var(--amber-rgb), 0.35);
  border-radius: 3px;
  background: var(--amber-muted);
  color: var(--navy);
  white-space: nowrap;
}

.meridian-result__excerpt {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  line-clamp: 3;
  overflow: hidden;
  margin: 0;
}

@media (max-width: 480px) {
  .meridian-result__thumb {
    width: 72px;
    height: 72px;
  }

  .meridian-result {
    gap: 0.8rem;
  }
}

/* --------------------------------------------------------------------------
 * Search-as-you-type dropdown
 *
 * Layout and rhythm only. The dropdown stays absolutely positioned inside
 * .scolta-search-input-wrap, so opening and updating it shifts nothing.
 * ----------------------------------------------------------------------- */

.scolta-sayt {
  font-family: var(--font-sans);
  padding: 0.25rem 0;
}

.scolta-sayt-option {
  padding: 0.55rem 0.9rem;
  border-bottom: none;
  border-left: 3px solid transparent;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.scolta-sayt-option:hover {
  background: var(--bg-subtle);
}

.scolta-sayt-option-active {
  border-left-color: var(--amber);
}

.scolta-sayt-kind {
  color: var(--amber);
  font-size: 0.95rem;
}

.scolta-sayt-title {
  font-family: var(--font-serif);
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text);
}

/* A recent search is history, not a document: sans-serif and quieter, so the
   two kinds of row are told apart without reading the glyph. */
.scolta-sayt-option-recent .scolta-sayt-kind {
  color: var(--slate-light);
}

.scolta-sayt-option-recent .scolta-sayt-title {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 400;
  font-style: italic;
}

.scolta-sayt-excerpt {
  font-size: 0.82rem;
  color: var(--slate-light);
  margin-top: 0.1rem;
}

/* --------------------------------------------------------------------------
 * Thumbnailed suggestion row
 *
 * Inner markup emitted by the suggestion renderer in
 * js/scolta-rich-results.js for title suggestions. The option element around
 * it stays the bundle's, so the rules below never reach past the row's inside.
 *
 * Title and excerpt carry the scolta-* class as well as the meridian-* one, so
 * they inherit the typography set above and these rules add only layout. Same
 * specificity, resolved by source order — this block is last.
 * ----------------------------------------------------------------------- */

.meridian-sayt {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Fixed box, sized before the image arrives, so a row settles its height at
   render and the rows under it never move as thumbnails load. */
.meridian-sayt__thumb {
  flex: 0 0 auto;
  display: block;
  width: 36px;
  height: 36px;
  overflow: hidden;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  background: var(--bg-subtle);
}

.meridian-sayt__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Two rows keep the box but draw nothing in it: a title suggestion with no
   image, and one whose image fails to load (the handler empties the box and
   adds this class). Sized, not drawn — so every title row's text starts on the
   same line whether or not the item has a picture, and a failed image reflows
   nothing. */
.meridian-sayt__thumb--empty {
  border-color: transparent;
  background: none;
}

.meridian-sayt__text {
  min-width: 0;
  flex: 1 1 auto;
}

/* One line each, ellipsised. A suggestion is a pointer, not a summary, and a
   row that wrapped would resize the dropdown on every keystroke. */
.meridian-sayt__title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Overrides the glyph gutter scolta.css gives an excerpt: in this row the
   thumbnail is the gutter, and the text column is already indented. */
.meridian-sayt__excerpt {
  display: block;
  margin-top: 0.05rem;
  margin-left: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
