/* V1.115 — nested rules details own focus while preserving their parent modal session. */
html body.rules-modal-open:not(.maintenance-mode) :is(
  #damageTypeDialog,
  #identityRulesDialog
)[data-nested-rules-detail="true"] {
  pointer-events: auto;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

html body.rules-modal-open:not(.maintenance-mode) :is(
  #damageTypeDialog,
  #identityRulesDialog
)[data-nested-rules-detail="true"] > .rules-box {
  max-height: min(92dvh, 920px);
  overflow: auto;
  overscroll-behavior: contain;
}

html body.rules-modal-open:not(.maintenance-mode) :is(
  #closeDamageTypeGuide,
  #closeIdentityRulesDetail
):focus-visible {
  outline: 2px solid #8edcff !important;
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(73, 178, 225, 0.18), 0 0 18px rgba(69, 184, 231, 0.2) !important;
}

@media (max-width: 720px) {
  html body.rules-modal-open:not(.maintenance-mode) :is(
    #damageTypeDialog,
    #identityRulesDialog
  )[data-nested-rules-detail="true"] > .rules-box {
    max-height: calc(100dvh - max(12px, env(safe-area-inset-top)) - max(12px, env(safe-area-inset-bottom)));
  }
}

@media (prefers-reduced-motion: reduce) {
  html body.rules-modal-open:not(.maintenance-mode) :is(
    #damageTypeDialog,
    #identityRulesDialog
  )[data-nested-rules-detail="true"] > .rules-box {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

@media (forced-colors: active) {
  html body.rules-modal-open:not(.maintenance-mode) :is(
    #closeDamageTypeGuide,
    #closeIdentityRulesDetail
  ):focus-visible {
    border: 2px solid CanvasText !important;
    outline: 2px solid Highlight !important;
    box-shadow: none !important;
  }
}
