/* ==========================================================================
   material-page.css — material detail pages. The book page
   ("الدروس المهمة لعامة الأمة") uses all of it; the audio and video pages
   reuse the hero/page head, the details card (chips, tools, cover, info,
   actions, translations dropdown) and the related-materials section.
   Book only: the reader (TOC sidebar/drawer, sticky toolbar, lesson text).
   ========================================================================== */

.mp-hero,
.mp-details,
.mp-read,
.mp-rel {
  --mp-blue: var(--color-blue-500);
  --mp-line: var(--color-line);
  --mp-line-soft: var(--color-line-soft);
  --mp-muted: var(--color-ink-500);
  --mp-navy: var(--color-navy-700);
  --mp-gold: var(--color-gold-500);
}

/* Shared inline-icon defaults */
.mp-details svg,
.mp-read svg {
  display: block;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Content wrapper shared by the details card and the reader */
.mp-wrap {
  max-width: var(--cww, 1320px);
  margin: 0 auto;
  padding: 0 24px 96px;
  box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Hero backdrop + page head
   -------------------------------------------------------------------------- */
.mp-hero {
  position: relative;
  margin-top: -88px;   /* slide up under the sticky header */
  padding-top: 88px;
  background: linear-gradient(180deg, var(--color-cream-200) 0%, var(--color-sky-50) 55%, var(--color-white) 100%);
}

.mp-head {
  position: relative;
  overflow-x: clip;
}

.mp-head__art {
  position: absolute;
  z-index: 0;
  bottom: -60px;
  left: -80px;
  width: 380px;
  height: auto;
  opacity: 0.06;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(closest-side, #000 20%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 20%, transparent 100%);
}

.mp-head__inner {
  position: relative;
  max-width: var(--cw, 1180px);
  margin: 0 auto;
  padding: var(--page-head-space) 24px; /* equal space above and below (css/base.css) */
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  text-align: center;
}

.mp-crumbs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  align-items: center;
  font-size: 14px;
  color: var(--mp-muted);
}

.mp-crumbs a,
.mp-crumbs a:hover {
  color: var(--mp-blue);
  font-weight: 700;
  text-decoration: none;
}

.mp-head__title {
  margin: 0;
  font-family: 'Almarai', 'Cairo', sans-serif;
  font-weight: 800;
  font-size: var(--fs-page-title);
  line-height: 1.2;
  color: var(--mp-navy);
}

/* --------------------------------------------------------------------------
   Details card: outer shell with chips/tools bar + white inner panel
   -------------------------------------------------------------------------- */
.mp-details {
  background: var(--color-white);
}

/* Book, audio and video pages: the partner banners box follows the details
   card closely — 24px above it; 64px under it before the reader or «ذات صلة»
   (partner-banners.css) */
.page-material .mp-details .mp-wrap,
.page-audio .mp-details .mp-wrap,
.page-video .mp-details .mp-wrap {
  padding-bottom: 24px;
}

.mp-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 42px;
  background: linear-gradient(180deg, var(--color-cream-200) 0%, var(--color-sky-50) 100%);
}

.mp-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mp-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mp-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--color-white);
  border: 1px solid var(--mp-line);
  color: var(--mp-navy);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.mp-chip svg {
  stroke: var(--mp-blue);
}

.mp-tools {
  display: flex;
  gap: 8px;
}

/* Round icon buttons (copy / QR / share) */
.mp-ib {
  width: 44px;
  height: 44px;
  box-sizing: border-box;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--mp-line);
  background: var(--color-white);
  color: var(--mp-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: inherit;
  transition: background .2s ease, color .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.mp-ib:hover {
  background: var(--mp-blue);
  border-color: var(--mp-blue);
  color: var(--color-white);
}

.mp-ib:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(59, 117, 150, .25);
}

/* Copy link: link icon, then green + check for a moment once copied
   (same success state as the other copy buttons of the site) */
.mp-ib .mp-ib__i-check, /* beats ".mp-details svg { display: block }" */
.mp-ib.is-copied .mp-ib__i-link {
  display: none;
}

