/* ============================================================
   Theologians Bible — shared app-shell polish (NT + OT readers)
   Visual refinement inside the existing dark/gold Byzantine style,
   plus app-quality mobile ergonomics.
   ============================================================ */

:root { --tb-bar-h: 58px; }

/* ---- reader refinement (all viewports) ---- */
.verse-block {
  contain: content;
  border-radius: 6px;
  transition: background .18s ease, box-shadow .18s ease;
}
.verse-block.has-commentary .v-num {
  color: var(--gold);
  text-shadow: 0 0 8px rgba(201, 162, 77, .35);
}
.chapter-heading { letter-spacing: .04em; }

/* skeleton shown until the deferred Scripture data executes */
#verse-list:empty::before {
  content: 'Loading the Holy Scriptures…';
  display: block;
  padding: 2.4rem 1rem;
  color: var(--text-faint, #5a5040);
  font-style: italic;
  animation: tb-pulse 1.2s ease-in-out infinite;
}
@keyframes tb-pulse {
  0%, 100% { opacity: .4; }
  50% { opacity: 1; }
}

/* search results dropdown */
.scripture-search-results.open {
  box-shadow: 0 18px 50px rgba(0, 0, 0, .65);
  border-radius: 10px;
  overflow: hidden;
}
.scripture-search-result { transition: background .15s ease; }
.scripture-search-result:hover { background: rgba(201, 162, 77, .08); }

/* the fixed bottom bar exists on mobile only */
.tb-bottom-bar { display: none; }

