/* ============================================
   Illuminated Page v2: the app layer
   Spec: UI/DESIGN.md. Tokens live in styles.css :root; load this sheet
   after styles.css and before the page-type sheet.

   Pages opt in with <body class="app">. Everything here is either a new
   class (app-bar, tab-bar, tile, sheet...) or scoped under body.app, so a
   page that has not moved to the shell yet is untouched.
   ============================================ */

/* ---------- Base for app screens ---------- */
body.app {
    font-family: var(--font-read);
    background: var(--surface-0);
    color: var(--text-1);
    line-height: 1.6;
    /* room for the bottom tab bar on phones and tablets */
    padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
}

html[lang="ar"] body.app {
    font-family: var(--font-ar);
}

body.app .floating-decorations {
    display: none;   /* motion policy: no ambient loops on app screens */
}

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Icons (vendor/icons/sprite.svg, Lucide, ISC) ---------- */
.icon {
    width: 24px;
    height: 24px;
    flex: none;
    stroke-width: 2;
    vertical-align: middle;
}

.icon-sm { width: 20px; height: 20px; }

/* Direction-bearing glyphs follow the reading direction */
[dir="rtl"] .flip-rtl {
    transform: scaleX(-1);
}

/* ---------- Top app bar ---------- */
.app-bar {
    position: sticky;
    top: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: var(--s-2);
    min-height: calc(var(--appbar-h) + var(--safe-top));
    padding: var(--safe-top) calc(var(--gutter) + var(--safe-end)) 0 calc(var(--gutter) + var(--safe-start));
    background: var(--surface-glass);
    -webkit-backdrop-filter: saturate(1.4) blur(16px);
            backdrop-filter: saturate(1.4) blur(16px);
    border-bottom: var(--hairline);
}

.app-bar__brand {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    min-height: var(--tap);
    color: var(--text-1);
    text-decoration: none;
    font-family: var(--font-title);
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.01em;
    line-height: 1;
}

.app-bar__brand .brand-mark {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: var(--action);
    color: var(--text-on-action);
    font-size: 1.05rem;
}

.app-bar__title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-family: var(--font-ui);
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

html[lang="ar"] .app-bar__title {
    font-family: var(--font-ui-ar);
}

.app-bar__spacer { flex: 1; }

.app-bar__actions {
    display: flex;
    align-items: center;
    gap: var(--s-1);
}

/* the language toggle inside the app bar keeps its 44px pill */
.app-bar .lang-toggle-btn {
    font-family: var(--font-ui-ar);
    font-size: 0.9375rem;
    font-weight: 700;
    padding: 0 var(--s-4);
}

/* ---------- Icon button (44px hit area, tactile press) ---------- */
.icon-btn {
    display: inline-grid;
    place-items: center;
    min-width: var(--tap);
    min-height: var(--tap);
    padding: 0;
    border: 0;
    border-radius: var(--r-pill);
    background: transparent;
    color: var(--text-1);
    cursor: pointer;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: var(--t-press);
}

.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(0.94); background: var(--action-wash); }
.icon-btn[aria-pressed="true"] { color: var(--action-text); background: var(--action-wash); }
.icon-btn:disabled,
.icon-btn[aria-disabled="true"] { opacity: 0.4; cursor: default; }
.icon-btn:disabled:active,
.icon-btn[aria-disabled="true"]:active { transform: none; background: transparent; }
.icon-btn[aria-disabled="true"]:hover { background: transparent; }

/* an answered quiz option stays focusable (aria-disabled) but inert to clicks */
.quiz-option[aria-disabled="true"] { cursor: default; }

/* v1's bedtime button is restyled as an icon button inside the app bar */
.app-bar .bedtime-btn {
    border: 0;
    color: var(--text-1);
    font-size: inherit;
}

.app-bar .bedtime-btn[aria-pressed="true"] {
    background: var(--reward-wash);
    color: var(--reward-text);
    border: 0;
}

