/**
 * SearchPalette V0.9 — styles overlay palette de recherche
 *
 * Décisions actées :
 *   - Pas d'avatar Alfred / pas de ✨ / pas de chaleur visuelle (ton Rufus)
 *   - Préservation 100% hero v2 actuel (palette = overlay distinct)
 *   - Backdrop-filter blur avec fallback @supports (Safari < 15, vieux Android)
 *   - Mobile : sheet bottom plein écran avec gestion clavier virtuel
 *   - Tab indicator animé porté depuis prototype design new/hero/
 *
 * Tokens Savoor utilisés :
 *   --color-coral (#FF6B6B), --color-vert-restes (#7cb083),
 *   --color-charcoal (#2a3540), --color-cream
 * Si non définis en cascade, fallbacks intégrés ci-dessous.
 */

/* ─── Variables locales (fallback si tokens globaux Savoor absents) ───── */
.search-palette {
  --sp-coral:        #FF6B6B;
  --sp-coral-hover:  #e55a5a;
  --sp-coral-glow:   rgba(255, 107, 107, 0.25);
  --sp-vert:         #7cb083;
  --sp-vert-hover:   #6a9a70;
  --sp-charcoal:     #2a3540;
  --sp-charcoal-90:  rgba(42, 53, 64, 0.92);
  --sp-cream:        #fdfaf2;
  --sp-text:         #1a1a1a;
  --sp-text-muted:   rgba(0, 0, 0, 0.55);
  --sp-text-faint:   rgba(0, 0, 0, 0.35);
  --sp-border:       rgba(0, 0, 0, 0.08);
  --sp-bg-panel:     #ffffff;
  --sp-bg-section:   #fafafa;
  --sp-bg-input:     #f3f4f6;
  --sp-bg-pill:      #f0f0f0;
  --sp-overlay:      rgba(0, 0, 0, 0.92);
  --sp-shadow-panel: 0 20px 60px rgba(0, 0, 0, 0.25);
  --sp-radius-panel: 16px;
  --sp-radius-input: 12px;
  --sp-radius-pill:  20px;
  --sp-anim-backdrop: 200ms ease-out;
  --sp-anim-panel:   280ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark mode adaptation (heuristique : body.dark-mode présent) */
body.dark-mode .search-palette {
  --sp-text:         #f0f0f0;
  --sp-text-muted:   rgba(255, 255, 255, 0.65);
  --sp-text-faint:   rgba(255, 255, 255, 0.35);
  --sp-border:       rgba(255, 255, 255, 0.10);
  --sp-bg-panel:     #2a3540;
  --sp-bg-section:   #323d48;
  --sp-bg-input:     #3a4550;
  --sp-bg-pill:      #4a5560;
}

/* ─── Overlay container ───────────────────────────────────────────────── */

.search-palette {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: none;
  align-items: center;
  justify-content: center;
  /* Padding-top compensé pour le header Savoor fixed (80px) — la palette
     se centre verticalement dans la zone visible SOUS le header.
     Padding-bottom symétrique pour respiration. */
  padding: 100px 20px 60px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.search-palette.is-open {
  display: flex;
  animation: sp-fade-in var(--sp-anim-backdrop) both;
}

.search-palette.is-closing {
  animation: sp-fade-out var(--sp-anim-backdrop) both;
}

.search-palette-backdrop {
  position: fixed;
  inset: 0;
  background: var(--sp-overlay);
}

@supports (backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px)) {
  .search-palette-backdrop {
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
  }
}

/* ─── Panel ──────────────────────────────────────────────────────────── */

.search-palette-panel {
  position: relative;
  width: 100%;
  max-width: 760px;
  background: var(--sp-bg-panel);
  border-radius: var(--sp-radius-panel);
  box-shadow: var(--sp-shadow-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(-12px) scale(0.98);
  opacity: 0;
}

.search-palette.is-open .search-palette-panel {
  animation: sp-panel-in var(--sp-anim-panel) both;
}

.search-palette.is-closing .search-palette-panel {
  animation: sp-panel-out var(--sp-anim-backdrop) both;
}

@keyframes sp-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes sp-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes sp-panel-in {
  from { transform: translateY(-12px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0)     scale(1);    opacity: 1; }
}

@keyframes sp-panel-out {
  from { transform: translateY(0)     scale(1);    opacity: 1; }
  to   { transform: translateY(-8px)  scale(0.99); opacity: 0; }
}

/* Reduce motion — désactive les animations pour les users qui le demandent */
@media (prefers-reduced-motion: reduce) {
  .search-palette,
  .search-palette-panel,
  .search-palette-tab-indicator {
    animation: none !important;
    transition: none !important;
  }
  .search-palette.is-open .search-palette-panel {
    transform: none;
    opacity: 1;
  }
}

/* ─── Tabs (mode classique / restes) ─────────────────────────────────── */

.search-palette-tabs {
  position: relative;
  display: flex;
  border-bottom: 1px solid var(--sp-border);
  padding: 4px 8px 0;
  margin: 4px 0 0;
}

.search-palette-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 16px 0 18px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--sp-text-muted);
  cursor: pointer;
  transition: color 180ms ease;
}