.mp-ib.is-copied .mp-ib__i-check {
  display: block;
}

.mp-ib.is-copied,
.mp-ib.is-copied:hover {
  background: var(--color-success);
  border-color: var(--color-success);
  color: var(--color-white);
}

.mp-inner {
  border-radius: 32px;
  background: var(--color-white);
  padding: 40px;
  box-sizing: border-box;
}

.mp-grid {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}

.mp-cover {
  display: flex;
  justify-content: center;
}

.mp-cover img {
  width: 260px;
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 4px 10px 10px 4px;
  box-shadow: 0 30px 50px -26px rgba(26, 43, 69, 0.6), 0 0 0 1px rgba(26, 43, 69, 0.06);
}

.mp-info {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.mp-titlerow {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.mp-tblock {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.mp-title {
  margin: 0;
  font-family: 'Almarai', 'Cairo', sans-serif;
  font-weight: 800;
  font-size: 30px;
  line-height: 1.35;
  color: var(--mp-navy);
}

.mp-author,
.mp-author:hover {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--mp-blue);
  text-decoration: none;
}

/* Small QR preview beside the title */
.mp-qrbox {
  flex: none;
  width: 88px;
  height: 88px;
  box-sizing: border-box;
  padding: 5px;
  border-radius: 18px;
  background: var(--color-white);
  border: 1px solid var(--color-mist-200);
  box-shadow: 0 16px 30px -22px rgba(26, 43, 69, 0.45);
  cursor: pointer;
  transition: border-color .2s ease;
}

.mp-qrbox:hover {
  border-color: var(--mp-blue);
}

.mp-qrbox img {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

.mp-desc {
  margin: 0;
  max-width: 680px;
  font-size: 17px;
  line-height: 2;
  color: var(--color-ink-600);
}

/* Action buttons */
.mp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 6px;
}

.mp-btn {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 52px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
}

.mp-btn--primary,
.mp-btn--primary:hover {
  padding: 0 28px;
  border: 1.5px solid var(--mp-blue);
  background: var(--mp-blue);
  color: var(--color-white);
  box-shadow: 0 14px 26px -16px rgba(59, 117, 150, 0.8);
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}

/* filled blue → cream, like the home hero's main button (colour only) */
.mp-btn--primary:hover {
  background: var(--hover-cream);
  border-color: var(--hover-cream-border);
  color: var(--hover-cream-ink);
}

.mp-btn--secondary,
.mp-btn--secondary:hover {
  padding: 0 26px;
  background: transparent;
  border: 1.5px solid var(--mp-blue);
  color: var(--mp-blue);
  transition: background .2s ease, color .2s ease;
}

.mp-btn--secondary:hover {
  background: var(--mp-blue);
  color: var(--color-white);
}

/* --------------------------------------------------------------------------
   Translations: title + quick-pick language chips + "+N" dropdown toggle
   -------------------------------------------------------------------------- */
.mp-tr {
  position: relative; /* anchors the dropdown */
  align-self: stretch;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  margin-top: 2px;
  border-top: 1px solid var(--mp-line-soft);
}

.mp-tr__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: var(--mp-navy);
}

.mp-tr__title svg {
  flex: none;
  width: 18px;
  height: 18px;
  stroke: var(--mp-blue);
}

.mp-tr__count {
  min-width: 26px;
  height: 22px;
  padding: 0 7px;
  box-sizing: border-box;
  border-radius: 999px;
  background: var(--color-blue-50);
  color: var(--mp-blue);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
}

.mp-langs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* One language chip: code badge + native name (title = Arabic name) */
.mp-lang,
.mp-lang:hover {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding-block: 0;
  padding-inline: 5px 16px;
  box-sizing: border-box;
  border-radius: 999px;
  border: 1px solid var(--mp-line-soft);
  background: var(--color-mist-50);
  color: var(--mp-navy);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  transition: background .2s ease, border-color .2s ease, color .2s ease;
}

.mp-lang:hover,
.mp-lang:focus-visible {
  background: var(--mp-blue);
  border-color: var(--mp-blue);
  color: var(--color-white);
}

.mp-lang__code {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--mp-line-soft);
  color: var(--color-blue-600) /* 5:1 on the badge */;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  transition: background .2s ease, color .2s ease;
}

