/* ==========================================================================
   Qalam & Kitab design system: responsive layer (Bookstore Styling v1.3.2)
   Printed last in <head> (after qbs-fixes.css), so it wins over the theme's
   Additional CSS, the section CSS and every Qalam plugin stylesheet.
   Mobile first: base rules = phones, then tablet, then desktop.
   Covers: theme Additional CSS, Qalam Print Studio 1.2.7,
   Qalam Content Manager 3.9.2, Bookstore Styling section CSS.
   Off switch: add_filter( 'qbs_responsive', '__return_false' );
   ========================================================================== */

/* ---------- 0. Tokens used only by this block ---------- */
:root {
  --qkf-gold-text: #8f5f12;   /* gold for small text on white: 5.51:1 (was var(--qk2-acc,#B7791F), 2.76:1) */
  --qkf-wa:        #13803f;   /* WhatsApp green with white text: 5.02:1 (was #1f9e50 3.46, #1fa855 3.09) */
  --qkf-wa-hover:  #0f6a34;
  --qkf-nav-h:     60px;      /* height of the phone bottom nav (.qk-bottomnav a min-height) */
  --qkf-tap:       44px;      /* minimum comfortable touch target (Apple HIG / WCAG 2.5.5) */
  /* QCM muted grey: 5.32:1 on the cream cover colour (was var(--qk2-mute,#64748B), 4.46:1 = fails AA) */
  --qcm-muted:     #5f6964;
}

/* ---------- 1. No sideways scrolling at ANY width ----------
   The old rule only clipped at <=820px. clip (not hidden) keeps
   position:sticky working for the header and the print summary. */
html, body { overflow-x: clip; }

/* ---------- 2. Colour contrast (all widths) ---------- */

/* Gold CTA ("Browse Free Reads"): white on var(--qk2-acc,#B7791F) is 2.76:1.
   Keep the brand gold, switch the label to ink: 6.17:1. */
