/* OVERLAY */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  z-index: 3000;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 0px;

  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;

  -webkit-backdrop-filter: var(--modal-backdrop-blur);
  backdrop-filter: var(--modal-backdrop-blur);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

/* MODAL */
.modal {
  background: #000;
  /* border: .1em solid var(--details); */

  /* width: 100%; */
  max-width: 65vw;
  /* height: 64%; */
  /* max-height: 100vh; */

  display: flex;
  flex-direction: column;

  overflow: hidden;
  position: relative;
  box-shadow: var(--modal-halo); /* halo: ver variables.css */
}

/* CLOSE */
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  color: var(--text);
}

/* CONTENT */
.modal-content {
  display: grid;
  grid-template-columns: 1fr;
  height: 100%;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

/* IMAGE */
.modal-image {
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;

  height: 100%;            
  /* padding: 24px;            */
  overflow: hidden;       
}

/* INFO */
.modal-info {
  height: 100%;
  padding: 40px 32px;      
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

/* TEXT */
.modal-category {
  font-size: var(--font-size-xs);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.modal-title {
  font-size: 1em;
  font-weight: 300;
  text-transform: uppercase;
}

/* Precio con más presencia que el texto secundario */
.modal-price {
  font-size: var(--font-size-xl);
  font-weight: 700;
  line-height: 1.2;
}

.modal-description {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-line;   /* respeta los saltos de línea de la descripción */
}

/* VARIANTS
   Bloque de opciones: línea blanca que lo separa del precio, título
   («Colores», «Presentación»…) y botones con borde blanco, como «Agregar al
   carrito». La opción elegida se invierte (fondo blanco, texto negro). */
.modal-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
  padding-top: 18px;
  border-top: 1px solid #fff;
}

.modal-options-title {
  font-size: var(--font-size-xs);
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text);
}

.modal-variants {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.variant-btn {
  padding: 9px 16px;
  border: 1px solid #fff;
  font-family: var(--font);
  font-size: var(--font-size-sm);
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  transition: all var(--t);
  text-transform: uppercase;
}

.variant-btn:hover {
  color: #fff;
  background-color: var(--details);
}

.variant-btn.active,
.variant-btn.active:hover {
  background: #fff;
  border-color: #fff;
  color: #000;
}

.variant-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.btn-add {
  width: 100%;
  padding: 14px 20px;
  border: 1px solid #fff;
  background: transparent;
  color: #fff;

  font-family: var(--font);
  font-size: var(--font-size-sm);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;

  margin-top: auto;
  transition: all var(--t);
}

.btn-add:hover {
  background: var(--details);
  color: #fff;
}

/* =========================
   DESKTOP
========================= */
@media (min-width: 768px) {

  .modal-content {
    grid-template-columns: 65% 35%;
    align-items: stretch;
    height: 100%;
  }

  .modal-image {
    height: 100%;
  }

  .modal-info {
    height: 100%;
  }
}

.modal-content > * {
  min-height: 0;
}
/* =========================
   GALERÍA
   Foto principal (clic → visor ampliado), flechas con mouse, deslizamiento
   táctil y tira de miniaturas cuadradas debajo (solo con 2 o más fotos).
========================= */
.modal-image { position: relative; }
.modal-image.has-gallery { flex-direction: column; }

.modal-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  cursor: zoom-in;
  touch-action: pan-y; /* el scroll vertical sigue siendo del navegador */
  -webkit-tap-highlight-color: transparent;
}
.has-gallery .modal-stage { flex: 1 1 auto; height: auto; }

.modal-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transition: opacity 0.2s ease, transform 0.25s ease;
}

/* Flechas laterales: solo con mouse (en táctil se desliza) */
.gallery-arrow {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-top: -20px;
  border-radius: 50%;
  color: #000;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  opacity: 0;
  transition: opacity var(--t), background var(--t);
}
.gallery-arrow.prev { left: 12px; }
.gallery-arrow.next { right: 12px; }
.gallery-arrow:hover { background: #fff; }
@media (hover: hover) and (pointer: fine) {
  .gallery-arrow { display: flex; }
  .modal-stage:hover .gallery-arrow,
  .gallery-arrow:focus-visible { opacity: 1; }
}

/* Miniaturas cuadradas debajo de la foto */
.modal-thumbs {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  background: #fff;
}
.modal-thumbs::-webkit-scrollbar { display: none; }

.modal-thumb {
  flex: 0 0 auto;
  width: 72px;
  aspect-ratio: 3 / 2;
  padding: 0;
  border: 2px solid transparent;
  background: #fff;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity var(--t), border-color var(--t);
}

/* Centradas si entran; si no, la tira se desplaza sin cortar las primeras */
.modal-thumb:first-child { margin-left: auto; }
.modal-thumb:last-child { margin-right: auto; }

.modal-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.modal-thumb:hover { opacity: 1; }
.modal-thumb.active { border-color: var(--details); opacity: 1; }

.btn-add:disabled { opacity: 0.5; pointer-events: none; }

@media (max-width: 767px) {
  .modal-thumb { width: 60px; }
  .modal-thumbs { padding: 8px 12px; }
  /* Lugar para la tira de miniaturas sin achicar la foto */
  .modal-image.has-gallery { min-height: 262px; }
}

/* Presentación sin stock: se puede ver, pero no comprar */
.variant-btn.out { text-decoration: line-through; opacity: 0.55; }

/* Foco visible en la galería: marrón de la marca */
.modal-stage:focus-visible,
.modal-thumb:focus-visible,
.gallery-arrow:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
  box-shadow: var(--focus-ring);
}
.modal-stage:focus-visible { outline-offset: -4px; }
