/* ==========================================================================
   Smart Popup — base layout (theme-agnostic)
   Theme files: smart_popup.theme-<name>.css
   License: GPLv3
   ========================================================================== */

/* Hidden source containers */
.smart-popup-source { display: none !important; }

/* Trigger baseline */
.smart-popup-trigger { cursor: pointer; font: inherit; }
.smart-popup-trigger[aria-busy="true"] { opacity: .7; cursor: progress; }

/* Screen-reader-only live region (announces open/close + loading) */
.smart-popup-live {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); clip-path: inset(50%);
  overflow: hidden; white-space: nowrap;
}

/* ---------- Popup base ---------- */
.smart-popup {
  position: absolute;
  z-index: 9999;
  max-width: min(420px, calc(100vw - 16px));
  min-width: 200px;
  opacity: 0;
  transform: translateY(4px) scale(.985);
  transition:
    opacity .22s ease,
    transform .32s cubic-bezier(.16,.84,.32,1);
  pointer-events: none;
  will-change: transform, opacity;
  /* @fix do not apply own font-style and font color if not wanted */
  /* font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  color: #1f2937; */
}
.smart-popup:focus { outline: none; }
.smart-popup.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Directional entry (popup slides slightly toward its trigger) */
.smart-popup.smart-popup--placement-top    { transform: translateY(-6px) scale(.985); }
.smart-popup.smart-popup--placement-bottom { transform: translateY( 6px) scale(.985); }
.smart-popup.smart-popup--placement-left   { transform: translateX(-6px) scale(.985); }
.smart-popup.smart-popup--placement-right  { transform: translateX( 6px) scale(.985); }
.smart-popup.is-open.smart-popup--placement-top,
.smart-popup.is-open.smart-popup--placement-bottom,
.smart-popup.is-open.smart-popup--placement-left,
.smart-popup.is-open.smart-popup--placement-right { transform: translate(0,0) scale(1); }

.smart-popup__inner {
  position: relative;
  padding: 14px 36px 14px 16px;
  border-radius: 10px;
  background: #ffffff;
}
.smart-popup__content { font-size: 14px; }
.smart-popup__content > :first-child { margin-top: 0; }
.smart-popup__content > :last-child  { margin-bottom: 0; }
.smart-popup__content a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.smart-popup__content a:hover { text-decoration-thickness: 2px; }

/* Loading spinner shown during AJAX fetch */
.smart-popup__loading {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: inherit; opacity: .85;
}
.smart-popup__spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: smart-popup-spin .8s linear infinite;
}
@keyframes smart-popup-spin { to { transform: rotate(360deg); } }

/* Close (X) built from two spans */
.smart-popup__close {
  position: absolute;
  top: 6px; right: 6px;
  width: 24px; height: 24px;
  border: 0; background: transparent; padding: 0;
  border-radius: 6px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s ease;
  color: inherit;
  opacity: .65;
}
.smart-popup__close:hover { background: rgba(0,0,0,.06); opacity: 1; }
.smart-popup__close:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.smart-popup__close-bar {
  position: absolute;
  width: 12px; height: 1.5px; border-radius: 2px;
  background: currentColor;
  transform: rotate(45deg);
}
.smart-popup__close-bar--alt { transform: rotate(-45deg); }

/* ---------- Arrow ---------- */
.smart-popup__arrow {
  position: absolute;
  width: 12px; height: 12px;
  pointer-events: none;
  z-index: -1;
}
.smart-popup--has-arrow .smart-popup__arrow::before {
  content: "";
  position: absolute; inset: 0;
  background: var(--smart-popup-arrow-bg, #ffffff);
  transform: rotate(45deg);
  border-radius: 2px;
}
.smart-popup__arrow--top    { bottom: -5px; }
.smart-popup__arrow--bottom { top: -5px; }
.smart-popup__arrow--left   { right: -5px; }
.smart-popup__arrow--right  { left: -5px; }

/* Focusable elements inside popup get visible focus ring */
.smart-popup__content :focus-visible,
.smart-popup__close:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
  border-radius: 3px;
}

/* Small screens */
@media (max-width: 480px) {
  .smart-popup { max-width: calc(100vw - 16px); }
  .smart-popup__inner { padding: 12px 32px 12px 14px; }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  .smart-popup,
  .smart-popup.smart-popup--placement-top,
  .smart-popup.smart-popup--placement-bottom,
  .smart-popup.smart-popup--placement-left,
  .smart-popup.smart-popup--placement-right {
    transition: opacity .12s linear;
    transform: none !important;
  }
  .smart-popup__spinner { animation: none; }
}
