/* The Holy Quran reader (quran/): an open mushaf on a rehal, 2.5D, with a 3D page turn. */
.qr-hero { padding: 34px 0 6px; text-align: center;
  background: radial-gradient(60% 80% at 50% 0%, rgba(207, 162, 69, .16), rgba(207, 162, 69, 0) 70%), var(--cream); }
.qr-hero h1 { margin: 6px 0 0; color: var(--green-900); font-size: clamp(30px, 5vw, 46px); }
.qr-hero .divider { margin: 4px auto 6px; }
.qr-sub { margin: 0 auto 14px; max-width: 40em; color: var(--muted); }
.qr-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 0 auto; }
.qr-controls label { display: inline-flex; align-items: center; gap: 8px; padding: 4px 6px 4px 14px; border-radius: 999px; background: var(--paper);
  border: 1px solid rgba(184, 137, 44, .45); color: var(--gold-700); font-size: 14px; line-height: var(--lh-ui); }
html[dir="rtl"] .qr-controls label { padding: 4px 14px 4px 6px; }
.qr-controls select, .qr-controls input { min-height: 36px; border: 0; border-radius: 999px; background: var(--gold-100); color: var(--green-900);
  font: 700 14px/1.4 "Noto Naskh Arabic", "Nunito", system-ui, sans-serif; padding: 0 12px; max-width: 46vw; }
