/* ============================================================
   BG PLOMBERIE CHAUFFAGE — Comparateur Avant / Après (v16)
   Composant unique, remplace les deux anciens sliders
   (premium-fx v13 + style.css v15) qui se marchaient dessus.

   Structure :
   .cmp-set                → bloc vitrine (viewer + panneau infos + onglets)
     .cmp-viewer           → empile les projets (un seul visible)
       figure.cmp          → un projet avant/après
         .cmp-stage        → zone interactive (photos + poignée)
         figcaption        → titre / lieu / description du projet
     .cmp-side             → panneau éditorial (texte du projet actif + onglets)

   Ajouter un projet = copier un <figure class="cmp"> (voir README).
   ============================================================ */

.cmp {
  --pos: 50%;
  --ratio: 3 / 4;
  position: relative;
  margin: 0;
}

/* ─── Zone interactive ─── */
.cmp-stage {
  position: relative;
  width: 100%;
  aspect-ratio: var(--ratio);
  overflow: hidden;
  background: var(--d2);
  border-radius: 3px;
  isolation: isolate;
  cursor: ew-resize;
  touch-action: pan-y;               /* le scroll vertical reste natif sur mobile */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow:
    0 0 0 1px var(--copper-line),
    0 40px 90px -30px rgba(0, 0, 0, 0.85),
    0 0 120px -50px rgba(184, 115, 51, 0.35);
}
.cmp.is-dragging .cmp-stage { cursor: grabbing; }

.cmp-img,
.cmp-img img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.cmp-img img {
  display: block;
  object-fit: cover;
  object-position: var(--focus, 50% 50%);
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

/* L'image AVANT est au-dessus, découpée à gauche de la poignée */
.cmp-before {
  z-index: 1;
  clip-path: inset(0 calc(100% - var(--pos)) 0 0);
  -webkit-clip-path: inset(0 calc(100% - var(--pos)) 0 0);
}
.cmp-after { z-index: 0; }

/* Léger voile pour la lisibilité des étiquettes */
.cmp-stage::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,0.38) 0%, transparent 22%, transparent 78%, rgba(0,0,0,0.3) 100%);
}

/* ─── Étiquettes Avant / Après ─── */
.cmp-tag {
  position: absolute;
  top: 1.1rem;
  z-index: 4;
  padding: 0.5rem 0.95rem 0.48rem;
  font-family: var(--fb);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--c6);
  background: rgba(8, 8, 8, 0.58);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(212, 149, 106, 0.35);
  border-radius: 2px;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.cmp-tag--before { left: 1.1rem; }
.cmp-tag--after  { right: 1.1rem; }
.cmp.is-left  .cmp-tag--before { opacity: 0; transform: translateX(-6px); }
.cmp.is-right .cmp-tag--after  { opacity: 0; transform: translateX(6px); }