.bedtime-btn .icon-sun { display: none; }
.bedtime-btn[aria-pressed="true"] .icon-moon { display: none; }
.bedtime-btn[aria-pressed="true"] .icon-sun { display: inline; }

/* ---------- Bottom tab bar (phone, tablet) / side rail (desktop) ---------- */
.tab-bar {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 900;
    padding: 0 var(--safe-end) var(--safe-bottom) var(--safe-start);
    background: var(--surface-glass);
    -webkit-backdrop-filter: saturate(1.4) blur(16px);
            backdrop-filter: saturate(1.4) blur(16px);
    border-top: var(--hairline);
}

.tab-bar ul {
    display: flex;
    justify-content: center;
    max-width: 560px;
    margin: 0 auto;
    padding: 0;
    list-style: none;
}

.tab-bar li { flex: 1; }

.tab-bar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: var(--tabbar-h);
    padding: var(--s-1) var(--s-2);
    color: var(--text-2);
    text-decoration: none;
    font-family: var(--font-ui);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    -webkit-tap-highlight-color: transparent;
    transition: var(--t-press);
}

html[lang="ar"] .tab-bar a {
    font-family: var(--font-ui-ar);
    font-size: 0.8125rem;
}

.tab-bar .tab-icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 30px;
    border-radius: var(--r-pill);
    transition: background-color var(--dur-2) var(--ease-out);
}

.tab-bar a[aria-current="page"] {
    color: var(--action-text);
}

.tab-bar a[aria-current="page"] .tab-icon {
    background: var(--action-wash);
}

.tab-bar a:active { transform: scale(0.95); }

.tab-bar a:focus-visible {
    outline-offset: -4px;
}

@media (min-width: 1024px) {
    body.app {
        padding-bottom: 0;
        padding-inline-start: calc(var(--rail-w) + var(--safe-start));
    }

    .tab-bar {
        top: calc(var(--appbar-h) + var(--safe-top));
        bottom: 0;
        inset-inline-start: 0;
        inset-inline-end: auto;
        width: calc(var(--rail-w) + var(--safe-start));
        padding: var(--s-5) 0;
        border-top: 0;
        border-inline-end: var(--hairline);
        background: var(--surface-0);
        -webkit-backdrop-filter: none;
                backdrop-filter: none;
    }

    .tab-bar ul {
        flex-direction: column;
        gap: var(--s-3);
    }

    .tab-bar li { flex: none; }

    .tab-bar a { min-height: 64px; font-size: 0.8125rem; }

    /* the rail starts under the app bar, so the app bar spans the full width */
    body.app .app-bar {
        margin-inline-start: calc(-1 * (var(--rail-w) + var(--safe-start)));
        padding-inline-start: calc(var(--gutter) + var(--safe-start));
    }
}

/* ---------- Screen and sections ---------- */
.screen {
    max-width: 1120px;
    margin: 0 auto;
    padding: var(--s-5) var(--gutter) var(--s-7);
}

.screen-head {
    margin-bottom: var(--s-5);
}

.eyebrow {
    display: block;
    margin-bottom: var(--s-1);
    color: var(--reward-text);
    font-family: var(--font-ui);
    font-size: var(--step--1);
    font-weight: 600;
    letter-spacing: 0.02em;
}

html[lang="ar"] .eyebrow { font-family: var(--font-ui-ar); letter-spacing: 0; }

.large-title {
    margin: 0;
    font-family: var(--font-title);
    font-size: var(--step-3);
    font-weight: 800;
    line-height: 1.12;
    letter-spacing: -0.02em;
    color: var(--text-1);
}

html[lang="ar"] .large-title {
    font-family: var(--font-ar);
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.4;
}

.screen-sub {
    margin: var(--s-2) 0 0;
    color: var(--text-2);
    font-size: var(--step-0);
    max-width: 52ch;
}

.section {
    margin-top: var(--s-6);
}

@media (min-width: 720px) {
    .section { margin-top: var(--s-7); }
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
    margin-bottom: var(--s-3);
}

.section-header h2 {
    margin: 0;
    font-family: var(--font-ui);
    font-size: var(--step-1);
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.25;
    color: var(--text-1);
}

