/* ==========================================================================
   THE CANTICLE / HYMNAL — HYMN-SPECIFIC STYLESHEET (css/hymnal.css)
   ========================================================================== */

/* Eyebrow and Subline Styling */
.canticle-eyebrow,
.hymnal-eyebrow {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.eyebrow-bullet,
.subline-divider {
  opacity: 0.5;
  font-weight: normal;
}

.hymn-metadata-subline {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   POPOVER ELEVATION & SOLID BACKGROUND (PREVENTS LINE BLEED-THROUGH)
   ========================================================================== */
.canticle-popover,
.hymnal-popover {
  width: min(520px, calc(100vw - 1.5rem)) !important;
  background-color: var(--ui-surface, #fcfbf9) !important;
  background: var(--ui-surface-elevated, var(--ui-surface, #fcfbf9)) !important;
  border: 1px solid var(--ui-line) !important;
  border-radius: 0.85rem !important;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.16), 0 3px 8px rgba(0, 0, 0, 0.06) !important;
  z-index: 100 !important;
}

.hymn-count-indicator {
  font-family: var(--font-ui);
  font-size: 0.66rem;
  color: var(--ui-muted);
  margin-bottom: 0.45rem;
}

/* Public Domain Notice in Popover */
.hymn-pd-notice {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  margin-bottom: 0.65rem;
  background: var(--ui-surface-2);
  border: 1px solid var(--ui-line);
  border-radius: 0.55rem;
  font-family: var(--font-ui);
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--ui-muted);
  line-height: 1.3;
}

.hymn-pd-notice svg {
  color: var(--ui-accent);
  flex-shrink: 0;
}

/* ==========================================================================
   UNIFIED ANVIL SEARCH BAR (FIXES DOUBLE BORDER & MISALIGNMENT)
   ========================================================================== */
.canticle-popover .reference-entry,
.hymnal-popover .reference-entry,
.reference-entry {
  display: flex !important;
  align-items: center !important;
  background: var(--ui-surface-2, #f5f0e6) !important;
  border: 1px solid var(--ui-line, #e2d9c8) !important;
  border-radius: 0.6rem !important;
  padding: 0.2rem 0.35rem 0.2rem 0.75rem !important;
  gap: 0.45rem !important;
  margin: 0.5rem 0 0.75rem 0 !important;
  box-sizing: border-box !important;
  width: 100% !important;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease !important;
}

/* Single glowing ring on focus */
.canticle-popover .reference-entry:focus-within,
.hymnal-popover .reference-entry:focus-within {
  border-color: var(--ui-accent-strong, #936322) !important;
  background: var(--ui-surface, #ffffff) !important;
  box-shadow: 0 0 0 2px var(--ui-accent-soft, rgba(147, 99, 34, 0.15)) !important;
}

/* Clean, borderless input filling the shell */
.canticle-popover .passage-reference-input,
.hymnal-popover .passage-reference-input,
.passage-reference-input {
  flex: 1 1 auto !important;
  border: none !important;
  outline: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0.4rem 0 !important;
  margin: 0 !important;
  font-family: var(--font-ui) !important;
  font-size: 0.8rem !important;
  color: var(--ui-ink) !important;
  line-height: 1.4 !important;
  min-width: 0 !important;
}

.canticle-popover .passage-reference-input::placeholder,
.hymnal-popover .passage-reference-input::placeholder,
.passage-reference-input::placeholder {
  color: var(--ui-muted, #78716c) !important;
  opacity: 0.8 !important;
}

/* Clean compact Clear button nestled on the right */
.canticle-popover .passage-reference-btn,
.hymnal-popover .passage-reference-btn,
.passage-reference-btn {
  appearance: none !important;
  border: 1px solid var(--ui-line, #e2d9c8) !important;
  background: var(--ui-surface, #ffffff) !important;
  color: var(--ui-muted, #78716c) !important;
  border-radius: 0.45rem !important;
  padding: 0.3rem 0.65rem !important;
  font-family: var(--font-ui) !important;
  font-size: 0.7rem !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  flex-shrink: 0 !important;
  line-height: 1.3 !important;
  transition: all 130ms ease !important;
}

.canticle-popover .passage-reference-btn:hover,
.hymnal-popover .passage-reference-btn:hover,
.passage-reference-btn:hover {
  border-color: var(--ui-accent, #ca8a04) !important;
  color: var(--ui-ink) !important;
  background: var(--ui-surface-2) !important;
}

.canticle-popover .passage-reference-btn:active,
.hymnal-popover .passage-reference-btn:active,
.passage-reference-btn:active {
  transform: scale(0.97) !important;
}

/* Divider inside Popover */
.popover-divider {
  height: 1px !important;
  background: var(--ui-line) !important;
  border: none !important;
  margin: 0.65rem 0 0.75rem 0 !important;
  opacity: 0.8 !important;
}

/* Scope Toggle: Stanza by Stanza vs Whole Hymn */
.passage-scope-toggle {
  display: flex !important;
  gap: 0.35rem !important;
  margin-bottom: 0.75rem !important;
  background: var(--ui-surface-2) !important;
  padding: 0.25rem !important;
  border-radius: 0.5rem !important;
  border: 1px solid var(--ui-line) !important;
}

.scripture-mode-choice {
  flex: 1 !important;
  padding: 0.35rem 0.65rem !important;
  border: none !important;
  background: transparent !important;
  color: var(--ui-muted) !important;
  font-family: var(--font-ui) !important;
  font-size: 0.7rem !important;
  font-weight: 700 !important;
  border-radius: 0.35rem !important;
  cursor: pointer !important;
  transition: all 130ms ease !important;
  text-align: center !important;
}

.scripture-mode-choice:hover {
  color: var(--ui-ink) !important;
}

.scripture-mode-choice.active {
  background: var(--ui-surface) !important;
  color: var(--ui-accent-strong) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
}

/* Scrollable Directory with Custom Scrollbar */
.hymn-list-scroll {
  display: flex !important;
  flex-direction: column !important;
  gap: 0.35rem !important;
  max-height: 290px !important;
  overflow-y: auto !important;
  padding-right: 0.35rem !important;
  overscroll-behavior: contain !important;
}

.hymn-list-scroll::-webkit-scrollbar {
  width: 5px;
}

.hymn-list-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.hymn-list-scroll::-webkit-scrollbar-thumb {
  background: var(--ui-line);
  border-radius: 4px;
}

.hymn-list-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--ui-muted);
}

/* Hymn Directory Card */
.hymn-card-item {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 0.75rem !important;
  border: 1px solid var(--ui-line) !important;
  background: var(--ui-surface) !important;
  padding: 0.55rem 0.95rem !important;
  border-radius: 0.55rem !important;
  cursor: pointer !important;
  transition: all 130ms ease !important;
  text-align: left !important;
}

.hymn-card-item:hover {
  border-color: var(--ui-accent) !important;
  background: var(--ui-surface-2) !important;
}

.hymn-card-item.selected {
  border-color: var(--ui-accent-strong) !important;
  background: var(--ui-accent-soft) !important;
}

.hymn-card-main {
  min-width: 0 !important;
  flex: 1 !important;
}

.hymn-card-title {
  font-family: 'EB Garamond', Georgia, serif !important;
  font-size: 1.05rem !important;
  font-weight: 600 !important;
  color: var(--ui-ink) !important;
  line-height: 1.2 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.hymn-card-sub {
  font-family: var(--font-ui) !important;
  font-size: 0.65rem !important;
  color: var(--ui-muted) !important;
  margin-top: 0.15rem !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* Stanza Selector Pills Row */
.stanza-pills-row {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 0.35rem !important;
  margin-bottom: 0.75rem !important;
  max-height: 80px !important;
  overflow-y: auto !important;
}

.stanza-pills-row:empty {
  display: none !important;
}

.stanza-pill-btn {
  appearance: none !important;
  border: 1px solid var(--ui-line) !important;
  background: var(--ui-surface) !important;
  color: var(--ui-muted) !important;
  border-radius: 999px !important;
  padding: 0.3rem 0.75rem !important;
  font-family: var(--font-ui) !important;
  font-size: 0.68rem !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  transition: all 130ms ease !important;
}

.stanza-pill-btn:hover {
  border-color: var(--ui-accent) !important;
  color: var(--ui-ink) !important;
}

.stanza-pill-btn.active {
  border-color: var(--ui-accent-strong) !important;
  background: var(--ui-accent-soft) !important;
  color: var(--ui-accent-strong) !important;
  font-weight: 800 !important;
}

.stanza-pill-btn.chorus-pill {
  border-color: var(--ui-accent) !important;
  color: var(--ui-accent-strong) !important;
  font-style: italic !important;
}

.stanza-pill-btn.chorus-pill.active {
  background: var(--ui-accent-soft) !important;
  border-color: var(--ui-accent-strong) !important;
}

/* ==========================================================================
   ARENA WITH ANVIL-PARITY SPACING & SHARP (NON-FADED) EDGES
   ========================================================================== */

.canticle-arena,
.hymnal-arena,
.typing-arena {
  position: relative !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-start !important;
  width: 100% !important;
  height: 380px !important;
  min-height: 380px !important;
  max-height: 380px !important;
  padding: 0 2rem !important;
  box-sizing: border-box !important;

  /* NO FADED EDGES */
  -webkit-mask-image: none !important;
  mask-image: none !important;
}

.canticle-arena::before,
.canticle-arena::after,
.hymnal-arena::before,
.hymnal-arena::after,
.typing-arena::before,
.typing-arena::after {
  display: none !important;
  content: none !important;
  opacity: 0 !important;
  background: none !important;
}

.canticle-arena #keystroke-receiver,
.hymnal-arena #keystroke-receiver,
.typing-arena #keystroke-receiver {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
  border: none !important;
  outline: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.canticle-arena::-webkit-scrollbar,
.hymnal-arena::-webkit-scrollbar,
.typing-arena::-webkit-scrollbar {
  display: none !important;
}

/* Poetic Display Box */
.hymn-poetic-display {
  position: relative !important;
  font-family: 'EB Garamond', Georgia, serif !important;
  font-size: clamp(1.4rem, 1.75vw, 1.85rem) !important;
  line-height: 1.6 !important;
  letter-spacing: 0.005em !important;
  width: max-content !important;
  min-width: min(640px, 100%) !important;
  margin: 0 auto !important;
  text-align: left !important;
  padding: 0 !important;
  box-sizing: border-box !important;
  transition: transform 0.18s cubic-bezier(0.2, 0, 0, 1) !important;
  will-change: transform !important;

  -webkit-mask-image: none !important;
  mask-image: none !important;
}

/* Stanza & Chorus Blocks */
.poetic-stanza-block {
  margin-bottom: 2.5rem !important;
  position: relative !important;
  width: 100% !important;
}

.poetic-stanza-block:last-child {
  margin-bottom: 0.5rem !important;
}

.poetic-stanza-header {
  font-family: var(--font-ui) !important;
  font-size: 0.68rem !important;
  font-weight: 800 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.14em !important;
  color: var(--ui-accent) !important;
  margin-bottom: 0.5rem !important;
  user-select: none !important;
  opacity: 0.9 !important;
}

.poetic-stanza-header.chorus-header {
  font-style: italic !important;
  letter-spacing: 0.16em !important;
  color: var(--ui-accent-strong) !important;
}

.chorus-block {
  padding-left: 0.9rem !important;
  border-left: 2px solid var(--ui-line) !important;
}

/* Poetic Line Layout (Never wraps) */
.poetic-verse-line {
  display: flex !important;
  flex-wrap: nowrap !important;
  white-space: nowrap !important;
  align-items: baseline !important;
  min-height: 1.6em !important;
  line-height: 1.6 !important;
  margin-bottom: 0.2em !important;
  position: relative !important;
  width: max-content !important;
}

.poetic-verse-line .word-segment {
  display: inline-flex !important;
  flex-shrink: 0 !important;
  align-items: baseline !important;
  white-space: pre !important;
}

/* Character Glyphs & Typing States */
.poetic-verse-line .char-glyph {
  position: relative !important;
  display: inline-block !important;
  flex-shrink: 0 !important;
  vertical-align: baseline !important;
  line-height: inherit !important;
  color: var(--ui-muted, #78716c) !important;
  opacity: 0.45 !important;
  transition: color 60ms ease, opacity 60ms ease !important;
}

.poetic-verse-line .char-glyph.correct {
  color: var(--ui-ink, #1c1917) !important;
  opacity: 1 !important;
}

.poetic-verse-line .char-glyph.incorrect {
  color: #dc2626 !important;
  background-color: rgba(220, 38, 38, 0.16) !important;
  border-radius: 2px !important;
  opacity: 1 !important;
}

.poetic-verse-line .char-glyph.current {
  opacity: 0.9 !important;
}

.poetic-verse-line .char-glyph.space-glyph {
  display: inline-block !important;
  flex-shrink: 0 !important;
  width: 0.32em !important;
  vertical-align: baseline !important;
  line-height: inherit !important;
  white-space: pre !important;
}

.poetic-verse-line .char-glyph.space-glyph.incorrect {
  background-color: rgba(220, 38, 38, 0.3) !important;
  border-bottom: 2px solid #dc2626 !important;
}

/* Active Typing Caret */
.typing-caret {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 2.5px !important;
  background-color: var(--ui-accent-strong, #b45309) !important;
  border-radius: 2px !important;
  pointer-events: none !important;
  transition: transform 0.06s cubic-bezier(0.2, 0, 0, 1) !important;
  will-change: transform !important;
  box-shadow: 0 0 8px var(--ui-accent, rgba(202, 138, 4, 0.4)) !important;
  z-index: 5 !important;
}

.typing-caret.hidden {
  display: none !important;
}

/* ==========================================================================
   RESULTS MODAL & APP TOAST STYLING
   ========================================================================== */

.completion-panel {
  position: fixed !important;
  inset: 0 !important;
  background: rgba(0, 0, 0, 0.5) !important;
  backdrop-filter: blur(4px) !important;
  display: none;
  align-items: center !important;
  justify-content: center !important;
  z-index: 1000 !important;
  opacity: 0;
  transition: opacity 180ms ease !important;
}

.completion-panel.showing {
  opacity: 1 !important;
}

/* App Toast Notification */
.app-toast {
  position: fixed !important;
  bottom: 2rem !important;
  right: 2rem !important;
  display: flex !important;
  align-items: center !important;
  gap: 0.6rem !important;
  padding: 0.65rem 1rem !important;
  background: var(--ui-surface) !important;
  border: 1px solid var(--ui-line) !important;
  border-radius: 0.6rem !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12) !important;
  font-family: var(--font-ui) !important;
  font-size: 0.78rem !important;
  font-weight: 600 !important;
  color: var(--ui-ink) !important;
  opacity: 0 !important;
  transform: translateY(12px) !important;
  pointer-events: none !important;
  transition: opacity 180ms ease, transform 180ms ease !important;
  z-index: 999 !important;
}

.app-toast.show {
  opacity: 1 !important;
  transform: translateY(0) !important;
}

.app-toast svg {
  color: var(--ui-accent) !important;
  flex-shrink: 0 !important;
}