/**
 * @file
 * Baseline styling for the real-time SearchBridge blocks.
 *
 * Deliberately light: enough to be legible and demoable standalone,
 * scoped so a theme can override without a specificity fight.
 */

.sb-query__form {
  display: flex;
  width: 100%;
}

.sb-query__input {
  flex: 1 1 auto;
  padding: 0.6rem 0.9rem;
  font-size: 1.1rem;
  border: 1px solid #b7bcc4;
  border-radius: 4px;
}

.sb-answer {
  margin: 1rem 0;
  padding: 1rem 1.25rem;
  background: #f4f7fb;
  border-left: 4px solid #2563a8;
  border-radius: 4px;
}

.sb-answer__text {
  margin: 0 0 0.5rem;
  line-height: 1.55;
}

/**
 * The contoured answer: sections born by the survey, each growing
 * in place as deeper layers stream into it.
 */
.sb-answer__section {
  margin: 0.75rem 0 0;
}

.sb-answer__section-heading {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  line-height: 1.3;
}

.sb-answer__section-text {
  margin: 0;
  line-height: 1.55;
}

/**
 * The latch's visible face: a live line naming the act underway
 * while deeper layers work. Quiet by design — the answer is the
 * star; this only says the machinery is truly moving.
 */
.sb-answer__progress {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: #4a4f57;
}

.sb-answer__sources-heading {
  margin: 0.75rem 0 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #4a4f57;
}

.sb-answer__sources {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.9rem;
}

/**
 * The listings as row-cards (the AI listings mock-up, 2026-09-30):
 * a thumbnail tile, the title as a bold link over a muted crumb of
 * the address, and a round arrow to the same page, each row a white
 * card on a light border. The tokens read the SHiNE theme's primary
 * where a theme sets it and fall back to the mock-up's own values,
 * so the block matches the site it lands on without a theme fight.
 */
.sb-listings {
  --sb-card-link: var(--tme-color-primary-1, #1a5fd0);
  --sb-card-link-tint: #e8f0fe;
  --sb-card-border: #e3e8ef;
  --sb-card-radius: 10px;
  --sb-card-tile: #eef2f7;
  --sb-card-muted: #6a6f77;
}

/**
 * The block's own label (Drupal's) is the heading; the stacked-discs
 * glyph rides it here so no script prints a heading string of its
 * own. A mask, not a background image, so the glyph takes the link
 * color rather than a color baked into the SVG.
 */
.block:has(.sb-listings) > h2::before {
  content: '';
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-right: 0.45em;
  vertical-align: -0.12em;
  background-color: var(--tme-color-primary-1, #1a5fd0);
  -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cellipse cx='12' cy='5' rx='9' ry='3'/%3E%3Cpath d='M21 12c0 1.7-4 3-9 3s-9-1.3-9-3'/%3E%3Cpath d='M3 5v14c0 1.7 4 3 9 3s9-1.3 9-3V5'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cellipse cx='12' cy='5' rx='9' ry='3'/%3E%3Cpath d='M21 12c0 1.7-4 3-9 3s-9-1.3-9-3'/%3E%3Cpath d='M3 5v14c0 1.7 4 3 9 3s9-1.3 9-3V5'/%3E%3C/svg%3E") no-repeat center / contain;
}

/**
 * Still an <ol> — rank is real and assistive technology reads it —
 * but the mock-up shows no numbers, so the marker goes and the gap
 * between cards says "a stack" instead.
 */
.sb-listings__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/**
 * The row is the frame; the card inside it is the row's anatomy —
 * first the provisional card the script paints (a div), then the
 * page's own rendered card (the article of its listing view mode),
 * which takes the same place with the same classes. An excerpt,
 * when the block shows one, sits beneath the card inside the frame
 * and survives the swap.
 */
.sb-listings__item {
  padding: 10px;
  background: #fff;
  border: 1px solid var(--sb-card-border);
  border-radius: var(--sb-card-radius);
}

.sb-listings__card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
}

/**
 * The tile: the page's picture when its display has one; otherwise
 * a neutral tile — the document kind as a small label, or the page
 * glyph on the empty tile. The picture fills the fixed box whatever
 * field markup wraps it, so the row never jumps and a theme's field
 * template cannot spill it.
 */
.sb-listings__tile {
  position: relative;
  display: flex;
  flex: 0 0 64px;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 48px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--sb-card-tile);
  color: var(--sb-card-muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sb-listings__tile:empty::before {
  content: '';
  width: 22px;
  height: 22px;
  background-color: var(--sb-card-muted);
  -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 2h8l5 5v15H6z'/%3E%3Cpath d='M14 2v5h5'/%3E%3Cpath d='M9 13h6M9 17h6'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 2h8l5 5v15H6z'/%3E%3Cpath d='M14 2v5h5'/%3E%3Cpath d='M9 13h6M9 17h6'/%3E%3C/svg%3E") no-repeat center / contain;
}

.sb-listings__tile img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sb-listings__text {
  flex: 1 1 auto;
  min-width: 0;
}

/*
 * The title and crumb together stand as tall as the tile, so the
 * text fills the row rather than floating in it.
 */
.sb-listings__title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.3;
}

.sb-listings__title a {
  color: var(--sb-card-link);
  text-decoration: none;
}

.sb-listings__title a:hover,
.sb-listings__title a:focus-visible {
  text-decoration: underline;
}

/* The address as slugs; a long one wraps rather than pushes. */
.sb-listings__crumb {
  margin: 2px 0 0;
  font-size: 0.9rem;
  line-height: 1.35;
  color: var(--sb-card-muted);
  overflow-wrap: anywhere;
}

/* Back only by the block's setting, beneath the card in its frame. */
.sb-listings__excerpt {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: #4a4f57;
  line-height: 1.5;
}

/**
 * The arrow: a round tinted button that is a second link to the
 * page (aria-labelled by the script), filling on hover and focus.
 */
.sb-listings__go {
  position: relative;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--sb-card-link-tint);
  transition: background-color 0.15s ease;
}

