/*
 * Apple design language layer for BibleAI — see docs/design/apple-design-language.md.
 *
 * Lives in BibleAI.UI so both hosts get one source of truth
 * (_content/BibleAI.UI/css/apple.css). Typography sits here rather than in
 * MudTheme because the brief asks for 72-96px headings that must still fit a
 * phone: clamp() expresses that, a fixed C# font size cannot.
 *
 * Light/dark needs no second rule set — every colour below derives from the
 * MudBlazor palette variables, which MudThemeProvider flips on theme change.
 * Translucency comes from color-mix() over those same variables, so the glass
 * surfaces follow the theme instead of hard-coding white and black.
 */

:root {
    /* SF Pro on Apple hardware, the platform UI font elsewhere, Inter/Helvetica
       as named in the brief. No web font is linked on purpose — the app must
       look right with no network (same rule the MAUI host already follows). */
    --ba-font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
        "Segoe UI Variable Display", "Segoe UI", Inter, "Helvetica Neue", Helvetica, Arial, sans-serif;

    /* 8pt grid — the only spacing values allowed. */
    --ba-space-1: 4px;
    --ba-space-2: 8px;
    --ba-space-3: 12px;
    --ba-space-4: 16px;
    --ba-space-5: 20px;
    --ba-space-6: 24px;
    --ba-space-8: 32px;
    --ba-space-10: 40px;
    --ba-space-12: 48px;
    --ba-space-16: 64px;
    --ba-space-24: 96px;
    --ba-space-32: 128px;

    /* One shape language: button/input 16, card 24, modal 28. */
    --ba-radius-button: 16px;
    --ba-radius-input: 16px;
    --ba-radius-card: 24px;
    --ba-radius-modal: 28px;
    --ba-radius-pill: 980px;

    /* "Elements have mass": slow, natural, never abrupt. */
    --ba-duration-fast: 240ms;
    --ba-duration: 320ms;
    --ba-duration-slow: 450ms;
    --ba-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ba-spring: cubic-bezier(0.34, 1.4, 0.64, 1);

    /* Glass: blur 20-40px, 60-80% opaque, 1px hairline. */
    --ba-glass-blur: 24px;
    --ba-glass-bg: color-mix(in srgb, var(--mud-palette-surface) 72%, transparent);
    --ba-hairline: color-mix(in srgb, var(--mud-palette-text-primary) 12%, transparent);

    /* Sections breathe: 120-180px on a desktop, proportionally less on a phone. */
    --ba-section-gap: clamp(48px, 9vw, 128px);
    --ba-hero-block: clamp(40px, 9vh, 120px);
}

/* ── Typography ───────────────────────────────────────────────────────────── */

html,
body,
.mud-typography,
.mud-input,
.mud-input-root,
.mud-button-root,
.mud-select,
.mud-list-item-text {
    font-family: var(--ba-font);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-size: 17px;
    line-height: 1.5;
    letter-spacing: -0.011em;
    background-color: var(--mud-palette-background);
}

/* Display sizes from the brief. Tight tracking is what makes large type read as
   Apple's rather than merely big. */
.ba-hero-title {
    font-size: clamp(2.75rem, 8.5vw, 6rem);
    font-weight: 600;
    line-height: 1.05;
    letter-spacing: -0.025em;
    margin: 0;
}

.ba-section-title {
    font-size: clamp(1.75rem, 4.5vw, 3rem);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin: 0;
}

.ba-page-title {
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 600;
    line-height: 1.08;
    letter-spacing: -0.022em;
    margin: 0 0 var(--ba-space-8);
}

.ba-lead {
    font-size: clamp(1.125rem, 2.2vw, 1.5rem);
    font-weight: 400;
    line-height: 1.4;
    letter-spacing: -0.012em;
    color: var(--mud-palette-text-secondary);
}

.ba-eyebrow {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: 0.01em;
    color: var(--mud-palette-text-secondary);
    text-transform: none;
}

.ba-caption {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--mud-palette-text-secondary);
}

