/* tafsir.css — what only the tafsir pages have: the surah-grouped sidebar, catalog filters and
   cards, the recording header, the audio bar, chunk-seam markers, muted closing dua, speaker
   badges and the Urdu-only toggle. Everything shared (tokens, shell, layout, rows, script
   typography, inline tags, print) is in base.css. */

/* ─── Sidebar: one <details> per focus surah ─────────────────────────────────────────────── */
.sb-year { margin-bottom: var(--space-1); }
.sb-year > summary {
  cursor: pointer; user-select: none; padding: var(--space-1) 6px;
  font-family: var(--font-ar); font-size: 17px; font-weight: 700; line-height: 1.6;
  color: var(--accent-2); direction: rtl; text-align: right;
}
.sb-date { font-family: var(--font-mono); color: var(--fg-2); }
.sb-refs {
  margin-left: auto; text-align: right; direction: rtl;
  font-family: var(--font-ar); font-size: 17px; line-height: 1.6; color: var(--accent-2);
}
.sb-item[data-current="true"] .sb-date { color: var(--accent-2); }
.sb-back { align-self: center; margin: var(--space-4) 0 6px; }

/* ─── Catalog: filter bar + card grid ────────────────────────────────────────────────────── */
.filter-bar {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg-2); border-bottom: 1px solid var(--border);
  padding: 10px var(--space-4);
  display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center;
}
.filter-search, .filter-input {
  padding: 5px var(--space-2); border: 1px solid var(--border); border-radius: 6px;
  font-size: var(--fs-s); background: var(--bg); font-family: inherit;
}
.filter-search-form { flex: 1 1 280px; display: flex; min-width: 200px; }
.filter-search-form .filter-search { flex: 1 1 auto; }
.filter-search { flex: 1 1 280px; min-width: 200px; padding: 6px 10px; font-size: 13px; }
.filter-label { display: inline-flex; gap: var(--space-1); align-items: baseline; font-size: 11px; color: var(--fg-2); }
.filter-label .filter-input { width: 70px; }
.filter-bar > * { direction: ltr; }  /* the bar is dir="rtl" (search box on the right); controls stay LTR */

/* RTL grid flow: the first card lands top-right, matching the Arabic surah index in the rail.
   Card contents flow RTL too (title, meta, pills and the call to action anchor on the right); each
   English leaf is its own LTR island, and a label+value pair (.toc-source) keeps its LTR order. */
.toc-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(380px, 100%), 1fr));
  gap: 14px; padding: var(--space-4); direction: rtl;
}
.toc-card {
  display: flex; flex-direction: column; gap: 6px;
  border-color: var(--rule); border-radius: var(--radius-m); box-shadow: none;
  padding: 14px var(--space-4);
}
.toc-card-head { font-size: var(--fs-m); display: flex; flex-direction: column; gap: var(--space-1); }
.toc-card-head .english-meta {  /* "date · min · chunks" keeps its LTR order, anchored right */
  display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: baseline; direction: ltr; justify-content: flex-end;
}
.toc-card-head strong { font-size: var(--fs-body); color: var(--accent-2); }
.toc-card-head .title-arabic { display: block; text-align: right; font-size: 18px; }
.toc-meta { color: var(--muted); font-size: 11px; font-family: var(--font-mono); }
.toc-source {
  color: var(--fg-2); font-size: var(--fs-s); display: flex; align-items: baseline; gap: 6px;
  direction: ltr; justify-content: flex-end;
}
.toc-cta { direction: ltr; unicode-bidi: isolate; }
.toc-source-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.65; }
.toc-source-name { font-family: var(--font-mono); font-size: 11.5px; word-break: break-all; }
.toc-refs { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: var(--space-1); }
.toc-themes { gap: 3px; margin-top: var(--space-1); }
.toc-cta { margin-top: auto; align-self: flex-start; }

/* ─── One recording ──────────────────────────────────────────────────────────────────────── */
.session { padding: 22px 28px; margin: var(--space-5) var(--space-6); scroll-margin-top: 70px; }
.archive-breadcrumb {
  display: flex; align-items: baseline; gap: 6px;
  font-size: var(--fs-s); margin: 0 0 10px; color: var(--fg-2);
}
.archive-breadcrumb-sep { color: var(--rule); }
.archive-breadcrumb-date { font-variant-numeric: tabular-nums; }
.session-header { margin-bottom: var(--space-3); }
/* The header is dir="rtl": the Arabic title and every meta row start at the right edge. Each English
   item stays an LTR island. */
