/* ==========================================================================
   UECF.NET — The Prayer Bible
   PDF reading-app stylesheet. Shares UECF.NET's site palette (navy / gold /
   cream / maroon / teal, Fraunces + Source Sans 3) and reading-app
   conventions already established by /study-bible/ (sticky header, mobile
   app bar, dark/light theme via [data-theme], font tokens) so the Prayer
   Bible feels like part of the same family of Bible readers.
   ========================================================================== */

:root {
  /* UECF.NET brand tokens (matches /study-bible/) */
  --ink: #101B31;
  --ink-soft: #2C3E60;
  --gold: #C79A3D;
  --gold-soft: #E4C685;
  --maroon: #8B3A42;
  --teal: #2F5D62;

  --paper: #FAF6EC;
  --paper-2: #F0E7D5;
  --paper-3: #E9DFC8;
  --text: #201A10;
  --text-2: #4A4239;
  --text-3: #7A6F61;
  --line: #E2D8C0;
  --line-2: #CFC2A0;
  --focus: #1d4ed8;
  --shadow: 0 1px 2px rgba(16,27,49,.08), 0 8px 24px rgba(16,27,49,.10);
  --shadow-lg: 0 4px 12px rgba(16,27,49,.14), 0 24px 56px rgba(16,27,49,.20);

  /* PDF stage — a distinct, slightly darker surface so pages read like paper
     resting on a desk rather than blending into the page chrome */
  --stage: #E7DEC9;
  --stage-2: #DED2B4;
  --page-shadow: 0 2px 6px rgba(16,27,49,.14), 0 18px 40px rgba(16,27,49,.22);

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --wrap: 1280px;
  --radius: 10px;
  color-scheme: light;
}

[data-theme="dark"] {
  --paper: #12100C;
  --paper-2: #1A1712;
  --paper-3: #241F17;
  --text: #EFE8D8;
  --text-2: #C9BFA9;
  --text-3: #978C77;
  --line: #35301F;
  --line-2: #443C28;
  --gold-soft: #E8C765;
  --ink: #0B1220;
  --ink-soft: #182238;
  --focus: #93c5fd;
  --stage: #0B0A08;
  --stage-2: #0E0D0A;
  --page-shadow: 0 2px 10px rgba(0,0,0,.55), 0 24px 56px rgba(0,0,0,.6);
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 8px 24px rgba(0,0,0,.4);
  --shadow-lg: 0 4px 12px rgba(0,0,0,.55), 0 24px 56px rgba(0,0,0,.55);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  height: 100%;
}
html, body { height: 100%; }