.search-palette-tab:hover,
.search-palette-tab:focus-visible {
  color: var(--sp-text);
}

.search-palette-tab.is-active {
  color: var(--sp-text);
}

.search-palette-tab:focus-visible {
  outline: 2px solid var(--sp-coral);
  outline-offset: -4px;
  border-radius: 4px;
}

/* Indicator animé porté depuis prototype design new/hero/ */
.search-palette-tab-indicator {
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 50%;
  height: 3px;
  background: var(--sp-coral);
  border-radius: 3px 3px 0 0;
  transition: transform var(--sp-anim-backdrop), background-color 180ms ease;
}

.search-palette[data-mode="restes"] .search-palette-tab-indicator {
  transform: translateX(100%);
  background: var(--sp-vert);
}

/* ─── Input principal ────────────────────────────────────────────────── */

/* Wrapper input = ligne plate sans pill (pas de background ni border).
   Pas de gap flex non plus — les éléments sont positionnés via le padding
   du wrapper et margin-left sur le bouton submit, pour éviter tout décalage
   visuel entre le hero v2 et la palette. */
.search-palette-input-wrapper {
  display: flex;
  align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid var(--sp-border);
}

.search-palette-tags-inline {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 60%;
}

.search-palette[data-mode="restes"] .search-palette-tags-inline {
  display: flex;
}

.search-palette-tag-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  margin-right: 6px;
  background: rgba(124, 176, 131, 0.12);
  border: 1px solid var(--sp-vert);
  color: var(--sp-vert);
  border-radius: var(--sp-radius-pill);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
}

.search-palette-tag-remove {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0 0 0 2px;
  opacity: 0.7;
}

.search-palette-tag-remove:hover {
  opacity: 1;
}

.search-palette-input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  font-size: 1.05rem;
  color: var(--sp-text);
  outline: none;
  padding: 22px 0;
}

.search-palette-input::placeholder {
  color: var(--sp-text-faint);
}

.search-palette-submit {
  width: 48px;
  height: 48px;
  margin-left: 12px;
  border-radius: 50%;
  border: none;
  background: var(--sp-coral);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms ease, transform 100ms ease;
  flex-shrink: 0;
}

.search-palette-submit:hover {
  background: var(--sp-coral-hover);
}

.search-palette-submit:focus-visible {
  outline: 2px solid var(--sp-coral);
  outline-offset: 2px;
}

.search-palette-submit:active {
  transform: scale(0.96);
}

.search-palette[data-mode="restes"] .search-palette-submit {
  background: var(--sp-vert);
}

.search-palette[data-mode="restes"] .search-palette-submit:hover {
  background: var(--sp-vert-hover);
}

/* ─── Badges filtres (mode classique) ────────────────────────────────── */
/* Réutilisent les modales hero v2 existantes (z-index 9999 > palette 9998).
   Style cohérent avec .hero-filter-badge mais adapté au panel palette. */

.search-palette-filters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 20px 24px 22px;
  border-bottom: 1px solid var(--sp-border);
}

.search-palette[data-mode="restes"] .search-palette-filters {
  display: none;
}

