/**
 * App shell — the top app bar and the navigation drawer of the public site.
 *
 * Replaces the AdminLTE navbar + sidebar (the admin area still uses AdminLTE).
 * Everything here follows the reading theme's variables, so the bar and the
 * drawer turn sepia/dark/black together with the page.
 *
 * Two rules matter more than they look:
 *  - The app bar hides by moving `top`, never with `transform`/`filter`: the
 *    Go To sheet and the text settings sheet are `position: fixed` children
 *    of the bar, and a transform would make the bar their containing block.
 *  - Nothing here changes the width of the content, so showing and hiding
 *    the chrome never reflows the text (that was why auto-hide was turned off).
 */

:root {
    --gb-appbar-h: 56px;
    --gb-hover: color-mix(in srgb, currentColor 9%, transparent);
    --gb-ease: cubic-bezier(0.2, 0, 0, 1);
}

body.gb-shell {
    padding-top: var(--gb-appbar-h);
}

/* The page behind the cards follows the reading theme too (beats Bootstrap's
   !important bg-body-tertiary utility on <body>). */
body.gb-shell:is(.theme-sepia, .theme-sage, .theme-stone, .theme-dark, .theme-black) {
    background-color: var(--bible-bg-primary) !important;
    color: var(--bible-text-primary);
}

/* ── App bar ─────────────────────────────────────────────────────────── */

.gb-appbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1040;
    height: var(--gb-appbar-h);
    background: var(--bible-bg-card, #fff);
    color: var(--bible-text-primary);
    border-bottom: 1px solid var(--bible-border);
    transition: top 0.25s var(--gb-ease);
}

body.chrome-hidden .gb-appbar {
    top: calc(-1 * var(--gb-appbar-h) - 2px);
}

.gb-appbar-inner {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 100%;
    padding: 0 8px;
}

.gb-icon-btn {
    flex: 0 0 auto;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    font-size: 1.25rem;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s;
}

.gb-icon-btn:hover,
.gb-icon-btn[aria-expanded="true"] {
    background: var(--gb-hover);
    color: inherit;
}

.gb-icon-btn:focus-visible,
.gb-passage-btn:focus-visible,
.gb-version-chip:focus-visible,
.gb-drawer-link:focus-visible {
    outline: 2px solid var(--bible-accent);
    outline-offset: 2px;
}

.gb-icon-btn.is-active {
    color: var(--bible-accent-dark);
}

/* Something is playing: a small dot on the Listen button. */
.gb-icon-btn.is-live::after {
    content: "";
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bible-accent);
    box-shadow: 0 0 0 2px var(--bible-bg-card, #fff);
}

.gb-aa {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.gb-aa small {
    font-size: 0.8em;
}

.gb-appbar-brand {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 8px 0 2px;
    color: inherit;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.01em;
    text-decoration: none;
}

.gb-appbar-brand:hover {
    color: inherit;
}

.gb-appbar-brand img {
    width: 28px;
    height: 28px;
    border-radius: 7px;
}

.gb-appbar-passage {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    justify-content: center;
}

.gb-appbar-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 2px;
}

@media (max-width: 991.98px) {
    .gb-appbar .gb-appbar-brand-text { display: none; }
}

@media (max-width: 767.98px) {
    .gb-appbar-inner { gap: 2px; padding: 0 4px; }
    .gb-appbar .gb-appbar-brand { display: none; }
    .gb-appbar-passage { justify-content: flex-start; }
}

/* ── Passage + version (the bible-navigation component) ──────────────── */

.gb-passage {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    max-width: 560px;
}

.gb-passage-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    height: 40px;
    padding: 0 12px 0 14px;
    border: 1px solid var(--bible-border);
    border-radius: 999px;
    background: var(--bible-bg-secondary);
    color: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

.gb-passage-btn:hover {
    border-color: var(--bible-accent);
}