.mp-lang:hover .mp-lang__code,
.mp-lang:focus-visible .mp-lang__code {
  background: var(--color-cream-200);
  color: var(--mp-navy);
}

.mp-lang__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* "+N لغة" — opens the dropdown with the remaining languages */
.mp-trbtn {
  height: 44px;
  padding: 0 16px;
  box-sizing: border-box;
  border-radius: 999px;
  border: 1px solid var(--mp-blue);
  background: var(--color-white);
  color: var(--mp-blue);
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}

.mp-trbtn:hover,
.mp-trbtn[aria-expanded="true"] {
  background: var(--mp-blue);
  color: var(--color-white);
}

/* The phone label and the "most used" group of the list only exist on phones,
   where only the first four chips show (see the 640px block), so the list
   there holds every language. */
.mp-trbtn__all,
.mp-trsep.mp-trgroup-top,
.mp-tri.mp-trgroup-top {
  display: none;
}

/* While searching, the chip languages are listed too, so every language
   can be found from the search box (rows that don't match stay [hidden]) */
.mp-trlist.is-searching .mp-tri.mp-trgroup-top {
  display: flex;
}

/* Transparent click-catcher behind the popover */
.mp-trbg {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: transparent;
}

.mp-trpop {
  position: absolute;
  /* --tr-pop-x / --tr-pop-y are set by material-page.js so the list opens under the "+N" toggle */
  top: var(--tr-pop-y, calc(100% + 8px));
  left: var(--tr-pop-x, 0);
  z-index: 41;
  width: min(360px, calc(100vw - 32px));
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  padding: 10px;
  background: var(--color-white);
  border: 1px solid var(--mp-line);
  border-radius: 22px;
  box-shadow: 0 24px 48px -24px rgba(26, 43, 69, .45);
  text-align: right;
  animation: mpTrIn .22s cubic-bezier(.22, .61, .36, 1);
}

@keyframes mpTrIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}

/* Sheet header (only shown as a bottom sheet on phones) */
.mp-trph {
  display: none;
}

.mp-trs {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 14px;
  box-sizing: border-box;
  border-radius: 999px;
  background: var(--color-mist-50);
  border: 1px solid var(--mp-line-soft);
}

.mp-trs svg {
  stroke: var(--mp-blue);
}

.mp-trs input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  color: var(--mp-navy);
  text-align: right;
}

.mp-trlist {
  margin-top: 8px;
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-blue-250) transparent;
}

.mp-trsep {
  padding: 8px 10px 4px;
  font-size: 12px;
  font-weight: 800;
  color: var(--color-gold-900);
}

.mp-tri,
.mp-tri:hover {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 14px;
  text-decoration: none;
  color: var(--mp-navy);
  text-align: right;
  transition: background .15s ease;
}

.mp-tri:hover {
  background: var(--color-blue-50);
}