/* ─── Poignée ─── */
.cmp-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos);
  z-index: 5;
  width: 0;
  pointer-events: none;
}
.cmp-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -1px;
  width: 2px;
  background: linear-gradient(180deg,
    rgba(212,149,106,0) 0%,
    rgba(212,149,106,0.75) 10%,
    rgba(245,222,200,0.95) 50%,
    rgba(212,149,106,0.75) 90%,
    rgba(212,149,106,0) 100%);
  box-shadow: 0 0 12px rgba(184,115,51,0.55), 0 0 2px rgba(245,222,200,0.8);
}
.cmp-handle {
  position: absolute;
  top: 50%;
  left: 0;
  width: 58px;
  height: 58px;
  margin: 0;
  padding: 0;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(212,149,106,0.7);
  color: var(--c5);
  background:
    radial-gradient(circle at 32% 26%, rgba(255,255,255,0.16), transparent 55%),
    linear-gradient(140deg, #1c1917 0%, #0a0a0a 100%);
  box-shadow:
    0 0 0 5px rgba(8,8,8,0.35),
    0 0 26px rgba(184,115,51,0.45),
    0 12px 28px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(245,222,200,0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  transition: transform 0.35s cubic-bezier(.22,.68,0,1.3), box-shadow 0.35s ease, border-color 0.35s ease;
}
/* Garde la poignée entièrement visible quand on est tout au bord */
.cmp.is-edge-left  .cmp-handle { left: 29px; }
.cmp.is-edge-right .cmp-handle { left: -29px; }

.cmp-handle svg { width: 24px; height: 24px; filter: drop-shadow(0 0 4px rgba(212,149,106,0.55)); }
.cmp-stage:hover .cmp-handle,
.cmp.is-dragging .cmp-handle {
  transform: translate(-50%, -50%) scale(1.08);
  border-color: rgba(245,222,200,0.95);
  box-shadow:
    0 0 0 6px rgba(8,8,8,0.35),
    0 0 38px rgba(184,115,51,0.6),
    0 14px 32px rgba(0,0,0,0.65),
    inset 0 1px 0 rgba(245,222,200,0.3);
}
.cmp.is-dragging .cmp-handle { cursor: grabbing; }
.cmp-handle:focus-visible {
  outline: 2px solid var(--c5);
  outline-offset: 5px;
}

/* Pulsation douce de la poignée tant que personne n'y a touché */
.cmp:not(.is-touched) .cmp-handle::after {
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 1px solid rgba(212,149,106,0.55);
  animation: cmpRing 2.4s cubic-bezier(.2,.6,.3,1) infinite;
  pointer-events: none;
}
@keyframes cmpRing {
  0%   { opacity: 0.9; transform: scale(0.92); }
  100% { opacity: 0;   transform: scale(1.55); }
}

/* Indication « Glissez » sous la poignée (mobile surtout) */
.cmp-hint {
  position: absolute;
  left: 50%;
  bottom: 1.1rem;
  z-index: 4;
  transform: translateX(-50%);
  padding: 0.45rem 1rem;
  font-family: var(--fb);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--c5);
  background: rgba(8,8,8,0.6);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--copper-line);
  border-radius: 999px;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
.cmp.is-touched .cmp-hint { opacity: 0; }

/* Légende d'un comparateur isolé */
.cmp-cap {
  margin-top: 1.4rem;
  text-align: center;
  font-family: var(--fb);
}
.cmp-cap .cmp-place {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--c4);
  margin-bottom: 0.4rem;
}
.cmp-cap .cmp-title {
  display: block;
  font-family: var(--fs);
  font-size: 1.6rem;
  font-weight: 400;
  color: var(--white);
}
.cmp-cap .cmp-desc { display: none; }

/* ============================================================
   VITRINE MULTI-PROJETS (.cmp-set)
   ============================================================ */
.cmp-set {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: clamp(2.5rem, 5vw, 6rem);
  align-items: center;
  margin-bottom: clamp(4rem, 7vw, 7rem);
}
.cmp-viewer {
  display: grid;
  width: 100%;
  max-width: min(100%, calc(78vh * 0.75));   /* reste dans l'écran sur desktop */
  justify-self: center;
}
.cmp-viewer > .cmp {
  grid-area: 1 / 1;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.985);
  transition: opacity 0.7s ease, transform 0.9s cubic-bezier(.22,.68,0,1.05), visibility 0s linear 0.7s;
}
.cmp-viewer > .cmp.is-active {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.7s ease, transform 0.9s cubic-bezier(.22,.68,0,1.05), visibility 0s;
}
/* Dans la vitrine, la légende est reprise dans le panneau de droite */
.cmp-viewer .cmp-cap {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.cmp-side .sl { margin-bottom: 1.2rem; }
.cmp-meta { min-height: 13rem; }
.cmp-meta .cmp-place {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--c4);
  margin-bottom: 1rem;
}
.cmp-meta .cmp-title {
  display: block;
  font-family: var(--fs);
  font-size: clamp(2.2rem, 3vw, 3.2rem);
  font-weight: 300;
  line-height: 1.12;
  color: var(--white);
  margin-bottom: 1.4rem;
}
.cmp-meta .cmp-desc {
  display: block;
  font-size: 1.15rem;
  font-weight: 300;
  line-height: 1.85;
  color: rgba(250,247,244,0.62);
  max-width: 34rem;
}
.cmp-meta > * { animation: cmpMetaIn 0.8s cubic-bezier(.22,.68,0,1.05) both; }
.cmp-meta > *:nth-child(2) { animation-delay: 0.06s; }
.cmp-meta > *:nth-child(3) { animation-delay: 0.12s; }
@keyframes cmpMetaIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

