/* XIII Popup - Mobile First */
.xiii-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease;
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
}

.xiii-popup-overlay[hidden] {
  display: none;
}

.xiii-popup-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

/* موقعیت پیش‌فرض موبایل */
.xiii-m-pos-bottom {
  align-items: flex-end;
  justify-content: center;
}
.xiii-m-pos-top {
  align-items: flex-start;
  justify-content: center;
}
.xiii-m-pos-center {
  align-items: center;
  justify-content: center;
}

.xiii-popup-box {
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  box-sizing: border-box;
  text-align: right;
  direction: rtl;
}

.xiii-popup-close {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  line-height: 1;
  color: #444;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s ease;
}

.xiii-popup-close:hover,
.xiii-popup-close:focus-visible {
  background: rgba(0, 0, 0, 0.07);
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
}

.xiii-popup-title {
  margin: 0 0 12px;
  font-size: 1.25rem;
  line-height: 1.5;
}

.xiii-popup-content {
  font-size: 1rem;
  line-height: 1.9;
}

.xiii-popup-content img {
  max-width: 100%;
  height: auto;
}

.screen-reader-text {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

/* موقعیت دسکتاپ */
@media (min-width: 768px) {
  .xiii-popup-overlay {
    padding: 32px;
  }

  .xiii-pos-center {
    align-items: center;
    justify-content: center;
  }
  .xiii-pos-top {
    align-items: flex-start;
    justify-content: center;
  }
  .xiii-pos-bottom {
    align-items: flex-end;
    justify-content: center;
  }
  .xiii-pos-top-right {
    align-items: flex-start;
    justify-content: flex-end;
  }
  .xiii-pos-top-left {
    align-items: flex-start;
    justify-content: flex-start;
  }
  .xiii-pos-bottom-right {
    align-items: flex-end;
    justify-content: flex-end;
  }
  .xiii-pos-bottom-left {
    align-items: flex-end;
    justify-content: flex-start;
  }

  .xiii-popup-box {
    padding: 32px;
  }
  .xiii-popup-title {
    font-size: 1.5rem;
  }
}

/* انیمیشن‌ها */
.xiii-popup-overlay.is-visible .xiii-anim-fadeIn {
  animation: xiiiFadeIn 0.35s ease both;
}
.xiii-popup-overlay.is-visible .xiii-anim-zoomIn {
  animation: xiiiZoomIn 0.35s ease both;
}
.xiii-popup-overlay.is-visible .xiii-anim-slideUp {
  animation: xiiiSlideUp 0.35s ease both;
}
.xiii-popup-overlay.is-visible .xiii-anim-slideDown {
  animation: xiiiSlideDown 0.35s ease both;
}

@keyframes xiiiFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes xiiiZoomIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
@keyframes xiiiSlideUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes xiiiSlideDown {
  from {
    opacity: 0;
    transform: translateY(-40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .xiii-popup-overlay,
  .xiii-popup-box {
    animation: none !important;
    transition: none !important;
  }
}

body.xiii-popup-open {
  overflow: hidden;
}
