/* sys-popup.css — Modal popup for cms-wide [data-cms-popup] anchors.
   Spec: docs/superpowers/specs/2026-05-19-popup-menu-and-shortcode-design.md
   Uses the native <dialog> element with showModal() so it lives in the
   browser's top layer -- escapes any ancestor transform/filter that would
   otherwise pin a fixed-positioned overlay to a non-viewport containing
   block. */

.cms-popup-dialog {
  /* Reset the default browser dialog frame */
  border: 0 !important;
  padding: 0 !important;
  background: #fff !important;
  color: inherit;

  /* Sizing -- 1250px max, with a small viewport gutter on small screens */
  width: min(1250px, calc(100vw - 32px)) !important;
  max-width: min(1250px, calc(100vw - 32px)) !important;
  max-height: 85vh !important;
  /* margin:auto + top:0 + bottom:0 makes <dialog> center vertically in the
     top layer. This is the magic that fixes the not-centered bug. */
  top: 0 !important;
  bottom: 0 !important;
  margin: auto !important;

  border-radius: 10px !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35) !important;
  overflow: hidden !important;

  display: flex;
  flex-direction: column;
}

/* :modal targets only dialogs opened with showModal() -- ensures these
   rules don't accidentally hit a normal <dialog open> (no top-layer). */
.cms-popup-dialog[open] {
  display: flex;
}

/* Dim backdrop */
.cms-popup-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.cms-popup-header {
  background: var(--cms-theme-color, #555);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}
.cms-popup-title {
  flex: 1;
  margin: 0;
  padding-right: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cms-popup-back,
.cms-popup-close {
  background: rgba(255, 255, 255, 0.18) !important;
  border: 0 !important;
  color: inherit !important;
  width: 38px !important;
  height: 38px !important;
  min-width: 38px !important;
  flex-shrink: 0 !important;
  border-radius: 50% !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 0 !important;
  cursor: pointer !important;
  padding: 0 !important;
  transition: background-color 120ms ease-out;
}
.cms-popup-back > svg,
.cms-popup-close > svg {
  display: block;
  width: 20px;
  height: 20px;
}
.cms-popup-back {
  margin-right: 10px !important;
}
.cms-popup-back[hidden] {
  display: none !important;
}
.cms-popup-back:hover,
.cms-popup-close:hover {
  background: rgba(255, 255, 255, 0.32) !important;
}
.cms-popup-back:focus,
.cms-popup-close:focus {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.cms-popup-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

.cms-popup-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 48px 0;
  color: #888;
  font-size: 14px;
}
.cms-popup-loading::before {
  content: '';
  width: 18px;
  height: 18px;
  margin-right: 10px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: cms-popup-spin 0.8s linear infinite;
}
@keyframes cms-popup-spin { to { transform: rotate(360deg); } }

body.cms-popup-open { overflow: hidden; }

@media (max-width: 640px) {
  .cms-popup-dialog {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
  }
}
