/* ==========================================================================
   MGP MOTO — « NOUVELLE GARDE » · LA FICHE (/vehicule/<id>/)
   Propriétaire : agent CATALOGUE. Gabarit : templates/pages/vehicule.html
   ========================================================================== */

/* --- Bandeau « masquée » (membre connecté seulement) ---------------------- */
.fiche-masquee {
  position: fixed; z-index: calc(var(--z-nav) - 1); left: 50%; top: calc(var(--nav-h) + .6rem);
  transform: translateX(-50%); width: max-content; max-width: calc(100% - 2 * var(--gutter));
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem 1rem .55rem .55rem; border-radius: var(--radius-pill);
  background: var(--warn); color: var(--ink-950); font-size: var(--fs-small); line-height: 1.3;
  box-shadow: var(--shadow-2);
}
.fiche-masquee .label { padding: .35rem .6rem; border-radius: var(--radius-pill); background: var(--ink-950); color: var(--warn); }

/* --- Ouverture ------------------------------------------------------------ */
.fiche-hero { padding-top: calc(var(--nav-h) + clamp(1.25rem, 3.5vh, 3rem)); padding-bottom: clamp(1.75rem, 3.5vw, 3rem); }
.fiche-hero__meta { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .7rem; margin-top: clamp(1.75rem, 4vh, 3rem); color: var(--paper-dim); }
.fiche-hero__meta a { transition: color var(--dur-2); }
.fiche-hero__meta a:hover { color: var(--paper); }
.fiche-hero__brand { color: var(--ember); }
a.fiche-hero__brand:hover { color: var(--ember-hot) !important; }
.fiche-hero__sep { color: var(--ink-500); }
.fiche-hero__title {
  margin-top: .9rem;
  font-family: var(--font-display); font-stretch: var(--wdth-display); font-weight: 900;
  font-size: clamp(2.7rem, .9rem + 6vw, 7.5rem); line-height: .88; letter-spacing: -.04em; text-transform: uppercase;
  text-wrap: balance; overflow-wrap: break-word;
}
.fiche-hero__line { margin-top: clamp(1rem, 2vw, 1.5rem); max-width: 36em; }
.fiche-hero__badges { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: clamp(1.25rem, 2.5vw, 1.75rem); list-style: none; padding: 0; }

/* --- Corps : colonne principale + bloc prix collant ----------------------- */
.fiche-body { padding-bottom: clamp(4rem, 3rem + 5vw, 8rem); }
.fiche-body__grid { display: grid; gap: clamp(1.75rem, 3vw, 3rem); align-items: start; }
.fiche-main { min-width: 0; }
@media (min-width: 1100px) {
  .fiche-body__grid { grid-template-columns: minmax(0, 1fr) clamp(20rem, 24vw, 25rem); gap: clamp(2.5rem, 4vw, 4.5rem); }
  .fiche-aside { position: sticky; top: calc(var(--nav-h) + 1.25rem); }
}
@media (max-width: 1099px) {
  /* Le bloc prix vient juste sous la photo, avant les chiffres et la galerie. */
  .fiche-main { display: contents; }
  .fiche-photo, .fiche-cover { order: 1; }
  .fiche-aside { order: 2; }
  .fiche-chiffres { order: 3; margin-top: 0 !important; }
  .fiche-galerie { order: 4; }
}

/* Photo principale : ratio natif, rien n'est recadré. */
.fiche-photo { margin: 0; }
.fiche-photo__link { display: block; position: relative; overflow: hidden; border-radius: var(--radius-m); background: var(--ink-850); }
.fiche-photo__img { display: block; width: 100%; height: auto; max-height: 86vh; object-fit: cover; transition: transform var(--dur-5) var(--ease-out); transform-origin: 0 0; }
.fiche-photo__link:hover .fiche-photo__img { transform: scale(1.025); }
.fiche-photo__cap { display: flex; justify-content: space-between; gap: 1rem; margin-top: .85rem; color: var(--mute); }

