/* css/library-reader.css — E-Reader Teológico y Estantería (Nivel Kindle / Apple Books) */

/* =====================================================
   SUBMÓDULOS DE BIBLIOTECA Y E-READER
   ===================================================== */
@import url('./library/shelf.css');
@import url('./library/reader-themes.css');
@import url('./library/reader-modals.css');
@import url('./library/reader-ui.css');

:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

/* ═══════════════════════════════════════════════════════════════════
   2. LECTOR INMERSIVO (E-READER VIEWPORT)
   ═══════════════════════════════════════════════════════════════════ */

.ereader-viewport {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  width: 100vw;
  height: 100%;
  height: 100vh;
  height: -webkit-fill-available;
  height: 100dvh;
  max-height: 100dvh;
  z-index: 100000;
  display: block;
  overflow: hidden;
  background: var(--ereader-bg, #faf7f2);
  color: var(--ereader-ink, #2c2523);
  opacity: 0;
  filter: blur(14px);
  transition: opacity 0.68s cubic-bezier(0.2, 0.8, 0.25, 1),
              filter 0.68s cubic-bezier(0.2, 0.8, 0.25, 1),
              background-color 0.3s ease, color 0.3s ease;
  user-select: text;
  --ereader-font-size: 18px;
}

.ereader-viewport.ereader-open {
  opacity: 1;
  filter: blur(0px);
}

/* En modo escritorio (>=1180px) dentro de ventana flotante, contener el lector */
@media (min-width: 1180px) {
  .desktop-window .ereader-viewport {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    border-radius: inherit;
  }
}


/* ─── Lienzo de Lectura (100% de Pantalla sin tarjetas ni recortes) ─── */
.ereader-scroll-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  background: var(--ereader-bg);
  z-index: 10;
}

/* Modo Paginado (Slide Horizontal a pantalla completa) */
.ereader-scroll-canvas.mode-paged {
  overflow: hidden;
  overflow: clip;
  position: absolute;
  inset: 0;
  padding: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  touch-action: pan-y pinch-zoom;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
}

.ereader-scroll-canvas.mode-paged .ereader-page-viewport {
  width: 100%;
  max-width: 820px;
  height: 100%;
  margin: 0 auto;
  padding: 0 !important;
  overflow: hidden !important;
  overflow: clip !important;
  position: relative;
  box-sizing: border-box;
}

.ereader-scroll-canvas.mode-paged .ereader-pages-wrapper {
  display: flex;
  flex-direction: row;
  height: 100%;
  width: 100%;
  transition: transform 0.32s cubic-bezier(0.2, 0.9, 0.3, 1);
  will-change: transform;
}

.ereader-scroll-canvas.mode-paged .ereader-page-sheet {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0 auto;
  padding: calc(0.75rem + env(safe-area-inset-top, 0px)) 1.25rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background: var(--ereader-bg);
  border: none;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}

@media (max-width: 640px) {
  .ereader-scroll-canvas.mode-paged .ereader-page-sheet {
    padding: calc(0.5rem + env(safe-area-inset-top, 0px)) 1rem calc(0.25rem + env(safe-area-inset-bottom, 0px));
  }
}

.ereader-scroll-canvas.mode-paged .ereader-sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  display: block;
  padding: 0;
}

/* Modo Continuo (Vertical a pantalla completa sin tarjetas) */
.ereader-scroll-canvas.mode-continuous {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  margin: 0;
  scroll-behavior: smooth;
  display: block;
  width: 100%;
  height: 100%;
  background: var(--ereader-bg);
}

.ereader-scroll-canvas.mode-continuous .ereader-page-viewport {
  width: 100%;
  max-width: 820px;
  min-height: 100%;
  margin: 0 auto;
  padding: 1rem 1.25rem 2.5rem;
  overflow: visible;
  position: relative;
  box-sizing: border-box;
}

.ereader-scroll-canvas.mode-continuous .ereader-pages-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 0;
  padding: 0;
}

.ereader-scroll-canvas.mode-continuous .ereader-page-sheet {
  width: 100%;
  min-height: auto;
  height: auto;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  background: var(--ereader-bg);
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0.65rem 0 1.25rem 0;
  scroll-margin-top: 1rem;
}

.ereader-scroll-canvas.mode-continuous .ereader-page-sheet:hover {
  box-shadow: none;
}

.ereader-scroll-canvas.mode-continuous .ereader-sheet-body {
  flex: none;
  overflow: visible;
  padding: 0;
}

/* Pie de página discreto con número de página (Común a Paginado y Continuo) */
.ereader-sheet-footer {
  display: flex !important;
  align-items: center;
  justify-content: center;
  height: 24px;
  min-height: 24px;
  padding: 0;
  margin-top: auto;
  flex-shrink: 0;
  user-select: none;
  z-index: 5;
}

.ereader-sheet-page-num {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ereader-muted);
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
  letter-spacing: 0.04em;
  line-height: 1;
}

.ereader-scroll-canvas.mode-continuous .ereader-sheet-footer {
  margin-top: 1rem;
  padding-bottom: 1.25rem;
}

