/* ============================================================
   CrossWord — reader.css
   Phase 4 additions: chapter nav, font controls,
   recent passage chips, popup study button.
   Append to or @import from main.css.
   ============================================================ */

/* ── Reader font size (controlled by JS) ─────────────────── */
:root {
  --reader-font-size: 18px;
  --reader-line-height: 2;
}

.passage-text .word-token {
  font-size: var(--reader-font-size);
}

/* ── Chapter navigation bar ──────────────────────────────── */
.chapter-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-sm) var(--sp-md);
  border-bottom: 1px solid var(--border-light);
}

.chapter-nav-bottom {
  border-bottom: none;
  border-top: 1px solid var(--border-light);
  margin-top: var(--sp-md);
}

.chapter-nav-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 6px 14px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--navy);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.chapter-nav-btn:hover:not(:disabled) {
  background: var(--parchment-mid);
  border-color: var(--gold-dark);
}

.chapter-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.chapter-nav-label {
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* ── Reader settings row ─────────────────────────────────── */
.reader-settings-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: var(--sp-xs) var(--sp-md);
  border-bottom: 1px solid var(--border-light);
  gap: var(--sp-md);
}

/* ── Font size controls ──────────────────────────────────── */
.font-size-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
}

.font-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 3px 8px;
  font-family: var(--font-display);
  font-size: 0.7rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s;
  line-height: 1.4;
}

.font-btn:hover { background: var(--parchment-mid); }

.font-size-label {
  font-family: var(--font-display);
  font-size: 0.65rem;
  color: var(--text-muted);
  min-width: 28px;
  text-align: center;
}

/* ── Popup study button ──────────────────────────────────── */
.popup-study-btn {
  display: block;
  width: 100%;
  margin-top: var(--sp-sm);
  padding: 5px 0;
  background: rgba(201,168,76,0.15);
  border: 1px solid rgba(201,168,76,0.35);
  border-radius: var(--r-sm);
  color: var(--gold-light);
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s;
}

.popup-study-btn:hover {
  background: rgba(201,168,76,0.25);
}

/* ── Recent passages chips ───────────────────────────────── */
#recent-passages {
  display: flex;
  gap: var(--sp-xs);
  padding: var(--sp-xs) var(--sp-md);
  overflow-x: auto;
  background: var(--navy-deep);
  border-bottom: 1px solid rgba(201,168,76,0.15);
  scrollbar-width: none;
}

#recent-passages::-webkit-scrollbar { display: none; }

.recent-chip {
  flex-shrink: 0;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: var(--r-pill);
  padding: 4px 12px;
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  color: rgba(237,227,207,0.75);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.recent-chip:hover {
  background: rgba(201,168,76,0.2);
  border-color: rgba(201,168,76,0.45);
  color: var(--gold-light);
}

/* ── Search row — add Go button ──────────────────────────── */
.selector-search-row {
  display: flex;
  gap: var(--sp-sm);
}

#btn-search-go {
  flex-shrink: 0;
}

/* ── Reading Preferences Panel ───────────────────────────── */
.reader-pref-btn {
    color: var(--text-muted);
    opacity: 0.7;
}
.reader-pref-btn:hover,
.reader-pref-btn[aria-expanded="true"] {
    opacity: 1;
    color: var(--gold);
}

.reader-pref-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: var(--sp-md);
    z-index: 200;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xl);
    padding: var(--sp-sm) var(--sp-md);
    min-width: 230px;
    animation: searchSlideDown 0.18s cubic-bezier(0.16,1,0.3,1);
}

.reader-pref-title {
    font-family: var(--font-display);
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding-bottom: var(--sp-xs);
    border-bottom: 1px solid var(--border-light);
    margin-bottom: var(--sp-xs);
}

/* Toggle row */
.reader-pref-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-md);
    padding: 8px 0;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border-light);
}
.reader-pref-row:last-child { border-bottom: none; }

.reader-pref-label {
    font-family: var(--font-body);
    font-size: 0.88rem;
    color: var(--text-primary);
    flex: 1;
}

/* Toggle switch */
.reader-pref-switch {
    position: relative;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

.reader-pref-cb {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.reader-pref-knob {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: var(--r-pill);
    transition: background 0.2s;
    cursor: pointer;
}

.reader-pref-knob::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.reader-pref-cb:checked + .reader-pref-knob {
    background: var(--navy-mid);
}

.reader-pref-cb:checked + .reader-pref-knob::after {
    transform: translateX(16px);
}

/* ── Display toggle CSS classes ──────────────────────────── */
/* Applied to #text-display — cascade down to all verses     */

/* Hide frequency underlines */
#text-display.hide-freq-underlines .word-token[data-freq] {
    border-bottom-color: transparent !important;
}

/* Hide verse numbers */
#text-display.hide-verse-numbers .verse-number {
    display: none;
}

/* Hide bookmark / xref buttons */
#text-display.hide-verse-actions .verse-actions {
    display: none;
}

/* ── Use line-height variable ────────────────────────────── */
/* Override the main.css .verse-text line-height */
.verse-text {
  line-height: var(--reader-line-height, 2) !important;
  transition: line-height 0.2s ease;
}

/* ── Line spacing slider ──────────────────────────────────── */
.reader-pref-spacing-row {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.reader-pref-slider-wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.reader-pref-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: var(--r-pill);
  outline: none;
  cursor: pointer;
}

.reader-pref-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--navy);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.reader-pref-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--navy);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.reader-pref-slider-val {
  font-family: var(--font-display);
  font-size: 0.65rem;
  color: var(--text-muted);
  min-width: 24px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Paragraph view (prose mode) ────────────────────────── */
/*
   When .para-view is on #text-display:
   - verse-blocks become inline (prose flow)
   - verse numbers become small superscripts inline
   - verse-actions are hidden (can't attach to inline elements cleanly)
   - para-break verses get a block-level visual paragraph indent
*/

#text-display.para-view {
  /* Let content flow as prose */
}

#text-display.para-view .verse-block {
  display: inline;   /* flow with siblings */
}

#text-display.para-view .verse-number {
  display: inline;
  font-size: 0.55rem;
  vertical-align: super;
  min-width: unset;
  padding: 0 2px 0 0;
  line-height: 1;
  color: var(--gold-dark);
}

#text-display.para-view .verse-text {
  display: inline;
}

#text-display.para-view .verse-actions {
  display: none;   /* actions don't work inline */
}

/* para-spacer provides the gap — verse itself stays inline */
#text-display.para-view .verse-block.para-break {
  display: inline;  /* flows with siblings, no isolation */
}

#text-display.para-view .verse-block.para-break::before {
  display: none;
}

/* ── Paragraph breaks (verse-per-line mode) ─────────────── */
.verse-block.para-break {
  margin-top: calc(var(--sp-lg) * 1.5);
}

.verse-block.para-break::before {
  content: '';
  position: absolute;
  top: calc(-1 * var(--sp-lg));
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(201,168,76,0.2);
}

/* ── Para-spacer (para-view mode only) ───────────────────── */
.para-spacer {
  display: none;   /* invisible in verse-per-line mode */
}

#text-display.para-view .para-spacer {
  display: block;
  height: 1.2em;   /* visual gap between paragraphs */
}