.qr-controls input { width: 5.2em; text-align: center; }
.qr-stage { padding: 6px 0 40px; background: linear-gradient(180deg, var(--cream), #f3ead2); overflow: hidden; }

/* The book: covers, a gold rim, the page stack, the spine, tilted back onto the rehal. */
.qr-book-wrap { position: relative; display: grid; justify-items: center; padding: 18px 0 0; perspective: 2400px; perspective-origin: 50% 0%; }
.qr-book { position: relative; z-index: 2; padding: 12px; border-radius: 12px; cursor: pointer; outline: none;
  background: linear-gradient(160deg, #1a6a4f, #0f4c3a 45%, #072a20);
  box-shadow: 0 2px 0 #b8892c, 0 34px 50px rgba(30, 20, 5, .38), inset 0 0 0 2px #cfa245, inset 0 0 0 5px rgba(7, 42, 32, .9), inset 0 0 0 6px rgba(236, 209, 143, .5);
  transform: rotateX(14deg); transform-origin: 50% 100%; transform-style: preserve-3d; -webkit-tap-highlight-color: transparent; }
.qr-book:focus-visible { box-shadow: 0 0 0 4px var(--gold-500), 0 34px 50px rgba(30, 20, 5, .38), inset 0 0 0 2px #cfa245; }
.qr-spread { position: relative; width: min(1040px, 92vw); aspect-ratio: 1.36; transform-style: preserve-3d; }
.qr-page { position: absolute; top: 0; bottom: 0; width: 50%; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 40%, #fffaf0, #fbf2dc 70%, #f3e5c2); color: #1b1712; }
.qr-right { right: 0; border-radius: 2px 6px 6px 2px; box-shadow: inset 22px 0 26px -18px rgba(70, 45, 10, .45); }
.qr-left { left: 0; border-radius: 6px 2px 2px 6px; box-shadow: inset -22px 0 26px -18px rgba(70, 45, 10, .45); }
.qr-spread::before, .qr-spread::after { content: ""; position: absolute; top: 3px; bottom: 3px; width: 7px; z-index: -1;
  background: repeating-linear-gradient(90deg, #f7ecd0 0 1px, #dccba0 1px 2px); }
.qr-spread::before { right: -6px; border-radius: 0 3px 3px 0; }
.qr-spread::after { left: -6px; border-radius: 3px 0 0 3px; }
.qr-spine { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; z-index: 3; pointer-events: none;
  background: linear-gradient(180deg, rgba(90, 60, 20, .5), rgba(90, 60, 20, .25)); }

/* A page of the mushaf. */
.qr-frame { position: absolute; inset: 4.2% 6.5% 3.6%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; padding: 1.6% 3.2% 0;
  border: 2px solid #b8892c; border-radius: 6px; box-shadow: 0 0 0 4px #fbf2dc, 0 0 0 5px rgba(184, 137, 44, .7), inset 0 0 0 3px rgba(184, 137, 44, .18); }
.qr-frame::before, .qr-frame::after { content: ""; position: absolute; width: 18px; height: 18px; top: -10px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M20 1.5 25.3 7.2 33.1 6.9 32.8 14.7 38.5 20 32.8 25.3 33.1 33.1 25.3 32.8 20 38.5 14.7 32.8 6.9 33.1 7.2 25.3 1.5 20 7.2 14.7 6.9 6.9 14.7 7.2Z' fill='%23cfa245'/%3E%3Ccircle cx='20' cy='20' r='6' fill='%23fbf2dc'/%3E%3C/svg%3E") center / contain no-repeat; }
.qr-frame::before { right: -10px; } .qr-frame::after { left: -10px; }
.qr-phead { display: flex; justify-content: space-between; align-items: center; direction: rtl; gap: 8px; padding: 0 2px 2px; color: #8f6a1d;
  border-bottom: 1px solid rgba(184, 137, 44, .45); font: 400 clamp(11px, 1.15vw, 16px)/1.6 "Amiri Quran", "Amiri", serif; }
.qr-body { position: relative; overflow: hidden; padding: .2em .1em 0; font-family: "Amiri Quran", "Amiri", "Noto Naskh Arabic", serif;
  font-size: 22px; line-height: 2.02; text-align: justify; text-align-last: center; direction: rtl; color: #17140f; word-spacing: .04em; }
.qr-ayat { margin: 0; }
.qr-n { display: inline-grid; place-items: center; min-width: 1.45em; height: 1.45em; padding: 0 .12em; margin: 0 .04em; vertical-align: -.12em;
  font: 700 .5em/1 "Noto Naskh Arabic", "Amiri", serif; color: #0f4c3a;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M20 1.5 25.3 7.2 33.1 6.9 32.8 14.7 38.5 20 32.8 25.3 33.1 33.1 25.3 32.8 20 38.5 14.7 32.8 6.9 33.1 7.2 25.3 1.5 20 7.2 14.7 6.9 6.9 14.7 7.2Z' fill='%23fbf2dc' stroke='%23b8892c' stroke-width='1.6'/%3E%3Ccircle cx='20' cy='20' r='12' fill='none' stroke='%23cfa245' stroke-width='1'/%3E%3C/svg%3E") center / contain no-repeat; }
.qr-sajda { text-decoration: underline; text-decoration-color: rgba(184, 137, 44, .8); text-underline-offset: .35em; }
.qr-sh { margin: .25em 0 .15em; padding: .05em .6em; text-align: center; text-align-last: center; border-radius: 6px; color: #f5e6bb; font-size: .86em; line-height: 1.75;
  background: linear-gradient(180deg, #145c45, #0b3b2e); box-shadow: inset 0 0 0 2px #cfa245, inset 0 0 0 4px #0b3b2e, inset 0 0 0 5px rgba(236, 209, 143, .55); }
.qr-bs { margin: 0 0 .1em; text-align: center; text-align-last: center; color: #0f4c3a; font-size: .96em; }
.qr-pfoot { padding: 1px 0 2px; text-align: center; color: #8f6a1d; font: 700 clamp(11px, 1.05vw, 15px)/1.6 "Noto Naskh Arabic", serif; }
.qr-short .qr-body { display: flex; flex-direction: column; justify-content: center; text-align: center; }
.qr-blank, .qr-paper { background: radial-gradient(120% 90% at 50% 40%, #fbf4e2, #f1e3bf); }

/* The page turn. */
.qr-leaf { position: absolute; top: 0; bottom: 0; width: 50%; z-index: 5; transform-style: preserve-3d;
  transition: transform .95s cubic-bezier(.42, .06, .22, 1); will-change: transform; pointer-events: none; }
.qr-leaf-next { left: 0; transform-origin: 100% 50%; }
.qr-leaf-prev { right: 0; transform-origin: 0% 50%; }
.qr-leaf-next.qr-go { transform: rotateY(180deg); }
.qr-leaf-prev.qr-go { transform: rotateY(-180deg); }
.qr-leaf-one { right: 0; width: 100%; transform-origin: 100% 50%; transition: transform .9s cubic-bezier(.42, .06, .22, 1), opacity .35s ease .55s; }
.qr-leaf-one.qr-go { transform: rotateY(180deg); opacity: 0; }
.qr-leaf-one.qr-start-turned { transform: rotateY(180deg); opacity: 0; transition: none; }
.qr-leaf-one.qr-unturn { transform: rotateY(0deg); opacity: 1; transition: transform .9s cubic-bezier(.42, .06, .22, 1), opacity .25s ease; }
.qr-face { position: absolute; inset: 0; width: 100%; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.qr-face.qr-back { transform: rotateY(180deg); }
.qr-face::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: linear-gradient(90deg, rgba(60, 40, 10, .0), rgba(60, 40, 10, .28) 70%, rgba(60, 40, 10, .45)); }
.qr-leaf-next .qr-front::after, .qr-leaf-one .qr-front::after { background: linear-gradient(270deg, rgba(60, 40, 10, .0), rgba(60, 40, 10, .25) 70%, rgba(60, 40, 10, .45)); }
.qr-turning .qr-face::after { animation: qr-shade .95s ease-in-out; }
@keyframes qr-shade { 0% { opacity: 0; } 50% { opacity: 1; } 100% { opacity: 0; } }

/* The rehal under the book. */
.qr-rehal { position: relative; z-index: 1; width: min(880px, 86vw); margin-top: -4.5%; }
.qr-rehal svg { width: 100%; height: auto; }

.qr-nav { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 10px 16px; margin-top: 18px; }
.qr-btn { min-height: 46px; padding: 2px 20px; border-radius: 999px; border: 1.5px solid rgba(15, 76, 58, .35); background: var(--paper); color: var(--green-800);
  font: 700 15px/var(--lh-ui) var(--font-body); cursor: pointer; }
.qr-btn.qr-next { background: linear-gradient(180deg, var(--green-700), var(--green-900)); color: #fff; border-color: transparent; }
.qr-pos { color: var(--gold-700); font-size: 14px; line-height: var(--lh-ui); min-width: 12em; text-align: center; }
.qr-credit { margin: 14px auto 0; text-align: center; color: var(--muted); font-size: 13px; }

@media (max-width: 760px) {
  .qr-book { padding: 9px; transform: rotateX(8deg); }
  .qr-spread { width: min(460px, 86vw); aspect-ratio: .68; }
  .qr-page.qr-right { width: 100%; border-radius: 4px; box-shadow: inset 18px 0 22px -16px rgba(70, 45, 10, .35); }
  .qr-page.qr-left, .qr-spine { display: none; }
  .qr-spread::after { display: none; }
  .qr-rehal { width: 96vw; margin-top: -12%; }
  .qr-phead, .qr-pfoot { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { .qr-leaf { transition: none; } .qr-turning .qr-face::after { animation: none; } }

/* ---- The teaching board: toolbar, modes, highlight, translation panel, tajweed, pen, pointer, focus, fullscreen ---- */
.qr-tools { display: grid; gap: 8px; width: min(1080px, 100%); margin: 10px auto 0; padding: 10px; border-radius: 18px; background: var(--paper);
  border: 1px solid rgba(184, 137, 44, .35); box-shadow: var(--shadow-sm); }
.qr-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.qr-seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: 999px; background: var(--gold-100); border: 1px solid rgba(184, 137, 44, .4); }
.qr-tb { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid rgba(15, 76, 58, .22);
  background: #fff; color: var(--green-800); font: 700 14px/var(--lh-ui) var(--font-body); cursor: pointer; white-space: nowrap; }
.qr-seg .qr-tb { border: 0; background: transparent; }
.qr-tb[aria-pressed="true"] { background: linear-gradient(180deg, var(--green-700), var(--green-900)); color: #fff; border-color: transparent; }
.qr-tb.qr-wa { background: linear-gradient(180deg, var(--wa-1), var(--wa-2)); color: #fff; border-color: transparent; }
.qr-tb.qr-playbtn { background: linear-gradient(180deg, #f1d58d, var(--gold-500)); color: #1d1606; border-color: transparent; min-width: 6.5em; justify-content: center; }
.qr-tb.qr-playbtn[aria-pressed="true"] { background: linear-gradient(180deg, #d6493c, #b5302a); color: #fff; }
.qr-field { display: inline-flex; align-items: center; gap: 6px; padding: 0 4px 0 12px; min-height: 40px; border-radius: 999px; background: #fff;
  border: 1px solid rgba(15, 76, 58, .22); color: var(--gold-700); font-size: 13.5px; line-height: var(--lh-ui); }
html[dir="rtl"] .qr-field { padding: 0 12px 0 4px; }
.qr-field select, .qr-field input { min-height: 32px; border: 0; border-radius: 999px; background: var(--gold-100); color: var(--green-900);
  font: 700 13.5px/1.4 "Noto Naskh Arabic", "Nunito", system-ui, sans-serif; padding: 0 10px; max-width: 52vw; }
.qr-field input { width: 6.5em; text-align: center; }
.qr-hint { margin: 8px auto 0; text-align: center; color: var(--gold-700); font-size: 14px; line-height: var(--lh-ui); }
@media (max-width: 760px) {
  .qr-tools { border-radius: 14px; padding: 8px 6px; }
  .qr-row { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .qr-row::-webkit-scrollbar { display: none; }
  .qr-tb, .qr-field { flex: none; }
}

.qr-teach .qr-book { cursor: default; }
.qr-teach .qr-a { cursor: pointer; border-radius: 6px; transition: background .15s ease; }
.qr-teach .qr-a:hover { background: rgba(207, 162, 69, .14); }
.qr-a.qr-sel { background: rgba(207, 162, 69, .28); box-shadow: 0 0 0 2px rgba(207, 162, 69, .35); border-radius: 6px; }
.qr-a.qr-play { background: rgba(31, 170, 82, .18); box-shadow: 0 0 0 2px rgba(31, 170, 82, .35); border-radius: 6px; }
.qr-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 7; pointer-events: none; touch-action: none; }
.qr-canvas.qr-on { pointer-events: auto; cursor: crosshair; }
.qr-laser { position: absolute; left: 0; top: 0; width: 46px; height: 46px; margin: -23px 0 0 -23px; z-index: 8; pointer-events: none; opacity: 0;
  border-radius: 50%; border: 3px solid rgba(214, 32, 44, .85); background: rgba(214, 32, 44, .12); box-shadow: 0 0 18px rgba(214, 32, 44, .45);
  transition: opacity .15s ease; }

.qr-panel { width: min(900px, 100%); margin: 16px auto 0; padding: 14px 18px; border-radius: 18px; background: var(--paper);
  border: 1.5px solid var(--gold-300); box-shadow: var(--shadow-sm); text-align: center; }
.qr-ref { display: inline-block; padding: 0 14px; border-radius: 999px; background: var(--gold-100); color: var(--gold-700); font-size: 14px; line-height: var(--lh-ui); }
.qr-par { margin: 6px 0 2px; font: 28px/2 "Amiri Quran", "Amiri", serif; color: var(--green-900); direction: rtl; }
.qr-ptr { margin: 0; color: var(--ink); font-size: 16px; }
.qr-ptr[lang="ur"] { font-family: "Noto Nastaliq Urdu", serif; line-height: 2.1; }
.qr-ptr[lang="sd"] { font-family: "Noto Naskh Arabic", serif; line-height: 1.9; }
.qr-ptr[lang="en"] { font-family: "Nunito", system-ui, sans-serif; line-height: 1.6; }

/* Tajweed colours (the usual colour-coded mushaf palette) and their legend. */
.qr-tajweed .tj-h, .qr-tajweed .tj-s, .qr-tajweed .tj-l { color: #a3a3a3; }
.qr-tajweed .tj-n { color: #537fff; } .qr-tajweed .tj-p { color: #4050ff; } .qr-tajweed .tj-o { color: #2144c1; } .qr-tajweed .tj-m { color: #000ebc; }
.qr-tajweed .tj-q { color: #dd0008; } .qr-tajweed .tj-c { color: #d500b7; } .qr-tajweed .tj-f { color: #9400a8; } .qr-tajweed .tj-w { color: #58b800; }
.qr-tajweed .tj-i { color: #26bffd; } .qr-tajweed .tj-a { color: #169777; } .qr-tajweed .tj-u { color: #169200; }
.qr-tajweed .tj-d, .qr-tajweed .tj-b { color: #8d8d8d; } .qr-tajweed .tj-g { color: #ff7e1e; }
.qr-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px; width: min(1000px, 100%); margin: 12px auto 0; padding: 10px 12px;
  border-radius: 14px; background: var(--paper); border: 1px solid rgba(184, 137, 44, .3); }
.qr-legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; line-height: var(--lh-ui); color: var(--ink); }
.qr-legend i { width: 14px; height: 14px; border-radius: 4px; flex: none; }

.qr-toast { position: fixed; left: 50%; bottom: 96px; z-index: 60; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 6px 18px;
  border-radius: 999px; background: var(--green-900); color: #fff; font-size: 14px; line-height: var(--lh-ui); transition: opacity .2s ease, transform .2s ease; }
.qr-toast.qr-show { opacity: 1; transform: translate(-50%, 0); }

/* Focus: one big page on any screen. */
.qr-one .qr-spread { width: min(620px, 92vw); aspect-ratio: .68; }
.qr-one .qr-page.qr-right { width: 100%; border-radius: 4px; box-shadow: inset 18px 0 22px -16px rgba(70, 45, 10, .35); }
.qr-one .qr-page.qr-left, .qr-one .qr-spine, .qr-one .qr-spread::after { display: none; }
@media (max-width: 760px) { .qr-one .qr-spread { width: min(460px, 86vw); } }

/* Fullscreen for screen sharing on Teams or WhatsApp. */
.qr-stage:fullscreen { overflow: auto; padding: 14px 0 20px; background: radial-gradient(70% 60% at 50% 30%, #145c45, #072a20); }
.qr-stage:fullscreen .qr-book-wrap { padding-top: 6px; }
.qr-stage:fullscreen .qr-spread { width: min(94vw, calc((100vh - 170px) * 1.36)); }
.qr-stage:fullscreen .qr-one .qr-spread { width: min(94vw, calc((100vh - 170px) * .68)); }
.qr-stage:fullscreen .qr-credit, .qr-stage:fullscreen .qr-rehal { display: none; }
.qr-stage:fullscreen .qr-pos { color: var(--gold-300); }
.qr-stage:fullscreen .qr-book { transform: rotateX(6deg); }

.qr-legend[hidden], .qr-panel[hidden], .qr-ptr[hidden] { display: none !important; }

/* Subcontinent mushaf details: surah header band with its details, ruku ends (ع), sajda label. */
.qr-sh { display: flex; align-items: center; justify-content: space-between; gap: .4em; }
.qr-shn { flex: 1; text-align: center; }
.qr-shi { flex: none; font-size: .5em; color: #ecd18f; white-space: nowrap; }
.qr-ruku { display: inline-block; margin-inline-start: .15em; color: #b8892c; font-size: .72em; font-weight: 700; line-height: 1; vertical-align: .1em; }
.qr-ruku sup { font-size: .55em; margin-inline-start: .05em; }
.qr-sjl { display: inline-block; margin-inline-start: .2em; padding: 0 .3em; border-radius: .4em; background: rgba(184, 137, 44, .16); color: #8f6a1d;
  font-size: .45em; line-height: 1.6; vertical-align: .35em; }
.qr-body.qr-scroll { overflow-y: auto; scrollbar-width: thin; }
@media (max-width: 760px) { .qr-spread, .qr-one .qr-spread { aspect-ratio: .58; } }
@media (max-width: 760px) {
  .qr-field select, .qr-field input, .qr-controls select, .qr-controls input { font-size: 16px !important; min-height: 36px; }
  .qr-stage, .qr-hero { max-width: 100vw; overflow-x: clip; }
  .qr-book-wrap { overflow: visible; }
}


/* ---- Phones (iPhone 11 etc.): built-in fullscreen, Big page, smooth scrolling (7 Oct) ---- */
html.qr-noscroll, html.qr-noscroll body { overflow: hidden; }
.qr-stage.qr-pseudo-fs { position: fixed; inset: 0; z-index: 80; margin: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; padding: calc(8px + env(safe-area-inset-top)) 0 calc(12px + env(safe-area-inset-bottom));
  background: radial-gradient(70% 60% at 50% 30%, #145c45, #072a20); }
.qr-pseudo-fs .qr-credit, .qr-pseudo-fs .qr-rehal, .qr-pseudo-fs .qr-legend { display: none; }
.qr-pseudo-fs .qr-pos, .qr-pseudo-fs .qr-hint { color: var(--gold-300); }
.qr-pseudo-fs .qr-spread { width: min(94vw, calc((100svh - 230px) * 1.36)); }
.qr-pseudo-fs .qr-one .qr-spread { width: min(94vw, calc((100svh - 230px) * .62)); }
.qr-body.qr-scroll { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
@media (max-width: 760px) {
  /* Flat book while scrolling (Safari re-rasterises 3D layers on scroll); the page turn keeps its depth. */
  .qr-book { transform: none; transform-style: flat; }
  .qr-spread { perspective: 1800px; }
  .qr-book, .qr-teach .qr-book { touch-action: pan-y; }
  /* Big page: the page fills the screen width and height, so the text fits much larger. */
  .qr-big .qr-spread, .qr-big .qr-one .qr-spread { width: 94vw; aspect-ratio: auto; height: calc(100svh - 150px); max-height: 940px; }
  .qr-big .qr-book { padding: 6px; }
  .qr-big .qr-rehal { display: none; }
  .qr-pseudo-fs .qr-spread, .qr-pseudo-fs .qr-one .qr-spread { width: 94vw; aspect-ratio: auto; height: calc(100svh - 210px); }
  .qr-pseudo-fs .qr-tools { position: sticky; top: 0; z-index: 3; }
}
