/**
 * Simulateur Mégalift — options de finition + aperçu en direct.
 *
 * L'aperçu superpose les rendus Sodimas (calques PNG recadrés sur la cabine et
 * convertis en WebP). Les attributs data-parois / data-plinthes / data-sol posés
 * sur #mg-cab décident du calque visible dans chaque famille ; l'ordre du DOM
 * reproduit les z-index du configurateur d'origine.
 */

:root {
  --mg-ink: #010206;
  --mg-amber: #ffc247;
  --mg-body: #474747;
}

/* ── Mise en page ────────────────────────────────────────────── */
.mg-layout { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 32px; align-items: start; }
.mg-preview-col { position: sticky; top: 20px; }
@media (max-width: 1023px) {
  .mg-layout { grid-template-columns: 1fr; }
  .mg-preview-col { position: static; order: -1; }
}

/* ── Groupes d'options ───────────────────────────────────────── */
.mg-group + .mg-group { margin-top: 28px; }
.mg-group-label {
  margin-bottom: 12px;
  font-size: 12px; font-weight: 500; letter-spacing: .16em; text-transform: uppercase;
  color: rgba(0, 0, 0, .62);
}
.mg-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 520px) { .mg-options { grid-template-columns: 1fr; } }

.mg-opt {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; cursor: pointer; background: #fff; text-align: left;
  border: none; font: inherit;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
  transition: box-shadow .2s ease;
}
.mg-opt:hover { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .45); }
.mg-opt[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--mg-amber); }
.mg-opt:focus-visible { outline: 2px solid var(--mg-ink); outline-offset: 2px; }

/* Pastille matière — extrait du rendu correspondant */
.mg-swatch {
  width: 38px; height: 38px; flex-shrink: 0; object-fit: cover;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15);
}

.mg-opt-txt { min-width: 0; }
/* Nom sur sa ligne, description en dessous. */
.mg-opt-name { display: block; font-size: 15px; font-weight: 600; color: var(--mg-ink); }
.mg-opt-sub { display: block; margin-top: 3px; font-size: 12.5px; line-height: 1.35; color: rgba(0, 0, 0, .62); }

/* Variante carte photo — mêmes visuels et mise en page que le simulateur ascenseurs. */
.mg-options-photo { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 520px) { .mg-options-photo { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* Liseré porté par un calque au-dessus : sur le bouton, la photo opaque le
   recouvrirait et il ne resterait visible que le long du libellé. */
.mg-opt-photo { position: relative; display: block; padding: 0; overflow: hidden; text-align: center; }
.mg-opt-photo, .mg-opt-photo:hover, .mg-opt-photo[aria-pressed="true"] { box-shadow: none; }
.mg-opt-photo::after {
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
  transition: box-shadow .2s ease;
}
.mg-opt-photo:hover::after { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .45); }
.mg-opt-photo[aria-pressed="true"]::after { box-shadow: inset 0 0 0 2px var(--mg-amber); }
.mg-opt-img { display: block; aspect-ratio: 443 / 1028; overflow: hidden; background: #fff; }
.mg-opt-img img { width: 100%; height: 100%; object-fit: contain; }
.mg-opt-photo .mg-opt-txt { display: block; padding: 12px; }
.mg-opt-photo .mg-opt-name { font-weight: 500; }

/* ── Aperçu ──────────────────────────────────────────────────── */
.mg-preview { background: #fff; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); }
.mg-preview-head {
  background: var(--mg-ink); color: #fff; padding: 9px 16px;
  font-size: 11px; font-weight: 500; letter-spacing: .16em; text-transform: uppercase;
}
/* Empilement de calques : le premier fixe la hauteur, les autres se superposent. */
.mg-cab { position: relative; display: block; width: 100%; background: #f7f6f3; }
.mg-layer { display: block; width: 100%; height: auto; }
.mg-layer + .mg-layer { position: absolute; inset: 0; }

.mg-recap { padding: 14px 16px; }
.mg-line {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 7px 0; border-bottom: 1px solid rgba(0, 0, 0, .07);
}
.mg-line-l { font-size: 12px; color: rgba(0, 0, 0, .62); }
.mg-line-v { font-size: 13px; font-weight: 500; color: var(--mg-ink); }
.mg-std { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.mg-std li {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12.5px; line-height: 1.45; color: var(--mg-body);
}
.mg-std svg { margin-top: 2px; flex-shrink: 0; color: var(--mg-amber); }
.mg-cta { padding: 0 16px 16px; }
.mg-cta a { width: 100%; justify-content: center; }

/* ── Visibilité des calques pilotée par les choix ─────────────── */
.mg-l-portes, .mg-l-parois, .mg-l-plinthes, .mg-l-sol, .mg-l-boutons { opacity: 0; transition: opacity .25s ease; }
.mg-cab[data-portes="traversant"] .mg-l-portes[data-value="traversant"],
.mg-cab[data-boutons="inox"]   .mg-l-boutons[data-value="inox"],
.mg-cab[data-boutons="or"]     .mg-l-boutons[data-value="or"],
.mg-cab[data-boutons="noir"]   .mg-l-boutons[data-value="noir"],
.mg-cab[data-boutons="sensy"]  .mg-l-boutons[data-value="sensy"],
.mg-cab[data-parois="inox"]    .mg-l-parois[data-value="inox"],
.mg-cab[data-parois="epoxy"]   .mg-l-parois[data-value="epoxy"],
.mg-cab[data-plinthes="inox"]  .mg-l-plinthes[data-value="inox"],
.mg-cab[data-plinthes="epoxy"] .mg-l-plinthes[data-value="epoxy"],
.mg-cab[data-sol="alu"]        .mg-l-sol[data-value="alu"],
.mg-cab[data-sol="inox"]       .mg-l-sol[data-value="inox"],
.mg-cab[data-sol="acier"]      .mg-l-sol[data-value="acier"],
.mg-cab[data-sol="pvc"]        .mg-l-sol[data-value="pvc"] { opacity: 1; }