/* Onglets projets (vignettes) */
.cmp-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: 2.6rem;
  padding: 0;
  list-style: none;
}
.cmp-tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.45rem 1.1rem 0.45rem 0.45rem;
  background: rgba(22,22,22,0.7);
  border: 1px solid rgba(184,115,51,0.2);
  border-radius: 999px;
  color: var(--white-60);
  font-family: var(--fb);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.4s ease, color 0.4s ease, background 0.4s ease, transform 0.4s cubic-bezier(.22,.68,0,1.2);
}
.cmp-tab img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  filter: grayscale(0.6) brightness(0.8);
  transition: filter 0.4s ease;
}
.cmp-tab:hover { color: var(--c5); border-color: rgba(212,149,106,0.55); transform: translateY(-1px); }
.cmp-tab:hover img { filter: none; }
.cmp-tab[aria-selected="true"] {
  color: var(--black);
  background: linear-gradient(135deg, var(--c2) 0%, var(--c3) 45%, var(--c4) 100%);
  border-color: var(--c3);
  font-weight: 700;
  box-shadow: 0 8px 26px -10px rgba(184,115,51,0.6);
}
.cmp-tab[aria-selected="true"] img { filter: none; box-shadow: 0 0 0 2px rgba(0,0,0,0.35); }

.cmp-note {
  margin-top: 2rem;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--white-40);
}

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .cmp-set { grid-template-columns: 1fr; gap: 2.2rem; }
  .cmp-viewer { max-width: 560px; }
  .cmp-side { text-align: left; }
  .cmp-meta { min-height: 0; }
  .cmp-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin: 1.8rem calc(-1 * clamp(1.25rem, 5vw, 8.75rem)) 0;
    padding: 0.2rem clamp(1.25rem, 5vw, 8.75rem) 0.6rem;
    scroll-snap-type: x proximity;
  }
  .cmp-tabs::-webkit-scrollbar { display: none; }
  .cmp-tab { flex: 0 0 auto; scroll-snap-align: start; }
}
@media (max-width: 600px) {
  .cmp { --ratio: 4 / 5; }
  .cmp-handle { width: 50px; height: 50px; }
  .cmp-handle svg { width: 20px; height: 20px; }
  .cmp.is-edge-left  .cmp-handle { left: 25px; }
  .cmp.is-edge-right .cmp-handle { left: -25px; }
  .cmp-tag { top: 0.8rem; font-size: 0.58rem; padding: 0.42rem 0.75rem; }
  .cmp-tag--before { left: 0.8rem; }
  .cmp-tag--after  { right: 0.8rem; }
  .cmp-meta .cmp-desc { font-size: 1.02rem; }
}

@media (prefers-reduced-motion: reduce) {
  .cmp:not(.is-touched) .cmp-handle::after { animation: none; opacity: 0; }
  .cmp-viewer > .cmp, .cmp-meta > * { transition: none; animation: none; }
}

/* v19 */
[id].cmp-set { scroll-margin-top: var(--nav-h, 84px); }
.cmp-meta .cmp-place { color: var(--white-40); }
.cmp-intro { max-width: 780px; margin: 0 0 3.5rem; }
.gallery-page .ch .cmp-set { margin: 0 0 34px; }
/* v19 : 2 onglets seulement → ils passent à la ligne sur mobile (plus de défilement coupé au bord) */
@media (max-width: 900px) {
  .cmp-tabs { flex-wrap: wrap; overflow: visible; margin: 1.8rem 0 0; padding: 0; scroll-snap-type: none; }
}
