/* Shared ref popup — parity with /pdd/slozhnye/ hq-rule-modal */

dialog.hq-rule-modal {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 1.1rem;
  border: none;
  background: transparent;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  z-index: 80;
  touch-action: none;
}

dialog.hq-rule-modal:not([open]) {
  display: none;
}

dialog.hq-rule-modal::backdrop {
  background: rgba(4, 10, 22, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 200ms ease;
}

dialog.hq-rule-modal.is-open::backdrop {
  opacity: 1;
}

dialog.hq-rule-modal.is-closing::backdrop {
  opacity: 0;
}

.hq-rule-modal__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(34rem, 100%);
  max-height: min(86vh, 40rem);
  overflow: hidden;
  padding: 1.25rem 0.35rem 1.1rem 1.15rem;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(160deg, rgba(18, 32, 52, 0.97), rgba(10, 18, 32, 0.99));
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.55);
  color: var(--text, #eef3ff);
  opacity: 0;
  transform: scale(0.92) translateY(12px);
  transition: opacity 200ms ease, transform 220ms ease;
  touch-action: manipulation;
}

dialog.hq-rule-modal.is-open .hq-rule-modal__panel {
  opacity: 1;
  transform: none;
}

dialog.hq-rule-modal.is-closing .hq-rule-modal__panel {
  opacity: 0;
  transform: scale(0.96) translateY(8px);
}

html[data-theme="light"] .hq-rule-modal__panel {
  background: linear-gradient(160deg, rgba(255, 252, 246, 0.98), rgba(245, 240, 230, 0.98));
  border-color: rgba(32, 27, 18, 0.12);
  color: #1b2430;
}

html[data-theme="light"] dialog.hq-rule-modal::backdrop {
  background: rgba(32, 27, 18, 0.5);
}

.hq-rule-modal__close {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  z-index: 2;
  width: 2.2rem;
  height: 2.2rem;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.hq-rule-modal__kicker {
  flex: 0 0 auto;
  margin: 0 2rem 0.35rem 0;
  padding-right: 0.8rem;
  font-size: 0.82rem;
  line-height: 1.35;
  opacity: 0.72;
}

.hq-rule-modal__title {
  flex: 0 0 auto;
  margin: 0 2rem 0.55rem 0;
  padding-right: 0.8rem;
  font-size: 1.25rem;
  line-height: 1.25;
}

.hq-rule-modal__body {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0.15rem 0.8rem 0.35rem 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-width: none;
  -ms-overflow-style: none;
  font-size: 0.98rem;
  line-height: 1.55;
  cursor: grab;
}

.hq-rule-modal__body.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.hq-rule-modal__body::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.hq-rule-modal__body p {
  margin: 0 0 0.65rem;
  white-space: pre-wrap;
}

.hq-rule-modal__img {
  display: block;
  width: min(12rem, 70%);
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  margin: 0 auto 0.85rem;
  padding: 0.45rem;
  border-radius: 14px;
  background: #fff;
  box-sizing: border-box;
}

.hq-rule-modal__sum {
  margin: 0.35rem 0 0 !important;
  font-weight: 750;
  color: #ff6b6b;
}

html[data-theme="light"] .hq-rule-modal__sum {
  color: #c62828;
}

.hq-rule-modal__table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 0.75rem;
  font-size: 0.92em;
  line-height: 1.4;
}

.hq-rule-modal__table th,
.hq-rule-modal__table td {
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 0.4rem 0.5rem;
  text-align: left;
  vertical-align: top;
  white-space: normal;
}

.hq-rule-modal__table th {
  font-weight: 750;
  background: rgba(90, 168, 255, 0.14);
}

.hq-rule-modal__table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.04);
}

html[data-theme="light"] .hq-rule-modal__table th,
html[data-theme="light"] .hq-rule-modal__table td {
  border-color: rgba(32, 27, 18, 0.12);
}

html[data-theme="light"] .hq-rule-modal__table th {
  background: rgba(30, 100, 200, 0.1);
}

html[data-theme="light"] .hq-rule-modal__table tbody tr:nth-child(even) td {
  background: rgba(32, 27, 18, 0.035);
}

.hq-rule-modal__actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.75rem;
  padding-right: 0.8rem;
}

.hq-rule-modal__cta {
  text-decoration: none;
}

@media (prefers-reduced-motion: reduce) {
  dialog.hq-rule-modal::backdrop,
  .hq-rule-modal__panel {
    transition: none !important;
  }

  dialog.hq-rule-modal.is-open .hq-rule-modal__panel,
  dialog.hq-rule-modal.is-closing .hq-rule-modal__panel {
    transform: none;
  }
}