.mud-typography-h1,
.mud-typography-h2,
.mud-typography-h3,
.mud-typography-h4,
.mud-typography-h5,
.mud-typography-h6 {
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.mud-typography-h4 {
    font-size: clamp(1.5rem, 3.6vw, 2.25rem);
}

.mud-typography-h5 {
    font-size: clamp(1.3rem, 3vw, 1.75rem);
}

.mud-typography-h6 {
    font-size: 1.1875rem;
}

.mud-typography-body1 {
    font-size: 1.0625rem;
    line-height: 1.55;
    letter-spacing: -0.011em;
}

.mud-typography-body2 {
    font-size: 0.9375rem;
    line-height: 1.5;
}

.mud-typography-caption {
    font-size: 0.875rem;
    letter-spacing: 0;
}

/* The brief bans decorative treatment; MudBlazor's overline is all-caps and
   wide-tracked, which reads as a Material label. */
.mud-typography-overline {
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    line-height: 1.4;
    color: var(--mud-palette-text-secondary);
}

/* ── Surfaces: no heavy shadows, one radius language ──────────────────────── */

.mud-paper,
.mud-card {
    border-radius: var(--ba-radius-card);
    background-image: none;
}

/* "The card lies on the surface" — a hairline instead of a drop shadow. Every
   elevation step is flattened, so an Elevation left in markup cannot reintroduce
   Material depth. */
.mud-paper,
.mud-card,
.mud-paper-outlined,
.mud-card-outlined,
[class*="mud-elevation-"] {
    box-shadow: none !important;
}

.ba-panel {
    background-color: var(--mud-palette-surface);
    border: 1px solid var(--ba-hairline);
    border-radius: var(--ba-radius-card);
    padding: var(--ba-space-6);
}

/* Secondary explanatory line inside a panel — the brief's "content first": a hint
   must read as a whisper next to the row it explains, never as a second heading. */
.ba-hint {
    margin: 0;
    padding-bottom: var(--ba-space-3);
    color: var(--mud-palette-text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}

.ba-sync-alert {
    margin-top: var(--ba-space-4);
    border-radius: var(--ba-radius-input);
}

.ba-quiet {
    background-color: color-mix(in srgb, var(--mud-palette-text-primary) 4%, transparent);
    border-radius: var(--ba-radius-card);
    padding: var(--ba-space-6);
}

.mud-divider {
    border-color: var(--ba-hairline);
}

/* ── Glass chrome: app bar + bottom navigation ────────────────────────────── */

.mud-appbar {
    background-color: var(--ba-glass-bg) !important;
    backdrop-filter: saturate(180%) blur(var(--ba-glass-blur));
    -webkit-backdrop-filter: saturate(180%) blur(var(--ba-glass-blur));
    border-bottom: 1px solid var(--ba-hairline);
    color: var(--mud-palette-text-primary) !important;
}

.ba-glass-bar {
    background-color: var(--ba-glass-bg);
    backdrop-filter: saturate(180%) blur(var(--ba-glass-blur));
    -webkit-backdrop-filter: saturate(180%) blur(var(--ba-glass-blur));
    border-top: 1px solid var(--ba-hairline);
}

.ba-wordmark {
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.012em;
    color: var(--mud-palette-text-primary);
}

.ba-bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 640px;
    margin-inline: auto;
    padding: var(--ba-space-2) 0 max(var(--ba-space-2), env(safe-area-inset-bottom));
}

.ba-bottom-nav-item.mud-button-root {
    flex-direction: column;
    gap: var(--ba-space-1);
    min-width: 64px;
    padding: var(--ba-space-2) var(--ba-space-3);
    border-radius: var(--ba-radius-button);
    font-weight: 400;
}

.ba-bottom-nav-label {
    font-size: 0.6875rem;
    letter-spacing: 0;
    line-height: 1.2;
}

/* ── Buttons: large, flat, few words ──────────────────────────────────────── */

.mud-button-root {
    border-radius: var(--ba-radius-button);
    text-transform: none;
    letter-spacing: -0.008em;
    font-weight: 500;
    background-image: none;
    transition: background-color var(--ba-duration-fast) var(--ba-ease),
                color var(--ba-duration-fast) var(--ba-ease),
                transform var(--ba-duration-fast) var(--ba-spring),
                opacity var(--ba-duration-fast) var(--ba-ease);
}

.mud-button-filled {
    padding: var(--ba-space-3) var(--ba-space-6);
    font-size: 1.0625rem;
    min-height: 48px;
}

.mud-button-filled:hover {
    filter: brightness(1.08);
}

.mud-button-root:active {
    transform: scale(0.98);
}

.ba-cta {
    min-height: 52px;
    padding-inline: var(--ba-space-8);
    border-radius: var(--ba-radius-pill);
    font-size: 1.0625rem;
}

.mud-icon-button {
    border-radius: 50%;
    transition: background-color var(--ba-duration-fast) var(--ba-ease),
                transform var(--ba-duration-fast) var(--ba-spring);
}

.mud-icon-button:active {
    transform: scale(0.94);
}

/* Thin, single-style icons at a consistent 24px. */
.mud-icon-root.mud-svg-icon {
    width: 24px;
    height: 24px;
}

/* ── Inputs ───────────────────────────────────────────────────────────────── */

.mud-input.mud-input-outlined .mud-input-outlined-border {
    border-radius: var(--ba-radius-input);
    border-color: var(--ba-hairline);
    transition: border-color var(--ba-duration-fast) var(--ba-ease);
}

.mud-input-root {
    font-size: 1.0625rem;
}

/* ── Dialogs ──────────────────────────────────────────────────────────────── */

.mud-dialog {
    border-radius: var(--ba-radius-modal);
    border: 1px solid var(--ba-hairline);
}

/* ── Alerts: informational, not decorative ────────────────────────────────── */

.mud-alert {
    border-radius: var(--ba-radius-card);
    font-size: 0.9375rem;
}

.mud-alert-outlined {
    border-color: var(--ba-hairline);
}

/* ── Layout: air, and a container that scales to the desktop ──────────────── */

.mud-main-content {
    background-color: var(--mud-palette-background);
}

.ba-page {
    max-width: 1200px;
    margin-inline: auto;
    padding-inline: clamp(20px, 5vw, 48px);
    padding-block: var(--ba-space-10) 128px;
}

.ba-section {
    margin-top: var(--ba-section-gap);
}

.ba-stack-4 > * + * {
    margin-top: var(--ba-space-4);
}

.ba-stack-6 > * + * {
    margin-top: var(--ba-space-6);
}

.ba-stack-8 > * + * {
    margin-top: var(--ba-space-8);
}

/* Reader measure: prose stops being readable past ~70 characters a line, and the
   1200px container is far wider than that on a desktop. */
.ba-reader {
    max-width: 68ch;
    margin-inline: auto;
}

/* ── Hero ─────────────────────────────────────────────────────────────────── */

.ba-hero {
    padding-block: var(--ba-hero-block);
    text-align: center;
}

.ba-hero > * + * {
    margin-top: var(--ba-space-6);
}

.ba-hero-visual {
    margin-top: var(--ba-space-16);
    border-radius: var(--ba-radius-card);
    padding: clamp(32px, 6vw, 80px) clamp(24px, 5vw, 64px);
    background: color-mix(in srgb, var(--mud-palette-text-primary) 4%, transparent);
}

.ba-verse {
    font-size: clamp(1.375rem, 3.2vw, 2.25rem);
    font-weight: 400;
    line-height: 1.35;
    letter-spacing: -0.018em;
    color: var(--mud-palette-text-primary);
    margin: 0;
}

/* ── Reader ───────────────────────────────────────────────────────────────── */

.ba-reader-toolbar {
    display: flex;
    align-items: center;
    gap: var(--ba-space-2);
    flex-wrap: wrap;
    margin-bottom: var(--ba-space-8);
}

.ba-chapter-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ba-space-2);
    margin-bottom: var(--ba-space-8);
}

