/* Installed-app shell (devotional-shell.js). Everything is scoped to .shell-active, which
   only the installed app on iOS and desktop gets, so a browser tab renders exactly as before. */

[data-shell-nav],
[data-shell-settings-header] {
    display: none;
}

.shell-active [data-shell-nav] {
    position: fixed;
    z-index: 50;
    display: flex;
    background: var(--surface);
    border: 0 solid var(--border);
}

.shell-active [data-shell-settings-header] {
    display: block;

    /* The page header is hidden, so the Settings title clears the status bar itself. */
    padding-top: calc(env(safe-area-inset-top) + 2rem);
}

.shell-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

.shell-tab:hover { color: var(--text); }

a.shell-tab { text-decoration: none; }

.shell-tab-icon,
.shell-tab svg {
    inline-size: 1.25rem;
    block-size: 1.25rem;
}

.shell-tab[aria-current="page"] { color: var(--accent); }

.shell-tab:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* Phone: bottom bar. */
.shell-active[data-shell-layout="bar"] [data-shell-nav] {
    inset: auto 0 0;
    border-top-width: 1px;
    padding-bottom: env(safe-area-inset-bottom);
}

.shell-active[data-shell-layout="bar"] .shell-tab {
    flex: 1;
    flex-direction: column;
    min-height: 3.5rem;
}

.shell-active[data-shell-layout="bar"] body { padding-bottom: calc(3.5rem + env(safe-area-inset-bottom)); }

/* Tablet and desktop: labelled rail. In landscape the iPhone cutout and status bar sit under it, so it
   grows by the inset on its own (start) edge and drops below the top inset. */
.shell-active[data-shell-layout="rail"] { --shell-rail-inset: env(safe-area-inset-left); }

.shell-active[dir="rtl"][data-shell-layout="rail"] { --shell-rail-inset: env(safe-area-inset-right); }

.shell-active[data-shell-layout="rail"] [data-shell-nav] {
    inset-block: 0;
    inset-inline: 0 auto;
    width: calc(12rem + var(--shell-rail-inset));
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.25rem;
    padding: calc(1rem + env(safe-area-inset-top)) 0.5rem 1rem;
    padding-inline-start: calc(0.5rem + var(--shell-rail-inset));
    border-inline-end-width: 1px;
}

.shell-active[data-shell-layout="rail"] .shell-tab {
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.9375rem;
}

.shell-active[data-shell-layout="rail"] .shell-tab[aria-current="page"] { background: var(--accent-soft); }

.shell-active[data-shell-layout="rail"] body { padding-inline-start: calc(12rem + var(--shell-rail-inset)); }

/* The reading column: capped and a single column. The page's own two-column grid (md:grid) is keyed
   to the viewport width, which the rail has already narrowed, so beside the rail it would squeeze the
   sidebar into a few hundred px; one column in DOM order is also the phone reading order. */
.shell-active main,
.shell-active [data-shell-settings] {
    max-width: var(--shell-content-max, 720px);
    margin-inline: auto;
}

.shell-active #font-scope { display: block; }

/* One tab at a time. */
.shell-active[data-shell-view="home"] [data-shell-settings] { display: none; }

.shell-active[data-shell-view="settings"] main { display: none; }

/* The browser-tab header links to Studies; the installed app has the Studies tab in its bar instead. */
.shell-active #nav-studies-item, .shell-active #nav-encounters-item { display: none; }

/* The font toggle moved to Settings, which leaves only the Bible version under this heading. */
.shell-active #reading-options-label { display: none; }

/* Google Play is for Android, which has no installed web app. */
.shell-active #app-banner,
.shell-active #download-app-android-btn { display: none; }

.shell-settings-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
}

/* The Settings tab is a plain list of rows, like the app's settings page: a label on one side, the
   control on the other. The footer belongs to the reading page and is hidden here. */
.shell-active[data-shell-view="settings"] #page-footer { display: none; }

.settings-list {
    max-width: var(--shell-content-max, 720px);
    padding-bottom: 2rem;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 0;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 1.05rem;
}

/* On a phone the language list is a scrollable sheet that ends just above the bottom bar. As the page's own
   dropdown it opens downwards from the row and ran under the bar, so the last languages could not be reached.
   i18n.js builds the dropdown with utility classes (absolute top-full left-0 right-0 overflow-hidden), so this
   rule must stay more specific than a single class: the e2e spec "every language can be chosen" guards it. */
.shell-active[data-shell-layout="bar"] .language-dropdown {
    position: fixed;
    inset-inline: 1rem;
    top: auto;
    bottom: calc(3.5rem + env(safe-area-inset-bottom) + 0.5rem);
    margin-top: 0;
    max-height: calc(100vh - 12rem);
    max-height: calc(100dvh - 12rem);
    overflow-y: auto;
}