.search-palette-filter-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--sp-bg-input);
  border: 1px solid transparent;
  border-radius: var(--sp-radius-pill);
  color: var(--sp-text);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-palette-filter-badge i {
  color: var(--sp-text-muted);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.search-palette-filter-badge:hover {
  background: var(--sp-bg-section);
  color: var(--sp-text);
}

.search-palette-filter-badge:hover i {
  color: var(--sp-coral);
}

.search-palette-filter-badge:focus-visible {
  outline: 2px solid var(--sp-coral);
  outline-offset: 2px;
}

/* État actif (filtre appliqué) — synchronisé depuis hero v2 via MutationObserver */
.search-palette-filter-badge.has-filters {
  border-color: var(--sp-coral);
  background: rgba(255, 107, 107, 0.12);
  color: var(--sp-text);
}

.search-palette-filter-badge.has-filters i {
  color: var(--sp-coral);
}

.search-palette-filter-badge .filter-count {
  display: none;
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--sp-coral);
  color: #fff;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.search-palette-filter-badge.has-filters .filter-count {
  display: inline-flex;
}

/* Mobile : 2 colonnes au lieu de 3 pour respiration */
@media (max-width: 480px) {
  .search-palette-filters {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    padding: 12px 16px;
  }
  .search-palette-filter-badge {
    padding: 8px 10px;
    font-size: 0.82rem;
  }
}

/* ─── Catégories ingrédients (mode restes) ───────────────────────────── */
/* Mêmes principes que .search-palette-filters mais accent vert (mode
   restes) au lieu de corail. Réutilisent les modales catégories hero v2
   via click programmatique (cf. setupRestesCategoriesSync). */

.search-palette-restes-categories {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 20px 24px 22px;
  border-bottom: 1px solid var(--sp-border);
}

.search-palette[data-mode="restes"] .search-palette-restes-categories {
  display: grid;
}

.search-palette-restes-category {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--sp-bg-input);
  border: 1px solid transparent;
  border-radius: var(--sp-radius-pill);
  color: var(--sp-text);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-palette-restes-category i {
  color: var(--sp-text-muted);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.search-palette-restes-category:hover {
  background: var(--sp-bg-section);
}

.search-palette-restes-category:hover i {
  color: var(--sp-vert);
}

.search-palette-restes-category:focus-visible {
  outline: 2px solid var(--sp-vert);
  outline-offset: 2px;
}

.search-palette-restes-category.has-filters {
  border-color: var(--sp-vert);
  background: rgba(124, 176, 131, 0.12);
}

.search-palette-restes-category.has-filters i {
  color: var(--sp-vert);
}

.search-palette-restes-category .filter-count {
  display: none;
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--sp-vert);
  color: #fff;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.search-palette-restes-category.has-filters .filter-count {
  display: inline-flex;
}

@media (max-width: 480px) {
  .search-palette-restes-categories {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    padding: 12px 16px;
  }
  .search-palette-restes-category {
    padding: 8px 10px;
    font-size: 0.82rem;
  }
}

/* ─── Zone filtre in-place (5 filtres simples) ───────────────────────── */
/* Affichée à la place des sections recents/suggestions quand un badge
   filtre est cliqué. Pills toggleables, état partagé avec les inputs
   cachés des modales hero v2 via syncPillsFromHero(). */

.search-palette-filter-content[hidden] {
  display: none;
}

.search-palette-filter-content {
  display: flex;
  flex-direction: column;
  padding: 18px 24px 22px;
}

.search-palette-filter-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.search-palette-filter-title {
  flex: 1;
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--sp-text);
}

