/* Quran reader — mushaf-style (website + app) */

.qrn {
  --qrn-ink: #1c1914;
  --qrn-muted: #6b6458;
  --qrn-line: rgba(40, 30, 10, 0.14);
  --qrn-soft: #f6f1e6;
  --qrn-accent: #0d5c3d;
  --qrn-arabic: #111;
  --qrn-rule: rgba(55, 40, 15, 0.22);
  --qrn-frame: #2a2216;
  --qrn-page: #fffcf5;
  --qrn-ar-size: 1.85rem;
  --qrn-line-h: 2.85rem;
  --qrn-font: "Scheherazade New", "Noto Naskh Arabic", "Traditional Arabic", serif;
  position: relative;
}

.qrn-hero .section-head { margin-bottom: 0; }

.qrn-list-bar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.qrn-search input {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--qrn-line);
  border-radius: 12px;
  background: #fff;
  font: inherit;
  color: var(--qrn-ink);
}

.qrn-search input:focus {
  outline: 2px solid rgba(13, 92, 61, 0.35);
  outline-offset: 1px;
}

.qrn-home-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: linear-gradient(135deg, #0d5c3d 0%, #147a52 100%);
  color: #fff;
}

.qrn-home-card-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.qrn-home-card-text span {
  font-size: 0.72rem;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.qrn-home-card-text strong {
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qrn-home-card-btn {
  flex: 0 0 auto;
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  background: #fff;
  color: #0d5c3d;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.qrn-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.25rem;
  border-radius: 12px;
  background: rgba(40, 30, 10, 0.06);
}

.qrn-tabs button {
  flex: 1;
  border: 0;
  border-radius: 10px;
  padding: 0.55rem 0.4rem;
  background: transparent;
  color: var(--qrn-muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.qrn-tabs button.is-on {
  background: #fff;
  color: var(--qrn-accent);
  box-shadow: 0 1px 4px rgba(40, 30, 10, 0.08);
}

.qrn-tabs em {
  font-style: normal;
  font-size: 0.72rem;
  opacity: 0.75;
  margin-left: 0.15rem;
}

.qrn-hifz-hint {
  margin: 0 0 0.75rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  background: var(--qrn-soft);
  color: var(--qrn-muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.qrn-saved {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.qrn-saved-row {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
}

.qrn-saved-go {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  text-align: left;
  padding: 0.8rem 1rem;
  border: 1px solid var(--qrn-line);
  border-radius: 12px;
  background: #fff;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.qrn-saved-go strong { color: var(--qrn-ink); font-size: 0.95rem; }
.qrn-saved-go span { color: var(--qrn-muted); font-size: 0.8rem; }

.qrn-saved-x {
  width: 2.5rem;
  border: 1px solid var(--qrn-line);
  border-radius: 12px;
  background: #fff;
  color: var(--qrn-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.qrn-empty {
  padding: 1.5rem 0.75rem;
  text-align: center;
  color: var(--qrn-muted);
  font-size: 0.92rem;
}

.qrn-list-scroll {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
}

@media (min-width: 640px) {
  .qrn-list-scroll { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 960px) {
  .qrn-list-scroll { grid-template-columns: 1fr 1fr 1fr; }
}

.qrn-surah {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  text-align: left;
  padding: 0.85rem 1rem;
  border: 1px solid var(--qrn-line);
  border-radius: 14px;
  background: #fff;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.qrn-surah:hover,
.qrn-surah:focus-visible {
  border-color: rgba(13, 92, 61, 0.45);
  box-shadow: 0 4px 14px rgba(13, 92, 61, 0.08);
  outline: none;
}

.qrn-surah-num {
  flex: 0 0 auto;
  width: 2.1rem;
  height: 2.1rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--qrn-soft);
  color: var(--qrn-accent);
  font-size: 0.8rem;
  font-weight: 700;
}

.qrn-surah-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.qrn-surah-meta strong {
  font-size: 0.98rem;
  color: var(--qrn-ink);
}

.qrn-surah-meta span {
  font-size: 0.8rem;
  color: var(--qrn-muted);
}

.qrn-surah-hifz {
  display: inline-block;
  margin-top: 0.2rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: rgba(13, 92, 61, 0.1);
  color: var(--qrn-accent);
  font-size: 0.72rem !important;
  font-weight: 700;
}

.qrn-surah-ar {
  font-family: var(--qrn-font);
  font-size: 1.35rem;
  color: var(--qrn-arabic);
  direction: rtl;
  line-height: 1.2;
}

/* —— Reading chrome —— */
.qrn-read {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.qrn-read-bar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 0.55rem 0.65rem;
  background: #fffcf5;
  border: 1px solid var(--qrn-line);
  border-radius: 14px;
}

.qrn-back {
  flex: 0 0 auto;
  width: 2.35rem;
  height: 2.35rem;
  border: 0;
  border-radius: 10px;
  background: var(--qrn-soft);
  color: var(--qrn-ink);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.qrn-read-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
}

.qrn-read-title strong {
  font-size: 0.98rem;
  color: var(--qrn-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qrn-read-title span {
  font-size: 0.74rem;
  color: var(--qrn-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qrn-tools {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.qrn-hifz-toggle {
  border: 1px solid var(--qrn-line);
  border-radius: 10px;
  padding: 0.4rem 0.55rem;
  background: #fff;
  color: var(--qrn-ink);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.qrn-hifz-toggle.is-on {
  background: #0d5c3d;
  border-color: #0d5c3d;
  color: #fff;
}

.qrn-hifz-banner {
  margin: 0;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  background: rgba(13, 92, 61, 0.1);
  color: #0d5c3d;
  font-size: 0.86rem;
  line-height: 1.4;
  max-width: 42rem;
  margin-inline: auto;
  width: 100%;
}

.qrn-size {
  display: inline-flex;
  border: 1px solid var(--qrn-line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.qrn-size button {
  border: 0;
  background: transparent;
  padding: 0.4rem 0.55rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--qrn-ink);
  cursor: pointer;
  line-height: 1;
}

.qrn-size button + button {
  border-left: 1px solid var(--qrn-line);
}

.qrn-lang select {
  border: 1px solid var(--qrn-line);
  border-radius: 10px;
  padding: 0.4rem 0.45rem;
  background: #fff;
  font: inherit;
  font-size: 0.8rem;
  color: var(--qrn-ink);
  max-width: 6.8rem;
}

/* —— Mushaf page —— */
.qrn-mushaf {
  max-width: 42rem;
  margin: 0 auto;
  padding: 0.35rem;
}

.qrn-mushaf-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0.55rem 0.65rem;
  direction: rtl;
}

.qrn-mushaf-surah {
  font-family: var(--qrn-font);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--qrn-ink);
}

.qrn-mushaf-info {
  font-size: 0.78rem;
  color: var(--qrn-muted);
  direction: ltr;
  text-align: left;
}

.qrn-mushaf-page {
  position: relative;
  background: var(--qrn-page);
  border: 2px solid var(--qrn-frame);
  box-shadow:
    inset 0 0 0 1px rgba(42, 34, 22, 0.35),
    inset 0 0 0 5px var(--qrn-page),
    inset 0 0 0 6px rgba(42, 34, 22, 0.55),
    0 10px 28px rgba(40, 30, 10, 0.08);
  padding: 1.1rem 0.95rem 1.35rem;
  border-radius: 2px;
}

.qrn-mushaf-page::before,
.qrn-mushaf-page::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--qrn-frame);
  pointer-events: none;
}

.qrn-mushaf-page::before {
  top: 8px;
  left: 8px;
  border-right: 0;
  border-bottom: 0;
}

.qrn-mushaf-page::after {
  bottom: 8px;
  right: 8px;
  border-left: 0;
  border-top: 0;
}

.qrn-bismillah {
  text-align: center;
  font-family: var(--qrn-font);
  font-size: calc(var(--qrn-ar-size) * 1.05);
  font-weight: 700;
  color: var(--qrn-arabic);
  direction: rtl;
  padding: 0.35rem 0.5rem 0.85rem;
  line-height: 1.6;
  border-bottom: 1px solid var(--qrn-rule);
  margin-bottom: 0.55rem;
}

/* Continuous Arabic (Arabic-only mode) */
.qrn-mushaf-flow {
  font-family: var(--qrn-font);
  font-size: var(--qrn-ar-size);
  font-weight: 400;
  line-height: var(--qrn-line-h);
  color: var(--qrn-arabic);
  direction: rtl;
  text-align: justify;
  text-align-last: center;
  word-spacing: 0.08em;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--qrn-line-h) - 1px),
    var(--qrn-rule) calc(var(--qrn-line-h) - 1px),
    transparent var(--qrn-line-h)
  );
  padding: 0 0.15rem;
}

.qrn-aya {
  scroll-margin-top: 5.5rem;
  cursor: pointer;
  border-radius: 4px;
}

.qrn-aya.is-bm {
  background: rgba(212, 160, 23, 0.18);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.qrn-aya.is-hf .qrn-aya-end {
  background: #0d5c3d;
  color: #fff;
  border-color: #0d5c3d;
}

.qrn-flow-hint {
  margin: 0.85rem 0 0;
  text-align: center;
  font-size: 0.78rem;
  color: var(--qrn-muted);
}

.qrn-aya-end {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55em;
  height: 1.55em;
  margin: 0 0.18em;
  border: 1.5px solid #3a3226;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px rgba(58, 50, 38, 0.35);
  font-family: var(--qrn-font);
  font-size: 0.52em;
  font-weight: 700;
  line-height: 1;
  color: #1c1914;
  vertical-align: middle;
  background: #fffdf8;
}

.qrn-mushaf-stack {
  display: block;
}

/* Stacked ayah + translation */
.qrn-ayah {
  position: relative;
  padding: 0.95rem 0.2rem 1.05rem;
  border-bottom: 1px solid var(--qrn-rule);
  scroll-margin-top: 5.5rem;
  content-visibility: auto;
  contain-intrinsic-size: auto 9.5rem;
  contain: layout style paint;
}

.qrn-ayah:last-child { border-bottom: 0; }

.qrn-ayah.is-bm {
  background: linear-gradient(90deg, rgba(212, 160, 23, 0.12), transparent 55%);
  margin-inline: -0.35rem;
  padding-inline: 0.55rem;
  border-radius: 10px;
}

.qrn-ayah.is-hf {
  box-shadow: inset 3px 0 0 #0d5c3d;
}

.qrn-ayah-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.qrn-ayah-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--qrn-muted);
  letter-spacing: 0.02em;
}

.qrn-ayah-actions {
  display: inline-flex;
  gap: 0.3rem;
}

.qrn-act {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--qrn-line);
  border-radius: 50%;
  background: #fff;
  color: var(--qrn-muted);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.qrn-act-play.is-playing {
  background: #0d5c3d;
  border-color: #0d5c3d;
  color: #fff;
}

.qrn-act-bm.is-on {
  background: #f6e7b2;
  border-color: #d4a017;
  color: #8a6a00;
}

.qrn-act-hf.is-on {
  background: #0d5c3d;
  border-color: #0d5c3d;
  color: #fff;
}

.qrn-ayah-ar {
  font-family: var(--qrn-font);
  font-size: var(--qrn-ar-size);
  line-height: 2.15;
  color: var(--qrn-arabic);
  direction: rtl;
  text-align: right;
  text-align-last: right;
  transition: filter 0.2s, opacity 0.2s;
}

.qrn-ayah-ar .qrn-aya-end {
  margin-inline-start: 0.25em;
}

.qrn-ayah-reveal {
  display: block;
  width: 100%;
  margin-bottom: 0.55rem;
  padding: 0.75rem 1rem;
  border: 1px dashed rgba(13, 92, 61, 0.45);
  border-radius: 12px;
  background: rgba(13, 92, 61, 0.06);
  color: var(--qrn-accent);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.qrn.is-hifz .qrn-ayah.is-masked .qrn-ayah-ar {
  filter: blur(7px);
  opacity: 0.55;
  user-select: none;
  pointer-events: none;
}

.qrn.is-hifz .qrn-ayah.is-masked .qrn-ayah-tr {
  filter: blur(4px);
  opacity: 0.5;
  user-select: none;
}

.qrn.is-hifz .qrn-ayah.is-revealed .qrn-ayah-ar,
.qrn.is-hifz .qrn-ayah.is-revealed .qrn-ayah-tr {
  filter: none;
  opacity: 1;
  pointer-events: auto;
  user-select: text;
}

.qrn-ayah-tr {
  margin-top: 0.7rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: rgba(246, 241, 230, 0.75);
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--qrn-ink);
  border-right: 3px solid rgba(13, 92, 61, 0.35);
}

.qrn-ayah-tr.is-ur {
  direction: rtl;
  text-align: right;
  font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", serif;
  font-size: 1.08rem;
  line-height: 2;
  border-right: 0;
  border-left: 3px solid rgba(13, 92, 61, 0.35);
}

.qrn-toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 40;
  margin: 0;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  background: rgba(26, 22, 16, 0.92);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  white-space: nowrap;
}

.is-app-page .qrn-toast {
  bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
}

.qrn-pager {
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  padding: 0.35rem 0 1rem;
  max-width: 42rem;
  margin: 0 auto;
  width: 100%;
}

.qrn-pager button {
  flex: 1;
  padding: 0.85rem 1rem;
  border: 1px solid var(--qrn-line);
  border-radius: 12px;
  background: #fff;
  color: var(--qrn-accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.qrn-pager button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.qrn-loading,
.qrn-error {
  padding: 1.5rem 0.5rem;
  text-align: center;
  color: var(--qrn-muted);
}

.qrn-error { color: #9b2c2c; }

.qrn-retry {
  display: inline-block;
  margin-left: 0.35rem;
  border: 1px solid var(--qrn-line);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  background: #fff;
  color: var(--qrn-accent);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

/* Desktop: larger mushaf */
@media (min-width: 768px) {
  .qrn {
    --qrn-ar-size: 2.15rem;
    --qrn-line-h: 3.15rem;
  }
  .qrn-mushaf { max-width: 46rem; }
  .qrn-mushaf-page {
    padding: 1.45rem 1.5rem 1.7rem;
  }
}

@media (min-width: 1100px) {
  .qrn {
    --qrn-ar-size: 2.35rem;
    --qrn-line-h: 3.35rem;
  }
}

/* App */
.is-app-page .qrn-app .qrn-read-bar {
  top: calc(var(--apg-bar-h, 52px) + env(safe-area-inset-top, 0px));
}

.is-app-page .qrn-app .qrn-aya,
.is-app-page .qrn-app .qrn-ayah {
  scroll-margin-top: calc(var(--apg-bar-h, 52px) + 4.8rem);
}

.is-app-page .qrn-app .qrn-surah { border-radius: 16px; }

.is-app-page .qrn-app .qrn-mushaf-page {
  margin-inline: -0.15rem;
}

.is-app-page .qrn-app {
  --qrn-ar-size: 1.75rem;
  --qrn-line-h: 2.7rem;
}

@media (min-width: 400px) {
  .is-app-page .qrn-app {
    --qrn-ar-size: 1.9rem;
    --qrn-line-h: 2.85rem;
  }
}
