/* quran/css/tafsir.css */

/* ═══════════════════════════════════════════════════════════════════════════
   وضع الشاشة الكاملة — مطابق لمنطق المصحف
   ═══════════════════════════════════════════════════════════════════════════ */

#tafsirArea.tafsir-fullscreen {
  background: #000 !important;
  padding: 0 !important;
  margin: 0 !important;
  width: calc(var(--mushaf-fullscreen-width-vw, 100) * 1vw);
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  display: flex !important;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
}

#tafsirArea.tafsir-fullscreen #tafsirFlipContainer {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  padding: 0.5rem 0;
  box-sizing: border-box;
}

#tafsirArea.tafsir-fullscreen #tafsirZoomWrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible;
  margin-top: 0 !important;
  max-height: 100vh;
  transform: none;
  box-sizing: border-box;
}

#tafsirArea.tafsir-fullscreen #tafsirBookFrame {
  width: auto;
  max-width: 100%;
  max-height: 96vh;
  margin: 0 auto;
  background: #fff !important;
  box-sizing: border-box;
}

#tafsirArea.tafsir-fullscreen #tafsirFlipBook {
  margin: 0 auto;
}

#tafsirArea.tafsir-fullscreen #tafsirFlipContainer,
#tafsirArea.tafsir-fullscreen #tafsirZoomWrapper {
  background: #000 !important;
}

#tafsirArea.tafsir-fullscreen #tafsirFlipBook .page {
  background: #fff !important;
}

#tafsirArea.tafsir-fullscreen #tafsirTopToolbar {
  display: none !important;
}

#tafsirArea.tafsir-fullscreen .tafsir-page-scroll {
  padding: 0.85rem 1.75rem 1.15rem;
  box-sizing: border-box;
}

#tafsirArea:fullscreen {
  background: #000 !important;
}

#tafsirArea:fullscreen::backdrop {
  background: #000 !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   نمط القراءة — إخفاء كل الواجهة ما عدا زر التفعيل + التفسير
   ═══════════════════════════════════════════════════════════════════════════ */

body.tafsir-reading-mode-active .wd-app {
  grid-template-columns: minmax(0, 1fr);
}

body.tafsir-reading-mode-active .wd-sidebar,
body.tafsir-reading-mode-active .wd-sidebar-toggle,
body.tafsir-reading-mode-active .wd-sidebar-overlay {
  display: none !important;
}

body.tafsir-reading-mode-active .wd-main,
body.tafsir-reading-mode-active .wd-content-quran,
body.tafsir-reading-mode-active .wd-quran-layout {
  width: 100%;
  max-width: 100%;
}

body.tafsir-reading-mode-active .wd-content-quran {
  padding: 0 !important;
}

body.tafsir-reading-mode-active .wd-quran-tools-top {
  position: fixed;
  top: 12px;
  inset-inline-start: 12px;
  inset-inline-end: auto;
  z-index: 220;
  width: auto;
  min-height: 0;
  padding: 0 !important;
  margin: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  pointer-events: none;
}

body.tafsir-reading-mode-active .wd-quran-tools-nav {
  width: auto;
  pointer-events: auto;
}

body.tafsir-reading-mode-active #tafsirTopToolbar {
  display: flex;
  width: auto;
  grid-template-columns: auto;
  justify-content: flex-start;
}

body.tafsir-reading-mode-active #tafsirTopToolbar .quran-toolbar-main {
  display: none !important;
}

body.tafsir-reading-mode-active #tafsirReadingModeToggle {
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.12);
}

body.tafsir-reading-mode-active .wd-quran-fullscreen-dock,
body.tafsir-reading-mode-active #quranToolsPanels {
  display: none !important;
}

body.tafsir-reading-mode-active .wd-quran-viewport {
  padding-top: 0 !important;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
}

body.tafsir-reading-mode-active .wd-quran-center {
  width: 100%;
  max-width: 100%;
  justify-content: center;
}