.ba-chapter-title-group {
    display: flex;
    align-items: center;
    gap: var(--ba-space-1);
    min-width: 0;
}

.ba-chapter-title {
    font-size: clamp(1.75rem, 5vw, 3rem);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.022em;
    margin: 0;
    text-align: center;
    color: var(--mud-palette-text-primary);
}

/* Warms the page through the theme's own variables, so it reads as dimmed in either theme
   instead of repainting a fixed cream panel. */
.ba-reader-sleep {
    background-color: color-mix(in srgb, #ffb340 12%, var(--mud-palette-surface));
    border-radius: var(--ba-radius-card);
    padding: var(--ba-space-6) var(--ba-space-5);
    filter: brightness(0.97);
}

.ba-section-heading {
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.3;
    color: var(--mud-palette-text-secondary);
    margin: var(--ba-space-8) 0 var(--ba-space-3);
}

.ba-reader > .ba-section-heading:first-child {
    margin-top: 0;
}

.ba-verse-text {
    line-height: 1.75;
    letter-spacing: -0.008em;
    color: var(--mud-palette-text-primary);
    margin: 0;
}

/* Superscript numbers are wayfinding, not content: present, quiet, never competing
   with the verse. */
.ba-verse-number {
    font-size: 0.6875em;
    font-weight: 500;
    color: var(--mud-palette-text-secondary);
    margin-right: 0.4em;
    vertical-align: super;
    line-height: 0;
}

.ba-favorite-mark {
    color: var(--mud-palette-primary);
    font-size: 0.625em;
    vertical-align: middle;
    margin-left: 0.4em;
}

.ba-note {
    display: block;
    width: 100%;
    text-align: left;
    font-family: inherit;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--mud-palette-text-secondary);
    background-color: color-mix(in srgb, var(--mud-palette-text-primary) 5%, transparent);
    border: none;
    border-left: 2px solid var(--mud-palette-primary);
    border-radius: var(--ba-space-2);
    padding: var(--ba-space-3) var(--ba-space-4);
    margin-block: var(--ba-space-2);
    cursor: pointer;
    transition: background-color var(--ba-duration-fast) var(--ba-ease);
}

