/* ============================================================
   FooyDeuk — Wizard de recherche guidée (overlay plein écran)
   ------------------------------------------------------------
   Port web du `SearchWizardModal` mobile (FooyDeukApp).
   - 2 cartes synchrones côte à côte dans le hero (Trouver / Publier)
   - Overlay plein écran avec barre de progression, footer Précédent/Passer
   - Compteur live "N biens" à partir de l'étape budget
   - Flux adaptatif (3 à 6 étapes selon le type sélectionné)
   ============================================================ */

/* ============= Zone "Actions" du hero (2 cartes côte à côte) ============= */

/* ============= Zone "Actions" du hero — 2 cartes glass jumelles =============
   Conception : ces cartes vivent DANS le hero immersif (sur la photo de fond).
   On évite donc les blocs pleins forest/terra qui écraseraient la photo. À la
   place : fond translucide + flou + bordure or fine, et un layout horizontal
   compact (icône à gauche, texte à droite) qui prend peu de hauteur. Résultat
   visible dès le premier coup d'œil, sans scroller. */

.hero-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
}

/* === Carte d'action — design "ticket" premium ===
   - Surface claire (cream) sur fond sombre du hero → l'œil va dessus
   - Icône carrée arrondie à gauche (terra/gold pleine)
   - Texte droite : eyebrow + titre + sous-titre
   - Flèche à droite qui glisse au hover
   - Bordure hairline or qui s'illumine au hover */