.search-palette-filter-back {
  width: 32px;
  height: 32px;
  background: var(--sp-bg-input);
  border: none;
  border-radius: 50%;
  color: var(--sp-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms ease;
  flex-shrink: 0;
}

.search-palette-filter-back:hover {
  background: var(--sp-bg-section);
}

.search-palette-filter-back:focus-visible {
  outline: 2px solid var(--sp-coral);
  outline-offset: 2px;
}

.search-palette-filter-reset {
  background: none;
  border: none;
  color: var(--sp-text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  transition: color 150ms ease, background 150ms ease;
}

.search-palette-filter-reset:hover {
  color: var(--sp-coral);
  background: var(--sp-bg-section);
}

.search-palette-filter-reset:focus-visible {
  outline: 2px solid var(--sp-coral);
  outline-offset: 2px;
}

.search-palette-filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Pills toggleables (radio ou checkbox) */
.search-palette-pill {
  display: inline-flex;
  align-items: center;
  padding: 9px 16px;
  background: var(--sp-bg-input);
  border: 2px solid transparent;
  border-radius: var(--sp-radius-pill);
  color: var(--sp-text);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
  user-select: none;
}

.search-palette-pill:hover {
  background: var(--sp-bg-section);
}

.search-palette-pill:focus-visible {
  outline: 2px solid var(--sp-coral);
  outline-offset: 2px;
}

.search-palette-pill.is-selected,
.search-palette-pill.is-active {
  background: var(--sp-coral);
  color: #fff;
  border-color: var(--sp-coral);
  box-shadow: 0 2px 8px var(--sp-coral-glow);
}

/* Mode restes : pas applicable aux 5 filtres simples (qui sont mode classique
   uniquement), mais au cas où on étendrait V1.x */
.search-palette[data-mode="restes"] .search-palette-pill.is-active,
.search-palette[data-mode="restes"] .search-palette-pill.is-selected {
  background: var(--sp-vert);
  border-color: var(--sp-vert);
  box-shadow: 0 2px 8px rgba(124, 176, 131, 0.3);
}

@media (max-width: 480px) {
  .search-palette-filter-content { padding: 14px 16px 18px; }
  .search-palette-pill { padding: 8px 12px; font-size: 0.85rem; }
}

/* ─── Sections dynamiques (recents, suggestions, alfred) ─────────────── */

.search-palette-sections {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 280px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.search-palette-section {
  padding: 20px 24px 22px;
  border-bottom: 1px solid var(--sp-border);
}

.search-palette-section:last-child {
  border-bottom: none;
}

.search-palette-section[hidden] {
  display: none;
}

.search-palette-section-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sp-text-muted);
  margin: 0 0 10px;
}

/* ─── Recherches récentes (3 max, localStorage) ─────────────────────── */

.search-palette-recents-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.search-palette-recents-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin: 0 -10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--sp-text);
}

.search-palette-recents-item:hover,
.search-palette-recents-item.is-selected {
  background: var(--sp-bg-section);
}

.search-palette-recents-icon {
  color: var(--sp-text-faint);
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* ─── Suggestions personnalisées ─────────────────────────────────────── */

.search-palette-suggestions-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.search-palette-suggestion-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  margin: 0 -10px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.search-palette-suggestion-item:hover,
.search-palette-suggestion-item.is-selected {
  background: var(--sp-bg-section);
}

.search-palette-suggestion-thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: var(--sp-bg-pill);
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--sp-text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-palette-suggestion-content {
  flex: 1;
  min-width: 0;
}

.search-palette-suggestion-name {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--sp-text);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-palette-suggestion-reason {
  font-size: 0.8rem;
  color: var(--sp-text-muted);
  margin: 2px 0 0;
}

/* ─── Réponse Alfred (intent conversational/factual) ────────────────── */

.search-palette-alfred-response {
  border-left: 3px solid var(--sp-coral);
  padding-left: 17px;
  background: var(--sp-bg-section);
}

.search-palette-alfred-content {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--sp-text);
  white-space: pre-wrap;
}

.search-palette-alfred-content a {
  color: var(--sp-coral);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.search-palette-alfred-content[aria-busy="true"] {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-palette-alfred-skeleton {
  height: 12px;
  background: linear-gradient(90deg, var(--sp-bg-pill) 0%, var(--sp-bg-input) 50%, var(--sp-bg-pill) 100%);
  background-size: 200% 100%;
  border-radius: 4px;
  animation: sp-skeleton 1.4s ease-in-out infinite;
}

.search-palette-alfred-skeleton:nth-child(1) { width: 90%; }
.search-palette-alfred-skeleton:nth-child(2) { width: 75%; }
.search-palette-alfred-skeleton:nth-child(3) { width: 60%; }

@keyframes sp-skeleton {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.search-palette-alfred-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.search-palette-alfred-continue {
  background: none;
  border: 1px solid var(--sp-border);
  color: var(--sp-text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 150ms ease;
}

.search-palette-alfred-continue:hover {
  background: var(--sp-bg-section);
}

.search-palette-alfred-error {
  font-size: 0.9rem;
  color: var(--sp-text-muted);
  margin: 0;
}

/* ─── Footer hint clavier ────────────────────────────────────────────── */

.search-palette-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-top: 1px solid var(--sp-border);
  background: var(--sp-bg-section);
  font-size: 0.78rem;
  color: var(--sp-text-muted);
  flex-wrap: wrap;
}

.search-palette-footer kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--sp-bg-pill);
  border: 1px solid var(--sp-border);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  color: var(--sp-text);
  margin-right: 2px;
}

/* ─── Empty state (pas encore de query, pas de recents/suggestions) ──── */

.search-palette-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--sp-text-muted);
  font-size: 0.95rem;
}