#tafsirArea.tafsir-reading-mode:not(.tafsir-fullscreen) {
  width: 100%;
  min-height: calc(100vh - 56px);
  justify-content: center;
  align-items: center;
}

#tafsirArea.tafsir-reading-mode #tafsirFloatExitDock {
  display: none !important;
}

#tafsirArea.tafsir-reading-mode:not(.tafsir-fullscreen) .tafsir-book-toolbar {
  display: none !important;
}

#tafsirArea.tafsir-reading-mode:not(.tafsir-fullscreen) #tafsirFlipContainer,
#tafsirArea.tafsir-reading-mode:not(.tafsir-fullscreen) #tafsirZoomWrapper {
  margin-top: 0 !important;
}

.wd-body-quran #tafsirArea.tafsir-reading-mode:not(.tafsir-fullscreen) #tafsirBookFrame {
  position: relative;
  height: var(--mushaf-max-height);
  max-height: var(--mushaf-max-height);
  max-width: var(--mushaf-max-width);
  border: none;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
}

.wd-body-quran #tafsirArea.tafsir-reading-mode:not(.tafsir-fullscreen) #tafsirFlipBook {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: none;
}

.wd-body-quran #tafsirArea.tafsir-reading-mode:not(.tafsir-fullscreen) .tafsir-page-scroll {
  padding: 0.75rem 1.4rem 1.1rem;
  box-sizing: border-box;
}

/* ═══════════════════════════════════════════════════════════════════════════
   مناطق نقر حواف الكتاب
   ═══════════════════════════════════════════════════════════════════════════ */

.tafsir-edge-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 18%;
  z-index: 500;
  cursor: pointer;
  pointer-events: all;
  background: transparent;
}

.tafsir-edge-left {
  left: 0;
}

.tafsir-edge-right {
  right: 0;
}

#tafsirModeWrapper #tafsirArea {
  width: 100%;
  min-height: 0;
  align-items: center;
}

#tafsirModeWrapper .page-content {
  height: 100%;
  overflow: hidden;
}

#tafsirModeWrapper .page-content > .flex {
  min-height: 0;
  height: 100%;
}

#tafsirModeWrapper .tafsir-page-scroll,
#tafsirArea .tafsir-page-scroll {
  min-height: 0;
  flex: 1 1 auto;
  max-height: none !important;
}

#tafsirModeWrapper .tafsir-book-btn {
  padding: 0.24rem 0.62rem !important;
  font-size: 0.78rem !important;
  line-height: 1.15 !important;
}

.tafsir-basmala {
  display: block;
  width: 100%;
  margin: 0.35rem 0 0.15rem;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.7;
  color: #047857;
}

.tafsir-ayah-line {
  display: block;
  width: 100%;
  margin: 0;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.7;
  color: #047857;
}

.tafsir-ayah-head {
  display: block;
  width: 100%;
  margin: 0 0 0.65rem;
  padding: 0.5rem 0.6rem 0.55rem;
  border-radius: 10px;
  background: #f0faf4;
  border: 1px solid #d1e7dd;
  box-sizing: border-box;
}

.tafsir-ayah-meta {
  display: block;
  width: 100%;
  margin: 0 0 0.35rem;
  text-align: center;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.35;
  color: #6b7280;
}

.tafsir-item {
  display: block;
  width: 100%;
}

.tafsir-item-sep {
  display: flex;
  justify-content: center;
  margin: 0.85rem 0;
}

.tafsir-item-sep::after {
  content: "";
  display: block;
  width: 3rem;
  height: 1px;
  background: #e5e7eb;
}

.tafsir-body {
  display: block;
  width: 100%;
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.8;
  color: #374151;
  text-align: justify;
}

/* Dashboard: same placement and dimensions as mushaf flip book */
.wd-body-quran #tafsirArea:not(.tafsir-fullscreen):not(.tafsir-reading-mode) #tafsirBookFrame {
  position: relative;
  height: var(--mushaf-max-height);
  max-height: var(--mushaf-max-height);
  max-width: var(--mushaf-max-width);
  border: none;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
}