.ba-note:hover {
    background-color: color-mix(in srgb, var(--mud-palette-text-primary) 9%, transparent);
}

/* ── Translator's notes: silent until asked for ───────────────────────────────
   A footnote marker sits inside the sentence, so it has to be the smallest mark
   on the page that a finger can still hit — hence a superscript glyph with an
   invisible padded hit area rather than a button that interrupts the line. */

.ba-note-marker {
    display: inline-block;
    font-family: inherit;
    font-size: 0.6875em;
    /* line-height must stay ≥ 1: at 0 the button collapses to a zero-height box that still
       paints its glyph, so the marker looks perfect and cannot be tapped at all. */
    line-height: 1;
    vertical-align: super;
    color: var(--mud-palette-primary);
    background: none;
    border: none;
    padding: 0.3em 0.4em;
    margin-inline: 0.05em;
    cursor: pointer;
}

.ba-note-marker:hover,
.ba-note-marker[aria-expanded="true"] {
    text-decoration: underline;
}

.ba-note-body {
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--mud-palette-text-secondary);
    border-left: 2px solid var(--ba-hairline);
    padding: var(--ba-space-2) var(--ba-space-4);
    margin-block: var(--ba-space-2);
}

.ba-note-origin {
    font-variant-numeric: tabular-nums;
    margin-right: var(--ba-space-2);
    color: var(--mud-palette-text-disabled);
}

/* A note about the whole chapter (psalm numbering, acrostic structure) belongs
   above the text, not hanging off any one verse. */
.ba-chapter-note {
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--mud-palette-text-secondary);
    text-align: center;
    max-width: 34em;
    margin: 0 auto var(--ba-space-6);
}

/* An inline reference reads as part of the sentence and only reveals itself as
   tappable on hover — a link-blue run through a footnote would shout. */
.ba-ref-link {
    font: inherit;
    color: var(--mud-palette-primary);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

.ba-ref-link:hover {
    text-decoration: underline;
}

/* ── Knowledge modules: a document reads like a page, not a data listing ───── */

.ba-doc-section {
    max-width: 38em;
    margin-bottom: var(--ba-space-10);
}

.ba-doc-text {
    font-size: 1.0625rem;
    line-height: 1.7;
    white-space: pre-line;
    color: var(--mud-palette-text-primary);
}

/* ── Figures (streak / bookmarks / …): numbers, not cards ─────────────────── */

.ba-figures {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--ba-space-2);
}

.ba-figure {
    text-align: center;
    padding: var(--ba-space-4) var(--ba-space-2);
}

.ba-figure + .ba-figure {
    border-left: 1px solid var(--ba-hairline);
}

.ba-figure-value {
    font-size: clamp(1.5rem, 4vw, 2.25rem);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--mud-palette-text-primary);
}

.ba-figure-label {
    font-size: 0.8125rem;
    color: var(--mud-palette-text-secondary);
    margin-top: var(--ba-space-1);
}

/* ── Rows ─────────────────────────────────────────────────────────────────── */

.ba-row {
    display: flex;
    align-items: center;
    gap: var(--ba-space-4);
    padding-block: var(--ba-space-3);
    min-height: 48px;
}

.ba-row-main {
    flex: 1;
    min-width: 0;
}

.ba-row-title {
    font-size: 1.0625rem;
    color: var(--mud-palette-text-primary);
}