.gb-passage-book {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gb-passage-chapter {
    flex: 0 0 auto;
}

.gb-passage-btn .bi {
    flex: 0 0 auto;
    font-size: 0.7rem;
    opacity: 0.65;
}

.gb-version-chip {
    flex: 0 0 auto;
    max-width: 6.5rem;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--bible-border);
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font-weight: 700;
    font-size: 0.78rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

.gb-version-chip:hover {
    border-color: var(--bible-accent);
    background: var(--gb-hover);
}

.gb-passage-alert {
    position: fixed;
    top: calc(var(--gb-appbar-h) + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: min(560px, calc(100vw - 16px));
    z-index: 1;
}

@media (max-width: 767.98px) {
    .gb-passage { gap: 4px; }
    .gb-passage-btn { height: 38px; padding: 0 10px 0 12px; font-size: 0.9rem; gap: 4px; }
    .gb-version-chip { max-width: 4.5rem; padding: 0 7px; font-size: 0.72rem; }
}

/* ── Overflow menu ────────────────────────────────────────────────────── */

.gb-appbar .dropdown-menu {
    min-width: 220px;
    padding: 6px;
    border: 1px solid var(--bible-border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}

.gb-appbar .dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 8px;
}

.gb-appbar .dropdown-item .bi {
    width: 1.1rem;
    text-align: center;
    opacity: 0.8;
}

/* ── Text settings ("Aa") panel ──────────────────────────────────────── */

.reading-settings-container {
    position: static;
}

.reading-settings-panel {
    position: fixed;
    top: calc(var(--gb-appbar-h) + 8px);
    right: 8px;
    left: auto;
    bottom: auto;
    z-index: 2;
    width: 360px;
    min-width: 0;
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - var(--gb-appbar-h) - 24px);
    max-height: calc(100dvh - var(--gb-appbar-h) - 24px);
    margin: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    color: var(--bible-text-primary);
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.reading-settings-header {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--bible-bg-card, #fff);
}

.reading-settings-scrim {
    display: none;
}

@media (max-width: 768px) {
    .reading-settings-panel {
        top: auto;
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        max-height: 75vh;
        max-height: 75dvh;
        border-radius: 20px 20px 0 0;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .reading-settings-scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1;
        background: rgba(0, 0, 0, 0.35);
    }
}

/* ── Navigation drawer ───────────────────────────────────────────────── */

.gb-drawer-scrim {
    position: fixed;
    inset: 0;
    z-index: 1045;
    background: rgba(0, 0, 0, 0.4);
}

.gb-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1046;
    display: flex;
    flex-direction: column;
    width: min(320px, 86vw);
    padding-top: env(safe-area-inset-top);
    background: var(--bible-bg-card, #fff);
    color: var(--bible-text-primary);
    box-shadow: 0 0 32px rgba(0, 0, 0, 0.2);
    border-radius: 0 16px 16px 0;
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform 0.28s var(--gb-ease), visibility 0s linear 0.28s;
}

.gb-drawer.is-open {
    transform: none;
    visibility: visible;
    transition: transform 0.28s var(--gb-ease);
}

.gb-drawer-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--gb-appbar-h);
    padding: 0 8px 0 18px;
}

.gb-drawer-head .gb-appbar-brand {
    margin: 0;
    flex: 1 1 auto;
}

.gb-drawer-body {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 10px 16px;
}

.gb-drawer-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 4px 6px;
    padding: 12px;
    border-radius: 14px;
    background: var(--bible-bg-secondary);
    color: inherit;
    text-decoration: none;
}

.gb-drawer-user:hover {
    color: inherit;
    background: color-mix(in srgb, var(--bible-bg-secondary) 85%, currentColor);
}

.gb-drawer-user-text {
    min-width: 0;
    line-height: 1.25;
}

.gb-drawer-user-name {
    display: block;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gb-drawer-user-sub {
    display: block;
    font-size: 0.8rem;
    color: var(--bible-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gb-avatar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bible-primary);
    color: #fff;
    font-weight: 700;
}

.gb-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gb-drawer-signin {
    display: flex;
    gap: 8px;
    margin: 0 4px 6px;
}

.gb-drawer-signin .btn {
    flex: 1 1 0;
    border-radius: 999px;
    font-weight: 600;
}

.gb-drawer-signin .btn-primary {
    --bs-btn-bg: var(--bible-primary);
    --bs-btn-border-color: var(--bible-primary);
    --bs-btn-hover-bg: var(--bible-primary-light);
    --bs-btn-hover-border-color: var(--bible-primary-light);
    --bs-btn-active-bg: var(--bible-primary-dark);
    --bs-btn-active-border-color: var(--bible-primary-dark);
}

.gb-drawer-section {
    padding: 16px 16px 6px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bible-text-secondary);
}