html[lang="ar"] .section-header h2 { font-family: var(--font-ui-ar); letter-spacing: 0; }

.section-header .see-all {
    display: inline-flex;
    align-items: center;
    gap: var(--s-1);
    min-height: var(--tap);
    padding: 0 var(--s-2);
    margin-inline-end: calc(-1 * var(--s-2));
    border-radius: var(--r-sm);
    color: var(--action-text);
    font-family: var(--font-ui);
    font-size: var(--step-0);
    font-weight: 600;
    text-decoration: none;
}

.section-header .see-all:hover { background: var(--action-wash); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    min-height: var(--tap);
    padding: 0 var(--s-5);
    border: 1px solid transparent;
    border-radius: var(--r-pill);
    font-family: var(--font-ui);
    font-size: var(--step-0);
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: var(--t-press);
}

html[lang="ar"] .btn { font-family: var(--font-ui-ar); }

.btn:active { transform: scale(0.97); }

.btn--primary {
    background: var(--action);
    color: var(--text-on-action);
}

.btn--primary:hover { background: #0B5A55; }

.btn--secondary {
    background: var(--surface-1);
    color: var(--text-1);
    border-color: var(--line);
}

.btn--secondary:hover { background: var(--surface-2); }

.btn--lg { min-height: var(--tap-lg); padding: 0 var(--s-6); font-size: 1.0625rem; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface-1);
    border: var(--hairline);
    border-radius: var(--r-md);
    padding: var(--s-5);
}

/* Lift on hover AND keyboard focus, never hover-only */
.lift {
    transition: var(--t-press);
}

@media (hover: hover) {
    .lift:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow);
    }
}

.lift:focus-visible {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.lift:active { transform: scale(0.98); }

/* ---------- "Tonight's story / Continue" card: the one gold card per screen ---------- */
.feature-card {
    display: grid;
    grid-template-columns: 1fr;
    overflow: hidden;
    background: var(--reward-wash);
    border: var(--hairline-gold);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
    color: var(--text-1);
    text-decoration: none;
}

.feature-card__cover {
    position: relative;
    aspect-ratio: 16 / 9;
    background: var(--surface-2);
}

.feature-card__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.feature-card__body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s-2);
    padding: var(--s-5);
}

.feature-card__kicker {
    display: inline-flex;
    align-items: center;
    gap: var(--s-1);
    color: var(--reward-text);
    font-family: var(--font-ui);
    font-size: var(--step--1);
    font-weight: 700;
    letter-spacing: 0.02em;
}

html[lang="ar"] .feature-card__kicker { font-family: var(--font-ui-ar); letter-spacing: 0; }

.feature-card__title {
    margin: 0;
    font-family: var(--font-title);
    font-size: var(--step-2);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.015em;
}

html[lang="ar"] .feature-card__title { font-family: var(--font-ar); font-weight: 700; letter-spacing: 0; line-height: 1.5; }

.feature-card__text {
    margin: 0;
    color: var(--text-2);
    font-size: var(--step-0);
    max-width: 46ch;
}

.feature-card__meta {
    color: var(--text-2);
    font-family: var(--font-ui);
    font-size: var(--step--1);
}

.feature-card .btn { margin-top: var(--s-2); }

@media (min-width: 720px) {
    .feature-card { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
    .feature-card__cover { aspect-ratio: auto; min-height: 260px; }
    .feature-card__body { justify-content: center; padding: var(--s-6); }
}

/* ---------- Shelves: horizontally scrollable rows of tiles ---------- */
.shelf {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(160px, 44%);
    gap: var(--s-4);
    margin: 0 calc(-1 * var(--gutter));
    padding: var(--s-1) var(--gutter) var(--s-4);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--gutter);
    scrollbar-width: thin;
    list-style: none;
}

.shelf > li { scroll-snap-align: start; min-width: 0; }

@media (min-width: 720px) {
    .shelf { grid-auto-columns: 220px; }
}