img { max-width: 100%; height: auto; }
a { color: var(--maroon); }
[data-theme="dark"] a { color: var(--gold-soft); }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--gold); color: var(--ink); padding: 10px 18px; z-index: 300; font-weight: 700; border-radius: 0 0 6px 0; }
.skip-link:focus { left: 0; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0 0 .4em; line-height: 1.2; color: var(--text); }
button { font: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ---------------------------------------------------------------- header */
.pb-header { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 200; border-bottom: 3px solid var(--gold); }
.pb-header-inner { display: flex; align-items: center; gap: 16px; justify-content: space-between; max-width: var(--wrap); margin: 0 auto; padding: 8px 16px; }
.pb-brand { display: flex; align-items: center; gap: 12px; color: #fff; }
.pb-brand:hover { text-decoration: none; }
.pb-brand img { width: 38px; height: 38px; flex: none; }
.pb-brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.pb-brand-text strong { font-family: var(--font-display); font-size: 1.05rem; }
.pb-brand-text small { color: var(--gold-soft); font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.pb-header-nav { display: flex; align-items: center; gap: 4px; font-size: .88rem; }
.pb-header-nav a { color: #fff; padding: 8px 10px; border-radius: 5px; }
.pb-header-nav a:hover { background: rgba(228,198,133,.15); color: var(--gold-soft); text-decoration: none; }

/* compact mobile app bar — replaces the full header below 760px */
.pb-mobile-bar { display: none; }
.pb-mobile-home {
  flex: none; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: #fff; border-radius: 8px; text-decoration: none;
}
.pb-mobile-home:hover { background: rgba(228,198,133,.15); text-decoration: none; }
.pb-mobile-title {
  flex: 1; min-width: 0; text-align: center; font-family: var(--font-display); font-weight: 600;
  font-size: 1rem; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pb-mobile-more {
  flex: none; width: 36px; height: 36px; border-radius: 8px; border: none; background: none;
  color: #fff; font-size: 1.35rem; line-height: 1; cursor: pointer;
}
.pb-mobile-more:hover, .pb-mobile-more[aria-expanded="true"] { background: rgba(228,198,133,.15); color: var(--gold-soft); }

/* --------------------------------------------------------------- toolbar */
.pb-toolbar { background: var(--paper-2); border-bottom: 1px solid var(--line); position: sticky; top: 55px; z-index: 190; }
.pb-toolbar-inner { max-width: var(--wrap); margin: 0 auto; padding: 8px 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pb-input {
  font-family: var(--font-body); font-size: .9rem; color: var(--text); text-align: center;
  background: var(--paper); border: 1px solid var(--line-2); border-radius: 7px;
  padding: 8px 6px; min-height: 40px;
}
.pb-input:focus { border-color: var(--gold); }
.pb-nav-btns { display: flex; gap: 4px; }
.pb-btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2);
  background: var(--paper); color: var(--text); border-radius: 7px; padding: 8px 12px;
  cursor: pointer; min-height: 40px; min-width: 40px; justify-content: center; white-space: nowrap;
}
.pb-btn:hover { border-color: var(--gold); color: var(--maroon); }
.pb-btn:disabled { opacity: .4; cursor: default; }
.pb-btn:disabled:hover { border-color: var(--line-2); color: var(--text); }
.pb-btn[aria-pressed="true"] { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.pb-page-jump { display: flex; align-items: center; gap: 6px; font-size: .88rem; color: var(--text-2); }
.pb-page-jump form { display: flex; align-items: center; gap: 4px; }
#pbPageInput { width: 3.4em; }
.pb-tool-group { display: flex; align-items: center; gap: 4px; }
.pb-zoom-group { display: flex; align-items: center; gap: 2px; }
.pb-zoom-pct { font-size: .85rem; color: var(--text-2); min-width: 3.6em; text-align: center; }
.pb-spacer { flex: 1 1 auto; }
.pb-progress { height: 3px; background: var(--paper-3); position: relative; overflow: hidden; }
.pb-progress span { display: block; height: 100%; width: 0; background: var(--gold); transition: width .15s ease; }

/* ------------------------------------------------------------------ main */
main#main { display: flex; flex-direction: column; min-height: calc(100vh - 95px); }
.pb-stage {
  flex: 1; background: var(--stage);
  background-image: radial-gradient(ellipse at top, var(--stage-2), var(--stage));
  padding: 28px 16px 56px; display: flex; justify-content: center;
  overflow: auto; touch-action: pan-y pinch-zoom;
}
.pb-page-wrap { position: relative; margin: 0 auto; touch-action: pan-y pinch-zoom; }
.pb-canvas-shell { position: relative; background: #fff; box-shadow: var(--page-shadow); border-radius: 3px; line-height: 0; }
.pb-canvas-shell canvas { display: block; border-radius: 3px; }
.pb-text-layer {
  position: absolute; inset: 0; overflow: hidden; line-height: 1;
  -webkit-user-select: text; user-select: text;
}
.pb-text-layer span, .pb-text-layer br { position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; color: transparent; }
.pb-text-layer ::selection { background: rgba(199,154,61,.5); }

.pb-loading, .pb-error {
  margin: 20vh auto; text-align: center; color: var(--text-2); font-family: var(--font-body);
  max-width: 30rem; padding: 0 16px;
}
.pb-loading .pb-spinner {
  width: 34px; height: 34px; border-radius: 50%; margin: 0 auto 14px;
  border: 3px solid var(--line-2); border-top-color: var(--gold); animation: pb-spin 0.9s linear infinite;
}
@keyframes pb-spin { to { transform: rotate(360deg); } }
.pb-error h2 { color: var(--maroon); }
.pb-error code { background: var(--paper-3); padding: 2px 6px; border-radius: 4px; font-size: .85em; word-break: break-all; }

/* bottom reader bar: prev/next + page indicator, always visible */
.pb-reader-bar {
  position: sticky; bottom: 0; z-index: 150; background: var(--paper-2); border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; gap: 14px; padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0));
}
.pb-reader-bar .pb-btn { min-width: 96px; }
.pb-page-indicator { font-family: var(--font-display); font-weight: 600; color: var(--text); font-size: 1rem; min-width: 8em; text-align: center; }
.pb-page-indicator small { display: block; font-family: var(--font-body); font-weight: 400; font-size: .7rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }

/* footer */
.pb-footer { background: var(--ink); color: #E1E6F0; padding: 28px 16px; text-align: center; font-size: .85rem; }
.pb-footer a { color: var(--gold-soft); }

/* back to top */
.pb-to-top { position: fixed; right: 20px; bottom: 78px; width: 44px; height: 44px; border-radius: 50%; background: var(--gold); color: var(--ink); border: none; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s ease; font-size: 1.1rem; z-index: 140; }
.pb-to-top.show { opacity: 1; pointer-events: auto; }

/* "More" bottom sheet: sister Bible editions + Home */
.pb-sheet-backdrop { position: fixed; inset: 0; background: rgba(16,27,49,.5); z-index: 420; }
.pb-sheet-backdrop[hidden] { display: none; }
.pb-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 430; max-width: var(--wrap); margin: 0 auto;
  background: var(--paper); border-radius: 16px 16px 0 0; box-shadow: var(--shadow-lg);
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom, 0));
}
.pb-sheet[hidden] { display: none; }
.pb-sheet-handle { width: 36px; height: 4px; background: var(--line-2); border-radius: 2px; margin: 4px auto 14px; }
.pb-sheet h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--teal); margin-bottom: 8px; }
.pb-sheet-links { display: grid; gap: 2px; margin-bottom: 14px; }
.pb-sheet-links a, .pb-sheet-current { display: flex; align-items: center; gap: 10px; padding: 12px 10px; border-radius: 8px; font-size: .98rem; }
.pb-sheet-links a { color: var(--text); }
.pb-sheet-links a:hover { background: var(--paper-2); text-decoration: none; }
.pb-sheet-current { color: var(--text-3); }

