/*
Theme Name: ArabicLab
Author: 79Mplus
Author URI: https://siananda.me/
Description: .
Version: 1.0.0
License: GNU General Public License v2 or later
License URI:
Tags: right-sidebar, custom-header, custom-menu, editor-style, featured-images, post-formats, sticky-post
Text Domain: arabiclab
*/

/** override bootstrap **/
:root {
  --bs-primary: #ff5733;
  --bs-secondary: #2a2a2a;
  --bs-btn-bg: #f8f9fa;
  --bs-border-radius: 4px; /* Change component shapes */
}

/* Story-lesson subtitles: streaming-style cue — soft gradient band per line, airy line gap. */
video::cue {
  font-size: max(14px, 2.6vmin);
  line-height: 2;
  color: #fff;
  background-color: transparent;
  background-image:
    linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.88) 32%, rgba(0, 0, 0, 0.88) 68%, transparent),
    linear-gradient(to right, transparent, rgba(0, 0, 0, 0.65) 6%, rgba(0, 0, 0, 0.65) 94%, transparent);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
}

/* Story-lesson transcript below the player: one row per cue, click to seek,
   .is-active follows the track's cuechange events. */
.al-transcript {
  margin: 10px 0 18px;
}
.al-transcript-list {
  margin: 0;
}
/* Platform markers are replaced by a real number span inside each button
** (PHP emits .al-transcript-num, aria-hidden: the list semantics carry the
** order for AT, the digit is a sighted-scanning aid). The compound selector
** out-specifies tutor-learning-area's (0,3,0) `list-style: revert` /
** `padding-inline-start: 16px` pair: an outside marker hangs left of the
** list box and tutor-lesson-wrapper (overflow-x: scroll) clips it — the
** "cut-off numbers" bug. Inside the button, the number cannot clip and
** belongs to the row's hit target, hover/active tint, and focus ring. */
.tutor-lesson-content .tutor-lesson-wrapper ol.al-transcript-list {
  list-style: none;
  padding-inline-start: 0;
}
.al-transcript-line {
  position: relative;
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 0 0 4px;
  /* Left gutter fits the widest cue number ("100.", measured 35px
  ** at 16px tabular-nums) starting at left:10 with room to spare:
  ** 10 + 35 + 7 gap. Single-digit rows share the same gutter. */
  padding: 8px 10px 8px 52px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 4px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
}
/* Cue number in its own gutter; line-height 1.6 matches the first text
** line so the digits sit on the Arabic line's baseline grid. */
.al-transcript-num {
  position: absolute;
  left: 10px;
  top: 8px;
  color: #6f7680; /* 4.6:1 on white (WCAG AA) for the sighted number gutter */
  font-variant-numeric: tabular-nums;
  line-height: 1.6;
}
.al-transcript-line:hover {
  background: #f2f4f7;
}
.al-transcript-line.is-active {
  background: #fff0eb;
  border-left-color: #ff5733;
}
.al-transcript-line:focus-visible {
  outline: 3px solid #ff8c00;
  outline-offset: 2px;
}
.al-transcript-text {
  display: block;
  line-height: 1.6;
}