.hero-action-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px 14px 14px;
  border-radius: 16px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  overflow: hidden;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  /* Fond clair (cream translucide) — contraste fort avec la photo + voile sombre du hero */
  background: linear-gradient(180deg, rgba(255, 249, 238, 0.96) 0%, rgba(247, 238, 218, 0.94) 100%);
  border: 1px solid rgba(244, 163, 0, 0.55);
  box-shadow:
    0 18px 38px -16px rgba(0, 0, 0, 0.55),
    0 2px 6px rgba(0, 0, 0, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  transition:
    transform var(--t-spring),
    border-color var(--t),
    box-shadow var(--t);
}
/* Lueur or interne — petite étincelle en haut à gauche, signature éditoriale */
.hero-action-card::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 14%;
  right: 14%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0;
  transition: opacity var(--t);
  pointer-events: none;
}
.hero-action-card:hover {
  transform: translateY(-3px);
  border-color: var(--gold);
  box-shadow:
    0 24px 48px -16px rgba(0, 0, 0, 0.6),
    0 4px 10px rgba(231, 111, 81, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
}
.hero-action-card:hover::before { opacity: 1; }
.hero-action-card:active { transform: translateY(-1px); }
.hero-action-card:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

/* Halo masqué (laissé pour rétro-compat HTML mais sans effet visuel). */
.hero-action-halo { display: none; }

/* Icône — carré arrondi (pas rond) — style éditorial 2024. */
.hero-action-icon {
  position: relative;
  z-index: 1;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--gold) 0%, #D88B05 100%);
  color: var(--forest);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
  box-shadow:
    0 6px 14px -4px rgba(244, 163, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform var(--t-spring);
}
.hero-action-card:hover .hero-action-icon { transform: rotate(-4deg) scale(1.05); }

.hero-action-text {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.hero-action-eyebrow {
  font-family: 'DM Sans', sans-serif;
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  color: var(--terra-text);
  text-transform: uppercase;
}

.hero-action-title {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: clamp(0.98rem, 1.55vw, 1.14rem);
  line-height: 1.18;
  color: var(--night);
  letter-spacing: -0.01em;
  margin: 0;
}

.hero-action-sub {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  color: var(--text-soft);
  font-weight: 500;
  margin: 0;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Flèche à droite — glisse au hover. */
.hero-action-arrow {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(15, 27, 22, 0.06);
  color: var(--forest);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
  transition: transform var(--t-spring), background var(--t), color var(--t);
}
.hero-action-card:hover .hero-action-arrow {
  transform: translateX(3px);
  background: var(--forest);
  color: var(--gold);
}

/* === Variante "Publier" — accent terra à la place du gold === */
.hero-action-card.is-publish {
  border-color: rgba(231, 111, 81, 0.50);
}
.hero-action-card.is-publish:hover {
  border-color: var(--terra);
  box-shadow:
    0 24px 48px -16px rgba(0, 0, 0, 0.6),
    0 4px 10px rgba(231, 111, 81, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
}
.hero-action-card.is-publish::before {
  background: linear-gradient(90deg, transparent, var(--terra), transparent);
}
.hero-action-card.is-publish .hero-action-eyebrow { color: var(--forest); }
.hero-action-card.is-publish .hero-action-icon {
  background: linear-gradient(135deg, var(--terra) 0%, #B84E2F 100%);
  color: #FFFFFF;
  box-shadow:
    0 6px 14px -4px rgba(231, 111, 81, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.30);
}
.hero-action-card.is-publish:hover .hero-action-arrow {
  background: var(--terra);
  color: #FFFFFF;
}

/* === Dark mode — la photo et le voile s'assombrissent, les cartes restent
   claires (contraste max, lisibilité). On ajuste juste l'ombre. === */
[data-theme="dark"] .hero-action-card {
  background: linear-gradient(180deg, rgba(255, 249, 238, 0.94) 0%, rgba(242, 232, 212, 0.92) 100%);
  box-shadow:
    0 20px 44px -16px rgba(0, 0, 0, 0.75),
    0 2px 6px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* === Responsive === */
@media (max-width: 720px) {
  .hero-actions-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    max-width: 460px;
  }
  .hero-action-card { padding: 12px 14px; gap: 12px; }
  .hero-action-icon { width: 40px; height: 40px; font-size: 0.98rem; border-radius: 11px; }
  .hero-action-arrow { width: 30px; height: 30px; font-size: 0.78rem; }
  .hero-action-title { font-size: 1rem; }
  .hero-action-sub { font-size: 0.76rem; }
}
@media (max-width: 380px) {
  .hero-action-card { padding: 10px 12px; }
  .hero-action-sub { display: none; }
}

/* ============= Overlay du wizard (modal plein écran) ============= */

.wizard-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 27, 22, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9990;
  display: flex;
  align-items: stretch;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.wizard-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.wizard-modal {
  position: relative;
  background: var(--bg);
  width: 100%;
  max-width: 820px;
  margin: auto;
  border-radius: 24px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px);
  opacity: 0;
  transition:
    transform 240ms cubic-bezier(0.16, 1, 0.3, 1),
    opacity 200ms ease;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.4);
}
.wizard-overlay.is-open .wizard-modal {
  transform: translateY(0);
  opacity: 1;
}

/* Sur mobile, plein écran sans border-radius pour gagner de la place. */
@media (max-width: 720px) {
  .wizard-modal {
    max-width: none;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    margin: 0;
  }
}

/* ============= Header du wizard (close + progress bar + step counter) ============= */

.wizard-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border-soft);
}

.wizard-close {
  width: 40px;
  height: 40px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  color: var(--text);
  cursor: pointer;
  transition: background var(--t), border-color var(--t);
  flex-shrink: 0;
}
.wizard-close:hover {
  background: var(--bg-sand);
  border-color: var(--terra);
}

.wizard-progress-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wizard-progress-track {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}
.wizard-progress-fill {
  height: 100%;
  background: var(--terra);
  border-radius: 3px;
  transition: width 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.wizard-step-counter {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  color: var(--text-mute);
  font-weight: 500;
}

/* ============= Body — contenu d'une étape (cards) ============= */

.wizard-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
}

.wizard-step {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: wizardStepIn 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes wizardStepIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.wizard-step-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}
.wizard-step-eyebrow {
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 1.2px;
  color: var(--terra-text);
  text-transform: uppercase;
}
.wizard-step-title {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: clamp(1.4rem, 3vw, 1.85rem);
  color: var(--text);
  margin: 0;
  letter-spacing: -0.01em;
}
.wizard-step-subtitle {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.92rem;
  color: var(--text-soft);
  margin: 0;
}

/* Grille de cartes d'options — 2 colonnes desktop, 1 mobile */
.wizard-options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (max-width: 540px) {
  .wizard-options-grid {
    grid-template-columns: 1fr;
  }
}

/* Carte d'option (les "WizardCard" du mobile) */
.wizard-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  text-align: left;
  cursor: pointer;
  transition:
    transform 220ms cubic-bezier(0.16, 1, 0.3, 1),
    border-color var(--t),
    box-shadow var(--t);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 150px;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.wizard-card:hover {
  transform: translateY(-3px);
  border-color: var(--terra);
  box-shadow: 0 16px 30px -14px rgba(231, 111, 81, 0.32);
}
.wizard-card:active {
  transform: translateY(-1px);
}
.wizard-card.is-selected {
  border-color: var(--terra);
  border-width: 2px;
  padding: 17px;
  box-shadow: 0 16px 30px -14px rgba(231, 111, 81, 0.45);
}

.wizard-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  /* `--card-accent` est défini inline par le JS pour chaque option */
  background: color-mix(in srgb, var(--card-accent, var(--terra)) 14%, transparent);
  color: var(--card-accent, var(--terra));
}

.wizard-card-label {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
  margin: 0;
  line-height: 1.2;
}

.wizard-card-sub {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  color: var(--text-soft);
  margin: 0;
  line-height: 1.35;
}