.sb-listings__go::before {
  content: '';
  position: absolute;
  inset: 6px;
  background-color: var(--sb-card-link);
  -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14'/%3E%3Cpath d='M12 5l7 7-7 7'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14'/%3E%3Cpath d='M12 5l7 7-7 7'/%3E%3C/svg%3E") no-repeat center / contain;
}

.sb-listings__go:hover,
.sb-listings__go:focus-visible {
  background: var(--sb-card-link);
}

.sb-listings__go:hover::before,
.sb-listings__go:focus-visible::before {
  background-color: #fff;
}

.sb-listings__empty,
.sb-assembly:empty {
  color: #6a6f77;
  font-style: italic;
}

.sb-faq__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sb-faq__entry {
  margin: 0 0 0.6rem;
}

.sb-faq__entry:last-child {
  margin-bottom: 0;
}

/**
 * FAQ entries are <details> accordions. The disclosure triangle is
 * the browser's own, so the affordance matches what the element
 * actually does — the previous pill looked like a button and behaved
 * like one, which is why clicking a heading ran a search instead of
 * opening the answer.
 */
.sb-faq__entry {
  border: 1px solid #cddbec;
  border-radius: 6px;
  background: #f7fafd;
}

.sb-faq__question {
  padding: 0.5rem 0.8rem;
  font: inherit;
  font-weight: 600;
  color: #2563a8;
  cursor: pointer;
}

.sb-faq__question:hover,
.sb-faq__question:focus-visible {
  background: #dde8f6;
  border-radius: 6px;
}

.sb-faq__entry[open] .sb-faq__question {
  border-bottom: 1px solid #cddbec;
  border-radius: 6px 6px 0 0;
}

/* Nothing to expand, so it reads as the search shortcut it is. */
.sb-faq__entry--searchable > .sb-faq__question::marker,
.sb-faq__entry--searchable > .sb-faq__question::-webkit-details-marker {
  content: '';
}

.sb-faq__answer {
  margin: 0;
  padding: 0.6rem 0.8rem;
  color: #333;
  line-height: 1.5;
}

.sb-faq__source {
  display: inline-block;
  padding: 0 0.8rem 0.6rem;
  font-size: 0.9rem;
}

/**
 * "Thinking" indicator — shown on every recipient block the instant a
 * query is broadcast, so the search feels live while the AI works.
 */
.sb-thinking {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #6a6f77;
  font-style: italic;
}

.sb-thinking__dots {
  display: inline-flex;
  gap: 3px;
}

.sb-thinking__dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2563a8;
  animation: sb-thinking-bounce 1.2s infinite ease-in-out both;
}

.sb-thinking__dots span:nth-child(1) {
  animation-delay: -0.24s;
}

.sb-thinking__dots span:nth-child(2) {
  animation-delay: -0.12s;
}

@keyframes sb-thinking-bounce {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Typing caret trailing the answer text while tokens stream in. */
.sb-answer__text.is-streaming::after {
  content: '▋';
  margin-left: 1px;
  color: #2563a8;
  animation: sb-caret-blink 1s steps(1) infinite;
}

@keyframes sb-caret-blink {
  50% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sb-thinking__dots span,
  .sb-answer__text.is-streaming::after {
    animation: none;
  }
}
