/* ==========================================================================
   product.css — Pantalla de producto + visor de fotos con zoom
   Se muestra en lugar del resto de la página (ver js/catalog.js).
   Izquierda: todas las fotos a la vista. Derecha: datos y compra (queda fija al bajar).
   ========================================================================== */

/* Mientras se ve la pantalla de producto, el header ya arranca sólido (hay fondo claro debajo) */
.is-product .site-header {
  background: rgba(240, 231, 224, .97);
  color: var(--c-ink);
}

.product-screen {
  min-height: 100vh;
  padding-top: calc(var(--header-h) + .6rem);
  padding-bottom: 6rem;
  background: var(--c-paper);
}
.product-screen[hidden] { display: none; }
.product-screen { animation: screen-in 240ms var(--ease-out) both; }      /* se repite cada vez que se abre una camisa */
@keyframes screen-in { from { opacity: 0; transform: translateY(10px); } }
.pp-item { animation: photo-in 320ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 50ms); }
@keyframes photo-in { from { opacity: 0; transform: translateY(10px); } }

.back-link {
  display: inline-flex; align-items: center; gap: .5rem;
  min-height: 48px; padding: .4rem .2rem; margin-bottom: .6rem;
  background: none; border: 0;
  font-weight: 600;
  text-decoration: underline; text-underline-offset: 4px;
}
.back-link .icon { text-decoration: none; }

.product-layout > * { min-width: 0; }
.product-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: start;
}

/* ---------- Fotos: todas juntas, en grilla de 2 columnas ---------- */
.product-photos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pp-item {
  padding: 0; border: 0;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: 6px;
  background: var(--c-cream);
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
  transition: transform 160ms var(--ease-out);
}
.pp-item:active { transform: scale(.985); }
.pp-item img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 400ms var(--ease-out); -webkit-user-drag: none; }
@media (hover: hover) and (pointer: fine) { .pp-item:hover img { transform: scale(1.03); } }
/* Si queda una foto sola en la última fila, va centrada y del mismo tamaño que las demás */
.pp-item:last-child:nth-child(odd):not(:only-child) { grid-column: 1 / -1; justify-self: center; width: calc(50% - 5px); }
.product-photos__empty { grid-column: 1 / -1; display: grid; place-items: center; align-content: center; gap: .8rem; min-height: 420px; border-radius: var(--r-m); color: var(--c-olive-deep); font-weight: 500; }
.product-photos__empty svg { width: 40%; }
.product-photos__counter { display: none; }

/* ---------- Datos del producto ---------- */
.product-info {
  position: sticky; top: calc(var(--header-h) + 1rem);
  display: grid; gap: 1.3rem; align-content: start;
  padding: .3rem 0 1rem;
}
/* Si los datos son más altos que la pantalla, dejan de quedar fijos y se recorren con el scroll normal de la página
   (no hay barra de scroll propia: solo la del navegador). js/catalog.js agrega esta clase cuando hace falta. */
.product-info.is-static { position: static; }
.product-info h1 { font-size: var(--fs-h2); }
.product-info h1:focus { outline: none; }
.product-info__sub { margin-top: .4rem; font-size: var(--fs-body); color: var(--c-ink-soft); }
.product-info__price { margin-top: .5rem; font-family: var(--f-display); font-size: var(--fs-h3); }
.pi-field { border: 0; padding: 0; margin: 0; min-width: 0; }

.product-buy { display: flex; align-items: center; gap: .8rem; }
.product-buy .btn { flex: 1; padding-inline: 1rem; white-space: nowrap; }
.product-buy .qty { flex: none; }

/* Secciones del producto: títulos chicos en mayúsculas y líneas finas */
.pi-section { display: grid; gap: .8rem; padding-top: 1.6rem; }
.pi-section[hidden] { display: none; }
.pi-title { font-family: var(--f-body); font-size: var(--fs-body); font-weight: 700; line-height: 1.2; }
.pi-section p { color: var(--c-ink-soft); }
.pi-section .btn { justify-self: start; }

