/* ============================================================
   Bible Reader — Web Edition  |  Dark Parchment Theme
   Palette mirrors the C++/ImGui desktop app (colors.h)
   ============================================================ */

/* ---------------------------------------------------------------------------
   Custom properties (palette from colors.h)
   --------------------------------------------------------------------------- */
:root {
  --bg-dark:       #1a1714;   /* COL_BG_DARK      0.10 0.09 0.08 */
  --bg-panel:      #211e1a;   /* sidebar / toolbar background    */
  --bg-hover:      #2d2820;   /* subtle hover bg                 */
  --bg-active:     #352e23;   /* active / selected bg            */

  --text-body:     #e5dece;   /* COL_TEXT_BODY    0.90 0.87 0.80 */
  --text-dim:      #8a8070;   /* COL_TEXT_DIM     0.54 0.50 0.44 */
  --text-faint:    #4d4540;   /* very faint / disabled           */

  --gold:          #b79451;   /* COL_VERSE_NUM    0.72 0.58 0.32 */
  --gold-bright:   #c8a84b;   /* COL_GOLD_FRAME   dropcap ring   */
  --gold-dim:      #8b6914;   /* dark gold for dropcap bg        */
  --gold-border:   #6b5010;   /* outer ring                      */

  --separator:     #3a3228;   /* line / border colour            */
  --scrollbar:     #3a3228;

  --sidebar-w:     240px;
  --toolbar-h:     48px;
  --parallel-w:    320px;
  --reader-max:    760px;
  --font-body:     'EB Garamond', Georgia, serif;
  --font-heading:  'Pirata One', cursive;
  --font-verse-num:'Crimson Pro', Georgia, serif;
  --font-ui:       'Roboto', system-ui, sans-serif;
  --font-hebrew:   'Noto Serif Hebrew', serif;
  --font-size:     18px;
  --line-height:   1.2;
}

/* ---------------------------------------------------------------------------
   Reset / base
   --------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: var(--font-size); scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: var(--line-height);
  background: var(--bg-dark);
  color: var(--text-body);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }

/* ---------------------------------------------------------------------------
   Scrollbars (Webkit)
   --------------------------------------------------------------------------- */
::-webkit-scrollbar            { width: 6px; }
::-webkit-scrollbar-track      { background: var(--bg-dark); }
::-webkit-scrollbar-thumb      { background: var(--scrollbar); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover{ background: var(--gold-border); }

/* ---------------------------------------------------------------------------
   Sidebar
   --------------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--separator);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.2s ease;
  z-index: 90;
}

.sidebar-inner {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 2rem;
}

.toolbar-trans {
  flex-shrink: 0;
}
.toolbar-trans .trans-select {
  width: auto;
  max-width: 160px;
}

.trans-select {
  background: var(--bg-dark);
  color: var(--text-body);
  border: 1px solid var(--separator);
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  cursor: pointer;
  outline: none;
}
.trans-select:focus { border-color: var(--gold-border); }

/* Testament tabs */
.testament-tabs {
  display: flex;
  border-bottom: 1px solid var(--separator);
}
.testament-tabs .tab {
  flex: 1;
  text-align: center;
  padding: 0.4rem 0;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.testament-tabs .tab:hover { color: var(--text-body); }
.testament-tabs .tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* Section heading — doubles as a collapse toggle when .collapsible */
.sidebar-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.6rem 0.85rem 0.3rem;
  font-family: var(--font-ui);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-dim);
  user-select: none;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: color 0.12s;
}
.sidebar-section-head:hover { color: var(--gold); }
.sidebar-section-head.open  { color: var(--gold); }
.collapse-arrow { font-size: 0.55rem; opacity: 0.7; }

/* Book list */
.book-list {
  list-style: none;
  padding: 0 0 0.5rem;
}

.book-link {
  display: block;
  padding: 0.2rem 0.85rem;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--text-dim);
  transition: color 0.12s, background 0.12s;
  border-left: 2px solid transparent;
}
.book-link:hover {
  color: var(--text-body);
  background: var(--bg-hover);
}
.book-link.active {
  color: var(--gold);
  background: var(--bg-active);
  border-left-color: var(--gold);
}

/* ---------------------------------------------------------------------------
   Main layout
   --------------------------------------------------------------------------- */