/* ---------- Tiles ---------- */
.tile {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    height: 100%;
    padding: 0 0 var(--s-1);
    border-radius: var(--r-md);
    color: var(--text-1);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.tile__cover {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: var(--r-md);
    border: var(--hairline);
    background: var(--surface-2);
}

.tile__cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tile__title {
    margin: 0;
    padding: 0 var(--s-1);
    font-family: var(--font-read);
    font-size: 1.0625rem;
    font-weight: 700;
    line-height: 1.3;
}

html[lang="ar"] .tile__title { font-family: var(--font-ar); font-size: 1.125rem; line-height: 1.5; }

.tile__meta {
    padding: 0 var(--s-1);
    color: var(--text-2);
    font-family: var(--font-ui);
    font-size: var(--step--1);
    line-height: 1.35;
}

html[lang="ar"] .tile__meta { font-family: var(--font-ui-ar); }

/* surah tiles have no painting yet: a girih-ruled plate with the name in Amiri */
.tile__cover--surah {
    display: grid;
    place-items: center;
    background:
        linear-gradient(var(--quran-wash), var(--quran-wash)) padding-box;
    border-color: var(--line);
}

.tile__cover--surah::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: var(--girih);
    background-size: 56px 56px;
    opacity: 0.18;
}

.tile__cover--surah .surah-name {
    position: relative;
    font-family: var(--font-quran);
    font-size: 2rem;
    line-height: 1.4;
    color: var(--quran);
    direction: rtl;
}

.tile__cover .tile__badge {
    position: absolute;
    inset-block-start: var(--s-2);
    inset-inline-start: var(--s-2);
    padding: 2px var(--s-2);
    border-radius: var(--r-pill);
    background: var(--surface-1);
    color: var(--reward-text);
    font-family: var(--font-ui);
    font-size: 0.75rem;
    font-weight: 700;
}

/* ---------- Progress row ---------- */
.stat-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--s-3);
}

.stat {
    padding: var(--s-4);
    background: var(--surface-1);
    border: var(--hairline);
    border-radius: var(--r-md);
}

.stat__value {
    display: block;
    font-family: var(--font-title);
    font-size: var(--step-2);
    font-weight: 800;
    line-height: 1.1;
    color: var(--text-1);
}

.stat__label {
    display: block;
    margin-top: var(--s-1);
    color: var(--text-2);
    font-family: var(--font-ui);
    font-size: var(--step--1);
    line-height: 1.3;
}

html[lang="ar"] .stat__label { font-family: var(--font-ui-ar); }

.meter {
    display: block;
    height: 6px;
    margin-top: var(--s-3);
    border-radius: var(--r-pill);
    background: var(--surface-2);
    overflow: hidden;
}

.meter > span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: var(--ornament);   /* reward = gold */
}

@media (max-width: 480px) {
    .stat { padding: var(--s-3); }
}

/* ---------- Grouped list (app list rows) ---------- */
.list {
    margin: 0;
    padding: 0;
    list-style: none;
    background: var(--surface-1);
    border: var(--hairline);
    border-radius: var(--r-md);
    overflow: hidden;
}

.list > li + li { border-top: var(--hairline); }

.list-row {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    min-height: 60px;
    padding: var(--s-2) var(--s-4);
    color: var(--text-1);
    text-decoration: none;
    font-size: var(--step-0);
}

a.list-row { transition: background-color var(--dur-2) var(--ease-out); }
a.list-row:hover { background: var(--surface-0); }
a.list-row:active { background: var(--action-wash); }

.list-row__icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--action-wash);
    color: var(--action-text);
    flex: none;
}

.list-row__text { flex: 1; min-width: 0; }
.list-row__title { display: block; font-weight: 700; line-height: 1.3; }
.list-row__sub { display: block; color: var(--text-2); font-size: var(--step--1); line-height: 1.35; }
.list-row .chev { color: var(--text-2); }

.list-row[aria-disabled="true"] .list-row__icon { background: var(--surface-2); color: var(--text-2); }