/* --------------------------------------------------------------- responsive */
@media (max-width: 760px) {
  .pb-header { display: none; }
  .pb-mobile-bar {
    display: flex; align-items: center; gap: 6px; position: sticky; top: 0; z-index: 210;
    background: var(--ink); border-bottom: 3px solid var(--gold); padding: 8px 10px;
  }
  .pb-toolbar { top: 52px; }
  .pb-toolbar-inner { padding: 6px 10px; }
  .pb-input, .pb-btn { min-height: 38px; padding: 6px 9px; font-size: .85rem; }
  .pb-stage { padding: 16px 8px 40px; }
  .pb-reader-bar .pb-btn { min-width: 76px; padding: 8px; }
  .pb-page-indicator { font-size: .92rem; min-width: 6.5em; }
  .pb-to-top { bottom: 74px; right: 14px; }
}
@media (max-width: 420px) {
  .pb-zoom-pct { display: none; }
  .pb-page-jump span.pb-page-jump-label { display: none; }
}

/* ------------------------------------------------------------------ print */
@media print {
  .pb-header, .pb-mobile-bar, .pb-toolbar, .pb-reader-bar, .pb-footer, .pb-to-top, .pb-sheet, .pb-sheet-backdrop { display: none !important; }
  .pb-stage { background: #fff; padding: 0; }
  .pb-canvas-shell { box-shadow: none; }
}