/* Out-specifies tutor-learning-area's (0,2,1) h1 2.5rem rule the
** same way the transcript list rule does: bare .al-lesson-title
** loses the cascade and renders at 40px. */
.tutor-lesson-content .tutor-lesson-wrapper h1.al-lesson-title {
  font-size: clamp(1.15rem, 1rem + 1.5vw, 1.6rem);
  line-height: 1.5;
  font-weight: 700;
  text-align: center;
  text-wrap: balance;
  margin: 0 0 12px;
  overflow-wrap: anywhere;
}
/* Pinned player state, toggled by the transcript script once the host
** top slides under Tutor's fixed 64px header (72px = header + gap).
** Width/left are set inline at pin time; a spacer holds the layout.
**
** z-index 5 keeps it above the page's own content, transcript rows included,
** and below every piece of Tutor's chrome. Tutor's ladder, read off
** plugins/tutor/assets/css/tutor-learning-area.min.css: `.tutor-learning-header`
** and `.tutor-learning-area-footer` are fixed at 10, and
** `.tutor-learning-sidebar` is fixed at 20 below 992px, which is the off-canvas
** curriculum. At 50 this player painted over that open sidebar on every width
** below 992, a fixed element beating the sidebar however the DOM is ordered.
** Below 10 rather than between the two, so Tutor's header and the Mark as
** Complete bar always win an overlap. The theme's own floating transcript nav
** (60) below stays the topmost thing on the page. */
.al-lesson-host.al-pinned {
  position: fixed;
  top: 72px;
  z-index: 5;
  margin: 0;
  background: #000;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}
/* The viewer pads the inner player 24px on all sides; while pinned
** that padding shows as black bars around the frame, so drop it —
** the box then hugs the video plus its control strip exactly. */
.al-lesson-host.al-pinned .al-lesson {
  padding: 0;
}
/* The viewer's active page carries a 24px bottom margin (unpinned
** breathing room); while pinned it becomes a black strip under the
** frame, so drop it too. */
.al-lesson-host.al-pinned .al-page {
  margin-bottom: 0;
}
/* Pinned on desktop, the player is a 480-capped mini while the
** viewport-relative cue size (2.6vmin) stays full-size — shrink the
** cues to the 14px mobile floor so three bands fit the small frame.
** Mobile viewports keep the base rule (their vmin already floors). */
@media (min-width: 768px) {
  .al-lesson-host.al-pinned video::cue {
    font-size: 14px;
    line-height: 1.7;
  }
}
/* The book page's fixed bar carries the lesson's own Complete control, and the
** vendored viewer files it at z-index 20 — the rung Tutor's off-canvas
** curriculum occupies (`.tutor-learning-sidebar`, fixed at 20 below 992px).
** Same rung and later in the DOM, the bar painted over the open drawer: on a
** phone the Complete/Next button lay across the lesson list and the drawer's
** own More control, and took their taps. One rung below Tutor's fixed chrome
** and above the page's static content — the choice `.al-lesson-host.al-pinned`
** already records — the drawer closes over the bar instead.
** The theme loads after the bundle, and two classes out-rank its single
** `.al-book-bar`, so the viewer's own stylesheet stays untouched. */
.al-book .al-book-bar {
  z-index: 5;
}
/* The Quran lesson's Hifz dock carries the lesson's own Complete control and
** files itself at z-index 40, or 20 from 960px up (frontend/build/
** HifzWizard.css, `.hifz-page__dock`). Tutor's off-canvas curriculum
** (`.tutor-learning-sidebar`) is fixed at 22 below 992px, so on a phone the
** Complete button lay across the open drawer's lesson list and its More
** control, and took their taps; at 1280 the dock's 20 tied the sidebar's and
** went to whichever came later in the DOM. One rung below the sidebar and
** above the footer that shares the bottom edge (`.tutor-learning-area-footer`,
** fixed at 10), the drawer closes over the bar while the bar still owns the
** bottom against Tutor's course-complete bar. The theme loads after the
** bundle and two classes out-rank its single `.hifz-page__dock`, so the
** plugin's source and its build stay untouched. */
.hifz-page .hifz-page__dock {
  z-index: 15;
}
.al-transcript-nav {
  display: flex;
  gap: 8px;
  margin: 0 0 8px;
}
.al-transcript-navbtn {
  padding: 6px 12px;
  border: 1px solid #d4d8dd;
  border-radius: 4px;
  background: #fff;
  color: inherit;
  font: inherit;
  font-size: 0.9em;
  cursor: pointer;
}
.al-transcript-navbtn:hover {
  background: #f2f4f7;
}
.al-transcript-navbtn:focus-visible {
  outline: 3px solid #ff8c00;
  outline-offset: 2px;
}
.al-transcript-float {
  position: fixed;
  right: 16px;
  bottom: 96px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}
.al-transcript-floatbtn {
  width: 44px;
  height: 44px;
  border: 1px solid #d4d8dd;
  border-radius: 50%;
  background: #fff;
  color: #2a2a2a;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
.al-transcript-floatbtn:hover {
  background: #f2f4f7;
}
.al-transcript-floatbtn:focus-visible {
  outline: 3px solid #ff8c00;
  outline-offset: 2px;
}

/* Quiz question title (AGENT-9 / FB-00112). The viewer offsets the question
** <legend> clear of the number badge with
** `margin-inline-start: calc(var(--al-quiz-badge-size) + 12px)` (the vendored
** bundle's `.al-quiz__question > legend`). A legend is laid out at its
** fieldset's content width and Chrome does not subtract that margin from it,
** so the 44px offset is spent on the card's inline-end edge instead: the title
** box ran 19px past the card border (43px past its content edge) at every
** width from 320 to 1280, and long Arabic titles painted outside the card on
** a phone. Padding spends the same 44px inside the box, so the title keeps its
** 12px gap after the badge and stays inside the card. Two classes
** out-specify the vendor's single-class rule, so this does not depend on
** stylesheet order after a viewer rebuild. */
.al-quiz .al-quiz__question > legend {
  margin-inline-start: 0;
  padding-inline-start: calc(var(--al-quiz-badge-size, 32px) + 12px);
}

/* Tutor dashboard bottom bar, "More" popover (AGENT-18 / FB-00111). The bar
** keeps the first two dashboard tabs and puts the rest — Wordbank is one —
** behind "More". Tutor's popover component (tutor-core.js) decides RTL from
** `document.dir` when the bundle is evaluated, and this platform switches
** direction after load (arabiclab-core sets `html[dir]` once the page is
** parsed), so the component always reads LTR. Its `top-end` placement then
** lines the panel's right edge up with the trigger's right edge; in RTL that
** trigger sits on the physical left of the bar, so the panel opened at
** left: -117px with only its last 52px on screen and the Wordbank entry was
** off-screen and unclickable at 320 and 390. The panel is positioned with an
** inline `left` from the script, so the correction has to win with
** !important; 16px is the bar's own inline inset, which puts the panel over
** the trigger. Scoped to RTL and to this one popover: LTR keeps Tutor's own
** maths, and every other Tutor popover is untouched. */
html[dir='rtl'] .tutor-dashboard-nav-mobile-more-popover {
  left: 16px !important;
}

/* Wordbank search field on a phone (AGENT-18 / FB-00111). The family-
** registration wordbank stylesheet gives `.alfr-wordbank-search`
** `flex: 1 1 240px` and leaves `min-width` at its default `auto`, so the flex
** item's automatic minimum size is the search input's intrinsic width — the
** input sets `flex: 1 1 160px` but carries no `size`, so a 16px font resolves
** it to ~450px. Inside a 252px toolbar (the wordbank card is 286px wide at a
** 390px viewport) the field could not shrink: it laid out 510px wide with its
** right edge at 579px, and the whole page scrolled sideways by 189px. In RTL
** the same box is clipped instead of scrolled, which is why the field also
** looked cut off in Arabic. `min-inline-size: 0` lets the auto minimum give
** way and the field takes the toolbar width. Scoped to the plugin's own
** small-screen breakpoint so tablet and desktop keep the layout they ship
** today (measured identical at 768 and 1280). */
@media (max-width: 560px) {
  .alfr-wordbank .alfr-wordbank-search {
    min-inline-size: 0;
  }
}

/* Child logout on a phone (AGENT-22 / FB-00111). The dashboard header is
** `position: sticky; z-index: 10`, so it opens a stacking context and the
** account sheet inside it (`.tutor-dashboard-header-user-popover`,
** `position: fixed; z-index: 100000`) is capped at the header's level. The
** Tutor bottom bar (`.tutor-dashboard-nav-mobile`, `position: fixed;
** z-index: 10`) is a sibling context and comes later in the DOM, so it wins
** the tie and paints its 73px over the bottom of the sheet — exactly where
** Tutor puts the child's only logout entry point
** (`.tutor-mobile-logout-wrapper`, measured at y 775..823 in a 390x844
** viewport with the bar covering 771..844). `document.elementFromPoint()` at
** the button's centre returned the bar's icon, not the link, at 320, 375, 390
** and 430; the sheet could not be scrolled (scrollHeight == clientHeight), so
** a child had no way to log out on a phone. One step above the bar restores
** the sheet's own intent (it was given z-index 100000 to sit over everything)
** while the sheet is open, which is what a full-screen account panel should
** do. Scoped to the phone widths where the bar exists: from 768px up the bar
** is `display: none` and the sheet keeps the layout it ships today. */
@media (max-width: 767.98px) {
  .tutor-dashboard-header {
    z-index: 11;
  }
}