.chip {
    display: inline-flex;
    align-items: center;
    padding: 2px var(--s-2);
    border-radius: var(--r-pill);
    background: var(--surface-2);
    color: var(--text-2);
    font-family: var(--font-ui);
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

html[lang="ar"] .chip { font-family: var(--font-ui-ar); }

/* ---------- Segmented control ---------- */
.segmented {
    display: inline-flex;
    gap: 2px;
    padding: 4px;
    border-radius: var(--r-pill);
    background: var(--surface-2);
    border: var(--hairline);
}

.segmented button {
    min-height: var(--tap);
    min-width: var(--tap);
    padding: 0 var(--s-4);
    border: 0;
    border-radius: var(--r-pill);
    background: transparent;
    color: var(--text-2);
    font-family: var(--font-ui);
    font-size: var(--step-0);
    font-weight: 600;
    cursor: pointer;
    transition: var(--t-press);
}

html[lang="ar"] .segmented button { font-family: var(--font-ui-ar); }

.segmented button:active { transform: scale(0.96); }

.segmented button[aria-pressed="true"],
.segmented button[aria-checked="true"] {
    background: var(--surface-1);
    color: var(--text-1);
    box-shadow: var(--shadow-sm), 0 0 0 1px var(--line);
}

/* ---------- Switch row (settings sheet) ---------- */
.switch {
    position: relative;
    flex: none;
    width: 52px;
    height: 32px;
    border-radius: var(--r-pill);
    background: var(--surface-2);
    border: 1px solid var(--line);
    transition: background-color var(--dur-2) var(--ease-out);
}

.switch::after {
    content: '';
    position: absolute;
    top: 3px;
    inset-inline-start: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--surface-1);
    box-shadow: var(--shadow-sm), 0 0 0 1px var(--line);
    transition: inset-inline-start var(--dur-2) var(--ease-out);
}

[aria-checked="true"] > .switch { background: var(--action); border-color: var(--action); }
[aria-checked="true"] > .switch::after { inset-inline-start: 23px; }

/* ---------- Bottom sheet (a <dialog>) ---------- */
.sheet {
    position: fixed;
    inset-inline: 0;
    inset-block-end: 0;
    inset-block-start: auto;
    width: min(100%, 560px);
    max-width: 100%;
    max-height: 88dvh;
    margin: 0 auto;
    padding: var(--s-2) var(--s-5) calc(var(--s-5) + var(--safe-bottom));
    border: var(--hairline);
    border-bottom: 0;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    background: var(--surface-1);
    color: var(--text-1);
    box-shadow: var(--shadow);
    overflow-y: auto;
}

.sheet[open] {
    animation: sheetIn var(--dur-3) var(--ease-out);
}

.sheet::backdrop {
    background: rgba(20, 56, 58, 0.36);
}

@keyframes sheetIn {
    from { transform: translateY(24px); opacity: 0; }
    to   { transform: none; opacity: 1; }
}

.sheet__grabber {
    width: 40px;
    height: 5px;
    margin: 0 auto var(--s-3);
    border-radius: var(--r-pill);
    background: var(--line);
}

.sheet__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    margin-bottom: var(--s-3);
}

.sheet__head h2 {
    margin: 0;
    font-family: var(--font-ui);
    font-size: 1.25rem;
    font-weight: 700;
}

html[lang="ar"] .sheet__head h2 { font-family: var(--font-ui-ar); }

.sheet-group {
    margin: 0 0 var(--s-4);
    padding: 0;
    border: 0;
}

.sheet-group > legend,
.sheet-label {
    display: block;
    margin-bottom: var(--s-2);
    color: var(--text-2);
    font-family: var(--font-ui);
    font-size: var(--step--1);
    font-weight: 600;
}

html[lang="ar"] .sheet-group > legend,
html[lang="ar"] .sheet-label { font-family: var(--font-ui-ar); }

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
    width: 100%;
    min-height: 56px;
    padding: var(--s-2) 0;
    border: 0;
    border-top: var(--hairline);
    background: transparent;
    color: var(--text-1);
    font-family: var(--font-ui);
    font-size: var(--step-0);
    font-weight: 600;
    text-align: start;
    cursor: pointer;
}