.body-below {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
}

/* ---------------------------------------------------------------------------
   Toolbar
   --------------------------------------------------------------------------- */
.toolbar {
  flex-shrink: 0;
  z-index: 100;
  height: var(--toolbar-h);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--separator);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
}

.sidebar-toggle {
  display: none;    /* shown on mobile */
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  line-height: 1;
}
.sidebar-toggle:hover { color: var(--text-body); }

.toolbar-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--gold);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chapter-nav {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 4px;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-dim);
  transition: color 0.12s, background 0.12s;
  cursor: pointer;
}
.nav-btn:hover { color: var(--gold); background: var(--bg-hover); }
.nav-btn.disabled { color: var(--text-faint); cursor: default; }

.chapter-jump {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.ch-input {
  width: 3.2rem;
  text-align: center;
  background: var(--bg-dark);
  border: 1px solid var(--separator);
  border-radius: 4px;
  color: var(--text-body);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  padding: 0.2rem 0.3rem;
  outline: none;
  -moz-appearance: textfield;
}
.ch-input::-webkit-outer-spin-button,
.ch-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.ch-input:focus { border-color: var(--gold-border); }
.ch-of {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--text-faint);
}

.layout-toggle {
  display: flex;
  border: 1px solid var(--separator);
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}
.layout-btn {
  background: none;
  border: none;
  border-right: 1px solid var(--separator);
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  padding: 0.25rem 0.55rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.12s, background 0.12s;
  line-height: 1;
}
.layout-btn:last-child { border-right: none; }
.layout-btn:hover { color: var(--text-body); background: var(--bg-hover); }
.layout-btn.active { color: var(--gold); background: var(--bg-active); }

.parallel-toggle {
  background: none;
  border: 1px solid var(--separator);
  border-radius: 4px;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.12s, border-color 0.12s;
}
.parallel-toggle:hover { color: var(--text-body); border-color: var(--gold-border); }
.parallel-toggle.active { color: var(--gold); border-color: var(--gold); }

/* ---------------------------------------------------------------------------
   Reader area
   --------------------------------------------------------------------------- */
.reader {
  flex: 1;
  padding: 2.5rem 2rem 4rem;
  max-width: calc(var(--reader-max) + 4rem);
  margin: 0 auto;
  width: 100%;
}

/* Columnar layout (non-strongs translations) */
.reader.columns {
  max-width: 1200px;
  column-count: 2;
  column-gap: 3rem;
  column-rule: 1px solid var(--separator);
}

/* KJV + Strong's side-by-side original language */
#reader-wrap {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: flex-start;
  flex-wrap: wrap;
}
#reader-wrap > #reader-heading {
  flex: 0 0 100%;
  padding: 2.5rem 2rem 0;
  margin-bottom: 0;
}
#reader-wrap[data-strongs] > #reader .chapter-heading {
  display: none;
}
#reader-wrap.has-orig > #reader {
  max-width: none;
  margin: 0;
  flex: 1;
  min-width: 0;
  border-right: 1px solid var(--separator);
  padding-top: 1.5rem;
}
.reader-orig {
  display: none;
  flex: 1;
  min-width: 0;
  padding: 2.5rem 2rem 4rem;
}
.reader-orig.orig-visible {
  display: block;
  padding-top: 1.5rem;
}
.orig-label {
  font-family: var(--font-ui, sans-serif);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
  opacity: 0.6;
}
.orig-empty {
  color: var(--text-dim);
  opacity: 0.4;
}
@media (max-width: 768px) {
  #reader-wrap.has-orig {
    flex-direction: column;
  }
  #reader-wrap.has-orig > #reader {
    border-right: none;
    border-bottom: 1px solid var(--separator);
    width: 100%;
  }
}
.reader.columns .chapter-heading {
  column-span: all;
}
.reader.columns .bottom-nav {
  column-span: all;
}

/* Verse 0 section heading (e.g. Odes titles) */
.verse-heading {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text-dim);
  font-style: italic;
  margin: 1.4rem 0 0.4rem;
  letter-spacing: 0.02em;
}

