/* Parallel / bilingual reader styles (logical properties only) */

.bi-wrap {
    max-width: 68rem;
    margin-inline: auto;
    padding-block: 1.25rem 3rem;
}

.bi-header {
    margin-block-end: 1.5rem;
}

.bi-eyebrow {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-muted, #6c757d);
    margin-block-end: 0.35rem;
}

.bi-title {
    font-family: var(--font-serif, Georgia, serif);
    font-size: clamp(1.7rem, 3vw, 2.35rem);
    line-height: 1.2;
    margin-block: 0 0.4rem;
}

.bi-subtitle {
    font-family: var(--font-serif, Georgia, serif);
    font-size: clamp(1.15rem, 2vw, 1.45rem);
    color: var(--ink-muted, #555);
    margin-block: 0 0.75rem;
}

.bi-intro {
    font-size: 1.05rem;
    line-height: 1.65;
    max-width: 48rem;
    color: var(--ink-soft, #444);
}

/* Language pair switcher pills */
.bi-pair-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-block: 1rem 1.75rem;
}

.bi-pair-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.42rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.14));
    background: var(--card-bg, rgba(255, 255, 255, 0.65));
    color: inherit;
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.bi-pair-pill:hover {
    border-color: var(--accent, #2c5282);
    background: rgba(44, 82, 130, 0.08);
}

.bi-pair-pill.is-active {
    background: var(--accent, #2c5282);
    border-color: var(--accent, #2c5282);
    color: #fff;
}

.bi-pair-count {
    font-size: 0.8rem;
    opacity: 0.78;
}

/* Hub cards */
.bi-pair-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(17.5rem, 1fr));
    gap: 1.15rem;
    margin-block: 1.5rem 2.25rem;
}

.bi-pair-card {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 1.25rem 1.35rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.12));
    background: var(--card-bg, rgba(255, 255, 255, 0.75));
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.bi-pair-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent, #2c5282);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.07);
}

.bi-pair-card-title {
    font-family: var(--font-serif, Georgia, serif);
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
}