html[lang="ar"] .setting-row { font-family: var(--font-ui-ar); }

.setting-row small {
    display: block;
    color: var(--text-2);
    font-size: var(--step--1);
    font-weight: 400;
}

/* ---------- Mini player (sticky, above the tab bar) ---------- */
.mini-player {
    position: sticky;
    bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--s-3));
    z-index: 800;
    display: flex;
    align-items: center;
    gap: var(--s-3);
    max-width: 560px;
    margin: var(--s-4) auto 0;
    padding: var(--s-2);
    padding-inline-end: var(--s-4);
    background: var(--surface-1);
    border: var(--hairline);
    border-radius: var(--r-pill);
    box-shadow: var(--shadow);
}

@media (min-width: 1024px) {
    .mini-player { bottom: var(--s-4); }
}

.play-btn {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: var(--tap-lg);
    height: var(--tap-lg);
    border: 0;
    border-radius: 50%;
    background: var(--action);
    color: var(--text-on-action);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: var(--t-press);
}

.play-btn:hover { background: #0B5A55; }
.play-btn:active { transform: scale(0.94); }
.play-btn[aria-disabled="true"] { background: var(--surface-2); color: var(--text-2); cursor: default; }
.play-btn .icon { width: 26px; height: 26px; }
.play-btn .icon-pause { display: none; }
.play-btn[aria-pressed="true"] .icon-play { display: none; }
.play-btn[aria-pressed="true"] .icon-pause { display: inline; }

.mini-player__text {
    flex: 1;
    min-width: 0;
    font-family: var(--font-ui);
    line-height: 1.3;
}

html[lang="ar"] .mini-player__text { font-family: var(--font-ui-ar); }

.mini-player__title { display: block; font-weight: 700; font-size: var(--step-0); }
.mini-player__sub { display: block; color: var(--text-2); font-size: var(--step--1); }

/* ---------- Skeleton: covers fade in, never a blank box ---------- */
.tile__cover img,
.feature-card__cover img {
    transition: opacity var(--dur-3) var(--ease-out);
}

.js-reveal .tile__cover img:not(.is-loaded),
.js-reveal .feature-card__cover img:not(.is-loaded) {
    opacity: 0;
}

/* ---------- Footer on app screens ---------- */
footer.app-footer {
    background: transparent;
    color: var(--text-2);
}

/* the shamsa colophon (styles.css footer::before) stays: it closes the book */

.app-footer {
    margin-top: var(--s-7);
    padding: var(--s-6) var(--gutter) var(--s-6);
    border-top: var(--hairline-gold);
    color: var(--text-2);
    font-size: var(--step--1);
    text-align: center;
}

.app-footer p { margin: 0; }

/* ---------- Bedtime ---------- */
html[data-theme="bedtime"] .btn--primary:hover,
html[data-theme="bedtime"] .play-btn:hover { background: #26847D; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .lift:hover, .lift:focus-visible { transform: none; }
    .sheet[open] { animation: none; }
}

@media print {
    .app-bar, .tab-bar, .mini-player, .sheet { display: none !important; }
    body.app { padding: 0; }
}

/* v1 footer content inside an app footer */
.app-footer .footer-content p,
.app-footer .footer-subtitle,
.app-footer .footer-dua p {
    color: var(--text-2);
}

/* anchors and scrollIntoView land below the sticky app bar */
body.app section,
body.app [id] {
    scroll-margin-top: calc(var(--appbar-h) + var(--safe-top) + var(--s-4));
}

/* the skip link appears when focused */
a.visually-hidden:focus {
    position: fixed !important;
    top: var(--s-2);
    inset-inline-start: var(--s-2);
    z-index: 2000;
    width: auto; height: auto;
    margin: 0;
    padding: var(--s-2) var(--s-4);
    clip: auto;
    white-space: normal;
    border-radius: var(--r-pill);
    background: var(--surface-1);
    color: var(--text-1);
    box-shadow: var(--shadow);
}

/* hidden must win over the display of a button class */
.btn[hidden],
.link-btn[hidden],
.setting-row[hidden] {
    display: none;
}

/* ---------- Featured card actions (primary + "Start over") ---------- */
.feature-card__cover { display: block; }

.feature-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-3);
    margin-top: var(--s-2);
}

