/* ==========================================================================
   SmartAGM v2 — Company search
   Markup: templates/home/v2/partials/search.html
   A centred heading and search field under the registration steps. Results
   (hidden until something is typed) span the container: a "Search Results"
   heading with the count, then a grid of the matching meetings' cards
   (3 → 2 → 1 columns), the same cards as "Meetings open now" and "To be
   announced" (meetings.css, announced.css). Logical properties mirror in RTL.
   ========================================================================== */

.search {
  /* The steps above and the next section bring their own spacing. */
  padding-block: 0;
}

.search__bar {
  max-width: 760px;
  margin-inline: auto;
}

/* Arabic: letter-spacing breaks the joined letters (card labels, countdown units). */
.search:lang(ar),
.search :lang(ar) {
  letter-spacing: 0;
}

.search__title {
  margin: 0 0 var(--space-5);
  text-align: center;
  font-size: clamp(var(--text-xl), 0.6vw + 16px, 24px);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-snug);
  text-wrap: balance;
}

/* ---- Field -------------------------------------------------------------- */

.search__form {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 6px;
  padding-inline-start: var(--space-5);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  transition: border-color var(--duration-fast) var(--ease-standard);
}

/* The field shows the focus; the input itself has no outline of its own. */
.search__form:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-tint);
}

.search__icon {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--color-text-subtle);
  stroke-width: 2;
  stroke-linecap: round;
}

.search__input {
  flex: 1;
  min-width: 0;
  padding: 10px 0;
  border: 0;
  background: none;
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-lg);
  outline: none;
}

.search__input::placeholder {
  color: var(--color-text-subtle);
  opacity: 1;
}

.search__submit {
  flex: none;
  padding: 12px 24px;
  border-radius: var(--radius-pill);
}

/* ---- Results ------------------------------------------------------------ */

.search__results {
  margin-top: var(--space-12);
}

.search__results[hidden] {
  display: none;
}

.search__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2) var(--space-8);
  margin-bottom: var(--space-6);
}

.search__results-title {
  margin: 0;
  /* 24px on phones → 32px on wide screens: under the page's section headings. */
  font-size: clamp(24px, 1vw + 20px, var(--text-3xl));
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-snug);
}

.search__count {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-base);
}

.search__empty {
  margin: 0;
  padding: var(--space-6) var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  color: var(--color-text-muted);
  text-align: center;
  text-wrap: pretty;
}

.search__empty[hidden] {
  display: none;
}

.search__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* The cards set their own display, which would beat the [hidden] default. */
.search__grid > [hidden] {
  display: none;
}

/* A card fades in each time it goes from hidden to shown (an animation restarts when an
   element comes back from display: none), so cards that stay matched while typing don't
   replay it. search.js sets --search-order (0, 1, 2… among the shown cards, capped) for a
   short stagger. */
.search__grid > *,
.search__empty {
  animation: search-fade-in 320ms var(--ease-standard) both;
}

.search__grid > * {
  animation-delay: calc(var(--search-order, 0) * 45ms);
}

@keyframes search-fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .search__grid > *,
  .search__empty {
    animation: none;
  }
}

/* ---- Smaller screens ---------------------------------------------------- */

@media (max-width: 1024px) {
  .search__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .search__form {
    padding-inline-start: var(--space-4);
  }

  .search__input {
    font-size: 16px; /* 16px stops iOS zooming in on focus. */
  }

  .search__submit {
    padding: 10px 18px;
  }

  .search__results {
    margin-top: var(--space-10);
  }

  .search__grid {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
  }
}