/* ── Plans ────────────────────────────────────────────────────────────────── */

.ba-plan-title {
    font-size: 1.375rem;
    font-weight: 600;
    letter-spacing: -0.016em;
    line-height: 1.2;
    margin: var(--ba-space-1) 0 0;
    color: var(--mud-palette-text-primary);
}

.ba-day-list {
    list-style: none;
    margin: var(--ba-space-2) 0 0;
    padding: 0;
}

.ba-day-list > li + li {
    border-top: 1px solid var(--ba-hairline);
}

.ba-day-done {
    text-decoration: line-through;
    color: var(--mud-palette-text-secondary);
}

/* ── Assistant ────────────────────────────────────────────────────────────── */

.ba-turn > * + * {
    margin-top: var(--ba-space-4);
}

/* The question leads the turn as a heading would — no chat bubble, no grey slab. */
.ba-question {
    font-size: clamp(1.375rem, 3vw, 1.875rem);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.018em;
    color: var(--mud-palette-text-primary);
    margin: 0;
}

.ba-answer {
    font-size: 1.0625rem;
    line-height: 1.65;
    letter-spacing: -0.011em;
    white-space: pre-wrap;
    color: var(--mud-palette-text-primary);
    margin: 0;
    max-width: 68ch;
}

.ba-citation {
    border: 1px solid var(--ba-hairline);
    border-radius: var(--ba-radius-card);
    padding: var(--ba-space-4) var(--ba-space-5);
}

.ba-citation-ref {
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.008em;
    color: var(--mud-palette-text-primary);
}

.ba-citation-kind {
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
    margin-left: var(--ba-space-2);
}

.ba-citation-text {
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--mud-palette-text-secondary);
    margin: var(--ba-space-2) 0 0;
}

/* The verdict row sits under the answer, quiet by default. Asking the reader to judge an answer must
   not compete with the answer — it is available, not insistent. */
.ba-verdict {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--ba-space-2);
    padding-top: var(--ba-space-2);
}

.ba-verdict .mud-button-root {
    min-width: 0;
}

.ba-verdict-note {
    font-size: 0.8125rem;
    color: var(--mud-palette-text-secondary);
    margin: 0;
}

/* ── Curated FAQ ──────────────────────────────────────────────────────────── */

.ba-faq-topic + .ba-faq-topic {
    margin-top: var(--ba-space-6);
}

.ba-faq-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ba-space-2);
    margin-top: var(--ba-space-3);
}

/* Pills, not list rows: a suggestion the reader may ignore should read lighter than
   anything the app is telling them. */
.ba-faq-chip {
    border: 1px solid var(--ba-hairline);
    border-radius: var(--ba-radius-pill);
    background: transparent;
    color: var(--mud-palette-text-primary);
    font: inherit;
    font-size: 0.9375rem;
    line-height: 1.3;
    text-align: left;
    padding: var(--ba-space-2) var(--ba-space-4);
    cursor: pointer;
    transition: background-color var(--ba-duration-fast) var(--ba-ease),
                border-color var(--ba-duration-fast) var(--ba-ease);
}

.ba-faq-chip:hover:not(:disabled) {
    border-color: var(--mud-palette-primary);
    background: var(--mud-palette-action-default-hover);
}

.ba-faq-chip:disabled {
    opacity: 0.5;
    cursor: default;
}

/* ── Review queue ─────────────────────────────────────────────────────────── */

.ba-review-entry {
    border: 1px solid var(--ba-hairline);
    border-radius: var(--ba-radius-card);
    padding: var(--ba-space-5);
}

.ba-review-entry > * + * {
    margin-top: var(--ba-space-3);
}

/* The doctrinal flag is the reason this screen exists; it must be visible before anything is read. */
.ba-review-flagged {
    border-color: var(--mud-palette-warning);
}

.ba-review-meta {
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
    margin: 0;
}

.ba-review-answer {
    font-size: 0.9375rem;
    line-height: 1.55;
    white-space: pre-wrap;
    color: var(--mud-palette-text-secondary);
    margin: 0;
}

/* ── Progress ─────────────────────────────────────────────────────────────── */

.mud-progress-linear {
    border-radius: var(--ba-radius-pill);
    overflow: hidden;
}

.mud-progress-linear.mud-progress-linear-color-primary .mud-progress-linear-bar {
    transition: transform var(--ba-duration-slow) var(--ba-ease);
}