/* Barra inferior de salto de capítulo en Modo Continuo */
.ereader-continuous-next-chap-bar {
  display: none;
}

.ereader-scroll-canvas.mode-continuous .ereader-continuous-next-chap-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2.2rem 1rem 3.5rem;
  width: 100%;
  box-sizing: border-box;
}

.ereader-next-chap-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1.75rem;
  background: var(--ereader-card, rgba(0, 0, 0, 0.06));
  border: 1.5px solid var(--ereader-line);
  border-radius: 9999px;
  color: var(--ereader-ink);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.07);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.ereader-next-chap-pill-btn:hover {
  background: var(--ereader-accent);
  color: #ffffff;
  border-color: var(--ereader-accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.14);
}

.ereader-next-chap-pill-btn:active {
  transform: translateY(0);
}

.ereader-next-chap-pill-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  transition: transform 0.2s ease;
}

.ereader-next-chap-pill-btn:hover svg {
  transform: translateX(3px);
}

/* Encabezado de Hoja (Oculto para lectura limpia a toda página) */
.ereader-sheet-header {
  display: none !important;
}

/* Cuerpo de Hoja (Aprovechamiento 100% de la pantalla) */
.ereader-sheet-body {
  flex: 1;
  padding: 0;
  overflow: hidden;
  box-sizing: border-box;
  font-size: var(--ereader-font-size, 18px);
  line-height: 1.72;
  color: var(--ereader-ink);
  letter-spacing: 0.01em;
}

@media (max-width: 640px) {
  .ereader-sheet-body {
    padding: 0;
  }
}

.ereader-sheet-body p,
.ereader-sheet-body .theology-paragraph,
.ereader-sheet-body .entry-text-paragraph p {
  margin-bottom: 0.85rem;
  line-height: 1.72;
}

.ereader-sheet-body p.paragraph-continuation,
.ereader-sheet-body .theology-paragraph.paragraph-continuation {
  margin-top: 0;
  text-indent: 0;
}

.ereader-sheet-body p:last-child,
.ereader-sheet-body .theology-paragraph:last-child,
.ereader-sheet-body .entry-text-paragraph:last-child p:last-child {
  margin-bottom: 0;
}

/* Flechas de navegación táctil para modo paginado */
.ereader-page-nav-edge {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 15%;
  max-width: 100px;
  z-index: 90;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease, background-color 0.2s ease;
  user-select: none;
}

.ereader-page-nav-edge:hover {
  opacity: 0.7;
  background: rgba(0, 0, 0, 0.03);
}

.ereader-page-nav-left {
  left: 0;
}

.ereader-page-nav-right {
  right: 0;
}