/* Sans photo : couverture typographique */
.fiche-cover {
  position: relative; overflow: hidden; isolation: isolate;
  min-height: 15rem; border-radius: var(--radius-m);
  display: flex; flex-direction: column; justify-content: flex-end; gap: 1rem;
  padding: clamp(1.25rem, 4cqi, 3rem);
  container-type: inline-size;
  background:
    radial-gradient(90% 70% at 100% 0%, rgba(255, 77, 31, .13), transparent 60%),
    linear-gradient(160deg, var(--ink-800), var(--ink-900) 70%);
  box-shadow: inset 0 0 0 1px var(--line);
}
@media (min-width: 760px) { .fiche-cover { aspect-ratio: 16 / 7; min-height: 0; } }
.fiche-cover__watermark { position: absolute; z-index: -1; left: 50%; top: 46%; width: 62%; max-height: 34%; object-fit: contain; transform: translate(-50%, -50%); filter: brightness(0) invert(1); opacity: .16; }
.fiche-cover__star { position: absolute; top: clamp(1.25rem, 4cqi, 3rem); right: clamp(1.25rem, 4cqi, 3rem); width: clamp(2.5rem, 7cqi, 4.5rem); --star-stroke: 1px; --star-color: var(--gold); }
.fiche-cover__note { max-width: 34em; color: var(--paper-dim); font-size: var(--fs-small); line-height: 1.5; }

/* Chiffres héros */
.fiche-chiffres { margin-top: clamp(2.5rem, 5vw, 4rem); }

/* --- Galerie éditoriale : rangées « justifiées », aucune photo recadrée ---- */
.fiche-galerie { margin-top: clamp(4rem, 8vw, 7rem); }
.fiche-galerie__head { display: grid; gap: .9rem; margin-bottom: clamp(1.5rem, 3vw, 2.5rem); }
.fiche-galerie__head .label--dim { color: var(--mute); }
.fiche-rows { display: grid; gap: clamp(.5rem, 1.1vw, 1rem); }
.fiche-row { display: flex; gap: clamp(.5rem, 1.1vw, 1rem); }
.fiche-shot {
  position: relative; display: block; overflow: hidden;
  flex: var(--r, 1.5) 1 0; min-width: 0; aspect-ratio: var(--r, 1.5);
  border-radius: var(--radius-m); background: var(--ink-850);
}
.fiche-shot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform var(--dur-5) var(--ease-out); }
.fiche-shot:hover img, .fiche-shot:focus-visible img { transform: scale(1.04); }
.fiche-shot__n {
  position: absolute; left: .7rem; bottom: .7rem; z-index: 1;
  padding: .3rem .5rem; border-radius: var(--radius-xs);
  background: rgba(7, 7, 9, .62); color: var(--paper);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
/* Mosaïque franche : chaque rangée occupe toute la largeur de la colonne,
   alignée aux deux bords, gouttières égales ; la hauteur de rangée découle
   des ratios (aucune photo recadrée). */

/* --- Bloc prix -------------------------------------------------------------- */
.fiche-buy {
  display: grid; gap: 1.15rem;
  padding: clamp(1.4rem, 1.1rem + 1vw, 2rem);
  border-radius: var(--radius-l);
  background: var(--ink-900);
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-1);
}
.fiche-buy__dispo { display: flex; align-items: center; gap: .6rem; color: var(--paper-dim); }
.fiche-buy__dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--ok); flex: none; }
.fiche-buy__dot--off { background: transparent; box-shadow: inset 0 0 0 1px var(--paper-dim); }
.fiche-buy__price { padding-block: .25rem .35rem; }
.fiche-buy__now {
  font-family: var(--font-display); font-stretch: var(--wdth-display); font-weight: 800;
  font-size: clamp(2.6rem, 2rem + 1.6vw, 3.6rem); line-height: .9; letter-spacing: -.045em;
  font-variant-numeric: tabular-nums;
}
.fiche-buy__was { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .9rem; margin-top: .7rem; }
.fiche-buy__was del { font: 400 var(--fs-small)/1 var(--font-mono); color: var(--mute); text-decoration-color: var(--ember); }
.fiche-buy__save { font: 600 var(--fs-label)/1 var(--font-mono); letter-spacing: var(--track-label); text-transform: uppercase; color: var(--ember); }
.fiche-buy__ask {
  font-family: var(--font-display); font-stretch: var(--wdth-display); font-weight: 800;
  font-size: clamp(1.6rem, 1.3rem + 1vw, 2.2rem); line-height: 1; letter-spacing: -.02em; text-transform: uppercase;
}
.fiche-buy__line { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding-top: .9rem; border-top: 1px solid var(--line); font-size: var(--fs-small); text-align: right; }
.fiche-buy__line .label { flex: none; }
.fiche-buy__actions { display: grid; gap: .6rem; margin-top: .4rem; }
.fiche-buy__actions .btn--block { justify-content: space-between; }
.fiche-buy__phone {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  padding: .85rem; border-radius: var(--radius-pill);
  font: 500 var(--fs-small)/1 var(--font-mono); letter-spacing: .04em; color: var(--paper-dim);
  transition: color var(--dur-2), background var(--dur-2);
}
.fiche-buy__phone svg { width: 1rem; height: 1rem; }
.fiche-buy__phone:hover { color: var(--paper); background: var(--ink-800); }
.fiche-buy__open { display: flex; justify-content: center; padding-top: .9rem; border-top: 1px solid var(--line); }