/* Chapter heading */
.chapter-heading {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 400;
  color: var(--gold);
  margin-bottom: 0.2rem;
  letter-spacing: 0.02em;
  line-height: 1.15;
}
.chapter-label {
  display: block;
  font-size: 1.1rem;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  margin-bottom: 1.8rem;
}

/* Verse paragraphs */
.verse-para {
  margin-bottom: 1em;
  text-align: justify;
  hyphens: auto;
  break-inside: avoid;
}
.reader[dir="rtl"] .verse-para {
  text-align: right;
  font-family: var(--font-hebrew);
  direction: rtl;
}

/* Verse number superscript */
.vnum {
  font-family: var(--font-verse-num);
  font-size: 0.62em;
  font-style: normal;
  font-weight: 600;
  color: var(--gold);
  vertical-align: super;
  line-height: 0;
  margin-right: 0.15em;
  cursor: pointer;
  user-select: none;
  padding: 0 2px;
  border-radius: 2px;
  transition: color 0.1s, background 0.1s;
}
.reader[dir="rtl"] .vnum { margin-right: 0; margin-left: 0.15em; }
.vnum:hover { color: var(--gold-bright); }
.vnum--active {
  color: var(--bg-dark);
  background: var(--gold);
}

/* Verse text inline span (for hover/select) */
.vtext { cursor: text; }

/* ---------------------------------------------------------------------------
   Dropcap — KJV chapter opening (verse 1)
   Styled to echo the ImGui gold-framed dropcap initial.
   --------------------------------------------------------------------------- */
.dropcap-wrap {
  display: block;
  overflow: hidden;   /* so text flows around the float */
}

.dropcap {
  float: left;
  font-family: var(--font-heading);
  font-size: 5.2em;
  line-height: 0.78;
  color: var(--bg-dark);
  background: linear-gradient(145deg, var(--gold-bright) 0%, var(--gold-dim) 100%);
  border: 2px solid var(--gold-bright);
  box-shadow:
    0 0 0 1px var(--gold-border),
    inset 0 1px 2px rgba(255,220,100,0.25);
  width: 1.05em;
  height: 1.05em;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.06em 0.55rem 0.1rem 0;
  position: relative;
  text-shadow: 0 1px 1px rgba(0,0,0,0.4);
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
  /* Corner diamonds via box-shadow pseudo approach is tricky in pure CSS;
     the border + box-shadow gives the gold frame effect */
}
.dropcap:hover {
  border-color: #e8c86b;
  box-shadow:
    0 0 0 1px var(--gold),
    0 0 8px 2px rgba(200,168,75,0.35),
    inset 0 1px 2px rgba(255,220,100,0.35);
}

/* ---------------------------------------------------------------------------
   Bottom navigation
   --------------------------------------------------------------------------- */
.bottom-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--separator);
}

.nav-btn-lg {
  display: inline-block;
  padding: 0.5rem 1.4rem;
  background: var(--bg-panel);
  border: 1px solid var(--separator);
  border-radius: 4px;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--text-dim);
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.nav-btn-lg:hover { color: var(--gold); border-color: var(--gold-border); background: var(--bg-hover); }
.nav-btn-lg.disabled { color: var(--text-faint); cursor: default; }

/* ---------------------------------------------------------------------------
   Parallel panel (slides in from the right)
   --------------------------------------------------------------------------- */
.parallel-panel {
  position: fixed;
  top: var(--toolbar-h);
  right: 0;
  bottom: 0;
  width: var(--parallel-w);
  background: var(--bg-panel);
  border-left: 1px solid var(--separator);
  transform: translateX(100%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow: hidden;
}
.parallel-panel.open { transform: translateX(0); }

.parallel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--separator);
  flex-shrink: 0;
}
.parallel-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  color: var(--gold);
}
.parallel-header-actions {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}
.parallel-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.2rem;
  transition: color 0.1s;
}
.parallel-close:hover { color: var(--text-body); }
.parallel-copy {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  transition: color 0.1s, background 0.1s;
  font-family: var(--font-ui);
}
.parallel-copy:hover { color: var(--gold); background: var(--bg-hover); }

.parallel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem 2rem;
}

.parallel-hint {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-family: var(--font-ui);
  margin-top: 0.5rem;
}
.loading {
  color: var(--text-dim);
  font-size: 0.9rem;
  font-family: var(--font-ui);
}

