/* Photos of products: the primary image in every list, a gallery on the product
   page. Kept out of site.css so the catalog image layer is easy to find. */

/* ── Card photo ───────────────────────────────────────────────────────────── */

/* Every card shows the same 4:3 media box. The photo sits inside it with
   object-fit: contain, so portrait and landscape shots never change the card
   height. */
.pcard__media {
  position: relative;
  display: block;
  height: auto;
  min-height: 0;
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  /* Photos are shot on white: the frame must not show a grey border around them. */
  background: #fff;
  border-bottom: 0;
}

/* Products without a photo keep the same box and show a «Нет фото» plate. */
.pcard__media--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: auto;
  aspect-ratio: 4 / 3;
  padding: 0;
  /* The same white frame as a photo card: no coloured block in the grid. */
  background: #fff;
  border-bottom: 0;
}

.pcard__no-photo {
  margin-bottom: 1.2rem;
  padding: 1rem 2rem;
  border: 1px dashed var(--mf-line-strong, var(--mf-line));
  border-radius: var(--mf-radius-md);
  color: var(--mf-muted, #8a90a6);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.pcard__photo {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0.6rem;
  object-fit: contain;
}

.pcard__photos {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgba(6, 5, 36, 0.62);
  color: #fff;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.pcard__media-meta {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: linear-gradient(to top, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0));
}

.pcard__media-meta .pcard__sku,
.pcard__media-meta .pcard__category {
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.85);
}


/* ── Gallery on the product page ──────────────────────────────────────────── */

.gallery {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.gallery__stage {
  position: relative;
  padding: 0.5rem;
  border: 1px solid var(--mf-line);
  border-radius: var(--mf-radius-lg);
  background: #fff;
}

.gallery__viewport {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
}

/* Invisible button over the photo: a click opens the original in the lightbox. */
.gallery__zoom {
  position: absolute;
  inset: 0;
  z-index: 1;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.gallery__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.gallery__nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--mf-line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--mf-ink);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
  transition: border-color 0.15s ease, color 0.15s ease;
}

.gallery__nav:hover {
  border-color: var(--mf-navy);
  color: var(--mf-navy-700);
}

.gallery__nav--prev { left: 0.6rem; }
.gallery__nav--next { right: 0.6rem; }

.gallery__counter {
  position: absolute;
  right: 0.7rem;
  bottom: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(6, 5, 36, 0.62);
  color: #fff;
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
}

.gallery__thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-bottom: 0.25rem;
  scroll-snap-type: x proximity;
}

.gallery__thumb {
  position: relative;
  flex: 0 0 auto;
  width: 74px;
  height: 74px;
  padding: 0.2rem;
  border: 1px solid var(--mf-line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  scroll-snap-align: start;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.gallery__thumb:hover { border-color: var(--mf-lav-400); }

.gallery__thumb.is-active {
  border-color: var(--mf-navy);
  box-shadow: 0 0 0 2px rgba(38, 46, 112, 0.14);
}

.gallery__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.gallery__thumb-mark {
  position: absolute;
  top: -5px;
  right: -5px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 1px solid var(--mf-line);
  border-radius: 50%;
  background: #fff;
  color: var(--mf-red);
  font-size: 0.625rem;
  line-height: 1;
}

.gallery__foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  align-items: center;
  font-size: 0.8125rem;
}

.gallery__download,
.gallery__all {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--mf-navy-700);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.gallery__download,
.gallery__all { min-height: 30px; padding: 4px 2px; }
.gallery__download::before,
.gallery__all::before {
  content: "↓";
  text-decoration: none;
  font-weight: 600;
}

.gallery__download:hover,
.gallery__all:hover { color: var(--mf-red); }

/* ── Product page: the same 4:3 frame when there is no photo ─────────────── */

.product-media__no-photo {
  color: var(--mf-navy-500);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.product-media__frame {
  aspect-ratio: 4 / 3;
  max-height: none;
}

@media (max-width: 720px) {
  .gallery__nav { width: 32px; height: 32px; font-size: 1.1rem; }
  .gallery__thumb { width: 62px; height: 62px; }
}

/* Cards keep one height even when the text inside is shorter. */
.pcard {
  height: 100%;
}

/* ── Full-size photo viewer ───────────────────────────────────────────────── */

body.lightbox-open {
  overflow: hidden;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 3rem);
  background: rgba(6, 5, 36, 0.94);
}

.lightbox[hidden] {
  display: none;
}

.lightbox__img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  background: #fff;
  border-radius: var(--mf-radius-md);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
}

.lightbox__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease;
}

.lightbox__close:hover {
  background: rgba(255, 255, 255, 0.24);
}

.lightbox__nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
  transition: background 0.15s ease;
}

.lightbox__nav:hover {
  background: rgba(255, 255, 255, 0.24);
}

.lightbox__nav--prev { left: 1rem; }
.lightbox__nav--next { right: 1rem; }

.lightbox__counter {
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  transform: translateX(-50%);
}

@media (max-width: 720px) {
  .lightbox__nav { width: 38px; height: 38px; font-size: 1.3rem; }
  .lightbox__close { top: 0.6rem; right: 0.6rem; width: 38px; height: 38px; }
}
