/* Recherche globale : le déclencheur de la barre du haut et la palette qu'il ouvre */

.topbar-search { display: flex; align-items: center; gap: 9px; height: 36px; flex: 0 0 auto; padding: 0 10px 0 11px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.045); color: var(--muted); cursor: pointer; transition: border-color .18s, background .18s, color .18s; }
.topbar-search:hover { border-color: var(--line-strong); background: rgba(255,255,255,.08); color: var(--ink); }
.topbar-search:focus-visible { outline: 2px solid rgba(255,103,111,.9); outline-offset: 3px; }
.topbar-search > .ui-icon { width: 16px; height: 16px; flex: 0 0 auto; }
.topbar-search-label { font-size: .76rem; white-space: nowrap; }
.topbar-search-key { padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; background: rgba(0,0,0,.28); color: var(--muted-2); font-family: inherit; font-size: .56rem; font-weight: 800; letter-spacing: .04em; }

/* La palette s'ouvre haut plutôt que centrée : les résultats s'ajoutent vers le
   bas au fil de la frappe, et une modale centrée sauterait à chaque caractère. */
.search-modal { width: min(660px, calc(100% - 24px)); max-height: min(640px, calc(100vh - 96px)); margin-block: 12vh auto; }
.search-shell { display: flex; flex-direction: column; max-height: min(640px, calc(100vh - 96px)); padding: 0; overflow: hidden; background: #101218; }

.search-field { display: grid; grid-template-columns: 22px minmax(0, 1fr) 34px; align-items: center; gap: 10px; flex: 0 0 auto; padding: 14px 15px; border-bottom: 1px solid var(--line); }
.search-field-icon { display: grid; place-items: center; color: #ff7d84; }
.search-field-icon > .ui-icon { width: 18px; height: 18px; }
.search-field input { width: 100%; padding: 0; border: 0; background: transparent; color: var(--ink); font-size: .95rem; box-shadow: none; }
.search-field input:focus { outline: 0; }
.search-field input::placeholder { color: var(--muted-2); }
.search-dismiss { width: 34px; height: 34px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.05); color: var(--muted); cursor: pointer; }
.search-dismiss:hover { border-color: var(--line-strong); color: var(--ink); }
.search-dismiss > .ui-icon { width: 14px; height: 14px; }

.search-results { flex: 1 1 auto; min-height: 0; padding: 6px 9px; overflow-y: auto; overscroll-behavior: contain; }
.search-results > .empty-panel { min-height: 190px; border: 0; background: transparent; }
.search-section + .search-section { margin-top: 4px; border-top: 1px solid var(--line); }
.search-section h2 { display: flex; align-items: center; gap: 7px; margin: 0; padding: 13px 8px 7px; color: var(--muted-2); font-size: .54rem; font-weight: 900; letter-spacing: .17em; text-transform: uppercase; }
.search-section h2 > span { padding: 2px 6px; border-radius: 999px; background: rgba(255,255,255,.06); color: var(--muted); font-size: .54rem; letter-spacing: 0; }

.search-result { width: 100%; display: grid; align-items: center; gap: 11px; padding: 8px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.search-result-movie { grid-template-columns: 40px minmax(0, 1fr); }
.search-result-member { grid-template-columns: 34px minmax(0, 1fr); }
.search-result-rating { grid-template-columns: 34px minmax(0, 1fr) auto; }
/* Le survol et la sélection au clavier partagent le même appui : la souris et
   les flèches désignent la même chose, elles doivent le dire pareil. */
.search-result:hover, .search-result.is-active { border-color: rgba(229,9,20,.34); background: rgba(229,9,20,.075); }
.search-result:focus-visible { outline: 2px solid rgba(255,103,111,.9); outline-offset: -2px; }
.search-poster { width: 40px; height: 55px; overflow: hidden; border-radius: 5px; background: #24272e; }
.search-poster img { width: 100%; height: 100%; object-fit: cover; }
.search-poster .poster-fallback { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted-2); font-size: .8rem; font-weight: 900; }
.search-avatar { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 34px; border-radius: 9px; background: var(--member-accent, linear-gradient(135deg, #7f1d1d, var(--red))); font-size: .72rem; font-weight: 900; }
.search-avatar.has-emblem { font-size: .95rem; }
.search-copy { min-width: 0; display: block; }
.search-copy strong { display: flex; align-items: baseline; gap: 7px; overflow: hidden; font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.search-copy small { display: block; margin-top: 3px; overflow: hidden; color: var(--muted); font-size: .6rem; text-overflow: ellipsis; white-space: nowrap; }
.search-when { flex: 0 0 auto; margin: 0; color: var(--muted-2); font-size: .55rem; font-weight: 700; }
/* Deux lignes d'extrait : de quoi rendre la phrase où le terme a été trouvé
   sans qu'un avis bavard pousse les résultats suivants hors de l'écran. */
.search-copy em { display: -webkit-box; max-height: 2.9em; margin-top: 4px; overflow: hidden; color: var(--muted); font-size: .63rem; font-style: normal; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.search-copy mark { padding: 0 1px; border-radius: 3px; background: rgba(245,196,81,.22); color: var(--gold); font-weight: 800; }
.search-result-rating .review-global { flex: 0 0 auto; }

.search-handoff { width: 100%; display: flex; align-items: center; gap: 8px; margin-top: 2px; padding: 9px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: .63rem; font-weight: 750; text-align: left; cursor: pointer; }
.search-handoff:hover, .search-handoff.is-active { background: rgba(255,255,255,.06); color: var(--ink); }
.search-handoff:focus-visible { outline: 2px solid rgba(255,103,111,.9); outline-offset: -2px; }
.search-handoff > .ui-icon { width: 14px; height: 14px; color: #ff7d84; }

.search-pending { display: flex; align-items: center; gap: 10px; margin: 0; padding: 4px 8px 12px; color: var(--muted); font-size: .65rem; }
.search-pending .spinner { width: 16px; height: 16px; flex: 0 0 auto; border-width: 2px; }
.search-failed { color: #fb8b91; }
.search-status { margin: 0; padding: 16px 17px 20px; color: var(--muted-2); font-size: .65rem; line-height: 1.5; }
.search-status:empty { display: none; }

/* L'avis atteint depuis la recherche est mis en avant dans la liste du film :
   sans repère, on retomberait sur une pile d'avis sans savoir lequel a répondu. */
.member-review-found { border-color: rgba(245,196,81,.45); box-shadow: 0 0 0 1px rgba(245,196,81,.22); }

@media (max-width: 820px) {
  /* La barre du bas porte déjà six onglets : un septième les rendrait
     illisibles. Le déclencheur rejoint donc l'espace laissé libre en haut,
     entre le logo et l'avatar, et s'y réduit à sa loupe. */
  .topbar-search { width: 40px; height: 40px; justify-content: center; margin-left: auto; padding: 0; border-radius: 11px; }
  .topbar-search-label, .topbar-search-key { display: none; }
  .profile-menu { margin-left: 8px; }
  /* Le clavier virtuel mange la moitié basse de l'écran : la palette se colle
     en haut pour que la saisie et les premiers résultats restent visibles. */
  .search-modal { width: calc(100% - 16px); max-height: calc(100dvh - 24px); margin-block: calc(10px + env(safe-area-inset-top)) auto; }
  .search-shell { max-height: calc(100dvh - 24px); padding: 0; }
  .search-field input { font-size: 1rem; }
  .search-result { padding: 9px 8px; }
  .search-copy strong { font-size: .8rem; }
}
