@import url('/fuentes.css');

:root {
  --bg-lectura: #F3EEE4;
  --bg-topbar: #EAE3D6;
  --bg-margen: #EAE3D6;
  --color-texto-lectura: #1C1915;
  --color-secundario: #3D362F;
  --color-terciario: #5E554B;
  --color-acento: #A63A26;
  --color-borde: #D9D0C1;
  --fuente-editorial: 'Playfair Display', Georgia, serif;
  --fuente-ui: 'Literata', Georgia, serif;
  --tamano-base-texto: 1.15rem;
  --ancho-lectura: 720px;
}

[data-tema="oscuro"] {
  --bg-lectura: #1C1915;
  --bg-topbar: #141210;
  --bg-margen: #221F1B;
  --color-texto-lectura: #EDE6D9;
  --color-secundario: #A89F91;
  --color-terciario: #807669;
  --color-acento: #C85A28;
  --color-borde: #3A352F;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border-radius: 0 !important;
  box-shadow: none !important;
}

body {
  background: var(--bg-lectura);
  color: var(--color-texto-lectura);
  font-family: var(--fuente-ui);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Topbar */
.lector-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--color-borde);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--fuente-ui);
  font-size: 0.9rem;
}

.btn-topbar-link {
  color: var(--color-secundario);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 600;
}

.btn-topbar-link:hover {
  color: var(--color-acento);
}

.separador {
  margin: 0 8px;
  color: var(--color-borde);
}

.topbar-obra {
  color: var(--color-secundario);
  font-weight: 500;
}

.topbar-capitulo {
  color: var(--color-texto-lectura);
  font-weight: 600;
}

.control-tipografia {
  display: flex;
  gap: 8px;
}

.btn-tipo {
  background: none;
  border: 1px solid var(--color-borde);
  color: var(--color-texto-lectura);
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: var(--fuente-ui);
}

.btn-tipo:hover {
  border-color: var(--color-acento);
}

.usuario-saldo-pill {
  background: var(--bg-lectura);
  border: 1px solid var(--color-borde);
  color: var(--color-acento);
  padding: 6px 14px;
  font-weight: 700;
  font-size: 0.85rem;
}

/* Barra de Progreso */
.barra-progreso-wrapper {
  position: fixed;
  top: 52px;
  left: 0;
  width: 100vw;
  height: 3px;
  background: transparent;
  z-index: 99;
}

.barra-progreso-fill {
  width: 0%;
  height: 100%;
  background: var(--color-acento);
  transition: width 0.1s ease;
}

/* Cuerpo de Lectura */
.lector-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 60px 24px 120px 24px;
  display: flex;
  justify-content: center;
  position: relative;
  gap: 40px;
}

.lector-articulo {
  max-width: var(--ancho-lectura);
  width: 100%;
}

.lector-tapa-portada {
  margin-bottom: 40px;
  display: flex;
  justify-content: center;
}

.lector-tapa-img {
  width: 180px;
  max-width: 100%;
  height: auto;
  display: block;
  border: 1px solid rgba(0, 0, 0, 0.2);
  margin-right: 18px;
  margin-bottom: 22px;
  box-shadow: 18px 22px 0 var(--color-borde, #D9D0C1) !important;
}

.lector-tapa-tipografica {
  width: 180px;
  height: 250px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #EDE6D9;
  border: 1px solid rgba(0, 0, 0, 0.2);
  margin-right: 18px;
  margin-bottom: 22px;
  box-shadow: 18px 22px 0 var(--color-borde, #D9D0C1) !important;
}

.lector-tapa-autor {
  font-family: var(--fuente-editorial);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.85;
}

.lector-tapa-tit {
  font-family: var(--fuente-editorial);
  font-size: 1rem;
  line-height: 1.25;
  margin: auto 0;
}

.lector-tapa-pie {
  font-size: 0.75rem;
  opacity: 0.75;
  border-top: 1px solid rgba(237, 230, 217, 0.25);
  padding-top: 8px;
}

.contenido-renderizado {
  font-size: var(--tamano-base-texto);
  line-height: 1.85;
  letter-spacing: -0.003em;
}

.contenido-renderizado p {
  margin-bottom: 1.6em;
  position: relative;
}

.contenido-renderizado h2, .contenido-renderizado h3 {
  font-family: var(--fuente-editorial);
  margin: 2em 0 0.8em 0;
  color: var(--color-texto-lectura);
}

/* Disparador de Anotaciones por Párrafo */
.trigger-margen {
  position: absolute;
  right: -32px;
  top: 0;
  width: 24px;
  height: 24px;
  background: var(--bg-topbar);
  border: 1px solid var(--color-borde);
  color: var(--color-secundario);
  font-size: 0.7rem;
  font-family: var(--fuente-ui);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.4;
  transition: all 0.2s;
}

.contenido-renderizado p:hover .trigger-margen {
  opacity: 1;
  border-color: var(--color-acento);
  color: var(--color-acento);
}

/* Panel Lateral Margen */
.panel-margen {
  width: 320px;
  background: var(--bg-margen);
  border: 1px solid var(--color-borde);
  padding: 20px;
  height: fit-content;
  position: sticky;
  top: 80px;
  display: none;
  flex-direction: column;
  gap: 16px;
  font-family: var(--fuente-ui);
}

.panel-margen.abierto {
  display: flex;
}

.margen-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.margen-header h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-texto-lectura);
}

