/* ═══════════════════════════════════════════════════════════════
   components.css — boutons, chips, champs, feuilles, toasts
   ═══════════════════════════════════════════════════════════════ */

/* ─────────────────────────── Boutons ─────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--touch-sm);
  padding: 0 var(--sp-5);
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--txt);
  font-size: var(--fs-md);
  font-weight: 500;
  border: 1px solid transparent;
  transition: transform 120ms var(--ease), background var(--dur) var(--ease), opacity var(--dur);
  white-space: nowrap;
}
.btn:active { transform: scale(.96); }
.btn[disabled] { opacity: .45; pointer-events: none; }

.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary .ico { fill: var(--accent-ink); }
.btn--ghost { background: transparent; border-color: var(--line); }
.btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn--danger .ico { fill: var(--danger); }
.btn--danger-solid { background: var(--danger); color: #fff; }
.btn--danger-solid .ico { fill: #fff; }
.btn--block { width: 100%; }
.btn--lg { min-height: var(--touch); font-size: var(--fs-lg); padding: 0 var(--sp-6); }

/* Bouton icône rond */
.iconBtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--touch-sm); height: var(--touch-sm);
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--txt);
  transition: transform 120ms var(--ease), background var(--dur) var(--ease);
}
.iconBtn:active { transform: scale(.9); }
.iconBtn--plain { background: transparent; }
.iconBtn--glass {
  background: rgba(20,20,24,.55);
  color: #fff;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
}
.iconBtn--glass .ico { fill: #fff; }
.iconBtn--lg { width: var(--touch); height: var(--touch); }
.iconBtn.is-on { background: var(--accent); color: var(--accent-ink); }
.iconBtn.is-on .ico { fill: var(--accent-ink); }

/* ─────────────────────────── Chips ─────────────────────────── */

.chip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  min-height: 46px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid transparent;
  color: var(--txt-2);
  font-size: var(--fs-sm);
  white-space: nowrap;
  flex: none;
  transition: transform 120ms var(--ease), background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur);
}
.chip:active { transform: scale(.95); }
.chip.is-on {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 600;
}
.chip.is-on .chip__dot { box-shadow: 0 0 0 2px var(--accent-ink); }
.chip--outline { background: transparent; border-color: var(--line); }
.chip--static { pointer-events: none; }

.chip__dot {
  width: 16px; height: 16px; border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(128,128,128,.35);
  flex: none;
}
.chip__count {
  font-size: var(--fs-xs);
  opacity: .7;
  font-variant-numeric: tabular-nums;
}

.chipRow { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* Badge compteur sur le bouton filtres */
.badge {
  min-width: 22px; height: 22px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-full);
  background: var(--accent); color: var(--accent-ink);
  font-size: var(--fs-xs); font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ─────────────────────────── Champs ─────────────────────────── */

.field { display: flex; flex-direction: column; gap: var(--sp-2); }
.field__label {
  font-size: var(--fs-sm);
  color: var(--txt-2);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.input, .textarea, .select {
  width: 100%;
  min-height: var(--touch);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  font-size: var(--fs-md);
  transition: border-color var(--dur) var(--ease);
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); }
.textarea { min-height: 110px; resize: none; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--txt-3); }

/* Recherche */
.search {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: var(--touch-sm);
  padding: 0 var(--sp-4);
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid transparent;
  flex: 1;
  min-width: 0;
}
.search:focus-within { border-color: var(--accent); }
.search .ico { fill: var(--txt-3); }
.search input {
  flex: 1; min-width: 0;
  background: none; border: 0;
  font-size: var(--fs-md);
  height: var(--touch-sm);
}

/* ─────────────────────────── Feuille modale ─────────────────────────── */

.layer { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.layer > * { pointer-events: auto; }

.scrim {
  position: absolute; inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 220ms var(--ease) both;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.sheet {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(760px, 100%);
  max-height: 92%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-3);
  animation: sheetIn 340ms var(--ease-out) both;
  overflow: hidden;
}
@keyframes sheetIn {
  from { transform: translate(-50%, 100%); }
  to   { transform: translate(-50%, 0); }
}
.sheet.is-closing { animation: sheetOut 220ms var(--ease) both; }
@keyframes sheetOut {
  from { transform: translate(-50%, 0); }
  to   { transform: translate(-50%, 100%); }
}

/* En paysage large, la feuille devient une carte centrée */
@media (orientation: landscape) and (min-height: 560px) {
  .sheet {
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    border-radius: var(--r-xl);
    max-height: 86%;
    animation: cardIn 300ms var(--ease-out) both;
  }
  @keyframes cardIn {
    from { transform: translate(-50%, -46%) scale(.96); opacity: 0; }
    to   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  }
  .sheet.is-closing { animation: cardOut 200ms var(--ease) both; }
  @keyframes cardOut {
    from { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    to   { transform: translate(-50%, -48%) scale(.97); opacity: 0; }
  }
  .sheet__grip { display: none; }
}

.sheet__grip {
  width: 48px; height: 5px; border-radius: var(--r-full);
  background: var(--surface-3);
  margin: var(--sp-3) auto var(--sp-1);
  flex: none;
}
.sheet__head {
  flex: none;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5) var(--sp-3);
  border-bottom: 1px solid var(--line-soft);
}
.sheet__title { font-family: var(--font-serif); font-size: var(--fs-lg); }
.sheet__head .iconBtn { margin-left: auto; }
.sheet__body { flex: 1; min-height: 0; padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-5); }
.sheet__foot {
  flex: none;
  display: flex; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5) calc(var(--safe-b) + var(--sp-4));
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
}
.sheet__foot .btn { flex: 1; }

/* ─────────────────────────── Toast ─────────────────────────── */

.toastHost {
  position: fixed;
  left: 50%; bottom: calc(var(--safe-b) + var(--sp-6));
  transform: translateX(-50%);
  z-index: 200;
  display: flex; flex-direction: column; gap: var(--sp-2);
  align-items: center;
  pointer-events: none;
  width: max-content; max-width: 90vw;
}
.toast {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-full);
  background: var(--surface-3);
  color: var(--txt);
  box-shadow: var(--shadow-2);
  font-size: var(--fs-md);
  animation: toastIn 260ms var(--ease-out) both;
}
.toast.is-out { animation: toastOut 220ms var(--ease) both; }
.toast--ok { background: var(--ok); color: #08120c; }
.toast--err { background: var(--danger); color: #fff; }
@keyframes toastIn  { from { opacity: 0; transform: translateY(16px) scale(.96) } to { opacity: 1; transform: none } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(.97) } }

/* ─────────────────────────── Divers ─────────────────────────── */

.spinner {
  width: 22px; height: 22px; flex: none;
  border-radius: 50%;
  border: 2.5px solid currentColor;
  border-top-color: transparent;
  animation: spin .8s linear infinite;
  opacity: .9;
}
@keyframes spin { to { transform: rotate(360deg) } }

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-4);
  padding: var(--sp-8) var(--sp-5);
  text-align: center;
  color: var(--txt-2);
}
.empty__icon { font-size: 56px; opacity: .35; }
.empty__title { font-family: var(--font-serif); font-size: var(--fs-lg); color: var(--txt); }

.divider { height: 1px; background: var(--line-soft); border: 0; margin: 0; }

.sectionTitle {
  display: flex; align-items: baseline; gap: var(--sp-3);
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  margin-bottom: var(--sp-4);
}
.sectionTitle small { font-family: var(--font-sans); font-size: var(--fs-sm); color: var(--txt-3); }
