/* pages/producto/producto.css
 *
 * Página de detalle de producto en formato modal/sheet sobre el home.
 *
 * Mobile:  bottom sheet deslizable desde abajo (estilo app nativa)
 * Tablet:  modal centrado tipo Tambo
 * PC:      modal grande con dos columnas
 *
 * Tokens del sitio:
 *   --mf-red, --mf-ink, --mf-mute, --mf-line, --mf-bg, --mf-bg-2, --mf-bg-3
 *   --mf-display (Geologica/Lexend), --mf-mono (Red Hat Mono)
 */

/* ============================================================
   RESET Y CONTEXTO
   ============================================================ */
.mf-page-product {
  background: var(--mf-bg-2);
  min-height: 100dvh;
  overflow: hidden;
}

/* Previene scroll del body cuando el modal overlay está abierto */
body.mf-modal-open {
  overflow: hidden;
}

/* En esta página anulamos TODO el layout de main.css sobre el body
   para que el sheet (position:fixed) no se vea afectado. */
body.mf-page-product {
  display: block;
  min-height: 100dvh;
  padding: 0;
  margin: 0;
  height: auto;
}

/* Iframe con el home detrás del modal */
.mf-product-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  z-index: 0;
  background: var(--mf-bg-2);
}

/* Header del sitio (sobre el iframe) */
.mf-page-product mf-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
}

/* Overlay oscuro */
.mf-product-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 50;
  opacity: 1;
  transition: opacity 0.25s ease;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