.btn-close-margen {
  background: none;
  border: none;
  color: var(--color-secundario);
  font-size: 1.2rem;
  cursor: pointer;
}

.margen-lista {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
}

.comentario-item {
  background: var(--bg-lectura);
  border: 1px solid var(--color-borde);
  padding: 10px;
  font-size: 0.85rem;
}

.comentario-autor {
  font-weight: 700;
  color: var(--color-acento);
  font-size: 0.8rem;
  margin-bottom: 4px;
  display: block;
}

.margen-input-box textarea {
  width: 100%;
  background: var(--bg-lectura);
  border: 1px solid var(--color-borde);
  color: var(--color-texto-lectura);
  padding: 8px;
  font-size: 0.85rem;
  font-family: var(--fuente-ui);
  resize: vertical;
  min-height: 60px;
  outline: none;
}

.btn-publicar-comentario {
  background: var(--color-acento);
  color: #ffffff;
  border: 1px solid var(--color-acento);
  width: 100%;
  padding: 10px;
  font-weight: 700;
  font-size: 0.85rem;
  margin-top: 6px;
  cursor: pointer;
}

/* Tarjeta de Bloqueo */
.bloqueo-creditos-card {
  background: var(--bg-topbar);
  border: 1px solid var(--color-acento);
  padding: 40px 32px;
  text-align: center;
  margin: 40px 0;
  font-family: var(--fuente-ui);
}

.bloqueo-tag {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--color-acento);
  font-weight: 700;
  letter-spacing: 0.1em;
}

.bloqueo-creditos-card h3 {
  font-family: var(--fuente-editorial);
  font-size: 1.8rem;
  margin: 14px 0;
}

.bloqueo-creditos-card p {
  color: var(--color-secundario);
  font-size: 1rem;
  margin-bottom: 28px;
}

.bloqueo-cta {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.btn-desbloqueo-cta {
  background: var(--color-acento);
  color: #ffffff;
  border: 1px solid var(--color-acento);
  padding: 12px 24px;
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
}

.btn-ir-recarga {
  background: transparent;
  border: 1px solid var(--color-borde);
  color: var(--color-texto-lectura);
  padding: 12px 20px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

/* Footer Nav */
.lector-footer {
  border-top: 1px solid var(--color-borde);
  background: var(--bg-topbar);
  padding: 20px 24px;
  font-family: var(--fuente-ui);
}

.footer-nav-container {
  max-width: var(--ancho-lectura);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
}

.btn-nav-cap {
  background: var(--bg-lectura);
  border: 1px solid var(--color-borde);
  color: var(--color-texto-lectura);
  padding: 10px 20px;
  cursor: pointer;
  font-weight: 600;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.btn-nav-cap:hover {
  border-color: var(--color-acento);
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.selector-capitulo {
  max-width: min(46vw, 420px);
  background: var(--bg-lectura);
  color: inherit;
  border: 1px solid var(--color-borde);
  padding: 8px 12px;
  font: inherit;
  font-size: 0.9rem;
  min-height: 40px;
}

.lector-titulo-capitulo {
  font-family: var(--fuente-editorial);
  font-size: 1.8rem;
  line-height: 1.25;
  margin: 0 0 28px;
}

.btn-nav-cap:disabled {
  opacity: 0.35;
  cursor: default;
}

.bloqueo-mensaje {
  min-height: 1.2em;
  margin-top: 12px;
  font-size: 0.95rem;
  color: var(--color-acento);
}

.btn-desbloqueo-cta:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .topbar-obra, .separador {
    display: none;
  }
  .selector-capitulo {
    max-width: 52vw;
  }
  .lector-titulo-capitulo {
    font-size: 1.4rem;
  }
}