.qk-btn--primary,
.qk-btn--gold { color: var(--qk2-ink,#1E293B) !important; }
.qk-btn--primary:hover,
.qk-btn--gold:hover { background: #d6a03e; color: var(--qk2-ink,#1E293B) !important; }

/* Small gold labels on white (11.5px tags, menu headings, logo strap) */
.qk-pg-card__tag,
.qk-mega__col h4,
.qk-logo__en { color: var(--qkf-gold-text); }

/* Hero: the gradient ends on #2d9e5f, where 82% white body text is
   only 2.80:1. Darker end stops + 90% white = 5.02:1 at the worst point. */
.qk-hero:not(.qk-hero--print):not(.qk-hero--shop):not(.qk-hero--faq):not(.qk-hero--kids) {
  background: linear-gradient(135deg, var(--qk2-pri-d,#3B6648) 0%, var(--qk2-pri,#4A7C59) 60%, #1d7442 100%);
}
.qk-hero__sub { color: rgba(255, 255, 255, 0.92); }
.qk-btn--outline { border-color: rgba(255, 255, 255, 0.85); } /* 3:1 outline for the button edge */

/* WhatsApp buttons (home, Print Studio, floating button, old bookstore) */
.entry-content a.qk-pg-btn--wa,
.qps-btn-wa,
.qps-sticky-wa,
.bookstore-whatsapp-btn {
  background: var(--qkf-wa) !important;
  border-color: var(--qkf-wa) !important;
}
.entry-content a.qk-pg-btn--wa:hover,
.qps-btn-wa:hover,
.qps-sticky-wa:hover,
.bookstore-whatsapp-btn:hover {
  background: var(--qkf-wa-hover) !important;
  border-color: var(--qkf-wa-hover) !important;
}

/* ---------- 3. Visible keyboard focus where it was missing ---------- */
.qk-btn:focus-visible,
.qk-cat-card:focus-visible,
.qk-section__link:focus-visible,
.qk-bottomnav a:focus-visible,
.qcm-btn:focus-visible,
.qcm-card-cover:focus-visible,
.qcm-reader-toolbar button:focus-visible,
.qcm-reader-nav button:focus-visible,
.qps-btn:focus-visible,
.qps-sticky-wa:focus-visible {
  outline: 3px solid var(--qk2-pri-d,#3B6648);
  outline-offset: 3px;
}
.qk-hero .qk-btn:focus-visible { outline-color: #fff; } /* green outline vanishes on the green hero */

/* ---------- 4. Touch targets: 44px minimum (phones first) ---------- */

/* "See all ... ->" section links: were ~20px-tall inline text */
.qk-section__link {
  min-height: var(--qkf-tap);
  align-items: center;
}
/* Print card "Order this ->" links: 40px -> 44px */
.entry-content a.qk-pg-card__link { min-height: var(--qkf-tap); }
/* What's New filter chips: 36px -> 44px */
.qk-reel__chip { min-height: var(--qkf-tap); }
/* QCM archive filter chips: ~30px -> 44px */
.qcm-grid-filters .qcm-chip {
  min-height: var(--qkf-tap);
  display: inline-flex !important;
  align-items: center;
}
/* Print Studio: option pills 40px, quick chips 38px, copy buttons 36px -> 44px */
.qps-seg span { min-height: var(--qkf-tap); line-height: 26px; }
.qps-chip,
.qps-copy,
.qps-attach,
.qps-btn-small { min-height: var(--qkf-tap); }
/* Reader toolbar (TOC, A-/A+, themes, bookmark, fullscreen): ~28px -> 44px */
.qcm-reader-toolbar .qcm-toc-toggle,
.qcm-reader-toolbar .qcm-font-decrease,
.qcm-reader-toolbar .qcm-font-increase,
.qcm-reader-toolbar .qcm-theme-btn,
.qcm-reader-toolbar .qcm-bookmark-toggle,
.qcm-reader-toolbar .qcm-fullscreen-toggle {
  min-width: var(--qkf-tap);
  min-height: var(--qkf-tap);
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}
/* Reader Prev / Next: ~37px -> 48px (the most-tapped control on the site) */
.qcm-reader-nav .qcm-prev-page,
.qcm-reader-nav .qcm-next-page {
  min-height: 48px;
  min-width: 96px;
  font-size: 1rem;
}
/* Footer link lists: give each link a real tap row instead of a text line */
.site-footer li > a,
footer li > a:not([class*="button"]) {
  display: inline-block;
  padding-top: 10px;
  padding-bottom: 10px;
}

/* ---------- 5. Phone-only fixes (<=820px, where the bottom nav shows) ---------- */
@media (max-width: 820px) {

  /* Bottom nav labels: 10.5px -> 12px (below 11px is hard to read on a phone) */
  .qk-bottomnav a { font-size: 12px; }

  /* Print Studio total bar: it sticks to bottom:0, which is UNDER the
     60px bottom nav (z-index 9999 vs 50), so "Place order" was hidden.
     Only applied while the calculator is in its narrow layout. */
  @container (max-width: 759px) {
    .qps-summary { bottom: calc(var(--qkf-nav-h) + var(--qk-safe-bottom, 0px)); }
  }

  /* Floating WhatsApp button sat on top of the bottom nav icons */
  .qps-sticky-wa { bottom: calc(var(--qkf-nav-h) + var(--qk-safe-bottom, 0px) + 12px); }

  /* Tiny labels -> readable */
  .qk-pg-card__tag,
  .qk-pg-card__soon { font-size: 12.5px; }
  .qk-cat-card__count { font-size: 13px; line-height: 1.4; }
}

/* Reader on phones: the box was a fixed 640px tall (inline style), so on a
   667px phone it was taller than the space left under the header and
   above the bottom nav: two scrollbars fighting each other. */
@media (max-width: 640px) {
  .qcm-reader { --qcm-reader-height: max(420px, calc(100vh - 230px)) !important; }
  @supports (height: 100svh) {
    .qcm-reader { --qcm-reader-height: max(420px, calc(100svh - 230px)) !important; }
  }
  /* Kids reader headings at line-height 1.1 clipped descenders when they wrapped */
  .qcm-reader-kids .qcm-page-inner h2 { line-height: 1.25; }
}

/* ---------- 6. Comfortable reading width (all widths, matters on desktop) ----------
   45-75 characters per line is the readable range. */

/* Book reader text: ~96 chars/line at 16px, ~88 at 1400px+ -> about 68 */
.qcm-page-content {
  max-width: 68ch;
  margin-left: auto;
  margin-right: auto;
}
/* Action Plan / Quick Notes pages: 820px ~ 95 chars/line -> 70ch */
.qk-note { max-width: 70ch; }
/* Home "Online learning for kids in Pakistan" paragraph: ~135 chars/line */
.qk-section > p,
#about-learning p { max-width: 72ch; }
.qk-section > p { line-height: 1.7; }

/* ---------- 7. Tablet (768-1024px) ---------- */
@media (min-width: 821px) and (max-width: 1024px) {
  /* Hero: the 3D shelf kept a fixed 380px, squeezing the headline into a
     ~360px column at 821px (3-line H1). Share the row 58/42 instead. */
  .qk-home-hero-text { flex: 1 1 0; min-width: 0; }
  .qk-home-hero-art  { flex: 0 0 42%; }
  .qk-home-h1 { font-size: clamp(30px, 4.2vw, 40px); }
  #qk-hero-canvas-wrap { height: 300px !important; }
}

/* ---------- 8. Desktop (1025px+) ---------- */
@media (min-width: 1025px) {
  /* Explore grid: auto-fill made 6 tracks for 5 cards, leaving an empty
     slot on the right. Five equal columns fill the row. */
  .qk-cat-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* ---------- 9. Respect "reduce motion" ---------- */
@media (prefers-reduced-motion: reduce) {
  .qk-cat-card, .qk-print-card, .qk-pg-card, .qcm-card, .qk-btn, .stat-card {
    transition: none !important;
  }
  .qk-cat-card:hover, .qk-print-card:hover, .qk-pg-card:hover,
  .qcm-card:hover, .qk-btn:hover, .stat-card:hover { transform: none !important; }
}

/* ---------- 10. Added in Bookstore Styling 1.3.1 ---------- */

/* Exam Resource Hub roadmap / Action Plan pills (section CSS): 34px -> 44px */
.qk-section li > a[href*="/challenges/"]:not([class]),
.qk-section li > a[href*="/solutions/"]:not([class]) { min-height: var(--qkf-tap); padding: 0 16px; }

/* Jump links (#print-copy, #books, #stories ...) land below the sticky header, not under it */
.qk-section[id], .qk-pg-group, .pg-sec, [id].qk-shelf { scroll-margin-top: 110px; }

/* Phones: the 72px logo plus the 60px bottom nav took ~150px of a 667px screen.
   A 56px logo gives that space back to the content. */
@media (max-width: 768px) {
  .ast-site-identity .custom-logo,
  .site-logo-img img,
  .ast-logo-title-inline img,
  .custom-logo-link img { max-height: 56px !important; }
}
/* ---------- 11. Added in Bookstore Styling 1.3.2: bullets and numbers on Exam Resource Hub pages ----------
   The 18 Nov Additional CSS fix ("double list markers on Challenge + Action Plan pages") switched the
   marker off for EVERY plain list in #content, assuming the page draws its own dot or number circle.
   Only lists that Bookstore Styling restyles (they get a qbs-* class) draw their own marker. Plain lists
   it does not restyle (nested lists, lists in the Qalam intro panel, callouts, "Remember / Avoid this"
   boxes, lists in designed sections) were left with no bullet or number at all.
   Classed lists are excluded by :not([class]), so no marker is doubled. This block has higher
   specificity than that Additional CSS rule and prints after it, so it works even while the old rule
   is still in Additional CSS. */
html body:is(.single-qcm_challenge, .single-qcm_solution) #content ul:not([class]) {
  list-style: disc outside !important;
  list-style-type: disc !important;
  margin-inline-start: 0 !important;
  padding-inline-start: 1.4em !important;
}
html body:is(.single-qcm_challenge, .single-qcm_solution) #content ol:not([class]) {
  list-style: decimal outside !important;
  list-style-type: decimal !important;
  margin-inline-start: 0 !important;
  padding-inline-start: 1.7em !important;
}
html body:is(.single-qcm_challenge, .single-qcm_solution) #content ul:not([class]) ul:not([class]) {
  list-style-type: circle !important;
}
html body:is(.single-qcm_challenge, .single-qcm_solution) #content :is(ul, ol):not([class]) > li {
  list-style-type: inherit !important;
  display: list-item;
}
html body:is(.single-qcm_challenge, .single-qcm_solution) #content :is(ul, ol):not([class]) > li::marker {
  content: normal !important;
  font-size: inherit !important;
  color: var(--qbs-green, var(--qk2-pri,#4A7C59));
  font-weight: 700;
}
/* Phones: keep the marker inside the screen and give the text the full line width. */
@media (max-width: 600px) {
  html body:is(.single-qcm_challenge, .single-qcm_solution) #content ul:not([class]) { padding-inline-start: 1.25em !important; }
  html body:is(.single-qcm_challenge, .single-qcm_solution) #content ol:not([class]) { padding-inline-start: 1.5em !important; }
}
/* ===== end responsive layer ===== */
