/* Configurateur Madly — mise en page en flux, 3 breakpoints
   ≥1200 : scène à gauche, rail 360 px à droite
   768–1199 : scène en haut, panneau dessous
   <768 : scène en haut, bottom sheet à deux hauteurs, familles fixées en bas */
:root {
  --bg: #0B0910; --bg2: #14111C; --bg3: #1A1724;
  --fg: #fff; --fg2: rgba(255,255,255,.72); --fg3: rgba(255,255,255,.5);
  --line: rgba(255,255,255,.12); --line2: rgba(255,255,255,.2);
  --glass: linear-gradient(145deg, rgba(58,54,66,.19) 0%, rgba(26,23,32,.15) 46%, rgba(14,12,18,.18) 100%);
  --radius: 20px; --rail: 360px;
  --font-title: Poppins, system-ui, sans-serif; --font: Nunito, system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.4 var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
h1, h2 { margin: 0; }
[hidden] { display: none !important; }

/* ------------------------------------------------ scène */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.stage { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #0A0806; overflow: hidden; isolation: isolate; }
.stage__canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; cursor: grab; }
.stage.is-drag .stage__canvas { cursor: grabbing; }
.stage.is-still .stage__canvas { cursor: default; }
.stage__load { position: absolute; left: 24px; right: 24px; bottom: 12px; height: 2px; border-radius: 2px; background: rgba(255,255,255,.14); overflow: hidden; transition: opacity .4s; z-index: 2; }
.stage__load b { display: block; height: 100%; width: 0; background: #fff; box-shadow: 0 0 10px rgba(255,255,255,.8); transition: width .2s linear; }
.stage__load.is-done { opacity: 0; }

.head { position: absolute; left: 0; right: 0; top: 0; z-index: 3; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 14px 20px 10px; background: linear-gradient(180deg, rgba(8,7,11,.72), rgba(8,7,11,0)); pointer-events: none; }
.head__name { font: 800 clamp(18px, 2.2vw, 26px)/1.05 var(--font-title); letter-spacing: -.02em; }
.head__sub { margin-top: 6px; display: flex; align-items: center; gap: 10px; font: 600 10px var(--font-title); letter-spacing: .16em; color: var(--fg2); text-transform: uppercase; }
.head__sub i { width: 3px; height: 3px; border-radius: 50%; background: rgba(255,255,255,.35); }
.specs { list-style: none; margin: 0; padding: 0; display: flex; gap: clamp(12px, 2vw, 26px); }
.specs li { text-align: left; }
.specs b { display: block; font: 800 clamp(15px, 1.8vw, 23px)/1 var(--font-title); }
.specs b small { font-size: .55em; color: var(--fg2); margin-left: 4px; font-weight: 700; }
.specs span { display: block; margin-top: 4px; font: 600 9px var(--font-title); letter-spacing: .14em; color: var(--fg3); }

.views { position: absolute; left: 16px; top: 76px; z-index: 3; display: flex; gap: 8px; }
.views__btn { width: 58px; height: 42px; border-radius: 11px; border: 1px solid rgba(255,255,255,.18); background: var(--bg2) center/cover; box-shadow: 0 6px 16px rgba(0,0,0,.35); color: #fff; display: flex; align-items: center; justify-content: center; transition: border-color .2s, box-shadow .2s; }
.views__btn.is-on { border-color: rgba(255,255,255,.95); box-shadow: 0 0 16px rgba(255,255,255,.4); }
.views__btn[data-view="rotation"] { background: rgba(26,21,34,.75); backdrop-filter: blur(10px); }
.views__btn[data-view="rotation"].is-on { background: rgba(255,255,255,.92); color: #14111C; }

.hint { position: absolute; left: 50%; bottom: 8%; transform: translateX(-50%); z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 4px; color: rgba(255,255,255,.85); font: 600 9.5px var(--font-title); letter-spacing: .14em; text-transform: uppercase; pointer-events: none; transition: opacity .3s; text-shadow: 0 1px 8px rgba(0,0,0,.7); }
.hint.is-off { opacity: 0; }

.busy { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: rgba(8,7,11,.35); backdrop-filter: blur(3px); }
.busy__ring { width: 46px; height: 46px; border-radius: 50%; border: 2px solid rgba(255,255,255,.16); border-top-color: #fff; animation: turn .9s linear infinite; }
.busy__label { font: 700 9px var(--font-title); letter-spacing: .18em; color: rgba(255,255,255,.85); }
@keyframes turn { to { transform: rotate(360deg); } }

/* ------------------------------------------------ rail */
.rail { display: flex; flex-direction: column; gap: 14px; padding: 14px 16px calc(16px + var(--safe-b)); background: var(--bg); }
.rail__grip { display: none; }

.vehicles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.veh { min-width: 0; border-radius: 14px; overflow: hidden; background: #15121C; border: 1.5px solid rgba(255,255,255,.1); box-shadow: 0 8px 22px rgba(0,0,0,.35); text-align: left; transition: border-color .2s, box-shadow .2s; }
.veh.is-on { border-color: rgba(255,255,255,.9); box-shadow: 0 0 18px rgba(255,255,255,.3), 0 8px 22px rgba(0,0,0,.35); }
.veh__img { display: block; aspect-ratio: 16 / 10; background: var(--bg2) center/cover; }
.veh__cap { display: block; padding: 6px 8px 7px; text-align: center; font: 700 11px var(--font-title); letter-spacing: .03em; background: #15121C; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.veh.is-on .veh__cap { background: #2A2438; }
.veh__cap small { display: block; font: 600 9px var(--font-title); color: var(--fg3); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 2px; }

.families { display: flex; justify-content: space-between; gap: 6px; }
.fam { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--fg2); min-width: 44px; }
.fam__disc { width: 50px; height: 50px; border-radius: 50%; background: rgba(26,21,34,.6); border: 1.5px solid rgba(255,255,255,.16); display: flex; align-items: center; justify-content: center; transition: background .2s, box-shadow .2s, border-color .2s; }
.fam__label { font: 700 9px var(--font-title); letter-spacing: .12em; text-transform: uppercase; }
.fam.is-on { color: #fff; }
.fam.is-on .fam__disc { background: linear-gradient(180deg, rgba(255,255,255,.3), rgba(255,255,255,.12)); border-color: rgba(255,255,255,.85); box-shadow: 0 0 22px rgba(255,255,255,.55); }

.panels { flex: 1; }
.panel { border-radius: var(--radius); background: var(--glass); border: 1px solid var(--line2); box-shadow: 0 18px 44px rgba(0,0,0,.4); padding: 12px 14px 14px; }
.panel__title { font: 700 9.5px var(--font-title); letter-spacing: .16em; text-transform: uppercase; color: var(--fg3); margin: 4px 0 10px; }
.panel__title + .panel__title { margin-top: 0; }
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.swatches--small { grid-template-columns: repeat(3, 1fr); }
.sw { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 0; }
.sw__chip { position: relative; width: 48px; height: 52px; }
.sw__ring { position: absolute; inset: 0; background: rgba(255,255,255,.22); clip-path: polygon(22% 0, 100% 0, 78% 100%, 0 100%); transition: background .2s; }
.sw__fill { position: absolute; inset: 2px; clip-path: polygon(22% 0, 100% 0, 78% 100%, 0 100%); }
.sw.is-on .sw__ring { background: rgba(255,255,255,.95); }
.sw.is-on .sw__fill { inset: 3px; }
.sw__label { font: 700 10px var(--font-title); color: var(--fg2); text-align: center; line-height: 1.2; }
.sw__price { font: 10px var(--font); color: var(--fg3); white-space: nowrap; }
.sw.is-on .sw__label, .sw.is-on .sw__price { color: #fff; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
/* Le bouton et son bloc image etaient en ligne : le format carre etait ignore et
   l'image de jante ne s'affichait pas du tout (Alex 15/09). display:block partout. */
.tile { display: block; width: 100%; border-radius: 14px; overflow: hidden; border: 2px solid rgba(255,255,255,.1); background: rgba(255,255,255,.04); transition: border-color .2s, box-shadow .2s; }
.tile.is-on { border-color: rgba(255,255,255,.9); box-shadow: 0 0 18px rgba(255,255,255,.3); }
.tile__img { display: block; width: 100%; aspect-ratio: 1; background: radial-gradient(circle at 50% 45%, #2a2633, #15121C 70%) center/70% no-repeat; }
/* libelle sur une ligne, prix en dessous : « +1 200 € » ne se coupe plus en deux */
.tile__cap { padding: 6px 8px 7px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.tile__cap b { font: 700 10.5px/1.2 var(--font-title); }
.tile__cap span { font: 10px var(--font); color: var(--fg3); white-space: nowrap; }
.tile.is-on .tile__cap span { color: rgba(255,255,255,.85); }

.tech { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.specs--panel { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 14px; margin: 0 0 14px; padding: 0; list-style: none; }
.specs--panel b { display: block; font: 800 20px/1 var(--font-title); }
.specs--panel b small { font-size: .55em; color: var(--fg2); margin-left: 4px; }
.specs--panel span { display: block; margin-top: 4px; font: 600 9px var(--font-title); letter-spacing: .14em; color: var(--fg3); }
.tech dt { font: 600 9px var(--font-title); letter-spacing: .16em; color: var(--fg3); text-transform: uppercase; }
.tech dd { margin: 3px 0 0; font: 700 12.5px var(--font-title); }

.price { display: flex; align-items: center; gap: 12px; min-width: 0; border-radius: var(--radius); background: var(--glass); border: 1px solid var(--line2); box-shadow: 0 18px 44px rgba(0,0,0,.4); padding: 12px 12px 12px 16px; }
.price__txt { flex: 1 1 0; min-width: 0; overflow: hidden; }
.price__base { font: 11px var(--font); color: var(--fg3); }
.price__row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.price__total { font: 800 clamp(19px, 2vw, 23px)/1 var(--font-title); letter-spacing: -.02em; transition: transform .25s; }
.price__total.is-bump { transform: translateY(-3px); }
.price__delta { font: 600 10px var(--font-title); color: var(--fg2); }
.cta { flex: none; height: 48px; padding: 0 20px; border-radius: 999px; background: rgba(255,255,255,.94); color: #14111C; font: 700 13px var(--font-title); white-space: nowrap; }
.cta--ghost { width: 100%; margin-top: 14px; background: rgba(255,255,255,.04); color: #fff; border: 1px solid var(--line2); }
.link { display: block; width: 100%; margin-top: 10px; text-align: center; font: 12px var(--font); color: var(--fg3); }
.pill { height: 34px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line2); font: 700 9.5px var(--font-title); letter-spacing: .14em; text-transform: uppercase; color: rgba(255,255,255,.85); }

/* ------------------------------------------------ récap */
.recap { position: fixed; inset: 0; z-index: 20; background: #0E0C13; overflow: auto; padding: 18px clamp(14px, 3vw, 24px) calc(24px + var(--safe-b)); }
.recap__head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.recap__back { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line2); font: 700 18px var(--font-title); color: var(--fg2); }
.recap__title { font: 800 clamp(18px, 2vw, 22px)/1 var(--font-title); letter-spacing: -.01em; }
.recap__sub { margin-top: 6px; font: 700 9px var(--font-title); letter-spacing: .16em; color: rgba(255,255,255,.45); text-transform: uppercase; }
.recap__actions { margin-left: auto; display: flex; gap: 10px; }
.recap__body { margin-top: 18px; display: grid; grid-template-columns: 1fr; gap: 18px; }
.recap__visuals { display: flex; flex-direction: column; gap: 14px; }
.recap__fig { margin: 0; position: relative; border-radius: 16px; overflow: hidden; border: 1px solid rgba(255,255,255,.08); background: var(--bg2); }
.recap__fig img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.recap__fig--big img { aspect-ratio: 16 / 9; }
.recap__fig figcaption { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; background: rgba(255,255,255,.05); font: 700 10px var(--font-title); letter-spacing: .1em; text-transform: uppercase; }
.recap__fig figcaption span { font: 11px var(--font); color: var(--fg3); text-transform: none; letter-spacing: 0; }
.recap__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.recap__grid img { aspect-ratio: 16 / 9; }
.recap__fig--carte img { object-fit: contain; padding: 4px; box-sizing: border-box; }
.recap__fig img[src=""] { visibility: hidden; }
@media (min-width: 900px) { .recap__body { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); align-items: start; } }
@media (max-width: 599px) { .recap__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.recap__side { display: flex; flex-direction: column; gap: 16px; }
.card { background: linear-gradient(180deg, #1A1724, #141119); border: 1px solid rgba(255,255,255,.1); border-radius: 18px; padding: 18px 20px; }
.card__k { font: 700 9px var(--font-title); letter-spacing: .18em; color: var(--fg3); }
.lines { margin-top: 12px; display: flex; flex-direction: column; gap: 9px; }
.line { display: flex; justify-content: space-between; gap: 16px; font: 12.5px var(--font); color: rgba(255,255,255,.82); padding: 4px 0; }
.line span:last-child { color: var(--fg3); }
.line.is-dim { color: var(--fg3); }
.line--total { margin-top: 10px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); align-items: flex-end; font: 700 9.5px var(--font-title); letter-spacing: .16em; color: var(--fg2); }
.line--total b { font: 800 26px/1 var(--font-title); letter-spacing: -.02em; color: #fff; }

.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); z-index: 30; padding: 8px 14px; border-radius: 999px; background: rgba(26,21,34,.85); border: 1px solid var(--line2); backdrop-filter: blur(14px); font: 600 10px var(--font-title); letter-spacing: .1em; text-transform: uppercase; }

/* pendant le drag : plus de flou de fond, ça coûte une recomposition par image */
.app.is-drag .panel, .app.is-drag .price, .app.is-drag .views__btn[data-view="rotation"] { backdrop-filter: none; background: rgba(20,17,28,.92); }

/* ================================================ ≥ 1200 : rail à droite */
@media (min-width: 1200px) {
  .app { flex-direction: row; height: 100dvh; min-height: 0; }
  .stage { flex: 1; aspect-ratio: auto; height: 100%; }
  .stage__canvas { object-fit: contain; }
  .rail { width: var(--rail); flex: none; height: 100%; overflow: auto; border-left: 1px solid var(--line); padding: 16px 16px calc(16px + var(--safe-b)); }
  .vehicles { grid-template-columns: repeat(3, 1fr); }
  .price { position: sticky; bottom: 0; margin-top: auto; }
}

/* ================================================ 768–1199 : scène puis panneau */
@media (min-width: 768px) and (max-width: 1199px) {
  .rail { display: grid; grid-template-columns: 1fr 1fr; grid-template-areas: "veh veh" "fam fam" "panels price"; align-items: start; gap: 14px 16px; padding: 16px clamp(16px, 3vw, 28px) calc(20px + var(--safe-b)); }
  .vehicles { grid-area: veh; grid-template-columns: repeat(3, minmax(0, 220px)); justify-content: center; }
  .families { grid-area: fam; max-width: 520px; margin: 0 auto; width: 100%; }
  .panels { grid-area: panels; }
  .price { grid-area: price; position: sticky; top: 10px; }
}

/* ================================================ < 768 : bottom sheet */
@media (max-width: 767px) {
  .app { height: 100dvh; min-height: 0; overflow: hidden; }
  .stage { flex: none; }
  .head { padding: 10px 12px 8px; }
  .head__sub { font-size: 9px; letter-spacing: .12em; }
  .head .specs { display: none; }
  .views { left: 10px; top: auto; bottom: 10px; }
  .views__btn { width: 46px; height: 44px; }
  .hint { left: auto; right: 12px; bottom: 18px; transform: none; flex-direction: row; gap: 8px; }
  .hint svg { width: 26px; height: 26px; }
  .stage__load { bottom: 60px; }

  .rail { position: relative; flex: 1; min-height: 0; overflow: auto; padding: 8px 12px calc(96px + var(--safe-b)); border-top-left-radius: 22px; border-top-right-radius: 22px; background: #0F0D15; transition: transform .3s; }
  .rail__grip { display: flex; justify-content: center; padding: 2px 0 8px; }
  .rail__grip i { width: 38px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.22); }
  .vehicles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .veh__cap { font-size: 10px; padding: 5px 4px 6px; }
  .veh__img { aspect-ratio: 16 / 9; }
  .veh__cap small { font-size: 8px; }
  .panel { padding: 10px 10px 12px; }
  .swatches { grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .sw__label { font-size: 9.5px; }
  .tiles { gap: 6px; }
  .tile__cap { padding: 5px 6px 6px; }

  /* barre du bas fixe : familles + total + CTA, toujours visibles */
  .families { position: fixed; left: 0; right: 0; bottom: 0; z-index: 12; padding: 8px 8px calc(8px + var(--safe-b)); background: rgba(11,9,16,.92); backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
  .fam__disc { width: 40px; height: 40px; }
  .fam__disc svg { width: 19px; height: 19px; }
  .fam__label { font-size: 8px; letter-spacing: .08em; }
  .price { position: fixed; left: 8px; right: 8px; width: auto; bottom: calc(76px + var(--safe-b)); z-index: 11; padding: 8px 8px 8px 12px; }
  .price__total { font-size: 18px; }
  .cta { height: 42px; padding: 0 16px; font-size: 12px; }
  .price__base { font-size: 10px; }

  /* sheet repliée : seules les vignettes véhicules sont visibles, on tire pour déplier */
  .app.is-collapsed .rail { overflow: hidden; }
  .app.is-collapsed .panels { display: none; }

  .recap__actions { width: 100%; margin-left: 0; }
}
@media (min-width: 768px) {
  .rail__grip { display: none; }
}
