/* Unified square product media across the storefront. */
.product-image,
.catalog-card .product-image {
  width: 100%;
  height: auto !important;
  aspect-ratio: 1 / 1 !important;
  overflow: hidden;
  background: #f3f3f3;
}

.product-image img,
.catalog-card .product-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.product-gallery-main {
  width: 100%;
  height: auto !important;
  aspect-ratio: 1 / 1;
}

.product-gallery-main img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.product-thumb {
  aspect-ratio: 1 / 1;
}

.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

/* Routed pages: calm, product-shaped loading state instead of generic blocks. */
.skeleton-grid {
  width: min(980px, 100%);
  min-height: clamp(560px, 62vh, 720px);
  margin: 0 auto;
  padding: 112px 0 70px;
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(300px, .94fr);
  grid-template-rows: minmax(250px, auto) minmax(92px, auto) minmax(88px, auto);
  gap: 18px;
  position: relative;
  align-content: start;
}

.skeleton-grid::before {
  content: "UP";
  position: absolute;
  left: 50%;
  top: 30px;
  translate: -50% 0;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--storefront-primary);
  color: #fff;
  font: 800 14px/1 var(--font-display);
  box-shadow: 0 0 0 8px rgba(1, 164, 158, .08);
  animation: routeLoaderPulse 1.65s ease-in-out infinite;
}

.skeleton-grid::after {
  content: "Загружаем страницу…";
  position: absolute;
  left: 50%;
  top: 88px;
  translate: -50% 0;
  color: #596666;
  font: 650 13px/1.2 var(--font-body);
  letter-spacing: .1px;
  white-space: nowrap;
  animation: routeLoaderText 1.65s ease-in-out infinite;
}

.skeleton-grid .skeleton {
  position: relative;
  height: auto !important;
  min-height: 88px;
  overflow: hidden;
  border: 1px solid #edf1f1;
  border-radius: 16px;
  background: linear-gradient(110deg, #f6f8f8 8%, #eef7f6 18%, #f6f8f8 33%);
  background-size: 220% 100%;
  box-shadow: 0 12px 30px rgba(28, 52, 51, .045);
  animation: routeLoaderShimmer 1.25s linear infinite;
}

.skeleton-grid .skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(1, 164, 158, .075), transparent);
  transform: translateX(-100%);
  animation: routeLoaderSweep 1.7s ease-in-out infinite;
}

.skeleton-grid .skeleton:nth-child(1) {
  grid-column: 1;
  grid-row: 1 / span 2;
  aspect-ratio: 1 / 1;
  min-height: 0;
}

.skeleton-grid .skeleton:nth-child(2) {
  grid-column: 2;
  grid-row: 1;
  min-height: 270px;
}

.skeleton-grid .skeleton:nth-child(3) {
  grid-column: 2;
  grid-row: 2;
  min-height: 92px;
}

.skeleton-grid .skeleton:nth-child(4) {
  grid-column: 1 / -1;
  grid-row: 3;
  min-height: 88px;
}

@keyframes routeLoaderShimmer {
  to { background-position-x: -220%; }
}

@keyframes routeLoaderSweep {
  50%, 100% { transform: translateX(100%); }
}

@keyframes routeLoaderPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 8px rgba(1, 164, 158, .08);
  }
  50% {
    transform: scale(1.07);
    box-shadow: 0 0 0 14px rgba(1, 164, 158, 0);
  }
}

@keyframes routeLoaderText {
  0%, 100% { opacity: .55; }
  50% { opacity: 1; }
}

@media (max-width: 760px) {
  .product-gallery-main {
    width: 100%;
    height: auto !important;
    aspect-ratio: 1 / 1;
  }

  .skeleton-grid {
    min-height: 540px;
    padding: 102px 0 54px;
    grid-template-columns: 1fr;
    grid-template-rows: none;
    gap: 12px;
  }

  .skeleton-grid::before {
    top: 26px;
    width: 46px;
    height: 46px;
  }

  .skeleton-grid::after {
    top: 80px;
  }

  .skeleton-grid .skeleton:nth-child(n) {
    grid-column: auto;
    grid-row: auto;
    aspect-ratio: auto;
    min-height: 82px;
  }

  .skeleton-grid .skeleton:nth-child(1) {
    aspect-ratio: 1 / 1;
    min-height: 0;
  }

  .skeleton-grid .skeleton:nth-child(2) {
    min-height: 150px;
  }

  .skeleton-grid .skeleton:nth-child(3) {
    min-height: 76px;
  }

  .skeleton-grid .skeleton:nth-child(4) {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-grid::before,
  .skeleton-grid::after,
  .skeleton-grid .skeleton,
  .skeleton-grid .skeleton::after {
    animation: none !important;
  }
}
