/**
 * Модалка карточки товара (главная, корзина, product-view).
 * Подключается через includes/product-modal-link.php
 */
dialog.pd-dlg:not([open]) {
  display: none !important;
}
dialog.pd-dlg {
  border: none;
  border-radius: var(--radius-lg, 12px);
  width: 450px;
  max-width: 95vw;
  height: 750px;
  max-height: 90vh;
  overflow: hidden;
  padding: 0;
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,.12));
  background: var(--card, #fff);
  position: fixed;
  inset: 0;
  margin: auto;
}
@media (max-width: 500px) {
  /* Выше шапки/моб. меню (.header__mobmenu-panel z-index:12000, .mobile-menu:1000) */
  dialog.pd-dlg {
    width: 95%;
    max-width: 95vw;
    height: 700px;
    max-height: min(700px, 95vh);
    z-index: 20000;
  }
  .pd-footer .btn,
  .pd-footer .preorder-btn,
  .pd-footer .out-of-stock-btn {
    font-size: 1rem !important;
    padding: 14px 18px !important;
    min-height: 48px;
  }
  .pd-footer .cart-qty-ctrl button {
    width: 44px;
    height: 42px;
    font-size: 1.4rem;
  }
  .pd-footer .cart-qty-ctrl .qty-val,
  .pd-footer .qty-val {
    font-size: 1.1rem;
    min-width: 36px;
  }
  .pd-footer .cart-in-label {
    font-size: 0.88rem;
  }
  .pd-mods .mod-pill {
    padding: 8px 16px;
    font-size: 0.88rem;
  }
}
dialog.pd-dlg[open] {
  display: flex !important;
  flex-direction: column;
}
/* Тост «нет отзывов» (fallback без Popover) — не обрезать fixed-потомка */
dialog.pd-dlg.pd-dlg--rv-empty-toast {
  overflow: visible;
}
/* Иначе overflow:hidden обрезает полноэкранный слой-потомок */
dialog.pd-dlg:has(.pd-fs-lightbox.is-open),
dialog.pd-dlg.pd-dlg--fs-open {
  overflow: visible;
}
dialog.pd-dlg::backdrop {
  background: rgba(0, 0, 0, 0.55);
}
.pd-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.pd-footer {
  flex: 0 0 auto;
  padding: 12px 20px;
  border-top: 1px solid var(--border-light, #EEE);
  background: var(--card, #fff);
  border-radius: 0 0 var(--radius-lg, 12px) var(--radius-lg, 12px);
}
/* «В корзине» по центру зоны слева; −/число/+ справа */
.pd-footer .cart-qty-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: auto;
  padding: 10px 12px;
  background: var(--primary, #005BFF);
  color: #fff;
  border-radius: var(--radius-sm, 4px);
}
.pd-footer .cart-qty-row.cart-qty-row--preorder {
  background: #ff9800 !important;
}
.pd-footer .cart-in-label {
  flex: 1;
  justify-content: center;
  min-width: 0;
}
.pd-footer .cart-qty-ctrl {
  flex-shrink: 0;
  align-self: auto;
}
@media (max-width: 500px) {
  .pd-footer .cart-qty-row {
    padding: 12px 14px;
    gap: 10px;
  }
}
.pd-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.pd-close:hover {
  background: rgba(0, 0, 0, 0.6);
}
.pd-gallery {
  position: relative;
  background: var(--card, #fff);
  border-radius: var(--radius-lg, 12px) var(--radius-lg, 12px) 0 0;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.pd-gallery img {
  width: 100%;
  height: 360px;
  object-fit: contain;
  display: block;
}
.pd-nav {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 30%;
  display: flex;
  align-items: center;
  cursor: pointer;
  z-index: 2;
  opacity: 0;
  transition: none;
}
.pd-nav i {
  display: none !important;
}
.pd-nav:hover {
  opacity: 0;
}
.pd-nav-l {
  left: 0;
  padding-left: 10px;
  justify-content: flex-start;
}
.pd-nav-r {
  right: 0;
  padding-right: 10px;
  justify-content: flex-end;
}
.pd-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  z-index: 3;
  pointer-events: auto;
  flex-wrap: wrap;
  padding: 0 8px;
  box-sizing: border-box;
}
.pd-dots__dot {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.28);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.pd-dots__dot.is-active {
  background: var(--primary, #005bff);
  transform: scale(1.2);
}
[data-theme="dark"] .pd-dots__dot {
  background: rgba(255, 255, 255, 0.35);
}
[data-theme="dark"] .pd-dots__dot.is-active {
  background: var(--primary, #5b9fff);
}
.pd-body {
  padding: 20px;
}
.pd-name {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
.pd-name__product {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
}
.pd-name__mod {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-secondary, #555);
}
[data-theme="dark"] .pd-name__mod {
  color: var(--text-muted, #aaa);
}
.pd-price-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
  flex-wrap: nowrap;
}
.pd-price-row .pd-price {
  flex: 1;
  min-width: 0;
}
.pd-price-row .pd-rating-row {
  flex-shrink: 0;
  margin: 0;
  justify-content: center;
}
.pd-price {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary, #005BFF);
  margin-bottom: 0;
}
.pd-price .old {
  font-size: 0.9rem;
  color: var(--text-muted, #999);
  text-decoration: line-through;
  margin-left: 8px;
  font-weight: 400;
}
.pd-price .badge {
  background: var(--danger, #F44336);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  margin-left: 8px;
}
.pd-desc {
  font-size: 0.9rem;
  color: var(--text-secondary, #666);
  line-height: 1.6;
  margin: 12px 0;
}
.pd-specs {
  margin: 12px 0;
}
.pd-mods {
  margin: 12px 0;
}
.pd-mods-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted, #999);
  margin-bottom: 6px;
}

.pd-specs-box {
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--bg-secondary, #f8f9fb);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text, #333);
}
.pd-specs-box__title {
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text, #333);
}
.pd-specs-box__row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 0;
  border-bottom: 1px solid var(--border-light, #eee);
}
.pd-specs-box__row:last-child {
  border-bottom: none;
}
.pd-specs-box__label {
  color: var(--text-muted, #888);
  flex-shrink: 0;
}

/* Полноэкранный просмотр фото (дочерний узел dialog → тот же top layer) */
.pd-fs-lightbox {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  box-sizing: border-box;
  z-index: 2147483000;
  background: #000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.pd-fs-lightbox.is-open {
  display: flex;
}
.pd-fs-close {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 2147483002;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pd-fs-close:hover {
  background: rgba(255, 255, 255, 0.28);
}
.pd-fs-frame {
  position: relative;
  max-width: 100vw;
  max-height: 100vh;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pd-fs-img {
  display: block;
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
  object-fit: contain;
  margin: 0;
  padding: 0;
  border: none;
  outline: none;
  box-shadow: none;
}
.pd-fs-hits {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 3fr 4fr 3fr;
  z-index: 2147483001;
}
.pd-fs-hit {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
.pd-fs-hit-l {
  cursor: w-resize;
}
.pd-fs-hit-c {
  cursor: zoom-out;
}
.pd-fs-hit-r {
  cursor: e-resize;
}
.pd-fs-hit:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: -2px;
}