.mp-tri__code {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  background: var(--mp-line-soft);
  color: var(--color-blue-600) /* 5:1 on the badge */;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.mp-tri__native {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mp-tri__ar {
  flex: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--mp-muted);
}

.mp-tre {
  margin: 0;
  padding: 18px 8px;
  text-align: center;
  font-size: 14px;
  color: var(--mp-muted);
}

/* --------------------------------------------------------------------------
   Media (audio / video pages): the player sits inside the details card,
   under the cover + info row, separated from the languages by a line
   -------------------------------------------------------------------------- */
.mp-media {
  display: flex;
  flex-direction: column;
  gap: 28px;
  margin-top: 32px;
  padding-top: 40px;
  border-top: 1px solid var(--mp-line-soft);
  scroll-margin-top: 128px;
}

/* centred title ("مشاهدة المقطع" / "استماع السلسلة"): section-title style at
   its own size (--fs-media-title, css/base.css) */
.mp-media__title {
  margin: 0;
  font-family: 'Almarai', 'Cairo', sans-serif;
  font-weight: 800;
  font-size: var(--fs-media-title);
  line-height: 1.3;
  color: var(--mp-navy);
  text-align: center;
}

.mp-media__title span {
  color: var(--mp-blue);
}

/* --------------------------------------------------------------------------
   Reader: title, grid (TOC + page)
   -------------------------------------------------------------------------- */
.mp-read {
  background: var(--color-white);
  scroll-margin-top: 128px; /* "قراءة الكتاب" jump lands below the header */
}

/* Related materials (audio / video pages): section title + card grid
   (.mgrid / .mcard from materials.css) */
.mp-rel {
  background: var(--color-white);
}

.mp-wrap--rel {
  padding-bottom: 112px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* four cards are rendered: the 4th fills the second row of the 2-column grid
   (760–1099px, materials.css) and is left out of the 1- and 3-column grids */
@media (max-width: 759px), (min-width: 1100px) {
  .mp-rel .mgrid > :nth-child(4) {
    display: none;
  }
}

.mp-wrap--read {
  padding-bottom: 112px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.mp-read__title {
  margin: 0;
  font-family: 'Almarai', 'Cairo', sans-serif;
  font-weight: 800;
  font-size: var(--fs-section-title);
  line-height: 1.2;
  color: var(--mp-navy);
  text-align: center;
}

.mp-read__title span {
  color: var(--mp-blue);
}

.mp-reader {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  column-gap: 20px;
  row-gap: 20px;
  align-items: start;
  overflow-x: clip;
  transition: grid-template-columns .45s cubic-bezier(.22, .61, .36, 1), column-gap .45s cubic-bezier(.22, .61, .36, 1);
}

/* Desktop: TOC collapsed */
.mp-reader.is-closed {
  grid-template-columns: 0px minmax(0, 1fr);
  column-gap: 0;
}

/* Drawer backdrop (phones/tablets only) */
.mp-tocbg {
  display: none;
}

/* ----- TOC sidebar ----- */
.mp-toc {
  position: sticky;
  top: calc(var(--hdr-h, 64px) + 40px);
  width: 320px;
  max-height: calc(100vh - var(--hdr-h, 64px) - 64px);
  display: flex;
  flex-direction: column;
  border-radius: 32px;
  background: linear-gradient(180deg, var(--color-cream-200) 0%, var(--color-sky-50) 100%);
  padding: 12px;
  box-sizing: border-box;
  transition: transform .45s cubic-bezier(.22, .61, .36, 1), opacity .35s ease, visibility 0s linear 0s,
    top .4s cubic-bezier(.22, .61, .36, 1), max-height .4s cubic-bezier(.22, .61, .36, 1);
}

/* Desktop sidebar moves up while the site header is hidden (drawer mode ≤1000px is fixed) */
@media (min-width: 1001px) {
  html.is-hdr-hidden .mp-toc {
    top: 24px;
    max-height: calc(100vh - 48px);
  }
}

.mp-reader.is-closed .mp-toc {
  transform: translateX(calc(100% + 32px));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform .45s cubic-bezier(.22, .61, .36, 1), opacity .35s ease, visibility 0s linear .45s;
}

.mp-tochd {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 10px 6px;
  font-size: 15px;
  font-weight: 800;
  color: var(--mp-navy);
}

.mp-tochd__title {
  flex: 1;
  padding-inline-start: 8px;
}

.mp-tochd__count {
  font-size: 13px;
  font-weight: 700;
  color: var(--mp-muted);
}

.mp-toctg {
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--mp-line);
  background: var(--color-white);
  color: var(--mp-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}

.mp-toctg:hover {
  background: var(--mp-blue);
  border-color: var(--mp-blue);
  color: var(--color-white);
}

.mp-toctg__close {
  display: none !important; /* beats the shared svg display rule; shown in drawer mode */
}

/* List scrolls with its scrollbar on the right (ltr box, rtl content) */
.mp-toclist {
  /*rtl:ignore*/
  direction: ltr;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 0 2px 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-blue-250) transparent;
}

.mp-toclist::-webkit-scrollbar {
  width: 6px;
}

.mp-toclist::-webkit-scrollbar-track {
  background: rgba(59, 117, 150, 0.08);
  border-radius: 999px;
  margin: 6px 0;
}

.mp-toclist::-webkit-scrollbar-thumb {
  background: var(--color-blue-250);
  border-radius: 999px;
}

.mp-toclist::-webkit-scrollbar-thumb:hover {
  background: var(--mp-blue);
}

.mp-toci {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-inline-start: 8px;
}

.mp-tocb {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: right;
  padding: 10px 12px;
  border-radius: 16px;
  border: 0;
  background: transparent;
  color: var(--mp-navy);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
  cursor: pointer;
  transition: background .2s ease;
}

.mp-tocb:not([aria-current="true"]):hover {
  background: var(--color-white);
}

.mp-tocb[aria-current="true"] {
  background: var(--mp-blue);
  color: var(--color-white);
}

.mp-tocb__n {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  background: var(--color-blue-50);
  color: var(--mp-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
}

.mp-tocb[aria-current="true"] .mp-tocb__n {
  background: var(--color-white);
}

/* ----- Page (article) ----- */
.mp-page {
  border-radius: 32px;
  background: var(--color-white);
  border: 1px solid var(--color-blue-line);
  overflow: clip;
}

/* Sticky toolbar */
.mp-ptool {
  position: sticky;
  top: var(--hdr-h, 64px); /* right under the site header (height published by header.js) */
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 20px;
  background: var(--color-mist-100);
  border-bottom: 1px solid var(--color-blue-line);
  transition: top .4s cubic-bezier(.22, .61, .36, 1); /* same timing as the header slide */
}

/* The site header hides while scrolling down (header.js) → toolbar moves up */
html.is-hdr-hidden .mp-ptool {
  top: 0;
}

.mp-ptool__start {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* "الفهرس" opener: collapsed to nothing while the sidebar is visible */
.mp-tocopen {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  box-sizing: border-box;
  border-radius: 999px;
  border: 1px solid var(--mp-blue);
  background: var(--color-white);
  color: var(--mp-blue);
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  opacity: 0;
  max-width: 0;
  padding: 0;
  border-width: 0;
  margin-inline-end: -10px;
  transition: opacity .3s ease, max-width .45s cubic-bezier(.22, .61, .36, 1), padding .45s cubic-bezier(.22, .61, .36, 1), margin .45s cubic-bezier(.22, .61, .36, 1);
}

.mp-reader.is-closed .mp-tocopen {
  opacity: 1;
  max-width: 160px;
  padding: 0 14px;
  border-width: 1px;
  margin-inline-end: 0;
  transition-delay: .15s;
}

.mp-tocopen:hover {
  background: var(--mp-blue);
  color: var(--color-white);
}

/* Current lesson: long label (desktop) / compact title (mobile) */
.mp-lesl {
  font-size: 14px;
  font-weight: 700;
  color: var(--mp-muted);
}

.mp-lesl strong {
  color: var(--mp-blue);
}

.mp-lesm,
.mp-aa {
  display: none;
}

/* Font size controls */
.mp-fsbox {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mp-fsgrp {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mp-fsgrp__label {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-slate-500); /* 4.5:1+ on the toolbar */
  margin-inline-end: 4px;
}

.mp-fs {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--color-blue-line);
  background: var(--color-white);
  color: var(--mp-blue);
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.mp-fs--up {
  font-size: 16px;
}

.mp-fs:hover {
  background: var(--mp-blue);
  color: var(--color-white);
}

/* ----- Book text ----- */
.mp-pbody {
  --mp-fs: 20px; /* reader font size, changed by the A-/A+ buttons */
  padding: 44px 56px 48px;
  display: flex;
  flex-direction: column;
}

.mp-les {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 36px;
  margin-top: 36px;
  border-top: 1px solid var(--mp-line-soft);
  scroll-margin-top: 131px; /* TOC jumps land below header + toolbar */
}

.mp-les:first-child {
  padding-top: 0;
  margin-top: 0;
  border-top: 0;
}

.mp-les__eyebrow {
  display: block;
  font-size: 14px;
  font-weight: 800;
  color: var(--color-gold-900) /* gold text on white: 5.5:1 */;
  margin-bottom: -10px;
}

.mp-les__title {
  margin: 0;
  font-family: 'Amiri', 'Almarai', serif;
  font-weight: 700;
  font-size: 30px;
  line-height: 1.5;
  color: var(--mp-navy);
}

.mp-les__bar {
  width: 48px;
  height: 3px;
  border-radius: 3px;
  background: var(--mp-gold);
}

/* Every text block of the book */
.mp-text {
  margin: 0;
  font-family: 'Amiri', serif;
  font-size: var(--mp-fs);
  font-weight: 400;
  line-height: 2.1;
  color: var(--color-slate-800);
}

.mp-text--center {
  text-align: center;
  font-weight: 700;
  color: var(--mp-navy);
}

/* Bulleted lists */
.mp-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mp-list__item {
  position: relative;
  padding-inline-start: 22px;
}

.mp-list__item::before {
  content: "";
  position: absolute;
  inset-inline-start: 4px;
  top: 1.05em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mp-gold);
}

/* Sub-heading inside a lesson */
.mp-sub {
  font-family: 'Almarai', 'Cairo', sans-serif;
  font-weight: 800;
  font-size: 17px;
  color: var(--mp-navy);
  margin-top: 8px;
}

/* Quotations: Qur'an verse / hadith with their reference line */
.mp-quote {
  margin: 0;
  display: flex;
  flex-direction: column;
}

.mp-quote--verse {
  gap: 8px;
}

.mp-quote--hadith {
  gap: 6px;
}

.mp-verse {
  text-align: center;
  color: var(--mp-navy);
  background: var(--color-mist-50);
  border: 1px solid var(--mp-line-soft);
  border-radius: 18px;
  padding: 14px 20px;
  line-height: 2.2;
}

.mp-ref {
  text-align: center;
  font-family: 'Almarai', 'Cairo', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-gold-900);
  line-height: 1.6;
}

.mp-hadith {
  color: var(--color-blue-600);
  font-weight: 700;
  border-inline-start: 3px solid var(--mp-gold);
  padding-inline-start: 14px;
}

.mp-src {
  font-family: 'Almarai', 'Cairo', sans-serif;
  font-size: 13px;
  color: var(--mp-muted);
  padding-inline-start: 17px;
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .mp-grid {
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 32px;
  }

  .mp-title {
    font-size: 26px;
  }
}

/* Tablet & phone reader: TOC becomes a drawer, toolbar becomes compact */
@media (max-width: 1000px) {
  .mp-reader,
  .mp-reader.is-closed {
    grid-template-columns: minmax(0, 1fr);
    column-gap: 0;
  }

  .mp-reader .mp-toc,
  .mp-reader.is-closed .mp-toc {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: min(340px, 86vw);
    max-height: none;
    height: 100%;
    z-index: 210;
    border-radius: 28px 0 0 28px;
    padding: 16px 12px;
    box-shadow: -24px 0 48px -24px rgba(15, 26, 44, .45);
    transform: translateX(105%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform .4s cubic-bezier(.22, .61, .36, 1), opacity .3s ease, visibility 0s linear .4s;
  }

  .mp-reader.is-drawer .mp-toc {
    transform: none;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: transform .4s cubic-bezier(.22, .61, .36, 1), opacity .3s ease, visibility 0s linear 0s;
  }

  .mp-toctg__collapse {
    display: none !important;
  }

  .mp-toctg__close {
    display: block !important;
  }

  .mp-tocbg {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 205;
    background: rgba(15, 26, 44, .45);
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s ease, visibility 0s linear .3s;
  }

  .mp-reader.is-drawer .mp-tocbg {
    opacity: 1;
    visibility: visible;
    transition: opacity .3s ease, visibility 0s linear 0s;
  }

  /* Toolbar */
  .mp-ptool {
    padding: 5px 10px;
    gap: 8px;
    flex-wrap: nowrap;
    min-height: 44px;
    box-sizing: border-box;
  }

  .mp-ptool__start {
    flex: 1 1 auto;
    min-width: 0;
    gap: 8px;
  }

  .mp-tocopen,
  .mp-reader.is-closed .mp-tocopen {
    opacity: 1;
    max-width: 160px;
    height: 34px;
    padding: 0 12px;
    border-width: 1px;
    margin-inline-end: 0;
    gap: 6px;
    justify-content: center;
    flex: none;
    font-size: 13px;
  }

  .mp-lesl {
    display: none;
  }

  .mp-lesm {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
    flex: 1 1 auto;
  }

  .mp-lesm__title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13.5px;
    font-weight: 800;
    color: var(--mp-navy);
  }

  .mp-lesm__n {
    flex: none;
    font-size: 12px;
    font-weight: 700;
    color: var(--mp-muted);
  }

  .mp-fsbox {
    flex: none;
  }

  /* "Aa" button opens the font-size controls as a small popover */
  .mp-aa {
    display: inline-flex;
    align-items: baseline;
    justify-content: center;
    gap: 1px;
    width: 34px;
    height: 34px;
    box-sizing: border-box;
    padding: 6px 0 0;
    border-radius: 50%;
    border: 1px solid var(--color-blue-line);
    background: var(--color-white);
    color: var(--mp-blue);
    font-family: inherit;
    font-weight: 800;
    cursor: pointer;
    line-height: 1;
  }

  .mp-aa__s {
    font-size: 12px;
  }

  .mp-aa__l {
    font-size: 17px;
  }

  .mp-aa[aria-expanded="true"] {
    background: var(--mp-blue);
    color: var(--color-white);
    border-color: var(--mp-blue);
  }

  .mp-fsgrp {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    z-index: 6;
    padding: 6px;
    background: var(--color-white);
    border: 1px solid var(--mp-line);
    border-radius: 999px;
    box-shadow: 0 16px 30px -18px rgba(26, 43, 69, .45);
  }

  .mp-fsgrp__label {
    display: none;
  }

  .mp-ptool.is-fs-open .mp-fsgrp {
    display: flex;
    animation: pop-drop .22s cubic-bezier(.22, .61, .36, 1); /* keyframes in css/base.css */
  }
}

/* Single-column details card */
@media (max-width: 860px) {
  .mp-grid {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    text-align: center;
  }

  .mp-info {
    align-items: center;
  }

  .mp-actions {
    justify-content: center;
  }

  .mp-cover img {
    width: 220px;
  }

  .mp-inner {
    padding: 28px 20px;
  }

  .mp-qrbox {
    display: none;
  }

  .mp-titlerow {
    justify-content: center;
  }

  .mp-tblock {
    align-items: center;
  }

  .mp-title {
    text-align: center;
  }

  .mp-author,
  .mp-author:hover {
    align-self: center;
  }

  .mp-tr__title,
  .mp-langs {
    justify-content: center;
  }

  .mp-media {
    gap: 22px;
    padding-top: 32px;
  }

}

@media (max-width: 640px) {
  .mp-head__inner {
    padding: var(--page-head-space) 16px;
  }

  .mp-wrap {
    padding-left: 16px;
    padding-right: 16px;
    padding-bottom: 64px;
  }

  .mp-title {
    font-size: 22px;
  }

  .mp-desc {
    font-size: 15.5px;
  }

  .mp-actions {
    flex-direction: column;
    align-self: stretch;
  }

  .mp-actions .mp-btn {
    width: 100%;
  }

  .mp-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .mp-chips,
  .mp-tools {
    justify-content: center;
  }

  /* Translations: the title, the first four chips in two columns, then one
     full-width button that opens every language (the bottom sheet below) */
  .mp-langs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mp-lang:nth-child(n + 5) {
    display: none;
  }

  .mp-trbtn {
    grid-column: 1 / -1;
    width: 100%;
    height: 48px;
    padding: 0 16px;
    border-color: var(--mp-line);
    background: var(--color-mist-50);
    color: var(--mp-navy);
    font-size: 15px;
    transition: border-color .2s ease, background .2s ease;
  }

  .mp-trbtn:hover,
  .mp-trbtn[aria-expanded="true"] {
    border-color: var(--mp-blue);
    background: var(--color-white);
    color: var(--mp-navy);
  }

  .mp-trbtn__more {
    display: none;
  }

  /* "عرض كل اللغات" + a chevron, centred like the action buttons above */
  .mp-trbtn__all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  .mp-trbtn__chev {
    flex: none;
    stroke: var(--mp-blue);
    transition: transform .25s ease;
  }

  .mp-trbtn[aria-expanded="true"] .mp-trbtn__chev {
    transform: rotate(180deg);
  }

  .mp-trsep.mp-trgroup-top {
    display: block;
  }

  .mp-tri.mp-trgroup-top {
    display: flex;
  }

  /* Language list becomes a bottom sheet */
  .mp-trbg {
    z-index: 230;
    background: rgba(15, 26, 44, .45);
    animation: mpTrFade .25s ease;
  }

  .mp-trpop {
    position: fixed;
    top: auto;
    right: 0;
    left: 0;
    bottom: 0;
    transform: none;
    width: 100%;
    max-height: 78vh;
    max-height: 78dvh; /* of the screen as it is now, the browser's bars shown (where supported) */
    z-index: 231;
    border-radius: 26px 26px 0 0;
    border: 0;
    padding: 14px 14px 20px;
    animation: mpTrUp .3s cubic-bezier(.22, .61, .36, 1);
  }

  .mp-trph {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 4px 12px;
    font-size: 16px;
    font-weight: 800;
    color: var(--mp-navy);
  }

  .mp-trx {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--mp-line);
    background: var(--color-white);
    color: var(--mp-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }

  .mp-trlist {
    max-height: none;
    flex: 1 1 auto;
    min-height: 0;
  }

  /* the player takes a little of the card's side padding on phones */
  .mp-media > :not(.mp-media__title) {
    margin-inline: -8px;
  }

  /* Reader */
  .mp-pbody {
    padding: 28px 20px 24px;
  }

  .mp-les__title {
    font-size: 24px;
  }
}

@keyframes mpTrFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes mpTrDown {
  to {
    transform: translateY(100%);
  }
}

@keyframes mpTrUp {
  from { transform: translateY(100%); }
  to   { transform: none; }
}

@media (max-width: 560px) {
  .mp-shell {
    padding: 10px;
    margin: 0 -8px;
  }

  .mp-inner {
    border-radius: 24px;
  }
}

/* four chips (audio / video pages) sit 2 × 2 on phones instead of 3 + 1 */
@media (max-width: 480px) {
  .mp-chips:has(> .mp-chip:nth-child(4)) {
    display: grid;
    grid-template-columns: repeat(2, max-content);
    justify-content: center;
  }

  .mp-chips:has(> .mp-chip:nth-child(4)) .mp-chip {
    justify-content: center;
  }
}

@media (max-width: 400px) {
  .mp-shell {
    margin: 0;
  }

  .mp-chip {
    height: 36px;
    padding: 0 12px;
    font-size: 13px;
  }

  .mp-wrap {
    padding-left: 12px;
    padding-right: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mp-reader,
  .mp-toc,
  .mp-tocopen,
  .mp-ptool,
  .mp-reader .mp-toc,
  .mp-tocbg {
    transition: none !important;
  }

  .mp-trpop,
  .mp-trbg,
  .mp-fsgrp {
    animation: none !important;
  }
}

/* Closing motion (.is-closing is set by GP.hide / GP.animateOut — js/core/dom.js) */
.mp-trbg.is-closing {
  animation: pop-fade-out .2s ease-in forwards;
}

.mp-trpop.is-closing,
.mp-ptool.is-fs-open .mp-fsgrp.is-closing { /* beats the open-state rule */
  animation: pop-lift .18s cubic-bezier(.4, 0, 1, 1) forwards;
}

@media (max-width: 640px) {
  /* the bottom sheet slides back down */
  .mp-trpop.is-closing {
    animation: mpTrDown .25s cubic-bezier(.4, 0, 1, 1) forwards;
  }
}