/* On a tablet or desktop rail the list opens under the language button, which sits at the end of its row. The page's
   own left-0 would open it from the button's start edge, and its 160px minimum width then ran past the screen
   edge even while closed. Opening from the end edge keeps it inside the row, in both text directions. */
.shell-active[data-shell-layout="rail"] .language-dropdown {
    inset-inline: auto 0;
}

/* The three controls moved in from the header and the reading page exist only inside the installed app. */
[data-shell-slot] { display: none; }
.shell-active [data-shell-slot] { display: flex; }

/* The installed app has its own bottom bar and Settings title, so the page header (brand and nav link) is
   hidden there. The nodes stay in the DOM: scripts still read their ids, and a browser tab is unchanged. */
.shell-active .site-nav { display: none; }

[data-app-version-row] { display: none; }
.shell-active [data-app-version-row] { display: flex; }
[data-app-version], [data-app-build] { font-variant-numeric: tabular-nums; }

.settings-build {
    margin-inline-start: 0.4rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}
.settings-build:not(:empty)::before { content: "\00b7\00a0"; }

.settings-switch {
    position: relative;
    flex: none;
    width: 3.25rem;
    height: 2rem;
    border: 0;
    border-radius: 1rem;
    background: var(--border);
    cursor: pointer;
    transition: background 0.15s;
}

.settings-switch::after {
    content: '';
    position: absolute;
    top: 0.25rem;
    inset-inline-start: 0.25rem;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    transition: inset-inline-start 0.15s;
}

.settings-switch[aria-checked="true"] { background: var(--accent); }

.settings-switch[aria-checked="true"]::after { inset-inline-start: 1.5rem; }

.settings-switch:disabled {
    opacity: 0.6;
    cursor: progress;
}

.settings-switch:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* The whole row is the target: the real select sits invisibly over it, so a tap opens the phone's own picker. */
.settings-time {
    position: relative;
    justify-content: flex-start;
    cursor: pointer;
}

.settings-time .settings-label { flex: 1; }

.settings-time .settings-icon,
.settings-time .settings-value { color: var(--accent); }

.settings-time .settings-value { font-weight: 600; }

.settings-chevron {
    flex: none;
    color: var(--text-muted);
}

[dir="rtl"] .settings-chevron { transform: scaleX(-1); }

.settings-time.is-off { opacity: 0.5; }

.settings-time select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.settings-time select:disabled { cursor: default; }

.settings-time:focus-within {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.settings-status {
    min-height: 1.25rem;
    padding-top: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.settings-status:empty { display: none; }

/* First-launch notification offer on Home (installed app only; revealed by devotional-push-offer.js). */
.push-offer {
    margin: 1rem 0 1.5rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    color: var(--text);
}

.push-offer-title {
    margin: 0 0 0.25rem;
    font-size: 1.05rem;
    font-weight: 700;
}

.push-offer-body {
    margin: 0 0 0.9rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}

.push-offer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

/* Home in the installed app on a phone: the hero runs edge to edge and up under the status bar (the page
   header is hidden above), with a round share button floating in its top-right corner. Tablet and desktop
   keep the card, because their rail would shift an edge-to-edge image. The share button keeps its id and its
   place in the DOM, so a cached older script still finds it; only its position changes. */
.shell-active[data-shell-layout="bar"] #shell-home-panel { padding-top: 0; }

.shell-active[data-shell-layout="bar"] #devotional-content { position: relative; }

.shell-active[data-shell-layout="bar"] div:has(> #back-link) { display: none; }

.shell-active[data-shell-layout="bar"] .hero-devotional {
    position: relative;

    /* Cancels the page's side padding (px-4), so the hero spans the whole content width. */
    margin-inline: -1rem;
    height: min(calc(52vw + env(safe-area-inset-top)), 420px);
    aspect-ratio: auto;
    border: 0;
    border-radius: 0;
}

.shell-active[data-shell-layout="bar"] .hero-devotional::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 40%;
    background: linear-gradient(to bottom, transparent, var(--bg));
    pointer-events: none;
}

/* :not(.hidden) keeps the button hidden where the browser cannot share (devotional-render-dom.js hides it). */
.shell-active[data-shell-layout="bar"] #share-native:not(.hidden) {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 0.75rem);
    inset-inline-end: 0;
    z-index: 5;
    display: grid;
    width: 2.75rem;
    height: 2.75rem;
    place-items: center;
    border-radius: 50%;

    /* The button carries inline colors for the browser tab, so the installed app needs !important. */
    background: color-mix(in srgb, var(--surface) 72%, transparent) !important;
    color: var(--text) !important;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* The bottom share row is gone: its label and rule go with the button. */
.shell-active[data-shell-layout="bar"] #comparte-label { display: none; }
.shell-active[data-shell-layout="bar"] div:has(> #share-native) { display: contents; }