/* --- Barre basse collante ----------------------------------------------- */
.fiche-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sticky);
  padding: .65rem var(--gutter) max(.65rem, env(safe-area-inset-bottom));
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-top: 1px solid var(--line);
  transition: transform .7s var(--ease-out);
}
.fiche-bar__inner { display: flex; align-items: center; gap: .55rem; max-width: var(--container); margin-inline: auto; }
.fiche-bar__id { flex: 1; min-width: 0; }
.fiche-bar__name {
  font-family: var(--font-display); font-stretch: var(--wdth-display); font-weight: 800;
  font-size: .95rem; line-height: 1.1; letter-spacing: -.01em; text-transform: uppercase;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fiche-bar__price { margin-top: .2rem; font: 500 var(--fs-small)/1.1 var(--font-mono); color: var(--paper-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fiche-bar__price del { color: var(--mute); font-size: .85em; text-decoration-color: var(--ember); }
/* Sans JavaScript la barre reste affichée : on réserve sa hauteur sous le pied de page.
   Avec JavaScript elle s'efface dès que le bandeau final ou le pied de page arrive. */
@media (max-width: 1099px) { html.no-js .page-vehicule { padding-bottom: calc(4.4rem + env(safe-area-inset-bottom)); } }
@media (max-width: 379px) { .fiche-bar__offre { display: none; } }
/* JavaScript : la barre n'apparaît qu'une fois le bloc prix sorti de l'écran. */
html.js .fiche-bar { transform: translateY(110%); }
html.js .fiche-bar.is-visible { transform: none; }
@media (min-width: 1100px) { html.no-js .fiche-bar { display: none; } }

/* --- Description (section claire) ---------------------------------------- */
.fiche-texte { font-size: 1.08rem; line-height: 1.7; max-width: 40em; }
.fiche-texte strong { font-weight: 650; }
.fiche-texte.is-folded { max-height: 26rem; overflow: hidden; -webkit-mask-image: linear-gradient(#000 62%, transparent); mask-image: linear-gradient(#000 62%, transparent); }
.fiche-texte__more { margin-top: 1.25rem; }
.fiche-texte__more[aria-expanded="true"] .btn__arrow { transform: rotate(45deg); }

.fiche-equip { padding-top: 1.25rem; border-top: 2px solid var(--ink-on-paper); }
.fiche-equip__label { color: var(--mute-on-paper); margin-bottom: 1rem; }
.fiche-equip__list { list-style: none; padding: 0; }
.fiche-equip__list li { display: grid; grid-template-columns: 1.1rem 1fr; gap: .75rem; padding-block: .7rem; border-bottom: 1px solid var(--line); font-size: .95rem; line-height: 1.45; }
.fiche-equip__list svg { width: 1.05rem; height: 1.05rem; margin-top: .15rem; color: var(--ember-deep); fill: none; stroke: currentColor; }
@media (max-width: 1099px) { .fiche-equip { margin-top: 2.5rem; } }

/* --- Fiche technique ----------------------------------------------------- */
.fiche-tech__tables { display: grid; gap: 2.5rem clamp(2rem, 4vw, 4rem); grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr)); align-items: start; }
.fiche-tech__tables .table-data tbody th { font-weight: 500; color: var(--paper-dim); }
.fiche-tech__tables .table-data td.num { color: var(--paper); font-size: .95rem; }
.fiche-tech__unit { color: var(--mute); font-size: .85em; }
.fiche-tech__note { margin-top: clamp(2rem, 4vw, 3rem); max-width: 46em; font-size: var(--fs-small); color: var(--mute); }

/* --- Visionneuse plein écran ---------------------------------------------- */
.viewer {
  position: fixed; inset: 0; z-index: var(--z-modal);
  width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: #050507; color: var(--paper);
  overflow: hidden;
}
.viewer::backdrop { background: transparent; }
.viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.viewer__top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; padding: .9rem var(--gutter); }
.viewer__count { font-variant-numeric: tabular-nums; color: var(--paper); }
.viewer__title { color: var(--paper-dim); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer__close { justify-self: end; }
.viewer__stage { position: relative; display: grid; place-items: center; padding: 0 clamp(.75rem, 6vw, 6rem); touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.viewer__stage { min-height: 0; overflow: hidden; }
.viewer__img { max-width: 100%; max-height: calc(100dvh - 11rem); width: auto; height: auto; object-fit: contain; border-radius: var(--radius-s); -webkit-user-drag: none; }
.viewer__nav {
  position: absolute; top: 50%; z-index: 2;
  display: grid; place-items: center; width: 3.4rem; height: 3.4rem; margin-top: -1.7rem;
  border-radius: 50%; background: rgba(18, 18, 22, .7); color: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: background var(--dur-2), color var(--dur-2), transform .5s var(--ease-out);
}
.viewer__nav svg { width: 1.15rem; height: 1.15rem; }
.viewer__nav:hover { background: var(--paper); color: var(--ink-950); }
.viewer__nav--prev { left: clamp(.5rem, 2vw, 2rem); }
.viewer__nav--next { right: clamp(.5rem, 2vw, 2rem); }
.viewer__nav--prev:hover { transform: translateX(-3px); }
.viewer__nav--next:hover { transform: translateX(3px); }
.viewer__thumbs { display: flex; justify-content: center; gap: .5rem; padding: 1rem var(--gutter) max(1rem, env(safe-area-inset-bottom)); list-style: none; overflow-x: auto; scrollbar-width: none; }
.viewer__thumb { display: block; width: 4.6rem; height: 3.1rem; border-radius: var(--radius-xs); overflow: hidden; opacity: .4; transition: opacity var(--dur-2); box-shadow: inset 0 0 0 1px var(--line); }
.viewer__thumb img { width: 100%; height: 100%; object-fit: cover; }
.viewer__thumb:hover { opacity: .8; }
.viewer__thumb.is-current { opacity: 1; box-shadow: 0 0 0 2px var(--paper); }
@media (max-width: 759px) {
  .viewer__title { display: none; }
  .viewer__top { grid-template-columns: 1fr auto; }
  .viewer__nav { top: auto; bottom: .25rem; margin-top: 0; width: 2.9rem; height: 2.9rem; }
  .viewer__stage { padding-bottom: 3.6rem; }
  .viewer__img { max-height: calc(100dvh - 9rem); }
  .viewer__thumbs { display: none; }
}

/* --- Sections de pied : la grille s'adapte au nombre d'éléments ------------
   `.cards` (auto-fill) laisserait 1, 2 ou 3 éléments petits et collés à
   gauche. 1 vidéo = grand format ; 2 = deux colonnes ; 3 = trois colonnes ;
   4 et plus = la grille commune. */
@media (min-width: 760px) {
  .fiche-cards[data-n="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1000px) {
  .fiche-cards[data-n="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 900px) {
  .fiche-cards[data-n="1"] { grid-template-columns: minmax(0, 1fr); }
  .fiche-cards[data-n="1"] .card-video__link {
    display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
    grid-template-rows: 1fr auto auto 1fr; column-gap: clamp(2rem, 4vw, 4.5rem);
  }
  .fiche-cards[data-n="1"] .card-video__media { grid-column: 1; grid-row: 1 / -1; }
  .fiche-cards[data-n="1"] .card-video__meta { grid-column: 2; grid-row: 2; margin-top: 0; }
  .fiche-cards[data-n="1"] .card-video__title {
    grid-column: 2; grid-row: 3; margin-top: 1rem;
    font-family: var(--font-display); font-stretch: var(--wdth-display); font-weight: 800;
    font-size: clamp(1.8rem, 1rem + 2vw, 3rem); line-height: 1; letter-spacing: var(--track-display); text-transform: uppercase;
  }
  .fiche-cards[data-n="1"] .card-a,
  .fiche-cards[data-n="1"] .card-v { max-width: 40rem; }
}

/* --- Fiche sur commande : la disponibilité dite une fois, en haut ---------- */
.fiche-hero__commande {
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem;
  margin-top: 1.25rem; max-width: 52rem; color: var(--paper-dim); line-height: 1.45;
}
.fiche-hero__commande .btn { color: var(--paper); }