.ereader-page-nav-edge svg {
  width: 32px;
  height: 32px;
  color: var(--ereader-muted);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.ereader-content-body {
  width: 100%;
  height: 100%;
}

/* Estilos Editoriales de Contenido */
.ereader-content-body h1,
.ereader-content-body h2 {
  font-family: var(--font-title, serif);
  color: var(--ereader-ink);
  margin-top: 2rem;
  margin-bottom: 0.8rem;
  line-height: 1.3;
}

.ereader-content-body h1 {
  font-size: 1.55em;
  border-bottom: 1px solid var(--ereader-line);
  padding-bottom: 0.5rem;
}

.ereader-content-body h2 {
  font-size: 1.22em;
}

.ereader-content-body p,
.theology-paragraph,
.entry-text-paragraph,
.entry-text-paragraph p {
  font-size: 1em;
  line-height: 1.78;
  margin-bottom: 1.25rem;
  text-align: justify;
  text-align-last: left;
  text-justify: inter-word;
  hyphens: auto;
  -webkit-hyphens: auto;
}

/* ─── Notas al Pie Editoriales (Footnotes) ─── */
sup.fn-ref {
  font-size: 0.76em;
  line-height: 0;
  vertical-align: super;
  margin-left: 2px;
  margin-right: 1px;
}

sup.fn-ref a {
  color: var(--ereader-accent, #b45309);
  text-decoration: none;
  font-weight: 700;
  padding: 1px 3px;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

sup.fn-ref a:hover {
  background: rgba(180, 83, 9, 0.15);
  text-decoration: underline;
}

.theology-footnotes-section {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--ereader-line, rgba(0, 0, 0, 0.15));
}

.theology-footnotes-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.theology-footnotes-icon {
  font-size: 1.1rem;
}

.theology-footnotes-title {
  font-family: var(--font-title, serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ereader-ink, inherit);
  letter-spacing: 0.02em;
  margin: 0;
  text-transform: uppercase;
  opacity: 0.85;
}

.theology-footnotes-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.theology-footnote-item {
  font-size: 0.88em;
  line-height: 1.65;
  color: var(--ereader-muted, #475569);
  padding: 0.5rem 0.75rem;
  background: rgba(0, 0, 0, 0.02);
  border-left: 3px solid var(--ereader-accent, #b45309);
  border-radius: 4px;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  scroll-margin-top: 80px;
  transition: background-color 0.3s;
}

.theology-footnote-item:target {
  background: rgba(180, 83, 9, 0.12);
  outline: 1px solid var(--ereader-accent, #b45309);
}

.theology-footnote-num {
  font-weight: 700;
  color: var(--ereader-accent, #b45309);
  flex-shrink: 0;
}

.theology-footnote-text {
  flex: 1;
}

.theology-footnote-back {
  color: var(--ereader-accent, #b45309);
  text-decoration: none;
  font-weight: bold;
  font-size: 1.1em;
  padding: 0 4px;
  flex-shrink: 0;
  opacity: 0.75;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
}

.theology-footnote-back:hover {
  opacity: 1;
  transform: translateY(-2px);
}

.theology-footnotes-divider {
  margin: 3rem auto 1.25rem;
  width: 140px;
  max-width: 35%;
  margin-left: 0;
  border: none;
  border-top: 1.5px solid var(--ereader-line, rgba(0,0,0,0.18));
}

.theology-footnote {
  font-size: 0.84em;
  line-height: 1.6;
  color: var(--ereader-muted, #64748b);
  margin-bottom: 0.65rem;
  padding: 0.35rem 0.65rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.02);
  border-left: 2px solid var(--ereader-line, #e2e8f0);
  text-align: left;
  text-align-last: left;
}

.theology-footnote .footnote-num {
  font-weight: 700;
  font-size: 0.82em;
  color: var(--ereader-accent, #92400e);
  margin-right: 0.4rem;
  vertical-align: super;
}

.theology-footnote:hover {
  background: rgba(0, 0, 0, 0.04);
}

.ereader-content-body .bible-ref {
  color: var(--ereader-accent, #2563eb);
  text-decoration: underline;
  text-decoration-style: dotted;
  cursor: pointer;
  font-weight: 600;
  transition: opacity 0.15s ease;
}

.ereader-content-body .bible-ref:hover {
  opacity: 0.8;
  text-decoration-style: solid;
}


.theology-paragraph {
  line-height: 1.78;
  margin-bottom: 1.25rem;
  text-align: justify;
  text-align-last: left;
  text-justify: inter-word;
  font-size: 1em;
  color: var(--ereader-ink, inherit);
}

.theology-chapter-header {
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--ereader-line, rgba(0,0,0,0.1));
}

.theology-chapter-title {
  font-family: var(--font-title, 'Cinzel', serif);
  font-weight: 700;
  color: var(--ereader-ink, inherit);
  letter-spacing: 0.01em;
}

.theology-chapter-sub {
  font-style: italic;
  opacity: 0.85;
  line-height: 1.55;
  margin-top: 0.5rem;
}

.ereader-toc-theology-item:hover {
  border-color: var(--studio-primary, #1e3a8a) !important;
  background: rgba(30, 58, 138, 0.05) !important;
}


/* ═══════════════════════════════════════════════════════════════════
   3. INTEGRACIÓN EN VENTANA DE ESCRITORIO (DESKTOP MODE)
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Modo Lector Activo en Contenedor (Tablet y Ventana) ─── */
#concordanceLibraryView.reader-open {
  position: relative !important;
  overflow: hidden !important;
  height: 100% !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
}

#concordanceLibraryView.reader-open > .bookshelf-hero,
#concordanceLibraryView.reader-open > .bookshelf-grid {
  display: none !important;
}

#concordanceLibraryView.reader-open .ereader-viewport {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  z-index: 30 !important;
}

#concordanceLibraryView.reader-open .ereader-toc-drawer {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  bottom: 0 !important;
  height: 100% !important;
  z-index: 40 !important;
  max-width: 80% !important;
}

#concordanceLibraryView.reader-open .library-lang-modal-overlay {
  position: absolute !important;
  inset: 0 !important;
  z-index: 50 !important;
}

.desktop-window #concordanceLibraryView,
#desktopWin_concordancia #concordanceLibraryView {
  position: relative;
  overflow: hidden;
  height: 100%;
  width: 100%;
}

.desktop-window #concordanceLibraryView .ereader-viewport,
#desktopWin_concordancia #concordanceLibraryView .ereader-viewport {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  z-index: 30;
}

.desktop-window #concordanceLibraryView .ereader-toc-drawer,
#desktopWin_concordancia #concordanceLibraryView .ereader-toc-drawer {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  height: 100%;
  z-index: 40;
  max-width: 80%;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
}

.desktop-window #concordanceLibraryView .library-lang-modal-overlay,
#desktopWin_concordancia #concordanceLibraryView .library-lang-modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  border-radius: 0 0 12px 12px;
}

@media (min-width: 1180px) {
  #concordanceLibraryView {
    position: relative;
    overflow: hidden;
    height: 100%;
    width: 100%;
  }

  #concordanceLibraryView .ereader-viewport {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 30;
  }

  #concordanceLibraryView .ereader-toc-drawer {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100%;
    z-index: 40;
    max-width: 80%;
  }

  #concordanceLibraryView .library-lang-modal-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
  }
}