.session-title-arabic-row { display: flex; justify-content: flex-start; margin-bottom: 6px; }
.session-title > *, .session-meta > *, .archive-breadcrumb > * { direction: ltr; unicode-bidi: isolate; }
.session-title-arabic-row .title-arabic, .session-title-arabic-row h1 { margin: 0; }
.session-title-arabic-row h1 { font-size: 26px; }
.title-en { color: var(--accent-2); font-size: var(--fs-m); font-weight: 600; }
.title-hijri { color: var(--muted); font-size: 13px; }
.title-arabic {
  font-family: var(--font-ar-display); font-size: 26px; font-weight: 700;
  color: var(--accent-2); direction: rtl; margin: var(--space-1) 0;
}
.session-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.title-date { color: var(--muted); font-size: 13px; font-family: var(--font-mono); margin-inline-end: var(--space-2); }
.audio-dot { font-size: var(--fs-m); }
.meta-series { font-style: italic; color: var(--fg-2); font-size: 13px; }
.session-meta {
  display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: baseline;
  margin-top: var(--space-1); font-size: var(--fs-s); color: var(--fg-2);
}
.theme-pills { margin-top: 6px; }
.topic-chips { margin-top: var(--space-3); }
.theme-pill { font-size: var(--fs-xs); }
.session-footer { margin-top: var(--space-4); padding-top: var(--space-3); border-top: 1px solid var(--rule); }