.parallel-entry {
  margin-bottom: 1.1rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--separator);
}
.parallel-entry:last-child { border-bottom: none; }

.parallel-trans {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.3rem;
}
.parallel-text {
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text-body);
}
.parallel-text.missing { color: var(--text-faint); font-style: italic; }
.parallel-entry.rtl .parallel-text {
  font-family: var(--font-hebrew);
  direction: rtl;
  text-align: right;
}

/* ---------------------------------------------------------------------------
   Strong's word highlights + tooltip popover
   --------------------------------------------------------------------------- */
span[data-s] {
  cursor: help;
  border-bottom: 1px dotted var(--gold-border);
  transition: background 0.1s, border-color 0.1s;
}
span[data-s]:hover {
  background: rgba(183, 148, 81, 0.15);
  border-bottom-color: var(--gold);
}

.strongs-popup {
  display: none;
  position: absolute;
  z-index: 500;
  max-width: 300px;
  min-width: 180px;
  background: var(--bg-panel);
  border: 1px solid var(--gold-border);
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  box-shadow: 0 4px 18px rgba(0,0,0,0.55);
  pointer-events: auto;
  font-family: var(--font-ui);
  line-height: 1.45;
}

.sp-num {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--gold);
  margin-bottom: 0.15rem;
}
.sp-lemma {
  font-family: 'Noto Serif Hebrew', var(--font-body);
  font-size: 1.05rem;
  color: var(--text-body);
  margin-bottom: 0.1rem;
}
.sp-translit {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 0.25rem;
}
.sp-def {
  font-size: 0.8rem;
  color: var(--text-body);
}

/* ---------------------------------------------------------------------------
   Error / utility
   --------------------------------------------------------------------------- */
.error-msg {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: #c06060;
  background: rgba(192,60,60,0.1);
  border: 1px solid rgba(192,60,60,0.25);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
}

/* ---------------------------------------------------------------------------
   Overflow menu (mobile ⋯ button)
   --------------------------------------------------------------------------- */
.inline-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.overflow-wrap {
  display: none;   /* shown only on mobile via media query */
  position: relative;
  flex-shrink: 0;
}
.overflow-btn {
  background: none;
  border: 1px solid var(--separator);
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.overflow-btn:hover { color: var(--text-body); border-color: var(--gold-border); }

.overflow-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--separator);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  min-width: 200px;
  z-index: 300;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  gap: 0.5rem;
  flex-direction: column;
}
.overflow-menu.open { display: flex; }

.overflow-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.overflow-label {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   Mobile / responsive
   --------------------------------------------------------------------------- */
@media (max-width: 900px) {
  :root { --parallel-w: min(320px, 90vw); }
}

@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--toolbar-h);
    bottom: 0;
    transform: translateX(-100%);
    z-index: 200;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }

  .sidebar-toggle { display: flex; }

  .toolbar { padding: 0 0.6rem; gap: 0.4rem; }
  .toolbar-trans { display: none; }

  .toolbar-title { font-size: 0.85rem; }

  .inline-controls { display: none; }
  .overflow-wrap   { display: block; }

  .overflow-trans { width: 100%; }

  .reader { padding: 1.5rem 1rem 3rem; }

  #reader-wrap > #reader-heading { padding: 1.5rem 1rem 0; }

  .chapter-heading { font-size: 1.7rem; }
}

@media (max-width: 480px) {
  :root { --parallel-w: 100vw; }
  .parallel-panel {
    top: 0;
    border-left: none;
  }
}

/* ---------------------------------------------------------------------------
   Interlinear view
   --------------------------------------------------------------------------- */
.interlinear-verse {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--separator);
  break-inside: avoid;
}

.interlinear-vnum {
  flex: 0 0 2rem;
  text-align: right;
  padding-top: 0.15em;
  font-size: 0.8em;
  line-height: 1.75;
}

.interlinear-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.interlinear-eng {
  color: var(--text-body);
  line-height: 1.75;
}

.interlinear-grk {
  color: var(--text-dim);
  font-size: 0.95em;
  line-height: 1.7;
}

.interlinear-heb {
  font-family: var(--font-hebrew);
  color: var(--text-dim);
  font-size: 1.05em;
  line-height: 1.9;
  text-align: right;
}
