/**
 * Модалка карточки товара (главная, корзина, product-view).
 * Подключается через includes/product-modal-link.php
 */
.apparel-color-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 5px 12px 5px 6px;
  border: 1px solid #ddd;
  border-radius: 16px;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
  background: #fff;
  color: #333;
  transition: all 0.15s;
}
.apparel-color-chip.active {
  border-color: #005bff;
  box-shadow: 0 0 0 2px rgba(0, 91, 255, 0.15);
  font-weight: 600;
}
.apparel-color-chip.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}
.apparel-color-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}
.mod-pill.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

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;
}
dialog.pd-dlg:focus,
dialog.pd-dlg:focus-visible {
  outline: none !important;
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,.12)) !important;
}
@media (max-width: 500px) {
  /* Выше шапки/моб. панели меню (.header__mobmenu-panel z-index:12000) */
  /* max-height: var(--pd-vh-px) задаётся в JS при открытии — без пересчёта vh при скрытии адресной строки */
  dialog.pd-dlg {
    width: 95%;
    max-width: 95vw;
    height: 700px;
    max-height: min(700px, var(--pd-vh-px, 95vh));
    z-index: 20000;
  }
  .pd-footer .btn,
  .pd-footer .pd-order-btn,
  .pd-footer .preorder-btn,
  .pd-footer .out-of-stock-btn {
    font-size: 1rem !important;
    padding: 14px 18px !important;
    min-height: 48px;
  }
  .pd-footer .pd-order-btn {
    font-size: 0.92rem !important;
    padding: 12px 10px !important;
    white-space: nowrap;
  }
  .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;
  /* Выше .pd-dlg-touch-guard (19999), иначе подложка перехватывает клики по карточке */
  z-index: 20001;
}
/* Тост «нет отзывов» (fallback без Popover) — не обрезать fixed-потомка */
dialog.pd-dlg.pd-dlg--rv-empty-toast {
  overflow: visible;
}
dialog.pd-dlg.pd-dlg--inline-toast {
  overflow: visible;
}
/* Тост «Ссылка скопирована» и др. — поверх скролла и кнопок шапки */
dialog.pd-dlg .rv-inline-toast {
  z-index: 100001;
  pointer-events: none;
}
/* Иначе 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 .pd-cart-split {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.pd-footer .pd-order-btn {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--radius-sm, 4px);
  background: var(--primary, #005BFF);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  white-space: nowrap;
  line-height: 1.15;
}
.pd-footer .pd-cart-split .cart-qty-ctrl {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 4px;
  background: var(--primary, #005BFF);
  color: #fff;
  border-radius: var(--radius-sm, 4px);
}
.pd-footer .pd-cart-split .cart-qty-ctrl button {
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-weight: 700;
}
.pd-footer .pd-cart-split .cart-qty-ctrl button:hover {
  background: rgba(255, 255, 255, 0.4);
  color: #fff;
  border-color: transparent;
}
.pd-footer .pd-cart-split .cart-qty-ctrl button:disabled {
  opacity: 0.45;
  cursor: default;
}
.pd-footer .pd-cart-split .cart-qty-ctrl .qty-val {
  min-width: 28px;
  text-align: center;
  color: #fff;
  font-weight: 700;
}
.pd-footer .pd-cart-split--preorder .pd-order-btn,
.pd-footer .pd-cart-split--preorder .cart-qty-ctrl {
  background: #ff9800;
}
.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-head-actions {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 10010;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.pd-head-actions__tools {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.pd-close {
  position: static;
  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;
  flex-shrink: 0;
}
/* Как .rv-card__icon-btn в отзывах */
.pd-icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--border, #ddd);
  background: var(--bg-secondary, #f7f7f7);
  color: var(--text-muted, #888);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
.pd-icon-btn:hover {
  color: var(--text, #333);
  border-color: #ccc;
}
.pd-icon-btn:focus,
.pd-icon-btn:focus-visible {
  outline: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
[data-theme='dark'] .pd-icon-btn {
  background: var(--bg-secondary, #1e1e1e);
  border-color: var(--border, #404040);
  color: var(--text-muted, #aaa);
}
[data-theme='dark'] .pd-icon-btn:hover {
  color: var(--text, #f5f5f5);
  border-color: var(--border, #505050);
}
.pd-close:hover {
  background: rgba(0, 0, 0, 0.6);
}
.pd-close:focus,
.pd-close:focus-visible,
.pd-fs-close:focus,
.pd-fs-close:focus-visible {
  outline: none;
  box-shadow: none;
}
.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-img-wrap {
  position: relative;
  display: block;
  width: 100%;
}
.pd-img-wrap > img {
  width: 100%;
  height: 360px;
  object-fit: contain;
  display: block;
}
.pd-img-overlays {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  max-width: calc(100% - 16px);
  pointer-events: none;
}
.pd-img-overlays .pd-rating-row {
  pointer-events: auto;
}
.pd-no-discounts-badge {
  position: static;
  top: auto;
  right: auto;
  left: auto;
  z-index: auto;
  margin: 0;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: #bf360c;
  background: rgba(255, 243, 224, 0.95);
  border: 1px solid rgba(230, 81, 0, 0.35);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  pointer-events: none;
}
.pd-no-discounts-badge[hidden] {
  display: none !important;
}
.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-rating-row__btn:focus,
.pd-rating-row__btn:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}
.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-subscription-warning {
  margin: 10px 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #ffe082;
  background: #fff8e1;
  color: #8d6e63;
  font-size: 0.86rem;
  line-height: 1.45;
}
[data-theme="dark"] .pd-subscription-warning {
  border-color: #6d4c41;
  background: rgba(109, 76, 65, 0.22);
  color: #ffcc80;
}
.pd-subscription-warning--blocked {
  border-color: #ef9a9a;
  background: #ffebee;
  color: #c62828;
  font-weight: 600;
}
[data-theme="dark"] .pd-subscription-warning--blocked {
  border-color: #c62828;
  background: rgba(198, 40, 40, 0.2);
  color: #ef9a9a;
}
.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;
}

/* Подложка под модалкой (моб.): ловит тапы/скролл вне карточки при полифилле <dialog> без backdrop */
.pd-dlg-touch-guard {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 19999;
  pointer-events: none;
  background: transparent;
}
.pd-dlg-touch-guard.pd-dlg-touch-guard--on {
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.01);
}

/* Модалка товара открыта: не скроллить фон (дополнение к перехвату pointer в product-modal.js) */
/* Без height:100% на html — на iOS это вместе с vh даёт «прилипание» низа карточки к смене высоты из-за адресной строки */
@media (max-width: 767px) {
  html.pd-dlg-open {
    overflow: hidden;
    overscroll-behavior: none;
  }
  html.pd-dlg-open body {
    overflow: hidden;
    overscroll-behavior: none;
  }
}