/* ── Accessibility ────────────────────────────────────────────────────────── */

/* A visible ring for keyboard users only — the brief demands keyboard
   navigation, and MudBlazor's ripple is not a focus indicator. */
:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 3px;
    border-radius: var(--ba-radius-input);
}

.mud-button-root:focus-visible,
.mud-icon-button:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 3px;
}

.ba-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* A link that must not shout — it sits in a caption and only earns its colour on
   hover, so the reference still reads as a reference. */
.ba-quiet-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid var(--ba-hairline);
    transition: color var(--ba-duration-fast) var(--ba-ease),
                border-color var(--ba-duration-fast) var(--ba-ease);
}

.ba-quiet-link:hover,
.ba-quiet-link:focus-visible {
    color: var(--mud-palette-primary);
    border-color: var(--mud-palette-primary);
}

/* ── Arriving by link ────────────────────────────────────────────────────────
   A shared link scrolls the verse to the middle of the screen, where it looks
   exactly like its neighbours. The ring says "this one" and then gets out of the
   way — it stays until the reader navigates, because a mark that fades on a timer
   is gone by the time a slow reader looks up. */

.ba-verse-focused {
    box-shadow: inset 0 0 0 2px var(--mud-palette-primary);
    animation: ba-verse-arrive var(--ba-duration-slow) var(--ba-ease);
}

@keyframes ba-verse-arrive {
    from {
        background-color: color-mix(in srgb, var(--mud-palette-primary) 18%, transparent);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ba-verse-focused {
        animation: none;
    }
}

/* ── Listening ───────────────────────────────────────────────────────────────
   The voice reads one verse at a time, and the reader follows along by eye. A
   wash rather than the arrival ring: this mark moves every few seconds, and a
   hard 2px border blinking down the page is the visual equivalent of a metronome. */

.ba-verse-speaking {
    background-color: color-mix(in srgb, var(--mud-palette-primary) 12%, transparent);
    transition: background-color var(--ba-duration-fast) var(--ba-ease);
}

/* Sticks under the toolbar so the controls stay reachable while the page scrolls
   itself along with the voice — the reader's hand should not have to chase Pause. */
.ba-listen-bar {
    position: sticky;
    top: var(--ba-space-2);
    z-index: 3;
    display: flex;
    align-items: center;
    gap: var(--ba-space-2);
    margin-bottom: var(--ba-space-4);
    padding: var(--ba-space-1) var(--ba-space-3);
    background-color: var(--mud-palette-surface);
    border: 1px solid var(--ba-hairline);
    border-radius: var(--ba-radius-card);
}

.ba-listen-where {
    font-size: 0.9375rem;
    font-variant-numeric: tabular-nums;
    color: var(--mud-palette-text-secondary);
}

/* ── Sharing a verse ─────────────────────────────────────────────────────────
   Opens under the verse it is about, so the reader never loses which one they
   picked — the same reason note editing is inline. */

.ba-share {
    margin-block: var(--ba-space-3);
    padding: var(--ba-space-4);
    border: 1px solid var(--ba-hairline);
    border-radius: var(--ba-radius-card);
    background-color: color-mix(in srgb, var(--mud-palette-text-primary) 4%, transparent);
}

.ba-share-preview {
    margin: 0 0 var(--ba-space-3);
    color: var(--mud-palette-text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
    /* The preview is the exact text that will be sent, newlines and all — showing it re-flowed
       would make the reader trust a layout they are not going to get. */
    white-space: pre-wrap;
    word-break: break-word;
}

.ba-share-actions {
    display: flex;
    align-items: center;
    gap: var(--ba-space-2);
    flex-wrap: wrap;
}

/* ── Choice cards: onboarding, and anywhere one of a few options is picked ────
   A radio group in a list of cards, built from real <button>s so the keyboard and
   the screen reader get a control each (aria-pressed carries the state). The
   selected one is marked by the accent border, not by a tick glyph: the brief
   rules out decoration that repeats what the shape already says. */

.ba-choice {
    display: flex;
    flex-direction: column;
    gap: var(--ba-space-1);
    width: 100%;
    text-align: left;
    font-family: inherit;
    background-color: var(--mud-palette-surface);
    border: 1px solid var(--ba-hairline);
    border-radius: var(--ba-radius-card);
    padding: var(--ba-space-5) var(--ba-space-6);
    cursor: pointer;
    transition: border-color var(--ba-duration-fast) var(--ba-ease),
                background-color var(--ba-duration-fast) var(--ba-ease),
                transform var(--ba-duration-fast) var(--ba-spring);
}

.ba-choice:hover {
    border-color: color-mix(in srgb, var(--mud-palette-text-primary) 24%, transparent);
}

.ba-choice:active {
    transform: scale(0.99);
}

.ba-choice-selected,
.ba-choice-selected:hover {
    border-color: var(--mud-palette-primary);
    background-color: color-mix(in srgb, var(--mud-palette-primary) 6%, var(--mud-palette-surface));
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 599px) {
    .ba-figures {
        grid-template-columns: repeat(2, 1fr);
        gap: 0;
    }

    /* With two per row the third cell starts a new row, so the left hairline
       would hang under nothing. */
    .ba-figure:nth-child(odd) {
        border-left: none;
    }

    .ba-figure:nth-child(n + 3) {
        border-top: 1px solid var(--ba-hairline);
    }

    .ba-page {
        padding-block: var(--ba-space-6) 120px;
    }
}

@media (min-width: 900px) {
    .ba-figures {
        gap: var(--ba-space-6);
    }
}

/* ── The verse in its own language ───────────────────────────────────────────
   Opens under the verse, like sharing and notes do. Each word is a real <button>:
   it is the control that opens the word's details, and a <span> with a click
   handler would be invisible to the keyboard. */

.ba-original {
    margin-block: var(--ba-space-3);
    padding: var(--ba-space-4);
    border: 1px solid var(--ba-hairline);
    border-radius: var(--ba-radius-card);
    background-color: color-mix(in srgb, var(--mud-palette-text-primary) 4%, transparent);
}

.ba-original-words {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ba-space-2);
}

.ba-original-word {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--ba-space-2) var(--ba-space-3);
    border: 1px solid transparent;
    border-radius: var(--ba-radius-button);
    background: transparent;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background-color var(--ba-duration-fast) var(--ba-ease), border-color var(--ba-duration-fast) var(--ba-ease);
}