.gb-drawer-link {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 44px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    transition: background-color 0.15s;
}

.gb-drawer-link:hover {
    color: inherit;
    background: var(--gb-hover);
}

.gb-drawer-link .bi {
    flex: 0 0 auto;
    width: 1.25rem;
    font-size: 1.15rem;
    text-align: center;
    opacity: 0.8;
}

.gb-drawer-link.is-active {
    background: color-mix(in srgb, var(--bible-accent) 20%, transparent);
    font-weight: 700;
}

.gb-drawer-link.is-active .bi {
    opacity: 1;
}

.gb-drawer-count {
    margin-left: auto;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--bible-bg-secondary);
    font-size: 0.75rem;
    font-weight: 600;
}

.gb-drawer-foot {
    flex: 0 0 auto;
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--bible-border);
    font-size: 0.75rem;
    color: var(--bible-text-secondary);
}

.gb-drawer-foot a {
    color: inherit;
}

/* A platform with no link yet: present, but plainly not clickable. */
.gb-drawer-link.is-soon {
    cursor: default;
    color: var(--bible-text-secondary);
}

.gb-drawer-link.is-soon:hover {
    background: transparent;
}

.gb-drawer-link.is-soon .gb-drawer-count {
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ── Footer ───────────────────────────────────────────────────────────── */

body.gb-shell .app-footer.gb-footer {
    padding: 0;
    border-top: 1px solid var(--bible-border);
    background: var(--bible-bg-secondary);
    color: var(--bible-text-secondary);
    font-size: 0.875rem;
}

.gb-footer-inner {
    max-width: 72rem;
    margin-inline: auto;
    padding: 40px 24px calc(20px + env(safe-area-inset-bottom));
}

.gb-footer-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
}

@media (min-width: 768px) {
    .gb-footer-top {
        grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr);
        gap: 48px;
    }
}

.gb-footer-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--bible-text-primary);
    font-size: 1.1rem;
    font-weight: 700;
    text-decoration: none;
}

.gb-footer-logo:hover {
    color: var(--bible-text-primary);
}

.gb-footer-tagline {
    max-width: 24rem;
    margin: 12px 0 20px;
    line-height: 1.55;
}

.gb-footer-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.gb-footer-badges a {
    display: inline-flex;
    border-radius: 8px;
    transition: transform 0.15s var(--gb-ease), opacity 0.15s;
}

.gb-footer-badges a:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.gb-footer-badges img {
    display: block;
    width: auto;
    height: 40px;
}

.gb-footer-cols {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px 24px;
}

@media (min-width: 576px) {
    .gb-footer-cols {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.gb-footer-col {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

.gb-footer-col h2 {
    margin: 0 0 4px;
    color: var(--bible-text-primary);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.gb-footer a:not(.gb-footer-logo) {
    color: inherit;
    text-decoration: none;
}

.gb-footer-col a:hover,
.gb-footer-bottom a:hover {
    color: var(--bible-text-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.gb-footer-bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px 24px;
    margin-top: 36px;
    padding-top: 20px;
    border-top: 1px solid var(--bible-border);
    font-size: 0.8rem;
    line-height: 1.6;
}

.gb-footer-assoc {
    display: block;
}

.gb-footer-legal {
    display: flex;
    gap: 20px;
}

/* ── Reader surface ───────────────────────────────────────────────────── */

/* A quiet page rather than an admin card; edge to edge on phones. */
.reader-card {
    border: 0;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

@media (max-width: 767.98px) {
    .app-content:has(.reader-card),
    .app-content > .container-fluid:has(.reader-card) {
        padding-left: 0;
        padding-right: 0;
    }

    .reader-card {
        border-radius: 0;
        box-shadow: none;
    }
}

/* A readable line length on wide screens (about 70 characters). */
@media (min-width: 992px) {
    .reader-card > .verses-container {
        width: 100%;
        max-width: 48rem;
        margin-inline: auto;
        padding-block: 2rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gb-appbar,
    .gb-drawer,
    .gb-drawer.is-open {
        transition: none;
    }
}