.wd-body-quran #tafsirArea:not(.tafsir-fullscreen):not(.tafsir-reading-mode) .tafsir-book-toolbar {
  position: static;
  flex: 0 0 auto;
  z-index: 2;
}

.wd-body-quran #tafsirArea:not(.tafsir-fullscreen):not(.tafsir-reading-mode) #tafsirFlipBook {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: none;
}

.wd-body-quran #tafsirArea:not(.tafsir-fullscreen):not(.tafsir-reading-mode) #tafsirBookFrame .page-content > .flex {
  padding-top: 0;
  box-sizing: border-box;
}

.wd-body-quran #tafsirArea:not(.tafsir-fullscreen):not(.tafsir-reading-mode) .tafsir-page-scroll {
  padding: 0.75rem 1.4rem 1.1rem;
  box-sizing: border-box;
}

.wd-body-quran #tafsirModeWrapper #tafsirArea:not(.tafsir-fullscreen):not(.tafsir-reading-mode) {
  justify-content: flex-start !important;
}

.wd-body-quran .wd-quran-viewport:has(#tafsirModeWrapper:not(.hidden)) {
  justify-content: flex-start;
  padding-top: 28px;
}

.wd-body-quran .wd-quran-viewport:has(#tafsirModeWrapper:not(.hidden)) .wd-quran-center {
  justify-content: flex-start;
}

@media (min-width: 901px) {
  .wd-body-quran
    .wd-quran-viewport:has(#tafsirModeWrapper:not(.hidden))
    #tafsirArea:not(.tafsir-fullscreen):not(.tafsir-reading-mode)
    #tafsirZoomWrapper {
    padding-top: 0 !important;
    padding-inline: clamp(0.75rem, 2.5vw, 1.75rem) !important;
    padding-bottom: clamp(0.35rem, 1vw, 0.85rem) !important;
  }
}

@media (min-width: 900px) {
  #tafsirModeWrapper #tafsirZoomWrapper,
  #tafsirArea #tafsirZoomWrapper {
    width: 100%;
    max-width: none;
  }

  #tafsirModeWrapper #tafsirFlipBook,
  #tafsirArea #tafsirFlipBook {
    margin-inline: auto !important;
  }
}

@media (max-width: 899px) {
  .tafsir-edge-zone {
    display: none !important;
  }

  #tafsirArea #tafsirFlipBook.st-page-flip::after,
  #tafsirArea #tafsirFlipBook.stf__parent::after,
  #tafsirModeWrapper #tafsirFlipBook.st-page-flip::after,
  #tafsirModeWrapper #tafsirFlipBook.stf__parent::after,
  #tafsirArea .stf__parent::after,
  #tafsirModeWrapper .stf__parent::after {
    display: none !important;
  }

  #tafsirModeWrapper #tafsirZoomWrapper,
  #tafsirArea #tafsirZoomWrapper {
    margin-top: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  #tafsirModeWrapper #tafsirArea,
  #tafsirArea {
    justify-content: flex-start !important;
    align-items: stretch !important;
  }

  #tafsirModeWrapper #tafsirBookFrame,
  #tafsirArea #tafsirBookFrame {
    height: auto !important;
    max-height: none !important;
  }

  .wd-body-quran #tafsirArea:not(.tafsir-fullscreen):not(.tafsir-reading-mode) #tafsirBookFrame {
    height: var(--mushaf-max-height) !important;
    max-height: var(--mushaf-max-height) !important;
  }

  #tafsirFlipBook .page,
  .stf__parent .page {
    top: 0 !important;
  }

  #tafsirModeWrapper .tafsir-page-scroll,
  #tafsirArea .tafsir-page-scroll {
    padding-left: 2.4rem !important;
    padding-right: 2.4rem !important;
    padding-bottom: 1.5rem !important;
  }
}