.ba-original-word:hover {
    background-color: color-mix(in srgb, var(--mud-palette-primary) 8%, transparent);
}

.ba-original-word--open {
    border-color: var(--mud-palette-primary);
    background-color: color-mix(in srgb, var(--mud-palette-primary) 10%, transparent);
}

.ba-original-text {
    /* The Greek needs a size of its own: at body size the diacritics are what disappear first. */
    font-size: 1.125rem;
    line-height: 1.4;
    color: var(--mud-palette-text-primary);
}

.ba-original-gloss {
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
}

.ba-original-detail {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--ba-space-1) var(--ba-space-3);
    margin: var(--ba-space-3) 0 0;
    padding-top: var(--ba-space-3);
    border-top: 1px solid var(--ba-hairline);
    font-size: 0.875rem;
}

.ba-original-detail dt {
    color: var(--mud-palette-text-secondary);
}

.ba-original-detail dd {
    margin: 0;
    color: var(--mud-palette-text-primary);
}

.ba-original-license {
    margin-top: var(--ba-space-3);
}

/* ── A lexicon article, opened from a Strong's number ─────────────────────── */

.ba-strongs {
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    color: var(--mud-palette-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.ba-lexicon {
    margin-top: var(--ba-space-3);
    padding-top: var(--ba-space-3);
    border-top: 1px solid var(--ba-hairline);
}

.ba-lexicon-entry + .ba-lexicon-entry {
    margin-top: var(--ba-space-4);
}

.ba-lexicon-head {
    display: flex;
    align-items: baseline;
    gap: var(--ba-space-2);
    flex-wrap: wrap;
    margin: 0 0 var(--ba-space-2);
}

.ba-lexicon-lemma {
    font-size: 1.125rem;
    color: var(--mud-palette-text-primary);
}

.ba-lexicon-gloss {
    font-size: 0.875rem;
    color: var(--mud-palette-text-secondary);
}

.ba-lexicon-body {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--mud-palette-text-primary);
    /* The article is structured by its own line breaks — re-flowing it loses the numbered senses. */
    white-space: pre-wrap;
}

.ba-lexicon-places {
    margin: var(--ba-space-3) 0 0;
    font-size: 0.875rem;
}

/* The build line: monospace so a commit hash read aloud digit by digit is unambiguous, and
   user-select so it can be copied into a bug report. */
.ba-build {
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8125rem;
    color: var(--mud-palette-text-secondary);
    user-select: all;
}

/* What the assistant proposed, as something to press. Bordered rather than tinted: it is an offer,
   not a result, and a filled block would read as already done. */
.ba-suggestion {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--ba-space-2);
    margin-top: var(--ba-space-6);
    padding: var(--ba-space-4);
    border: 1px solid var(--mud-palette-primary);
    border-radius: var(--ba-radius-card);
}