/* Badge ✓ en coin haut-droit quand la carte est sélectionnée */
.wizard-card-check {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  border-radius: 12px;
  background: var(--terra);
  color: #FFFFFF;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}
.wizard-card.is-selected .wizard-card-check {
  display: inline-flex;
}

/* ============= Récap (dernière étape) ============= */

.wizard-recap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}
.wizard-recap-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}
.wizard-recap-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  color: var(--text-soft);
}
.wizard-recap-value {
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}
.wizard-finish-btn {
  width: 100%;
  padding: 16px 24px;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #E2613F 0%, #B84E2F 100%);
  color: #FFFFFF;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform var(--t-spring), box-shadow var(--t), filter var(--t);
  box-shadow: 0 14px 32px -10px rgba(184, 78, 47, 0.55);
}
.wizard-finish-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.05);
  box-shadow: 0 20px 40px -10px rgba(184, 78, 47, 0.72);
}
.wizard-finish-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============= Footer (Précédent / Passer / Compteur live) ============= */

.wizard-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface);
  flex-wrap: wrap;
}

.wizard-foot-btn {
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--t);
}
.wizard-foot-btn:hover:not(:disabled) {
  background: var(--bg-sand);
}
.wizard-foot-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.wizard-foot-skip {
  color: var(--text-soft);
}

.wizard-live-count {
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 0.88rem;
  color: #FFFFFF;
  background: var(--terra);
  padding: 8px 14px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
}
.wizard-live-count[hidden] {
  display: none;
}

/* ============================================================
   Compact mobile — tout doit tenir dans le viewport sans scroll.
   Strategy : grid auto-fit minmax(110px), padding compact, icônes plus
   petites, headers serrés. Couvre purpose (3 cards), type (9 cards),
   budget (6 cards), bedrooms (5 cards), vibe (5 cards).
   ============================================================ */
@media (max-width: 720px) {
  .wizard-modal { max-height: 100svh; height: 100svh; }
  .wizard-header { padding: 10px 14px 10px; gap: 12px; }
  .wizard-close { width: 34px; height: 34px; border-radius: 17px; font-size: 0.9rem; }
  .wizard-progress-wrap { gap: 4px; }
  .wizard-progress-track { height: 5px; }
  .wizard-step-counter { font-size: 0.72rem; }

  .wizard-body { padding: 14px 14px 12px; }
  .wizard-step { gap: 12px; }
  .wizard-step-head { gap: 4px; margin-bottom: 0; }
  .wizard-step-eyebrow { font-size: 0.64rem; letter-spacing: 1px; }
  .wizard-step-title { font-size: clamp(1.15rem, 4.6vw, 1.45rem); line-height: 1.15; }
  .wizard-step-subtitle { font-size: 0.82rem; line-height: 1.35; }

  /* Grille auto-adaptative : 2 colonnes par défaut, 3 si labels courts */
  .wizard-options-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
  }
  /* Si grille avec exactement 3 enfants → 3 colonnes (purpose) */
  .wizard-options-grid:has(> .wizard-card:nth-child(3):last-child) {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  /* Si beaucoup de cards (≥7 → type, budget vente) → 3 colonnes plus serrées */
  .wizard-options-grid:has(> .wizard-card:nth-child(7)) {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  .wizard-card {
    padding: 10px 8px !important;
    min-height: 84px !important;
    gap: 4px;
    border-radius: 12px;
    align-items: center;
    text-align: center;
  }
  .wizard-card.is-selected { padding: 9px 7px !important; }
  .wizard-card-icon {
    width: 34px;
    height: 34px;
    border-radius: 17px;
    font-size: 0.92rem;
  }
  .wizard-card-label { font-size: 0.85rem; }
  .wizard-card-sub { font-size: 0.68rem; line-height: 1.2; }
  .wizard-card-check {
    top: 6px; right: 6px; width: 18px; height: 18px; border-radius: 9px; font-size: 0.6rem;
  }

  .wizard-footer { padding: 8px 14px; gap: 8px; }
  .wizard-foot-btn { padding: 6px 10px; font-size: 0.84rem; }
  .wizard-live-count { font-size: 0.76rem; padding: 6px 10px; min-height: 26px; }
  .wizard-finish-btn { padding: 12px 18px; font-size: 0.96rem; }
}

/* Très petits écrans — encore plus compact */
@media (max-width: 380px) {
  .wizard-card-label { font-size: 0.78rem; }
  .wizard-card-sub { display: none; }
  .wizard-card { min-height: 76px !important; }
}

/* Écrans bas (laptops 768h, paysage mobile) — réduit le padding vertical */
@media (max-height: 680px) {
  .wizard-modal { max-height: 100vh; }
  .wizard-body { padding: 10px 16px; }
  .wizard-step { gap: 8px; }
  .wizard-step-head { gap: 2px; }
  .wizard-card { min-height: 76px !important; padding: 8px 8px !important; }
}

/* Réduction des animations pour les utilisateurs qui le demandent */
@media (prefers-reduced-motion: reduce) {
  .wizard-step,
  .wizard-overlay,
  .wizard-modal,
  .hero-action-card {
    animation: none !important;
    transition: none !important;
  }
}