.feature-card__actions .btn { margin-top: 0; }

/* ---------- Text field (the child's name) ---------- */
.text-field {
    display: block;
    width: 100%;
    min-height: 52px;
    padding: 0 var(--s-4);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface-1);
    color: var(--text-1);
    font-family: var(--font-read);
    font-size: 1.125rem;
    transition: border-color var(--dur-2) var(--ease-out);
}

html[lang="ar"] .text-field { font-family: var(--font-ar); font-size: 1.25rem; }

.text-field:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    border-color: var(--focus);
}

.field-hint {
    margin: var(--s-2) 0 0;
    color: var(--text-2);
    font-family: var(--font-ui);
    font-size: var(--step--1);
}

html[lang="ar"] .field-hint { font-family: var(--font-ui-ar); }

/* ---------- Text button (e.g. "Add your child's name") ---------- */
.link-btn {
    display: inline-flex;
    align-items: center;
    min-height: var(--tap);
    margin-top: var(--s-1);
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--action-text);
    font-family: var(--font-ui);
    font-size: var(--step-0);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: var(--line-strong);
    text-underline-offset: 4px;
    cursor: pointer;
}

html[lang="ar"] .link-btn { font-family: var(--font-ui-ar); }

/* Focus not obscured (WCAG 2.4.11): keyboard focus and scrollIntoView stop
   short of the sticky app bar and the fixed tab bar / reader transport.
   On surah screens the sticky mini player adds its height. */
html:has(body.app),
html:has(body.reader) {
    scroll-padding-block-start: calc(var(--appbar-h) + var(--safe-top) + var(--s-4));
}

@media (max-width: 1023px) {
    html:has(body.app) {
        scroll-padding-block-end: calc(var(--tabbar-h) + var(--safe-bottom) + var(--s-4));
    }
    html:has(body.surah-screen) {
        scroll-padding-block-end: calc(var(--tabbar-h) + var(--safe-bottom) + 96px);
    }
}

@media (min-width: 1024px) {
    html:has(body.surah-screen) {
        scroll-padding-block-end: 96px;
    }
}

html:has(body.reader) {
    scroll-padding-block-end: calc(56px + 2 * var(--s-2) + var(--s-4) + var(--safe-bottom) + var(--s-4));
}


/* ---------- Non-text contrast (WCAG 1.4.11): every control edge >= 3:1 ---------- */
.segmented button[aria-pressed="true"],
.segmented button[aria-checked="true"],
body.app .stage-buttons.segmented .stage-btn[aria-pressed="true"] {
    box-shadow: var(--shadow-sm), 0 0 0 1px var(--line-control);   /* 3.51:1 on the track (was 1.18) */
}

.switch { border-color: var(--line-control); }                    /* off state: 4.15:1 (was 1.40) */
.text-field { border-color: var(--line-control); }                /* 4.15:1 (was 1.40) */

/* the stage picker never overflows at 320px: it wraps and tightens */
.segmented { max-width: 100%; flex-wrap: wrap; }

@media (max-width: 360px) {
    body.app .stage-buttons.segmented .stage-btn { padding: 0 var(--s-3); }
}

/* Reflow (WCAG 1.4.4 / 1.4.10): at 320px or 200% text the app bar never
   overflows. The wordmark gives way first (the mark and the actions stay),
   then the title truncates. */
.app-bar__brand {
    flex: 0 1 auto;
    min-width: 0;
}

.app-bar__brand > span:not(.brand-mark) {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-bar__spacer { min-width: 0; }
.app-bar__actions { flex: none; }
.app-bar .lang-toggle-btn { padding: 0 var(--s-3); }