/* Urdu-only toggle: hides the English column (choice persisted by tafsir.js). */
.urdu-toggle-bar { display: flex; justify-content: flex-end; align-items: center; margin: 0 0 var(--space-2); padding: 6px 0; }
.urdu-toggle-btn .lbl-ar { font-family: var(--font-ur); font-size: 15px; line-height: 1; direction: rtl; }
.urdu-toggle-btn .lbl-en { font-size: var(--fs-s); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.urdu-toggle-btn .lbl-sep { color: var(--rule); }
.urdu-toggle-btn.active .lbl-en, .urdu-toggle-btn.active .lbl-sep { color: inherit; opacity: 0.8; }
body.urdu-only { --print-cols: 1fr; }
body.urdu-only .aligned { grid-template-columns: 1fr; }
body.urdu-only .aligned .trans-cell,
body.urdu-only .aligned .trans-col-header { display: none !important; }

/* ─── Transcript specifics ───────────────────────────────────────────────────────────────── */
.block:hover { background: var(--bg-3); border-radius: var(--radius-s); }
.aligned .orig-cell.stack.untranslated .block { opacity: 0.65; }
.speaker-label, .speaker-tag {
  display: inline-block; padding: 0 var(--space-1); margin-right: var(--space-1);
  background: var(--bg-3); color: var(--accent-2);
  border-radius: 3px; font-size: 0.8em; font-weight: 600; cursor: help;
}
.speaker-inline { display: block; margin-top: 6px; }  /* one line per speaker turn */
/* Public: a listener's turn, labelled "سامع:" (no speaker letters). */
.listener-label { cursor: auto; font-family: var(--font-ur); font-weight: 500; }
.trans-cell .listener-label { font-family: var(--font-en); }
/* Public: silence or missing audio, a quiet one-line note instead of the pipeline's markers. */
.quiet-line {
  color: var(--fg-2); font-family: var(--font-ur); font-size: var(--fs-m); line-height: 2;
  text-align: center !important; opacity: 0.8;
}
.quiet-line [lang="en"] { font-family: var(--font-en); font-size: var(--fs-s); }
.aligned .quiet-row .orig-cell { grid-column: 1 / -1; }
.speaker-inline:first-child { margin-top: 0; }
.quran-truncation-warn {
  display: inline-block; margin-left: 6px; padding: 1px 6px; vertical-align: middle;
  background: var(--warn-bg); color: var(--gap-fg); border: 1px solid var(--gap-border);
  border-radius: 3px; font-size: var(--fs-xs); font-weight: 600; cursor: help;
}
/* Chunk seams; missing-chunk markers must stand out: the reader needs to know content is absent. */
.aligned .chunk-boundary-row .trans-cell,
.aligned .chunk-boundary-row .orig-cell.chunk-boundary {
  border-top: 2px dotted var(--accent); border-bottom: 2px dotted var(--accent);
  background: var(--bg-3); padding: var(--space-2) var(--space-3);
  font-family: var(--font-mono); font-size: 11px; color: var(--accent-2); text-align: center;
}
.aligned .chunk-boundary-row .orig-cell.chunk-boundary.chunk-gap {
  background: var(--gap-bg); color: var(--gap-fg); font-weight: 600;
  border-top: 2px solid var(--gap-border); border-bottom: 2px solid var(--gap-border);
}
/* The Mufti's closing dua: visible but de-emphasized (colour + opacity; never italic Nastaliq). */
.aligned .block[data-editorial-muted="1"],
.aligned .trans-cell .seg-muted,
.aligned .row.editorial-muted .trans-cell,
.aligned .row.editorial-muted .orig-cell { color: var(--muted); opacity: 0.7; }

/* ─── Audio bar: fixed thin bottom player, stopping at the sidebar's edge ───────────────── */
body.per-mp3 { padding-bottom: 64px; }
.session-audio-wrap {
  position: fixed; left: 0; right: var(--sidebar-w); bottom: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 18px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  backdrop-filter: blur(10px) saturate(120%);
  border-top: 2px solid var(--accent);
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.04), 0 -8px 24px rgba(138, 109, 59, 0.10);
}
@media (max-width: 1100px) { .session-audio-wrap { right: 0; } }
.session-audio-wrap audio.session-audio { display: none; }
.aud-date, .aud-time {
  font-family: var(--font-mono); font-size: var(--fs-s); color: var(--fg-2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.aud-time { font-size: 11px; }
.aud-title-ar {
  font-family: var(--font-ar-ui); font-size: var(--fs-body); line-height: 1; font-weight: 500;
  direction: rtl; color: var(--accent-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px;
  margin-left: auto;  /* pushes title + download to the right edge */
}
.aud-download { font-size: var(--fs-s); padding: 5px var(--space-3); }
.aud-download-icon { width: 14px; height: 14px; flex: 0 0 14px; }
@media (max-width: 720px) { .aud-title-ar { display: none; } }
@media (max-width: 860px) { .aud-download-label { display: none; } }
@media (max-width: 540px) { .aud-download { display: none; } }
.aud-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-2); border: 1.5px solid var(--accent); color: var(--accent-2);
  font-family: var(--font-en); font-weight: 600;
  cursor: pointer; user-select: none; transition: background 0.12s, color 0.12s, transform 0.06s;
}
.aud-btn:hover { background: var(--bg-3); }
.aud-btn:active { transform: scale(0.94); }
.aud-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.aud-skip { height: 32px; min-width: 46px; padding: 0 var(--space-2); border-radius: 16px; gap: 3px; font-size: var(--fs-s); }
.aud-skip .skip-arrow { font-size: 13px; line-height: 1; }
.aud-skip .skip-num { font-variant-numeric: tabular-nums; font-size: 11px; }
.aud-play {
  width: 38px; height: 38px; border-radius: 19px; font-size: var(--fs-m); line-height: 1;
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
  box-shadow: 0 2px 6px rgba(138, 109, 59, 0.3);
}
.aud-play:hover { background: var(--accent-2); border-color: var(--accent-2); }
.aud-play .pause-glyph { display: none; font-size: 11px; }
.aud-play.playing .play-glyph { display: none; }
.aud-play.playing .pause-glyph { display: inline; }
.aud-scrub {
  flex: 1 1 180px; min-width: 100px; height: 22px; margin: 0 2px;
  -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer;
}
.aud-scrub::-webkit-slider-runnable-track {
  height: 5px; border-radius: 3px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--seek-pct, 0%),
    var(--rule) var(--seek-pct, 0%), var(--rule) 100%);
}
.aud-scrub::-moz-range-track { height: 5px; border-radius: 3px; background: var(--rule); }
.aud-scrub::-moz-range-progress { height: 5px; border-radius: 3px; background: var(--accent); }
.aud-scrub::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; margin-top: -7px;
  width: 18px; height: 18px; border-radius: 9px; cursor: grab;
  background: var(--accent-2); border: 3px solid var(--bg-2); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.aud-scrub::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 9px; cursor: grab;
  background: var(--accent-2); border: 3px solid var(--bg-2); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.aud-scrub::-webkit-slider-thumb:active { cursor: grabbing; }