/* Botón flotante X — solo visible en tablet/PC */
.mf-product-close {
  position: fixed;
  top: calc(0.7rem + env(safe-area-inset-top, 0px));
  right: 0.7rem;
  z-index: 200;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  border: 0;
  color: var(--mf-ink);
  display: none; /* oculto en mobile por defecto */
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.mf-product-close svg { width: 18px; height: 18px; }
.mf-product-close:active { transform: scale(0.92); background: var(--mf-red); color: #fff; }

/* ============================================================
   SHEET / MODAL — base (mobile-first)
   ============================================================ */
.mf-product-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  z-index: 100;
  background: var(--mf-bg);
  border-radius: 22px 22px 0 0;
  height: 70dvh;
  min-height: 70dvh;
  max-height: 70dvh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.18);
  transform: translateY(0);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

/* Drag handle en la parte superior (solo mobile) */
.mf-product-sheet__handle {
  display: block;
  width: 44px;
  height: 5px;
  border-radius: 999px;
  background: var(--mf-line-2);
  margin: 0.55rem auto 0.2rem;
  flex-shrink: 0;
  cursor: grab;
  touch-action: none;
}
.mf-product-sheet__handle:active { cursor: grabbing; }

/* El sheet se vuelve scrollable: su contenido interior */
.mf-product-sheet > .mf-product,
.mf-product-sheet > .mf-product__skeleton,
.mf-product-sheet > .mf-product-empty {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* El modal vacío también scrollea si su contenido excede */
.mf-product-sheet > .mf-product-empty {
  padding: 1rem 1.5rem 2rem;
}

/* ============================================================
   PRODUCT — layout interno
   ============================================================ */
.mf-product {
  display: flex;
  flex-direction: column;
  background: var(--mf-bg);
}

/* ===========================
   MEDIA — imagen del producto
   =========================== */
.mf-product__media {
  position: relative;
  background: var(--mf-bg-3);
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 36vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.mf-product__media img,
.mf-product__media picture {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  padding: 1.25rem;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.mf-product__media:active img,
.mf-product__media:active picture {
  transform: scale(1.04);
}

.mf-product__media-badges {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  z-index: 2;
}
.mf-product__discount-badge {
  display: inline-flex;
  align-items: center;
  background: var(--mf-red);
  color: #fff;
  font-family: var(--mf-display);
  font-weight: 800;
  font-size: 13px;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 12px rgba(255,49,49,0.32);
}
.mf-product__top-tag {
  display: inline-flex;
  align-items: center;
  background: var(--mf-ink);
  color: #fff;
  font-family: var(--mf-mono);
  font-weight: 700;
  font-size: 10px;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.mf-product__media-share {
  display: none;
}

/* ===========================
   INFO — columna de datos
   =========================== */
.mf-product__info {
  padding: 0.85rem 1.1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
  flex: 1;
}

/* ============================================================
   MOBILE MINIMALISTA
   - Sin eyebrow, sin brand, sin stock, sin selector de cantidad,
     sin notas de confianza, sin precio destacado, sin share.
   - Solo: imagen (con badges), título, descripción, botón full-width.
   ============================================================ */

/* Elementos "extras" ocultos por defecto en mobile */
.mf-product__extras,
.mf-product__price-row--desktop {
  display: none;
}

/* Descripción más prominente en mobile */
.mf-product__desc {
  font-size: 13px;
  color: var(--mf-ink-2);
  line-height: 1.55;
  margin: 0;
}

/* Fila inferior: selector de cantidad + botón de compra.
   Pegada al borde inferior del sheet (al límite del teléfono). */
.mf-product__cta {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  margin-top: auto;
  padding: 0.55rem 1.1rem 0;
  background: var(--mf-bg);
  border-top: 1px solid var(--mf-line);
  flex-shrink: 0;
}
.mf-product__cta-buy {
  appearance: none;
  border: 0;
  background: var(--mf-red);
  color: #fff;
  padding: 0.45rem 1rem;
  border-radius: 10px;
  font-family: var(--mf-display);
  font-size: 13.5px;
  font-weight: 600; /* menos grueso */
  letter-spacing: 0.01em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex: 1;
  min-height: 32px;
  transition: background 0.15s, transform 0.1s;
  box-shadow: 0 2px 8px rgba(255,49,49,0.25);
  -webkit-tap-highlight-color: transparent;
}
.mf-product__cta-buy:active { transform: scale(0.98); }
.mf-product__cta-buy:disabled {
  background: var(--mf-mute);
  cursor: not-allowed;
  box-shadow: none;
}
.mf-product__cta-buy-label { font-weight: 600; }
.mf-product__cta-buy-sep {
  opacity: 0.5;
  font-weight: 300;
  margin: 0 -0.05rem;
}
.mf-product__cta-buy-price {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.mf-product__cta-currency {
  font-weight: 500;
  margin-right: 1px;
}

/* Selector de cantidad — compacto, igual en mobile y tablet/PC */
.mf-qty {
  display: inline-flex;
  align-items: center;
  border: 1.5px solid var(--mf-line-2);
  border-radius: 10px;
  overflow: hidden;
  background: var(--mf-bg);
  flex-shrink: 0;
}
.mf-qty button {
  appearance: none;
  background: transparent;
  border: 0;
  width: 28px;
  height: 34px;
  cursor: pointer;
  color: var(--mf-ink);
  transition: background 0.12s, color 0.12s;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
}
.mf-qty button:active { background: var(--mf-bg-3); color: var(--mf-red); }
.mf-qty button:disabled { opacity: 0.35; cursor: not-allowed; }
.mf-qty input {
  appearance: none;
  background: transparent;
  border: 0;
  width: 32px;
  height: 34px;
  text-align: center;
  font-family: var(--mf-display);
  font-weight: 600;
  font-size: 13px;
  color: var(--mf-ink);
  outline: none;
  -moz-appearance: textfield;
}
.mf-qty input::-webkit-outer-spin-button,
.mf-qty input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.mf-product__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--mf-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mf-red);
  align-self: flex-start;
  background: rgba(255,49,49,0.07);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  text-decoration: none;
}

.mf-product__brand {
  font-family: var(--mf-mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--mf-mute);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 0;
}

.mf-product__title {
  font-family: var(--mf-display);
  font-size: 1.4rem;
  font-weight: 500; /* semi-bold, mucho menos grueso que 700/800 */
  letter-spacing: -0.015em;
  line-height: 1.2;
  color: var(--mf-ink);
  margin: 0;
}

/* mf-product__price-row y sus derivados están ocultos en mobile
   (se muestran solo en tablet/PC con la clase --desktop) */

.mf-product__stock {
  font-family: var(--mf-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  align-self: flex-start;
}
.mf-product__stock::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px currentColor;
  opacity: 0.18;
}
.mf-product__stock--in   { color: #0d6b4a; background: #e6f7f0; }
.mf-product__stock--low  { color: #a05a00; background: #fef3c7; }
.mf-product__stock--out  { color: var(--mf-red); background: var(--mf-red-3); }

/* ===========================
   SELECTOR DE CANTIDAD
   =========================== */
.mf-product__qty-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}
.mf-product__qty-label {
  font-family: var(--mf-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mf-mute);
}

/* SEO copy (oculto) */
.mf-product__seo {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   SKELETON LOADER
   ============================================================ */
@keyframes mf-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.mf-product__skel-media {
  aspect-ratio: 1 / 1;
  max-height: 45vh;
  background: linear-gradient(90deg, var(--mf-bg-3) 0%, #ececec 50%, var(--mf-bg-3) 100%);
  background-size: 200% 100%;
  animation: mf-shimmer 1.4s infinite linear;
  flex-shrink: 0;
}
.mf-product__skel-info {
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.mf-product__skel-line {
  height: 13px;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--mf-bg-3) 0%, #ececec 50%, var(--mf-bg-3) 100%);
  background-size: 200% 100%;
  animation: mf-shimmer 1.4s infinite linear;
}
.mf-product__skel-line--xs { width: 28%; }
.mf-product__skel-line--sm { width: 48%; }
.mf-product__skel-line--md { width: 72%; }
.mf-product__skel-line--lg { width: 94%; }

/* ============================================================
   ERROR STATE
   ============================================================ */
.mf-product-empty {
  text-align: center;
  padding: 1.5rem 1.5rem 2.5rem;
  color: var(--mf-mute);
}
.mf-product-empty h1 {
  font-family: var(--mf-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--mf-ink);
  margin: 0.6rem 0 0.4rem;
}
.mf-product-empty p {
  color: var(--mf-ink-2);
  margin: 0 0 1.2rem;
  font-size: 12.5px;
}
.mf-product-empty__icon {
  width: 60px;
  height: 60px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--mf-bg-3);
  color: var(--mf-mute);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mf-product-empty__icon svg { width: 26px; height: 26px; }
.mf-product-empty__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .mf-product-sheet,
  .mf-product-overlay,
  .mf-product__media img,
  .mf-product__share,
  .mf-product__cta-buy {
    transition: none;
  }
  .mf-shimmer, .mf-product__skel-media, .mf-product__skel-line {
    animation: none;
  }
}

/* ============================================================
   MODAL OVERLAY — estilos específicos para el componente
   inyectado dinámicamente desde el home (producto-modal.js)
   
   Reutiliza las clases .mf-product-* pero añade comportamientos
   específicos de overlay (z-index superior, cierre por popstate).
   ============================================================ */

/* Overlay oscuro sobre el home */
.mf-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 9998;
  opacity: 1;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: mf-fade-in 0.25s ease forwards;
}
@keyframes mf-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* Sheet/modal contenedor */
.mf-modal-sheet {
  /* En mobile: bottom sheet */
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  z-index: 9999;
  background: var(--mf-bg);
  border-radius: 22px 22px 0 0;
  height: 70dvh;
  min-height: 70dvh;
  max-height: 70dvh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.18);
  transform: translateY(0);
  animation: mf-sheet-up 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  will-change: transform;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

/* Botón X del modal — visible en tablet/PC, oculto en mobile */
.mf-modal-close {
  display: none; /* oculto en mobile por defecto */
}

/* El contenido del producto dentro del modal DEBE scrollear */
.mf-modal-sheet > .mf-product {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.mf-modal-sheet > .mf-product-empty,
.mf-modal-sheet > .mf-product__skeleton {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