.bi-pair-card-stats {
    font-size: 0.9rem;
    color: var(--accent, #2c5282);
    font-weight: 600;
}

.bi-pair-card-desc {
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--ink-muted, #555);
    margin: 0;
}

/* Book / story list cards on pair hub */
.bi-section-heading {
    font-family: var(--font-serif, Georgia, serif);
    font-size: 1.35rem;
    margin-block: 2rem 0.4rem;
}

.bi-section-lead {
    font-size: 0.95rem;
    color: var(--ink-muted, #666);
    margin-block-end: 1rem;
}

.bi-book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
    gap: 0.9rem;
}

.bi-book-card {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 1rem 1.15rem;
    border-radius: 0.65rem;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.11));
    background: var(--card-bg, rgba(255, 255, 255, 0.7));
    color: inherit;
    text-decoration: none;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.bi-book-card:hover {
    border-color: var(--accent, #2c5282);
    background: rgba(44, 82, 130, 0.04);
}

.bi-book-target {
    font-family: var(--font-serif, Georgia, serif);
    font-size: 1.08rem;
    font-weight: 700;
    line-height: 1.3;
    text-align: start;
}

.bi-book-en {
    font-size: 0.94rem;
    color: var(--ink-soft, #444);
}

.bi-book-meta {
    margin-block-start: auto;
    padding-block-start: 0.35rem;
    font-size: 0.82rem;
    color: var(--ink-muted, #6c757d);
}

/* Parallel reader toolbar */
.bi-toolbar {
    position: sticky;
    top: 3.9rem;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    padding: 0.65rem 1rem;
    margin-block: 1rem 1.25rem;
    border-radius: 0.65rem;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.12));
    background: var(--paper-bg, #faf8f3);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.05);
}

.bi-toolbar-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
}

.bi-btn {
    padding: 0.38rem 0.78rem;
    border-radius: 0.45rem;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.18));
    background: transparent;
    color: inherit;
    font-size: 0.86rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.bi-btn:hover {
    border-color: var(--accent, #2c5282);
}

.bi-btn.is-active {
    background: var(--accent, #2c5282);
    border-color: var(--accent, #2c5282);
    color: #fff;
}

.bi-tip {
    font-size: 0.84rem;
    color: var(--ink-muted, #6c757d);
}

/* Column headings */
.bi-col-headers {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.75rem;
    padding-inline: 0.75rem;
    padding-block-end: 0.55rem;
    margin-block-end: 0.5rem;
    border-block-end: 2px solid var(--border-color, rgba(0, 0, 0, 0.12));
    font-size: 0.84rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-muted, #6c757d);
}

.bi-col-head-target {
    order: 1;
}

.bi-col-head-en {
    order: 2;
}

.bi-swapped .bi-col-head-target {
    order: 2;
}

.bi-swapped .bi-col-head-en {
    order: 1;
}

/* Paragraph pair rows */
.bi-rows {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.bi-pair {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.75rem;
    padding: 0.85rem 0.75rem;
    border-radius: 0.5rem;
    border-block-end: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.06));
    transition: background-color 0.12s ease;
}

.bi-pair:hover {
    background: rgba(44, 82, 130, 0.045);
}

.bi-cell {
    font-family: var(--reader-font, var(--font-serif, Georgia, serif));
    font-size: calc(1.06rem * var(--reader-scale, 1));
    line-height: 1.75;
    margin: 0;
    text-align: start;
}

.bi-cell-target {
    order: 1;
}

.bi-cell-en {
    order: 2;
    color: var(--ink-soft, #3a3a3a);
}

.bi-swapped .bi-cell-target {
    order: 2;
}

.bi-swapped .bi-cell-en {
    order: 1;
}

.bi-cell-target[dir="rtl"] {
    font-family: 'Frank Ruhl Libre', 'Assistant', Georgia, serif;
    font-size: calc(1.12rem * var(--reader-scale, 1));
}

.bi-num {
    display: inline-block;
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 0.72rem;
    color: var(--ink-muted, #888);
    text-decoration: none;
    margin-inline-end: 0.45rem;
    vertical-align: 0.12em;
    opacity: 0.65;
}

.bi-num:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Tap-to-peek mode: blur the translation cell until clicked/focused */
.bi-peek .bi-cell-en {
    cursor: pointer;
    border-radius: 0.35rem;
    padding-inline: 0.45rem;
    transition: filter 0.18s ease, opacity 0.18s ease, background-color 0.18s ease;
}

.bi-peek .bi-cell-en:not(.is-revealed) {
    filter: blur(5.5px);
    opacity: 0.45;
    user-select: none;
}

.bi-peek .bi-cell-en:not(.is-revealed):hover {
    opacity: 0.62;
}

.bi-peek .bi-cell-en.is-revealed {
    filter: none;
    opacity: 1;
    background: rgba(44, 82, 130, 0.05);
}

/* Cross-links on regular story & chapter pages */
.bilingual-link-bar {
    font-size: 0.92rem;
    margin-block: 0.4rem 0.6rem;
    color: var(--ink-muted, #555);
}

.bilingual-link-bar a {
    font-weight: 500;
}

/* Bilingual chapter list cards */
.bi-chapter-card {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem 1rem;
    border-radius: 0.55rem;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.11));
    background: var(--card-bg, rgba(255, 255, 255, 0.65));
    color: inherit;
    text-decoration: none;
    margin-block-end: 0.55rem;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.bi-chapter-card:hover {
    border-color: var(--accent, #2c5282);
    background: rgba(44, 82, 130, 0.05);
}

.bi-chapter-titles {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.bi-chapter-target {
    font-weight: 600;
}

.bi-chapter-en {
    font-size: 0.9rem;
    color: var(--ink-muted, #555);
}

/* Dark mode & sepia integration */
.dark-mode .bi-toolbar {
    background: #1e2024;
    border-color: rgba(255, 255, 255, 0.12);
}

.dark-mode .bi-pair-card,
.dark-mode .bi-book-card,
.dark-mode .bi-chapter-card,
.dark-mode .bi-pair-pill {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.12);
}

.dark-mode .bi-pair:hover {
    background: rgba(255, 255, 255, 0.04);
}

.dark-mode .bi-cell-en,
.dark-mode .bi-book-en,
.dark-mode .bi-intro {
    color: #c9cdd4;
}

.dark-mode .bi-eyebrow,
.dark-mode .bi-subtitle,
.dark-mode .bi-book-meta,
.dark-mode .bi-col-headers,
.dark-mode .bi-tip,
.dark-mode .bi-chapter-en,
.dark-mode .bilingual-link-bar {
    color: #9ba3b0;
}

.sepia .bi-toolbar {
    background: #f4ecd8;
}

/* Responsive mobile stacking */
@media (max-width: 767.98px) {
    .bi-col-headers {
        display: none;
    }

    .bi-pair {
        grid-template-columns: 1fr;
        gap: 0.55rem;
        padding: 0.85rem 0.65rem;
        border: 1px solid var(--border-color, rgba(0, 0, 0, 0.09));
        margin-block-end: 0.5rem;
    }

    .bi-cell-en {
        padding-block-start: 0.45rem;
        border-block-start: 1px dashed var(--border-color, rgba(0, 0, 0, 0.12));
        font-size: calc(0.98rem * var(--reader-scale, 1));
    }

    .bi-toolbar {
        top: 3.4rem;
    }
}