/* ─── Mobile : sheet bottom plein écran ──────────────────────────────── */

@media (max-width: 640px) {
  .search-palette {
    align-items: flex-end;
    padding: 0;
  }

  .search-palette-panel {
    max-width: 100%;
    height: 100dvh; /* gère clavier virtuel iOS via dynamic viewport */
    height: 100vh;  /* fallback */
    border-radius: 0;
    transform: translateY(20px);
  }

  .search-palette.is-open .search-palette-panel {
    animation-name: sp-panel-in-mobile;
  }

  @keyframes sp-panel-in-mobile {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
  }

  .search-palette-sections {
    flex: 1;
    max-height: none;
  }

  /* Swipe handle visuelle */
  .search-palette-panel::before {
    content: "";
    display: block;
    width: 36px;
    height: 4px;
    background: var(--sp-text-faint);
    border-radius: 2px;
    margin: 8px auto 0;
    opacity: 0.4;
  }

  /* Footer kbd hints masqué en mobile (pas de clavier physique) */
  .search-palette-footer {
    display: none;
  }
}

/* ─── Accessibilité — visually-hidden ────────────────────────────────── */

.search-palette .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ─── No-JS fallback : palette inactive (le JS a la responsabilité d'ouvrir) ── */

.search-palette[hidden] {
  display: none !important;
}

/* ─── Body lock scroll (palette ouverte) ─────────────────────────────── */
/* Convention UI/UX Savoor (cf. .claude/rules/ui-ux-conventions.md +
   hero-v2-modals.js qui suit le même pattern) : la scrollbar reste VISIBLE
   TELLE QUELLE pendant qu'une modale est ouverte. Pas de padding-right de
   compensation, pas de overflow:hidden sur le body.

   Astuce : on applique la classe sur HTML *ET* body :
     - html.search-palette-open : overflow-y: scroll → la scrollbar du
       document reste forcée visible même quand le body devient fixed.
     - body.search-palette-open : position: fixed (scroll bloqué + position
       courante préservée via --sp-scroll-top).

   Sans la classe sur html, le body fixed retire la scrollbar du document
   (rien à scroller) → layout shift de ~17px sur Windows. Avec la classe
   sur html, la scrollbar reste affichée mais non-fonctionnelle. */
html.search-palette-open {
  overflow-y: scroll;
}

body.search-palette-open {
  position: fixed;
  left: 0;
  right: 0;
  top: calc(var(--sp-scroll-top, 0px) * -1);
}

/* ════════════════════════════════════════════════════════════════════════
   MODE HOME_DROPDOWN — léger, attaché au hero v2 sur la home (V0.9.1)
   ════════════════════════════════════════════════════════════════════════
   Pas d'overlay, pas de backdrop, pas de body lock. Le dropdown s'ouvre
   sous l'input #heroSearchInput au focus. Position absolue dans #heroSearchBox
   (qui doit être en position relative — déjà le cas dans page-accueil-hero-v2.css).
   Largeur = 100% de l'input wrapper. Animation discrète.
   ════════════════════════════════════════════════════════════════════════ */

.search-palette-home-dropdown {
  /* Variables locales (réutilise fallbacks de la palette) */
  --sphd-bg:           #ffffff;
  --sphd-text:         #1a1a1a;
  --sphd-text-muted:   rgba(0, 0, 0, 0.55);
  --sphd-text-faint:   rgba(0, 0, 0, 0.35);
  --sphd-border:       rgba(0, 0, 0, 0.08);
  --sphd-bg-section:   #fafafa;
  --sphd-bg-chip:      #f3f4f6;
  --sphd-bg-chip-hov:  #e8eaed;
  --sphd-coral:        #FF6B6B;
  --sphd-radius:       14px;
  --sphd-radius-chip:  20px;
  --sphd-shadow:       0 12px 32px rgba(0, 0, 0, 0.12),
                       0 2px 8px rgba(0, 0, 0, 0.06);

  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--sphd-bg);
  border-radius: var(--sphd-radius);
  box-shadow: var(--sphd-shadow);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 160ms ease-out, transform 160ms ease-out;
  pointer-events: none;
  /* max-height pour éviter dropdown gigantesque sur grand écran */
  max-height: min(70vh, 520px);
  overflow-y: auto;
  /* Empêche la propagation du focus visible si dropdown clicked */
  -webkit-tap-highlight-color: transparent;
}