/* ---- mobile app shell ---- */
@media (max-width: 960px) {
  html { -webkit-text-size-adjust: 100%; }
  body { -webkit-tap-highlight-color: rgba(201, 162, 77, .16); }

  .tb-bottom-bar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 220;
    grid-template-columns: repeat(5, 1fr);
    background: rgba(8, 8, 8, .97);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--gold-border, rgba(201, 162, 77, .2));
    padding: 5px 6px calc(5px + env(safe-area-inset-bottom));
  }
  body.tb-bar-on .tb-bottom-bar { display: grid; }
  body.tb-bar-on { padding-bottom: calc(var(--tb-bar-h) + env(safe-area-inset-bottom)); }

  /* the bar replaces the legacy floating commentary pill and the big
     in-flow chapter arrows on mobile */
  body.tb-bar-on #sidebar-toggle-btn { display: none !important; }
  body.tb-bar-on #page-scripture .chapter-arrow { display: none !important; }

  /* compact the reader controls: search input on its own line, then
     Search / settings / audio / speed sharing one row */
  body.tb-bar-on #page-scripture .scripture-search {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto auto auto !important;
    gap: .45rem !important;
    align-items: center !important;
  }
  body.tb-bar-on #page-scripture .scripture-search input[type="search"] {
    grid-column: 1 / -1 !important;
    height: 46px !important;
    min-height: 46px !important;
    max-height: none !important;
    border-radius: 10px !important;
  }
  body.tb-bar-on #page-scripture .scripture-search > button:not(.gear-btn):not(.audio-play-btn) {
    grid-column: 1 / 2 !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 44px !important;
    min-height: 44px !important;
    max-height: none !important;
    border-radius: 10px !important;
  }
  /* OT page: the audio toggle is a direct child rather than wrapped */
  body.tb-bar-on #page-scripture .scripture-search > button.audio-play-btn {
    grid-column: 3 / 4 !important;
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    max-height: none !important;
    border-radius: 10px !important;
  }
  body.tb-bar-on #page-scripture .scripture-search .gear-btn {
    grid-column: 2 / 3 !important;
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    max-height: none !important;
    border-radius: 10px !important;
  }
  body.tb-bar-on #page-scripture .scripture-search [class*="audio-language-wrap"] {
    grid-column: 3 / 4 !important;
    width: auto !important;
  }
  body.tb-bar-on #page-scripture .scripture-search [class*="audio-speed-select"] {
    grid-column: 4 / 5 !important;
    width: auto !important;
    min-width: 66px !important;
    max-width: none !important;
    height: 44px !important;
    min-height: 44px !important;
    border-radius: 10px !important;
  }
  body.tb-bar-on #page-scripture .scripture-search [class*="audio-status"],
  body.tb-bar-on #page-scripture .scripture-search .scripture-search-results {
    grid-column: 1 / -1 !important;
  }
  body.tb-bar-on #page-scripture .scripture-search [class*="audio-status"]:empty {
    display: none !important;
  }
  body.tb-bar-on #page-scripture .sel-row select.translation-select {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    max-width: none !important;
  }

  .tb-bar-btn {
    appearance: none;
    background: none;
    border: 0;
    color: var(--text-dim, #a09880);
    font-family: var(--cinzel, serif);
    font-size: .55rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 2px;
    min-height: 48px;
    cursor: pointer;
    text-decoration: none;
    border-radius: 10px;
  }
  .tb-bar-btn .tb-ico { font-size: 1.2rem; line-height: 1; }
  .tb-bar-btn.active,
  .tb-bar-btn:active { color: var(--gold, #C9A24D); background: rgba(201, 162, 77, .08); }

  /* comfortable touch targets */
  .sel-row select,
  .scripture-search input,
  .scripture-search button { min-height: 44px; }
  .book-tab { padding: .6rem .9rem !important; min-height: 42px; }
  .chapter-arrow { min-width: 44px; min-height: 44px; }
  .verse-block { padding: .55rem .6rem; }

  /* modals become bottom sheets */
  .settings-modal-overlay,
  .modal-overlay { align-items: flex-end !important; }
  .settings-modal,
  .modal {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    border-radius: 18px 18px 0 0 !important;
    padding-bottom: calc(1.4rem + env(safe-area-inset-bottom)) !important;
    max-height: 85vh;
    overflow: auto;
    animation: tb-sheet-up .28s cubic-bezier(.32, .72, .35, 1);
  }
  @keyframes tb-sheet-up {
    from { transform: translateY(48px); opacity: .4; }
    to { transform: none; opacity: 1; }
  }

  .scripture-sidebar { overscroll-behavior: contain; }
  .mobile-nav,
  .mobile-nav-drawer { padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }

  /* ---- Holy Father commentary as a bottom sheet ---- */
  body.tb-bar-on #page-scripture .scripture-layout.commentary-open {
    display: block !important;
    grid-template-columns: 1fr !important;
  }
  body.tb-bar-on #page-scripture .scripture-layout.commentary-open .scripture-main {
    width: 100% !important;
    border-right: 0 !important;
  }
  body.tb-bar-on #page-scripture .scripture-layout.commentary-open .scripture-sidebar {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: calc(var(--tb-bar-h) + env(safe-area-inset-bottom)) !important;
    width: 100% !important;
    height: min(72vh, 620px) !important;
    max-height: none !important;
    z-index: 210 !important;
    background: rgba(10, 10, 9, .98) !important;
    border-top: 1px solid var(--gold-border, rgba(201, 162, 77, .2)) !important;
    border-radius: 18px 18px 0 0 !important;
    overflow: auto !important;
    padding: .65rem 1.1rem 1.2rem !important;
    box-shadow: 0 -18px 50px rgba(0, 0, 0, .6) !important;
    animation: tb-sheet-up .3s cubic-bezier(.32, .72, .35, 1);
  }
  body.tb-bar-on #page-scripture .scripture-layout.commentary-open .scripture-sidebar::before {
    content: '';
    display: block;
    width: 44px;
    height: 4px;
    border-radius: 2px;
    background: rgba(201, 162, 77, .45);
    margin: .2rem auto .9rem;
  }
  .tb-sheet-close {
    display: none;
    position: sticky;
    top: 0;
    float: right;
    margin: 0 0 .4rem .6rem;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--gold-border, rgba(201, 162, 77, .25));
    background: rgba(20, 18, 12, .9);
    color: var(--gold, #C9A24D);
    font-size: .95rem;
    line-height: 1;
    cursor: pointer;
    z-index: 5;
  }
  body.tb-bar-on #page-scripture .scripture-layout.commentary-open .scripture-sidebar .tb-sheet-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}
