/* ============================================================================
 * MODALE DEVIS — formulaire multi-step (3 étapes), Swiss, poste sur /api/devis
 * ========================================================================= */

.modal {
  position: fixed;
  inset: 0;
  z-index: 9800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-3);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 280ms var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1)),
    visibility 0s linear 280ms;
}
.modal.is-open {
  opacity: 1;
  visibility: visible;
  transition:
    opacity 280ms var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1)),
    visibility 0s;
}
.modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(17, 19, 22, 0.72);
  backdrop-filter: blur(3px);
}
.modal__card {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 2 * var(--s-3));
  overflow-y: auto;
  background: var(--paper);
  border-top: 3px solid var(--accent);
  transform: translateY(24px) scale(0.98);
  transition: transform 320ms var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
}
.modal.is-open .modal__card {
  transform: translateY(0) scale(1);
}

.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-5) var(--s-5) var(--s-3);
}
.modal__eyebrow {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.modal__title {
  margin-top: 6px;
  font-size: var(--t-h3);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.modal__close {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--paper);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  transition:
    background-color 160ms ease,
    color 160ms ease;
}
.modal__close:hover {
  background: var(--ink);
  color: var(--paper);
}

/* — Barre de progression (3 segments) — */
.modal__progress {
  display: flex;
  gap: 6px;
  padding: 0 var(--s-5) var(--s-4);
}
.modal__progress span {
  flex: 1;
  height: 3px;
  background: var(--line);
  transition: background-color 280ms ease;
}
.modal__progress span.is-active,
.modal__progress span.is-done {
  background: var(--accent);
}

/* — Étapes — */
.modal__body {
  padding: 0 var(--s-5) var(--s-5);
}
.mstep {
  display: none;
}
.mstep.is-current {
  display: block;
  animation: mstepIn 320ms var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
}
@keyframes mstepIn {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
.mstep__legend {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--s-3);
}

.mfield {
  display: flex;
  flex-direction: column;
  margin-bottom: var(--s-3);
}
.mfield--row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-3);
}
.mfield label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.mfield input,
.mfield select,
.mfield textarea {
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 14px;
  width: 100%;
  transition: border-color 160ms ease;
}
.mfield input:focus,
.mfield select:focus,
.mfield textarea:focus {
  outline: none;
  border-color: var(--ink);
}
.mfield input[aria-invalid='true'],
.mfield select[aria-invalid='true'] {
  border-color: var(--accent);
}
.mfield__err {
  color: var(--accent);
  font-size: 0.76rem;
  margin-top: 5px;
  min-height: 1em;
}

/* choix segmentés (type d'événement) */
.mchoice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.mchoice__opt {
  position: relative;
  border: 1px solid var(--line);
  padding: 12px 14px;
  cursor: pointer;
  font-size: 0.9rem;
  transition:
    border-color 160ms ease,
    background-color 160ms ease;
}
.mchoice__opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.mchoice__opt:hover {
  border-color: var(--ink-3);
}
.mchoice__opt:has(input:checked) {
  border-color: var(--accent);
  background: rgba(11, 92, 171, 0.06);
  font-weight: 600;
}

/* honeypot */
.modal .hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* — Footer (navigation steps) — */
.modal__nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin-top: var(--s-4);
}
.modal__nav .btn {
  padding: 14px 24px;
}
/* .btn est inline-flex → un [hidden] natif ne suffit pas, on force. */
.modal__nav .btn[hidden] {
  display: none;
}
.modal__back {
  background: transparent;
  border: none;
  color: var(--ink-3);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 8px 4px;
}
.modal__back:hover {
  color: var(--ink);
}
.modal__back[hidden] {
  visibility: hidden;
}
.modal__error {
  color: var(--accent);
  font-size: 0.85rem;
  margin-top: var(--s-3);
}

/* — Écran de confirmation — */
.modal__done {
  display: none;
  text-align: center;
  padding: var(--s-6) var(--s-5);
}
.modal__done.is-shown {
  display: block;
  animation: mstepIn 320ms var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
}
.modal__done-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--s-3);
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}
.modal__done-title {
  font-size: var(--t-h3);
  font-weight: 600;
}
.modal__done-text {
  margin-top: var(--s-2);
  color: var(--ink-2);
  line-height: 1.6;
}

@media (max-width: 480px) {
  .mfield--row,
  .mchoice {
    grid-template-columns: 1fr;
  }
  .modal__card {
    border-top-width: 3px;
  }
}