/* ---------- Zoom de una foto (lo usa el visor) ---------- */
.zoom {
  position: relative;
  overflow: hidden;
  display: grid; place-items: center;
  cursor: zoom-in;
  touch-action: pan-y;
  user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.zoom.is-zoomed { cursor: grab; }
.zoom.is-zoomed:active { cursor: grabbing; }
/* La foto se ve COMPLETA: se achica para entrar, nunca se recorta */
.zoom img { transition: opacity 180ms ease-out; max-width: 100%; max-height: 100%; width: auto; height: auto; transform-origin: center; will-change: transform; -webkit-user-drag: none; pointer-events: none; }
.zoom img.is-loading { opacity: 0; }
.zoom:focus-visible { outline: 2px solid rgba(240, 231, 224, .55); outline-offset: -4px; }

.zoom__controls { position: absolute; right: .8rem; bottom: .8rem; display: flex; gap: .5rem; z-index: 2; }
.zoom__controls button {
  display: grid; place-items: center;
  min-width: 48px; height: 48px; padding: 0 .9rem;
  border: 0; border-radius: 999px;
  background: rgba(250, 246, 242, .94); color: var(--c-ink);
  font-weight: 600; font-size: var(--fs-body);
  box-shadow: 0 6px 18px -6px rgba(38, 36, 27, .45);
  transition: background-color 150ms ease, transform 160ms var(--ease-out), opacity 150ms ease;
}
.zoom__controls button:active:not(:disabled) { transform: scale(.95); }
@media (hover: hover) and (pointer: fine) { .zoom__controls button:hover:not(:disabled) { background: var(--c-rose); } }
.zoom__controls button:disabled { opacity: .45; cursor: default; }
.zoom__controls button[hidden] { display: none; }
.zoom__hint { font-size: var(--fs-small); color: var(--c-ink-soft); text-align: center; }

/* ---------- Visor de fotos: pantalla completa ---------- */
.viewer {
  position: fixed; inset: 0;
  width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: #1c1b12; color: var(--c-cream);
}
.viewer[open] { display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.viewer, .viewer[open] { transform: none; }          /* el visor solo se desvanece (no se achica) */
@starting-style { .viewer[open] { opacity: 0; transform: none; } }
.viewer::backdrop { background: #000; }
.viewer .zoom { height: 100%; min-height: 0; }
.viewer .zoom img { max-height: calc(100vh - 6rem); max-height: calc(100svh - 6rem); }
.viewer__hint { color: rgba(240, 231, 224, .75); padding: .5rem 1rem 1rem; }
.viewer__counter { position: absolute; top: 1.2rem; left: 50%; transform: translateX(-50%); z-index: 3; padding: .35rem .9rem; border-radius: 999px; background: rgba(28, 27, 18, .62); font-weight: 600; font-size: var(--fs-small); letter-spacing: .08em; }
.viewer__close, .viewer__nav {
  position: absolute; z-index: 3;
  display: grid; place-items: center;
  width: 52px; height: 52px; border: 0; border-radius: 50%;
  background: rgba(250, 246, 242, .94); color: var(--c-ink);
  transition: background-color 150ms ease, transform 160ms var(--ease-out);
}
.viewer__close:active { transform: scale(.95); }
.viewer__nav:active { transform: translateY(-50%) scale(.95); }
@media (hover: hover) and (pointer: fine) { .viewer__close:hover, .viewer__nav:hover { background: var(--c-rose); } }
.viewer__close { top: 1rem; right: 1rem; }
.viewer__nav { top: 50%; transform: translateY(-50%); }
.viewer__nav--prev { left: 1rem; }
.viewer__nav--next { right: 1rem; }
.viewer__nav[hidden] { display: none; }

/* ---------- Tablet y celular: una columna, fotos que se deslizan ---------- */
@media (max-width: 860px) {
  .product-layout { grid-template-columns: minmax(0, 1fr); }   /* minmax(0, …): la columna nunca se agranda más que la pantalla */

  .product-photos {
    display: flex; gap: 8px;
    overflow-x: auto; scroll-snap-type: x mandatory;
    margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); scroll-padding-inline: var(--gutter);
    scrollbar-width: none;
  }
  .product-photos::-webkit-scrollbar { display: none; }
  .pp-item { flex: 0 0 84%; max-width: 440px; scroll-snap-align: start; }
  .pp-item:only-child { flex-basis: 100%; max-width: none; }
  .pp-item:last-child:nth-child(odd):not(:only-child) { grid-column: auto; justify-self: auto; width: auto; }
  .product-photos__counter { display: block; margin-top: .6rem; text-align: center; font-size: var(--fs-small); font-weight: 600; color: var(--c-ink-soft); letter-spacing: .08em; }

  .product-info { position: static; max-height: none; overflow: visible; padding: 0; }
  /* Cantidad + botón quedan siempre a mano, sin tener que scrollear hasta el final */
  .product-buy {
    position: sticky; bottom: .8rem; z-index: 5;
    box-shadow: 0 0 0 .8rem var(--c-paper), 0 10px 24px -6px rgba(38, 36, 27, .35);
    background: var(--c-paper); border-radius: 999px;
  }
  /* Los botones flotantes de contacto siguen visibles, un poco más arriba para no tapar el botón de reservar */
  .is-product .float-contact { bottom: 6.2rem; }

  /* Flechas del visor más chicas y a los costados, para no tapar los botones + y − */
  .viewer__close, .viewer__nav { width: 46px; height: 46px; }
  .viewer__nav { background: rgba(250, 246, 242, .82); }
  .viewer__nav--prev { left: .5rem; }
  .viewer__nav--next { right: .5rem; }
  .product-buy { gap: .6rem; }
  .product-buy .qty button { width: 42px; }
  .product-buy .btn { font-size: 1rem; padding-inline: .8rem; }   /* 16 px: así "Agregar a mi reserva" entra completo junto a la cantidad */
}
