/* Celular: el detalle del producto se ve como una tarjeta sobre la página (igual que en la computadora),
   con el botón de cerrar redondo sobre la foto y el botón de agregar dentro de la tarjeta. */
@media (max-width: 640px) {
  .modal-overlay { padding: 8px; align-items: center; justify-content: center; }
  .modal-box {
    position: relative; display: block; width: 100%; height: auto;
    max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px);
    margin: 0; padding: 10px 10px 14px; border-radius: 14px; overflow-y: auto;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .38);
    animation: kv-pop .3s cubic-bezier(.2, .7, .3, 1) both; transform: none;
  }
  .modal-grid { gap: 12px; margin: 0; }
  /* La foto se ve entera (sin recortar), con su proporción real */
  .modal-foto { aspect-ratio: auto; height: auto; min-height: 0; max-height: none; border-radius: 10px; display: flex; justify-content: center; background: var(--color-surface); }
  .modal-foto img { width: 100%; height: auto; max-height: 52vh; max-height: 52dvh; object-fit: contain; }
  .modal-info, .modal-grid > div + div { padding: 0 4px; }

  /* Botón de cerrar: redondo, arriba a la derecha de la foto */
  #modalBox > div:first-child { position: absolute; top: 18px; right: 18px; z-index: 6; display: block; }
  #btnCerrarModal {
    width: 38px; height: 38px; min-height: 0; padding: 0; border-radius: 50%; border: 0;
    background: rgba(255, 255, 255, .92); color: #1a1410; box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
    font-size: 0; display: block;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231a1410' stroke-width='2.6' stroke-linecap='round'><path d='M6 6l12 12M18 6L6 18'/></svg>");
    background-repeat: no-repeat; background-position: center; background-size: 16px 16px;
  }

  /* Botón de agregar: dentro de la tarjeta, no pegado al borde de la pantalla */
  .modal-add {
    position: static !important; left: auto; right: auto; bottom: auto;
    width: 100% !important; margin: 12px 0 0 !important; border-radius: 10px; min-height: 52px; padding-bottom: 0;
  }
}
