/* qamar-common common.css — the shared primary header and content footer of muftiqamar.com and
   maktaba.muftiqamar.com. Owned by the dars repo; vendored (pinned + hash-checked) by both sites. See README.md.

   No palette and no @font-face of its own: every colour, radius, space and font is read from the tokens both sites
   define (--bg-2 --bg-3 --fg --fg-2 --accent --accent-2 --on-accent --border --radius-s --radius-pill --space-1..5
   --font-ur --font-en), through --qc-* aliases a site may override. Dark mode comes from the site's own tokens
   (header.js forces light/dark by rewriting the prefers-color-scheme media rules). Every selector is .qc-*. */

.qc-header, .qc-footer {
  --qc-bar: var(--bg-3, #f3f4ef);
  --qc-surface: var(--bg-2, #fff);
  --qc-fg: var(--fg, #1b211e);
  --qc-fg-2: var(--fg-2, #565c57);
  --qc-accent: var(--accent, #0d6647);
  --qc-accent-2: var(--accent-2, #0a4732);
  --qc-on-accent: var(--on-accent, #fff);
  --qc-border: var(--border, #e2e4dc);
  --qc-r-s: var(--radius-s, 6px);
  --qc-r-pill: var(--radius-pill, 999px);
  --qc-s1: var(--space-1, 4px); --qc-s2: var(--space-2, 8px); --qc-s3: var(--space-3, 12px);
  --qc-s4: var(--space-4, 16px); --qc-s5: var(--space-5, 24px);
  --qc-font-ur: var(--font-ur, 'Noto Nastaliq Urdu', serif);
  --qc-font-en: var(--font-en, Georgia, serif);
  --qc-fs-ur: var(--fs-chrome-ur, 17px);  /* 1.4.3: Urdu nav labels and footer text; 1.6.1: a fixed chrome token */
  --qc-fs-en: var(--fs-chrome-en, 14px);  /* 1.6.1: English nav labels and footer text (fixed) */
  --qc-fs-en-s: var(--fs-chrome-en-s, 12px);  /* 1.6.1: English nav labels on phones (fixed) */
  --qc-tap: var(--ctl-h, 44px);          /* 1.4.3: minimum touch target */
  /* Library gold (tokens.css; the only non-green accent, Library item only) */
  --qc-gold: var(--library-gold, #7a5200);
  --qc-gold-bg: var(--library-gold-bg, #f8edc8);
  --qc-gold-ring: var(--library-gold-ring, #c9a23c);
  --qc-gold-glow: var(--library-gold-glow, rgba(201, 162, 60, 0.4));
  --qc-gold-sel: var(--library-gold-sel, #ffe27a);
  --qc-gold-on-sel: var(--library-gold-on-sel, #5c3d00);
  --qc-gold-sel-ring: var(--library-gold-sel-ring, #f0b400);
  --qc-gold-sel-glow: var(--library-gold-sel-glow, rgba(255, 196, 0, 0.65));
  box-sizing: border-box;
}
.qc-header *, .qc-footer * { box-sizing: border-box; }

/* ─── Header: one row, RTL (Home rightmost), the scheme toggle at the left end. Sticky + smart since 1.6.2 (header.js). ─── */
.qc-header {
  position: relative; z-index: 40;
  display: flex; align-items: center; gap: var(--qc-s2);
  padding-inline-end: var(--qc-s3);
  background: var(--qc-bar); border-bottom: 1px solid var(--qc-border);
  font-family: var(--qc-font-en); font-size: var(--qc-fs-en); line-height: 1.6;  /* 1.6.1: fixed, never the page's scaled size */
}
/* Smart header (1.6.2; header.js adds .qc-smart, toggles .qc-hidden): sticky, slides away on scroll down and back on
   scroll up with transform only (no layout shift: the sticky box keeps its place, the page never jumps). Reduced motion:
   no slide, instant. Print: static. A site's own bars stick below it at top: var(--header-offset, 0px). */
.qc-header.qc-smart { position: sticky; top: 0; transition: transform 200ms ease; }
.qc-header.qc-smart.qc-hidden { transform: translateY(-100%); }
@media (prefers-reduced-motion: reduce) { .qc-header.qc-smart { transition: none; } }
@media print { .qc-header.qc-smart { position: static; transform: none; } }
.qc-nav {
  flex: 1 1 auto;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 2px var(--qc-s2);
  padding: var(--qc-s1) var(--qc-s4);
}
.qc-nav-item {
  display: inline-flex; align-items: baseline; gap: var(--qc-s2);
  padding: 2px var(--qc-s3); border-radius: var(--qc-r-pill);
  color: var(--qc-accent-2); text-decoration: none;
  font-family: var(--qc-font-en); font-size: var(--qc-fs-en); font-weight: 600; line-height: 2;
  border: 1px solid transparent;
}
.qc-nav-item .qc-ur { font-family: var(--qc-font-ur); font-weight: 400; font-size: var(--qc-fs-ur); line-height: 2; }
.qc-nav-item .qc-en { font-family: var(--qc-font-en); }
.qc-nav-item:hover { border-color: var(--qc-accent); }
.qc-nav-item[aria-current="page"] { background: var(--qc-accent); color: var(--qc-on-accent); }
.qc-nav-item:focus-visible { outline: 2px solid var(--qc-accent); outline-offset: 2px; }
.qc-search { gap: 6px; }
.qc-icon { width: 14px; height: 14px; align-self: center; flex: 0 0 auto; }
/* Library (مکتبہ, the last item) and Naat (نعت, 1.8.0, just before it): the two sections that include texts by others
   besides the Mufti's own; GOLD, the single exception to the green palette (README "Library gold"). Same rest, hover,
   focus and the same brighter glow when pressed or current. */
.qc-library, .qc-naat {
  color: var(--qc-gold); background: var(--qc-gold-bg);
  box-shadow: inset 0 0 0 1px var(--qc-gold-ring), 0 0 10px var(--qc-gold-glow);
}
.qc-library:hover, .qc-naat:hover { border-color: var(--qc-gold); box-shadow: inset 0 0 0 1px var(--qc-gold-ring), 0 0 14px var(--qc-gold-glow); }
.qc-library:focus-visible, .qc-naat:focus-visible { outline: 2px solid var(--qc-gold); outline-offset: 2px; }
.qc-library:active, .qc-library[aria-current="page"], .qc-naat:active, .qc-naat[aria-current="page"] {
  background: var(--qc-gold-sel); color: var(--qc-gold-on-sel); border-color: var(--qc-gold-sel-ring);
  box-shadow: inset 0 0 0 1px var(--qc-gold-sel-ring), 0 0 6px var(--qc-gold-sel-glow), 0 0 20px var(--qc-gold-sel-glow);
}
.qc-library[aria-current="page"]:focus-visible, .qc-naat[aria-current="page"]:focus-visible { outline-color: var(--qc-gold); }

/* ─── Lead language (1.8.0): English lead reorders and resizes the nav pairs; only the nav's order flips ───
   The header itself never changes direction: the tools stay at the top-left in both leads. In English lead the nav runs
   left to right (Home at its left end, right of the divider) and each item shows English first; nothing is hidden. */
html[data-lead="en"] .qc-nav { direction: ltr; }
html[data-lead="en"] .qc-nav-item .qc-en { order: -1; }
html[data-lead="en"] .qc-nav-item .qc-icon { order: -2; }
html[data-lead="en"] .qc-nav-item .qc-ur { font-size: var(--qc-fs-en); opacity: 0.8; line-height: 1.8; }

/* ─── Tools at the top-left (1.6.0; 1.8.0: the cluster) ───
   [language | colour | text size], left to right, in that fixed order in both leads (dir="ltr" on .qc-tools; the
   header stays RTL, so the cluster is always its left end). A light vertical rule separates it from the nav. */
.qc-tools { flex: 0 0 auto; display: flex; align-items: center; gap: var(--qc-s2); direction: ltr;
  padding-right: var(--qc-s3); border-right: 1px solid var(--qc-border); }  /* physical: the cluster is always at the left */
.qc-scheme-toggle, .qc-ts-open, .qc-ts-btn {
  flex: 0 0 auto; min-width: 32px; height: 32px; padding: 0; margin: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--qc-s1);
  font: 600 16px/1 var(--qc-font-en); cursor: pointer;
  color: var(--qc-accent-2); background: var(--qc-surface);
  border: 1px solid var(--qc-border); border-radius: var(--qc-r-pill);
}
.qc-scheme-toggle:hover, .qc-ts-open:hover, .qc-ts-btn:hover { border-color: var(--qc-accent); color: var(--qc-accent); }
.qc-scheme-toggle:focus-visible, .qc-ts-open:focus-visible, .qc-ts-btn:focus-visible { outline: 2px solid var(--qc-accent); outline-offset: 2px; }
/* the colour button: icon + a visible «رنگ» on wide screens (1.6.0); title / aria-label are Urdu first */
.qc-scheme-icon { display: inline-block; width: 1em; text-align: center; }
.qc-scheme-label { display: none; font-family: var(--qc-font-ur); font-weight: 400; font-size: var(--qc-fs-ur); line-height: 1; padding-bottom: 0.15em; }
@media (min-width: 1000px) {
  .qc-scheme-toggle { width: 76px; padding-inline: 8px; }
  .qc-scheme-label { display: inline; }
}
/* Text size A− · A · A+ (1.6.0). Shown only once <html data-qc-text> is set (head-early.html, before first paint, or
   header.js), so without scripts the control is absent and nothing shifts when it appears. Wide screens: the three
   steps inline. <= 720 px: one «Aa» button opens them as a small panel below the header. */
.qc-textsize { display: none; position: relative; align-items: center; }
html[data-qc-text] .qc-textsize { display: flex; }
.qc-ts-open { display: none; font-size: 15px; }
.qc-ts-steps { display: flex; align-items: center; gap: 2px; direction: ltr; }
.qc-ts-btn { width: 36px; font-size: 14px; letter-spacing: 0.02em; }  /* fixed widths: a late font never moves the nav */
.qc-ts-btn[data-qc-text-step="+1"] { font-size: 17px; }
.qc-ts-btn[data-qc-text-step="-1"] { font-size: 13px; }
.qc-ts-btn[aria-disabled="true"] { opacity: 0.45; cursor: default; border-color: var(--qc-border); color: var(--qc-accent-2); }
/* The lead-language switch «اردو | English» (1.8.0): a two-part segmented control, the first of the tools. Shown only
   once <html data-lead> is set (head-early.html or header.js), as the text size waits for data-qc-text. Below 1600 px
   (where the nav needs the room: dars's eight items stay one row from 1240 px) it is ONE capsule naming the other
   language in full, «English» or «اردو» (1.8.1, user: no «EN» abbreviation; the pressed half is hidden; aria-pressed
   stays on both). */
.qc-lang { display: none; flex: 0 0 auto; direction: ltr; height: 32px; padding: 2px; gap: 2px; align-items: stretch;
  background: var(--qc-surface); border: 1px solid var(--qc-border); border-radius: var(--qc-r-pill); }
html[data-lead] .qc-lang { display: inline-flex; }
.qc-lang-btn { display: inline-flex; align-items: center; justify-content: center; margin: 0; padding: 0 10px; min-width: 0;
  border: 0; border-radius: var(--qc-r-pill); background: transparent; color: var(--qc-accent-2); cursor: pointer;
  font: 600 var(--qc-fs-en)/1 var(--qc-font-en); white-space: nowrap; }
.qc-lang-btn[lang="ur"] { font: 400 var(--qc-fs-ur)/1 var(--qc-font-ur); padding-bottom: 0.2em; }
.qc-lang-btn:hover { color: var(--qc-accent); }
.qc-lang-btn:focus-visible { outline: 2px solid var(--qc-accent); outline-offset: 1px; }
/* the lead in force, from <html data-lead> (right before header.js runs) */
html:not([data-lead="en"]) .qc-lang-btn[data-qc-lead="ur"], html[data-lead="en"] .qc-lang-btn[data-qc-lead="en"] {
  background: var(--qc-accent); color: var(--qc-on-accent); cursor: default; }
@media (max-width: 1599px) {
  .qc-header .qc-lang { width: auto; padding: 0; justify-content: center; }
  html:not([data-lead="en"]) .qc-header .qc-lang-btn[data-qc-lead="ur"],
  html[data-lead="en"] .qc-header .qc-lang-btn[data-qc-lead="en"] { display: none; }
  .qc-header .qc-lang-btn { flex: 1; padding: 0 8px; min-width: 0; }
  .qc-header .qc-lang-btn[lang="en"] { font-size: 13px; }
  .qc-header .qc-lang-btn[lang="ur"] { font-size: 14px; }
}
/* 721-1599 px: the colour button drops its «رنگ» word (icon and title stay) and the nav items sit a little closer, so
   the nav keeps one row where it had one before the language switch and Naat joined it */
@media (min-width: 721px) and (max-width: 1599px) {
  .qc-header .qc-scheme-label { display: none; }
  .qc-header .qc-scheme-toggle { width: 32px; padding-inline: 0; }
  .qc-nav { padding-inline: var(--qc-s2); gap: 2px var(--qc-s1); }
  .qc-nav-item { padding-inline: var(--qc-s2); }
}
@media print { .qc-lang { display: none !important; } }
.qc-vh { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Guest mode (1.6.0): a site that is a guest of this header (maktaba: render.header(guest=True), the default there)
   drops the items whose meaning belongs to the host site (dars's lecture topics and lecture search), so its own
   bar's Topics / Search are the only ones on the page. */
.qc-header.qc-guest .qc-home-only { display: none; }

@media (max-width: 720px) {
  /* Phones: stacked bilingual labels (Urdu over English). 1.6.0: Urdu 17 px (the floor; was 16), English 12 px,
     items at least 44 px; when the items do not fit one row they wrap into two full rows, 4 + 4 at 360-430 px (RTL
     order, Home first at the right; flex-basis 20% (1.8.0; was 22%, the tools grid is wider; from ~600 px a row may take 5: 5 + 3), and >= 44 px wide; each row's items share
     its width), so Search and Library are always visible. English labels stay at every width (1.6.0; they were
     hidden at <= 360 px): at <= 380 px they shrink to 11 px, at <= 340 px a long one may wrap onto a second line. */
  .qc-header { padding-inline-end: var(--qc-s1); gap: 2px; }
  .qc-nav { min-width: 0; padding: 4px 2px; gap: 2px 0; justify-content: center; flex-wrap: wrap; }
  .qc-nav-item { flex: 1 0 20%; min-width: min-content; min-height: var(--qc-tap); flex-direction: column; align-items: center;
    justify-content: center; gap: 0; padding: 2px 4px; line-height: 1.2; border-radius: var(--qc-r-s); text-align: center; }
  .qc-nav-item .qc-ur { font-size: var(--qc-fs-ur); line-height: 1.8; white-space: nowrap; }
  .qc-nav-item .qc-en { font-size: var(--qc-fs-en-s); font-weight: 600; letter-spacing: 0.01em; white-space: nowrap; }
  .qc-header.qc-guest .qc-nav-item { flex-basis: 30%; }  /* guest: six items (1.8.0, with Naat), 3 + 3 */
  .qc-search .qc-icon { display: none; }
  /* 1.8.0: the three tools as a 2 x 2 grid, language and colour over text size (still the reading order), so the
     cluster is never taller than the nav's two rows: the shared header stays about 100-115 px tall */
  .qc-tools { display: grid; grid-template-columns: auto auto; gap: 2px; align-content: center; justify-items: center;
    padding-right: var(--qc-s1); }
  .qc-scheme-toggle, .qc-ts-open { width: 36px; height: 36px; font-size: 15px; }
  .qc-header .qc-lang { height: 36px; grid-column: 1 / -1; }  /* 1.8.1: the capsule spans the 2 x 2 grid's top row */
  .qc-header .qc-lang-btn { padding: 0 6px; }
  .qc-header .qc-lang-btn[lang="en"] { font-size: 12px; }
  html[data-lead="en"] .qc-nav-item .qc-en { font-size: var(--qc-fs-en-s); }  /* the same width as in Urdu lead: rows unchanged */
  html[data-lead="en"] .qc-nav-item .qc-ur { font-size: var(--qc-fs-en-s); line-height: 1.7; }
  .qc-ts-btn { width: var(--qc-tap); height: var(--qc-tap); }
}
/* The «Aa» panel (1.6.0): one «Aa» button opens the steps below the header. 1.8.1: below 1400 px on every device
   (was: phones and touch tablets below 1000 px), so the full-word language capsule costs the nav no row: dars's eight
   items stay one row from 1240 px in both leads. */
@media (max-width: 1399px) {
  .qc-ts-open { display: inline-flex; }
  .qc-textsize { position: static; }
  .qc-ts-steps { display: none; position: absolute; z-index: 60; top: calc(100% + 4px); left: var(--qc-s1);  /* physical: the tools sit at the left end */
    padding: var(--qc-s2); gap: var(--qc-s2); background: var(--qc-surface); border: 1px solid var(--qc-border);
    border-radius: var(--qc-r-s); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18); }
  .qc-textsize.qc-open .qc-ts-steps { display: flex; }
  .qc-ts-open[aria-expanded="true"] { background: var(--qc-accent); color: var(--qc-on-accent); border-color: var(--qc-accent); }
}
@media (max-width: 380px) {
  .qc-nav-item { padding-inline: 2px; }
  .qc-nav-item .qc-en, html[data-lead="en"] .qc-nav-item .qc-en { font-size: 11px; letter-spacing: 0; }
}
@media (max-width: 340px) { .qc-nav-item .qc-en { white-space: normal; line-height: 1.15; } }
@media (max-width: 1599px) and (pointer: coarse) { .qc-header .qc-lang { height: var(--qc-tap); } }
/* Under 380 px (1.8.0): the three tools as one column of 36 px buttons, also on touch screens (the 44 px targets would
   cost the nav a third row): the header stays about 120 px tall at 320-379 px */
@media (max-width: 379px) {
  .qc-header .qc-tools { grid-template-columns: auto; }
  .qc-header .qc-scheme-toggle, .qc-header .qc-ts-open { width: 36px; min-width: 36px; height: 36px; }
  /* 1.8.1: the full-word capsule as narrow as it reads well, so the nav keeps its rows */
  .qc-header .qc-lang { height: 36px; }
  .qc-header .qc-lang-btn { padding: 0 3px; }
  .qc-header .qc-lang-btn[lang="en"] { font-size: 11px; letter-spacing: -0.01em; }
}
@media (max-width: 339px) {  /* 1.8.1: with the capsule, labels that would wrap make the rows taller: shrink, never wrap */
  .qc-nav-item .qc-en, html[data-lead="en"] .qc-nav-item .qc-en { white-space: nowrap; font-size: 10px; }
  .qc-nav-item { padding-inline: 1px; }
}
}
@media (pointer: coarse) {
  /* 1.4.3: touch targets */
  .qc-nav-item { min-height: var(--qc-tap); align-items: center; }
  .qc-scheme-toggle, .qc-ts-open, .qc-ts-btn { min-width: var(--qc-tap); height: var(--qc-tap); }
  .qc-ts-btn { width: var(--qc-tap); }
  .qc-ts-steps { gap: var(--qc-s1); }
  .qc-lang { height: var(--qc-tap); }
  .qc-lang-btn { min-width: 40px; }
  .qc-footer-links a { display: inline-flex; align-items: center; min-height: var(--qc-tap); padding-inline: var(--qc-s1); }
}

/* ─── Footer (1.7.0: compact, identical on both sites): one Urdu + one English line (provenance + feedback address),
   then Home · Reference library · ChatGPT / Claude · Privacy, then the site's optional footer_extra (.site-updated) ─── */
.qc-footer {
  margin-top: auto;
  color: var(--qc-fg-2); background: var(--qc-bar);
  border-top: 1px solid var(--qc-border);
  padding: var(--qc-s4) 16px var(--qc-s3);
  font-family: var(--qc-font-en); font-size: var(--qc-fs-en); line-height: 1.5;
  text-align: center;
}
.qc-footer-notes { max-width: 820px; margin: 0 auto var(--qc-s2); }
.qc-footer-note { margin: 0; font-size: 13px; }
.qc-footer-note[lang="ur"] { font-family: var(--qc-font-ur); font-size: 15px; line-height: 2; }
.qc-footer a { color: var(--qc-accent-2); }
.qc-mail { font-family: var(--qc-font-en); font-size: 13px; unicode-bidi: isolate; }
.qc-footer-links {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline;
  gap: 0 var(--qc-s3);
}
.qc-footer-links a { text-decoration: none; font-size: 13px; }
.qc-footer-links a [lang="ur"] { font-family: var(--qc-font-ur); font-size: var(--qc-fs-ur); }
.qc-footer-links a [lang="en"] { font-family: var(--qc-font-en); }
.qc-footer-links a:hover { text-decoration: underline; }
.qc-sep { opacity: 0.6; }
/* English lead (1.8.0): the English line first, and English first in each link; both stay */
html[data-lead="en"] .qc-footer-notes { display: flex; flex-direction: column; }
html[data-lead="en"] .qc-footer-note[lang="en"] { order: -1; }
html[data-lead="en"] .qc-footer-links { direction: ltr; }
html[data-lead="en"] .qc-footer-links a { display: inline-flex; align-items: baseline; gap: 0.3em; }
html[data-lead="en"] .qc-footer-links a [lang="en"] { order: -1; }
.qc-footer .site-updated { margin: var(--qc-s1) 0 0; font-size: 12px; color: var(--qc-fg-2); text-align: center; }

/* Slim footer (1.6.0, footer-slim.html): utility pages (about, privacy, search form): contact line + the same links. */
.qc-footer-slim .qc-footer-note { max-width: 820px; margin: 0 auto; }
.qc-footer-slim .qc-footer-links { margin-top: var(--qc-s2); }
html[data-lead="en"] .qc-footer-slim { display: flex; flex-direction: column; }  /* 1.8.0: the English line first */
html[data-lead="en"] .qc-footer-slim > .qc-footer-note[lang="en"] { order: -1; }

/* Print (1.6.0): the header and the footer's screen parts are not printed; in their place one black citation line
   (site · page title — address), so a printed sheet says where it came from. A page with its own fuller citation (the
   library reader) hides the whole footer in its print CSS. */
.qc-print-cite { display: none; }
@media print {
  .qc-header { display: none !important; }
  .qc-footer { display: block !important; margin: 12pt 0 0; padding: 4pt 0 0; background: none; border: 0;
    border-top: 1px solid #000; color: #000; }
  .qc-footer > :not(.qc-print-cite) { display: none !important; }
  .qc-print-cite { display: block; margin: 0; font: 10pt/1.9 var(--qc-font-en); color: #000; text-align: right; }
  .qc-print-cite [lang="ur"] { font-family: var(--qc-font-ur); }
  /* 1.6.1: the separators in Source Serif with a clear gap on both sides (a space after Nastaliq is narrow) */
  .qc-print-cite .qc-cite-sep { font-family: var(--qc-font-en); white-space: pre; padding-inline: 0.25em; }
  /* the page title's face follows its language (cite_lang): Nastaliq, Amiri (never bold), Source Serif; a title with
     no lang (an overridden runtime title) uses Source Serif for Latin and falls through to Nastaliq for Urdu */
  .qc-print-cite bdi:first-of-type { font-family: 'Source Serif 4', 'Noto Nastaliq Urdu', var(--qc-font-ur); }
  .qc-print-cite bdi[lang="ur"] { font-family: var(--qc-font-ur); }
  .qc-print-cite bdi[lang="ar"] { font-family: var(--font-ar, 'Amiri', serif); font-weight: 400; }
  .qc-print-cite bdi[lang="en"] { font-family: var(--qc-font-en); }
}
