/**
 * Culmine — Avant / Après
 *
 * Les variables ci-dessous sont le seul point de reglage : le widget Elementor
 * les pose par ses selecteurs, le shortcode par ses attributs css_*.
 *
 *   --caa-ratio            format de la boite            4/3
 *   --caa-rayon            arrondi des angles            18px
 *   --caa-avant-fond       etiquette « avant », fond     #9d7747
 *   --caa-avant-texte      etiquette « avant », texte    #ffffff
 *   --caa-apres-fond       etiquette « apres », fond     #96ab67
 *   --caa-apres-texte      etiquette « apres », texte    #ffffff
 *   --caa-trait            le trait de separation        #ffffff
 *   --caa-poignee-fond     la pastille ronde, fond       #ffffff
 *   --caa-poignee-icone    les fleches                   #6e824b
 *   --caa-legende-couleur  la legende sous les photos    inherit
 */

.caa {
  --caa-ratio: 4/3;
  --caa-rayon: 18px;
  --caa-avant-fond: #9d7747;
  --caa-avant-texte: #ffffff;
  --caa-apres-fond: #96ab67;
  --caa-apres-texte: #ffffff;
  --caa-trait: #ffffff;
  --caa-poignee-fond: #ffffff;
  --caa-poignee-icone: #6e824b;
  --caa-legende-couleur: inherit;
}

.caa-vue {
  position: relative;
  aspect-ratio: var(--caa-ratio);
  overflow: hidden;
  border-radius: var(--caa-rayon);
  background: rgba(0, 0, 0, .04);
  cursor: ew-resize;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Les deux images se superposent exactement : c'est ce qui rend la decoupe
   credible. Sans object-fit, deux photos de proportions differentes glissent
   l'une par rapport a l'autre. */
.caa-vue .caa-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  pointer-events: none;
  -webkit-user-drag: none;
}

.caa-vue .caa-avant {
  clip-path: inset(0 50% 0 0);
}

.caa-poignee {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  background: var(--caa-trait);
  transform: translateX(-50%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .12);
  pointer-events: none;
}

.caa-poignee::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--caa-poignee-fond);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
}

.caa-poignee::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  background: var(--caa-poignee-icone);
  -webkit-mask: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9.5 7 5 12l4.5 5M14.5 7l4.5 5-4.5 5' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / contain;
          mask: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9.5 7 5 12l4.5 5M14.5 7l4.5 5-4.5 5' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / contain;
  pointer-events: none;
}

.caa-etiq {
  position: absolute;
  top: 12px;
  z-index: 2;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  line-height: 1;
  padding: 6px 12px;
  border-radius: 100px;
  pointer-events: none;
}

.caa-etiq-avant {
  left: 12px;
  background: var(--caa-avant-fond);
  color: var(--caa-avant-texte);
}

.caa-etiq-apres {
  right: 12px;
  background: var(--caa-apres-fond);
  color: var(--caa-apres-texte);
}

.caa-vue:focus {
  outline: none;
}

.caa-vue:focus-visible {
  outline: 3px solid var(--caa-poignee-icone);
  outline-offset: 3px;
}

.caa-legende {
  margin: 12px 0 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--caa-legende-couleur);
}

.caa-vide {
  padding: 14px 16px;
  border: 1px dashed #9c5b3a;
  border-radius: 8px;
  color: #9c5b3a;
  font-size: 14px;
}

/* Tant que le script n'a pas pris la main, la decoupe reste celle du depart :
   la page ne montre jamais deux images empilees sans separation. */
.caa-vue[data-caa-pret] {
  cursor: ew-resize;
}