.search-palette-home-dropdown.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.search-palette-home-dropdown[hidden] {
  display: none !important;
}

body.dark-mode .search-palette-home-dropdown {
  --sphd-bg:           #2a3540;
  --sphd-text:         #f0f0f0;
  --sphd-text-muted:   rgba(255, 255, 255, 0.65);
  --sphd-text-faint:   rgba(255, 255, 255, 0.35);
  --sphd-border:       rgba(255, 255, 255, 0.10);
  --sphd-bg-section:   #323d48;
  --sphd-bg-chip:      #3a4550;
  --sphd-bg-chip-hov:  #4a5560;
}

.search-palette-home-dropdown .sphd-inner {
  padding: 14px 16px 10px;
}

.search-palette-home-dropdown .sphd-section {
  margin-bottom: 12px;
}
.search-palette-home-dropdown .sphd-section:last-child {
  margin-bottom: 0;
}
.search-palette-home-dropdown .sphd-section[hidden] {
  display: none !important;
}

.search-palette-home-dropdown .sphd-section-title {
  margin: 0 0 8px;
  padding: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sphd-text-muted);
}

/* ── Recents (chips horizontaux, scrollable mobile) ─────────────────── */

.search-palette-home-dropdown .sphd-recents-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.search-palette-home-dropdown .sphd-recent-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--sphd-bg-chip);
  border: 1px solid transparent;
  border-radius: var(--sphd-radius-chip);
  font-size: 0.86rem;
  color: var(--sphd-text);
  cursor: pointer;
  transition: background 120ms ease-out, border-color 120ms ease-out;
  font-family: inherit;
}

.search-palette-home-dropdown .sphd-recent-chip:hover {
  background: var(--sphd-bg-chip-hov);
  border-color: var(--sphd-border);
}

.search-palette-home-dropdown .sphd-recent-chip:focus-visible {
  outline: 2px solid var(--sphd-coral);
  outline-offset: 2px;
}

.search-palette-home-dropdown .sphd-recent-icon {
  font-size: 0.95rem;
  color: var(--sphd-text-faint);
  line-height: 1;
}

/* ── Suggestions (liste verticale, ligne par recette) ──────────────── */

.search-palette-home-dropdown .sphd-suggestions-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.search-palette-home-dropdown .sphd-suggestions-list li {
  margin: 0;
  padding: 0;
}

.search-palette-home-dropdown .sphd-suggestion {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--sphd-text);
  transition: background 100ms ease-out;
}

.search-palette-home-dropdown .sphd-suggestion:hover {
  background: var(--sphd-bg-section);
}

.search-palette-home-dropdown .sphd-suggestion-content {
  flex: 1;
  min-width: 0;
}

.search-palette-home-dropdown .sphd-suggestion-name {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--sphd-text);
}

.search-palette-home-dropdown .sphd-suggestion-reason {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--sphd-text-muted);
  line-height: 1.3;
}

/* ── Mobile : largeur pleine sous le wrapper input, pas de bord arrondi */

@media (max-width: 640px) {
  .search-palette-home-dropdown {
    border-radius: 10px;
    max-height: 60vh;
  }
  .search-palette-home-dropdown .sphd-inner {
    padding: 12px 12px 8px;
  }
}

/* ── Reduced motion : désactive l'animation ────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .search-palette-home-dropdown {
    transition: none;
  }
}
