/*
 * before-after.css
 * Componente slider Prima / Dopo — martamiceli.com child theme
 * Enqueued da functions.php dopo marta-miceli-child.
 * Aggiunto: 2026-05-31
 *
 * Struttura HTML attesa:
 * <div class="mm-ba-section section section-alt">
 *   <div class="container">
 *     <div class="mm-ba-grid">
 *       <div class="mm-ba-card">
 *         <div class="mm-ba-slider" data-mm-ba>
 *           <div class="mm-ba-after"><img ...></div>
 *           <div class="mm-ba-before"><img ...></div>
 *           <div class="mm-ba-handle" aria-hidden="true">...</div>
 *           <span class="mm-ba-label mm-ba-label-before">Prima</span>
 *           <span class="mm-ba-label mm-ba-label-after">Dopo</span>
 *         </div>
 *         <div class="mm-ba-footer">
 *           <h3>...</h3>
 *           <div class="mm-ba-tags">...</div>
 *         </div>
 *       </div>
 *     </div>
 *   </div>
 * </div>
 */


/* ── Grid contenitore ───────────────────────────────── */

.mm-ba-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
  margin-top: 52px;
}


/* ── Card ───────────────────────────────────────────── */

.mm-ba-card {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  background: var(--color-white);
  border: 1px solid rgba(201, 168, 124, 0.12);
  transition: var(--transition);
}

.mm-ba-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-4px);
}


/* ── Slider (core) ──────────────────────────────────── */

.mm-ba-slider {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  cursor: col-resize;
  user-select: none;
  -webkit-user-select: none;
  background: var(--color-nude);
  /* Blocca overflow durante il drag */
  touch-action: none;
}

/* Layer After — sfondo, visibile per intero */
.mm-ba-after {
  position: absolute;
  inset: 0;
}

/* Layer Before — sopra, clippato dinamicamente via JS */
.mm-ba-before {
  position: absolute;
  inset: 0;
  clip-path: inset(0 50% 0 0); /* aggiornato via JS */
  will-change: clip-path;
}

/* Immagini — riempiono l'intero layer */
.mm-ba-after img,
.mm-ba-before img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  pointer-events: none; /* impedisce drag nativo */
  -webkit-user-drag: none;
}

/* Placeholder (quando non c'è ancora l'immagine reale) */
.mm-ba-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--color-taupe);
  font-size: 1rem;
}

.mm-ba-placeholder .mm-ba-placeholder-icon {
  font-size: 2.4rem;
  opacity: 0.35;
  line-height: 1;
}

.mm-ba-placeholder .mm-ba-placeholder-text {
  font-size: 0.72rem;
  font-family: var(--font-sans);
  font-style: normal;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-bronze);
  opacity: 0.55;
}


/* ── Handle (linea + cerchio) ───────────────────────── */

.mm-ba-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%; /* aggiornato via JS */
  transform: translateX(-50%);
  width: 2px;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 10;
  will-change: left;
}

.mm-ba-handle-circle {
  width: 44px;
  height: 44px;
  background: var(--color-white);
  border-radius: 50%;
  box-shadow: 0 2px 16px rgba(61, 43, 31, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1.5px solid rgba(201, 168, 124, 0.3);
}

.mm-ba-handle-circle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--color-espresso);
  stroke-width: 2;
  stroke-linecap: round;
}

/* Handle accessibile via tastiera */
.mm-ba-handle-kb {
  pointer-events: all;
  position: absolute;
  inset: 0;
  width: 44px;
  height: 44px;
  margin: auto;
  background: transparent;
  border: none;
  cursor: col-resize;
  border-radius: 50%;
  z-index: 11;
}

.mm-ba-handle-kb:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 3px;
}


/* ── Label Prima / Dopo ─────────────────────────────── */

.mm-ba-label {
  position: absolute;
  bottom: 14px;
  font-family: var(--font-sans);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-white);
  background: rgba(61, 43, 31, 0.52);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  pointer-events: none;
  z-index: 8;
  transition: opacity 0.25s ease;
}

.mm-ba-label-before { left: 12px; }
.mm-ba-label-after  { right: 12px; }


/* ── Hint "scorri" (scompare dopo il primo drag) ────── */

.mm-ba-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(61, 43, 31, 0.68);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: var(--radius-pill);
  padding: 8px 18px;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--color-white);
  pointer-events: none;
  z-index: 20;
  white-space: nowrap;

  /* Animazione: appare dopo 0.6s, sparisce dopo 2.5s */
  animation: mm-ba-hint-fade 2.8s ease 0.6s both;
}

@keyframes mm-ba-hint-fade {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
  15%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Hint nascosto dopo interazione */
.mm-ba-slider.mm-ba-active .mm-ba-hint {
  display: none;
}


/* ── Footer card (titolo + tag) ─────────────────────── */

.mm-ba-footer {
  padding: 20px 22px 22px;
}

.mm-ba-footer h3 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--color-espresso);
  margin-bottom: 4px;
}

.mm-ba-footer-sub {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--color-gold);
  text-transform: uppercase;
  margin-bottom: 12px;
  display: block;
}

.mm-ba-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mm-ba-tag {
  font-family: var(--font-sans);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--color-nude);
  border: 1px solid rgba(201, 168, 124, 0.25);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  color: var(--color-taupe);
}


/* ── Nota admin (visibile solo nel backend) ─────────── */

.mm-ba-admin-note {
  background: rgba(201, 168, 124, 0.08);
  border: 1px dashed rgba(201, 168, 124, 0.4);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 0.82rem;
  color: var(--color-taupe);
  text-align: center;
  font-style: italic;
}


/* ── Responsive ─────────────────────────────────────── */

@media (max-width: 1024px) {
  .mm-ba-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  /* Nascondi la terza card su tablet → solo 2 slider */
  .mm-ba-card:nth-child(3) {
    display: none;
  }
}

@media (max-width: 640px) {
  .mm-ba-grid {
    grid-template-columns: 1fr;
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
  }
  /* Mostra tutte le card su mobile (scorrevoli) */
  .mm-ba-card:nth-child(3) {
    display: block;
  }
  .mm-ba-slider {
    aspect-ratio: 4 / 5;
  }
}


/* ── prefers-reduced-motion ─────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .mm-ba-card {
    transition: none;
  }
  .mm-ba-hint {
    animation: none;
    display: none;
  }
  .mm-ba-before {
    will-change: auto;
  }
  .mm-ba-handle {
    will-change: auto;
  }
}
