/* ===================================================
   ספר רב ממדי™ - סגנונות מודאל, סטיקי ונגן יוטיוב
   =================================================== */

/* --- 1. מעטפת המודאל והרקע הכהה --- */
.modal-overlay,
.custom-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
}

/* מסגרת התוכן הראשית של המודאל */
.modal-window,
.modal-container {
  position: relative;
  background-color: #ffffff;
  border-radius: 8px;
  max-width: 90vw;
  max-height: 90vh;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}

/* --- 2. טיפול בכפתור סגירה (מוגן מפני דריסה ב-LTR/RTL ויוטיוב) --- */
.modal-close-btn,
.close-button,
#youtube-modal .close-button {
  position: absolute;
  top: 12px;
  z-index: 100000; /* מעל ה-iframe של יוטיוב ומעל כל אלמנט פנימי */
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background-color: rgba(0, 0, 0, 0.6);
  color: #ffffff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: background-color 0.2s ease;
}

.modal-close-btn:hover,
.close-button:hover,
#youtube-modal .close-button:hover {
  background-color: rgba(0, 0, 0, 0.85);
}

/* מיקום כפתור סגירה ב-RTL (ברירת מחדל: שמאל למעלה) */
[dir="rtl"] .modal-close-btn,
[dir="rtl"] .close-button,
.modal-window:not([dir="ltr"]) .modal-close-btn {
  left: 12px;
  right: auto;
}

/* מיקום כפתור סגירה ב-LTR (ימין למעלה, מונע היעלמות) */
[dir="ltr"] .modal-close-btn,
[dir="ltr"] .close-button,
[dir="ltr"] #youtube-modal .close-button {
  right: 12px;
  left: auto;
}

/* --- 3. נגן יוטיוב רספונסיבי --- */
.youtube-wrapper {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* יחס מסך 16:9 */
  height: 0;
  overflow: hidden;
  border-radius: 8px;
}

.youtube-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* --- 4. מנגנון Sticky עבור openContentModal --- */

/* הקונטיינר היחיד שמבצע גלילה */
.modal-content-scroll {
  overflow-y: auto;
  position: relative;
  height: 100%;
  padding: 24px;
  box-sizing: border-box;
}

/* האלמנט שנשאר דביק למעלה בזמן גלילת הטקסט */
.modal-sticky-header,
.modal-sticky-element {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: #ffffff; /* רקע אטום למניעת התמזגות עם טקסט נגלל */
  padding-bottom: 12px;
  margin-top: 0;
}