.aud-scrub:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: var(--radius-s); }

@media screen and (max-width: 1100px) {
  .aligned .chunk-boundary-row .trans-cell { display: none; }  /* stacked: the banner alone */
}
@media (max-width: 720px) {
  .filter-bar { position: static; }
  .session { margin: var(--space-3) var(--space-2); padding: var(--space-4); }
}

@media print {
  .cost-panel, .toc-cta, .archive-link { display: none !important; }
  .session { break-inside: avoid; }
}

/* ─── Lecture pages: click-a-paragraph audio jump (tafsir.js) ───────────────────────────────── */
/* Every block and English paragraph leaves room at its inline-start edge (right for Urdu, left for English) for the
   play button, so jumpable and plain paragraphs stay aligned. */
.lecture .session-body .block,
.lecture .aligned .orig-cell.stack .block,
.lecture .aligned .trans-cell > p,
.lecture .aligned .trans-cell[data-t] { position: relative; padding-inline-start: 30px; }
.lecture .aligned .trans-cell[data-t] > p { padding-inline-start: 0; }
.lecture .session-body [data-t], .lecture .session-body .block[data-c] { cursor: pointer; }
.lecture .session-body .jump {
  position: absolute; inset-inline-start: 4px; top: 0.45em;
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; padding: 0; border-radius: 11px;
  background: var(--bg-2); color: var(--accent-2); border: 1px solid var(--accent);
  cursor: pointer; opacity: 0; transition: opacity 0.12s, background 0.12s;
}
.lecture .session-body .jump svg { width: 12px; height: 12px; }
.lecture .session-body [data-t]:hover > .jump,
.lecture .session-body [data-t]:focus-within > .jump,
.lecture .session-body .block.now-playing > .jump { opacity: 1; }
.lecture .session-body .jump:hover { background: var(--accent); color: var(--on-accent); }
.lecture .session-body .jump:focus-visible { opacity: 1; outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: none) { .lecture .session-body .jump { opacity: 0.55; } }
.lecture .trans-cell [data-t]:hover, .lecture .trans-cell[data-t]:hover { color: var(--accent-2); }
/* The paragraph being heard: a thin accent bar at its inline-start edge and a faint tint. */
.lecture .session-body .block.now-playing { background: color-mix(in srgb, var(--accent) 7%, transparent); border-radius: var(--radius-s); }
.lecture .session-body .block.now-playing::before {
  content: ""; position: absolute; inset-block: 3px; inset-inline-start: 0; width: 3px;
  border-radius: 2px; background: var(--accent);
}
@media print { .jump { display: none !important; } }

/* ─── Edited / as-spoken toggle and the Print menu (lecture pages; dars.site.tafsir.printview, dars.edit) ─── */
.urdu-toggle-bar { gap: var(--space-2); flex-wrap: wrap; }
.view-toggle { display: inline-flex; gap: 4px; }
.view-btn .lbl-ar, .print-menu .lbl-ar { font-family: var(--font-ur); font-size: 15px; line-height: 1; direction: rtl; }
.view-btn .lbl-en, .print-menu .lbl-en { font-size: var(--fs-s); text-transform: uppercase; letter-spacing: 0.06em; }
.view-btn .lbl-sep, .print-menu .lbl-sep { color: var(--rule); }
.print-menu { position: relative; }
.print-menu > summary { list-style: none; }
.print-menu > summary::-webkit-details-marker { display: none; }
.print-menu-list {
  position: absolute; inset-inline-end: 0; top: calc(100% + 4px); z-index: 5; min-width: 15rem; white-space: nowrap;
  display: flex; flex-direction: column; padding: 4px; background: var(--bg); border: 1px solid var(--rule);
  border-radius: 8px; box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
}
.print-menu-list a, .print-menu-list button {
  display: block; padding: 8px 10px; border: 0; background: none; color: var(--fg); text-align: start;
  font: inherit; font-size: 14px; text-decoration: none; cursor: pointer; border-radius: 6px;
}
.print-menu-list a:hover, .print-menu-list button:hover { background: var(--bg-2); color: var(--accent); }
.print-menu-list [lang="ur"] { font-family: var(--font-ur); }
.session-body[hidden] { display: none !important; }
.block-edited { box-shadow: inset -3px 0 0 var(--accent); }