.ba-suggestion-title {
    margin: 0;
    color: var(--mud-palette-text-primary);
}

/* ── «Запитати ШІ» над виділеним текстом ──────────────────────────────────────
   Fixed, not absolute: the coordinates come from the pointer event, which reports viewport
   coordinates, and an absolutely-positioned element would land a scroll-offset away from the
   finger that summoned it. */

.ba-selection-ask {
    position: fixed;
    z-index: 1400;
    display: flex;
    align-items: center;
    gap: var(--ba-space-1);
    padding: var(--ba-space-1);
    border-radius: var(--ba-radius-button);
    background-color: var(--mud-palette-surface);
    box-shadow: 0 8px 24px rgb(0 0 0 / 22%);
    /* Sits above and slightly left of the gesture so the reader's own finger is not covering it,
       and never past the right edge on a phone. */
    transform: translate(-50%, calc(-100% - var(--ba-space-3)));
    max-width: calc(100vw - var(--ba-space-4));
}

.ba-selection-ask-button {
    padding: var(--ba-space-2) var(--ba-space-4);
    border: none;
    border-radius: var(--ba-radius-button);
    background-color: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    font: inherit;
    font-size: 0.875rem;
    white-space: nowrap;
    cursor: pointer;
}

.ba-selection-ask-close {
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: var(--ba-radius-button);
    background: transparent;
    color: var(--mud-palette-text-secondary);
    font: inherit;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

.ba-selection-ask-close:hover {
    background-color: color-mix(in srgb, var(--mud-palette-text-primary) 8%, transparent);
}

/* ── Where a Strong's number stands ──────────────────────────────────────────
   One place per row, and the whole row is the control that opens it: the reader is scanning a list
   to pick a verse, so a small link inside each row would be the wrong target on a phone. */

.ba-strongs-place {
    display: flex;
    flex-direction: column;
    gap: var(--ba-space-1);
    width: 100%;
    padding: var(--ba-space-3) var(--ba-space-4);
    border: 1px solid var(--ba-hairline);
    border-radius: var(--ba-radius-card);
    background: transparent;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background-color var(--ba-duration-fast) var(--ba-ease);
}

.ba-strongs-place:hover {
    background-color: color-mix(in srgb, var(--mud-palette-primary) 6%, transparent);
}

.ba-strongs-place-ref {
    font-size: 0.875rem;
    color: var(--mud-palette-primary);
}

.ba-strongs-place-original {
    display: flex;
    align-items: baseline;
    gap: var(--ba-space-2);
    flex-wrap: wrap;
}

.ba-strongs-place-verse {
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--mud-palette-text-secondary);
}

/* The raw morphology code beside its Ukrainian reading: present for anyone who works in the codes,
   quiet enough not to compete with the words. */
.ba-morph-code {
    margin-left: var(--ba-space-2);
}

/* A source tag inside an answer. Styled as text the reader can press rather than as a button: it sits
   mid-sentence, and a real button there would break the line the sentence is read on. */
.ba-tag {
  appearance: none;
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 0.85em;
  color: var(--mud-palette-primary);
  cursor: pointer;
  vertical-align: baseline;
}

.ba-tag:hover,
.ba-tag:focus-visible {
  text-decoration: underline;
}

/* The same tag on the card it points at, so the two read as a pair. */
.ba-citation-tag {
  font-size: 0.8em;
  color: var(--mud-palette-primary);
  margin-inline-end: 0.4em;
}

/* The fold for the source cards. Looks like the eyebrow label it replaced, because that is what it is —
   a heading you can press — rather than a button competing with the answer for attention. */
.ba-sources-toggle {
  appearance: none;
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--mud-palette-text-secondary);
  cursor: pointer;
  display: block;
}

.ba-sources-toggle:hover,
.ba-sources-toggle:focus-visible {
  color: var(--mud-palette-text-primary);
}
