/* Revista Digital Requena — estilos del visor (todo bajo .rd-visor para no chocar con el tema) */

.rd-visor {
  --rd-bg: #232427;
  --rd-bg-2: #303136;
  --rd-bar: #18191b;
  --rd-fg: #f2f2f0;
  --rd-fg-dim: #a9aaae;
  --rd-accent: #f5b335;
  --rd-alto: 85vh;
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 1.5em 0;
  background: radial-gradient(ellipse at 50% 40%, var(--rd-bg-2) 0%, var(--rd-bg) 70%);
  color: var(--rd-fg);
  border-radius: 6px;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.2;
  box-sizing: border-box;
  outline: none;
  -webkit-user-select: none;
  user-select: none;
}
.rd-visor *, .rd-visor *::before, .rd-visor *::after { box-sizing: border-box; }

/* Antes de que cargue el script (o si falla) */
.rd-visor .rd-fallback { padding: 2em; text-align: center; }
.rd-visor .rd-fallback a { color: var(--rd-accent); }

/* ---------- Escenario ---------- */
.rd-visor .rd-stage {
  position: relative;
  height: var(--rd-alto);
  min-height: 340px;
  padding: 24px 72px;
}
.rd-visor.rd-single .rd-stage { padding: 14px 10px; }

.rd-visor .rd-area {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rd-visor .rd-book { margin: 0 auto; filter: drop-shadow(0 14px 28px rgba(0, 0, 0, .45)); }

/* Páginas */
.rd-visor .rd-page { background: #fff; overflow: hidden; }
.rd-visor .rd-page-inner { position: relative; width: 100%; height: 100%; }
.rd-visor .rd-page img {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  box-shadow: none !important;
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
}
.rd-visor .rd-page.rd-loaded img { opacity: 1; }
/* Sombra de lomo para dar volumen al pliego */
.rd-visor .rd-page-inner::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 7%;
  pointer-events: none;
}
.rd-visor .rd-page-left .rd-page-inner::after { right: 0; background: linear-gradient(to left, rgba(0,0,0,.16), rgba(0,0,0,0)); }
.rd-visor .rd-page-right .rd-page-inner::after { left: 0; background: linear-gradient(to right, rgba(0,0,0,.16), rgba(0,0,0,0)); }
.rd-visor.rd-single .rd-page-inner::after,
.rd-visor .rd-page[data-density="hard"] .rd-page-inner::after { display: none; }

.rd-visor .rd-spin {
  position: absolute;
  top: 50%; left: 50%;
  width: 26px; height: 26px;
  margin: -13px 0 0 -13px;
  border: 3px solid #ddd;
  border-top-color: #999;
  border-radius: 50%;
  animation: rd-spin 0.9s linear infinite;
}
.rd-visor .rd-page.rd-loaded .rd-spin { display: none; }
@keyframes rd-spin { to { transform: rotate(360deg); } }

/* ---------- Botones (reseteo para que el tema no los pise) ---------- */
.rd-visor .rd-btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--rd-fg);
  box-shadow: none;
  text-transform: none;
  text-decoration: none;
  font: inherit;
  line-height: 1;
  cursor: pointer;
  transition: background-color .15s ease, opacity .15s ease, transform .15s ease;
}
.rd-visor .rd-btn svg {
  width: 22px; height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.rd-visor .rd-btn:focus-visible { outline: 2px solid var(--rd-accent); outline-offset: 2px; }
.rd-visor .rd-btn:disabled { opacity: .28; cursor: default; }

/* Flechas laterales grandes */
.rd-visor .rd-nav {
  position: absolute;
  top: 50%;
  width: 52px; height: 52px;
  margin-top: -26px;
  background: rgba(255, 255, 255, .08);
  z-index: 5;
}
.rd-visor .rd-nav svg { width: 28px; height: 28px; }
.rd-visor .rd-nav:hover:not(:disabled) { background: rgba(255, 255, 255, .18); }
.rd-visor .rd-nav:active:not(:disabled) { transform: scale(.94); }
.rd-visor .rd-nav-prev { left: 12px; }
.rd-visor .rd-nav-next { right: 12px; }
.rd-visor .rd-nav:disabled { opacity: 0; pointer-events: none; }
/* En celular las flechas van encima de la página, más discretas */
.rd-visor.rd-single .rd-nav { width: 42px; height: 42px; margin-top: -21px; background: rgba(0, 0, 0, .38); }
.rd-visor.rd-single .rd-nav-prev { left: 6px; }
.rd-visor.rd-single .rd-nav-next { right: 6px; }

/* ---------- Barra inferior ---------- */
.rd-visor .rd-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 6px 12px;
  background: var(--rd-bar);
  border-top: 1px solid rgba(255, 255, 255, .06);
}
.rd-visor .rd-tb-group { display: flex; align-items: center; gap: 2px; }
.rd-visor .rd-tb-left, .rd-visor .rd-tb-right { flex: 1 1 0; min-width: 0; }
.rd-visor .rd-tb-right { justify-content: flex-end; }
.rd-visor .rd-tb-btn { width: 40px; height: 40px; }
.rd-visor .rd-tb-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .1); }
.rd-visor .rd-title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--rd-fg-dim);
}
.rd-visor .rd-counter {
  min-width: 92px;
  padding: 0 6px;
  text-align: center;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--rd-fg);
}
@media (max-width: 560px) {
  .rd-visor .rd-tb-left { display: none; }
  .rd-visor .rd-tb-center { flex: 1 1 auto; justify-content: flex-start; }
  .rd-visor .rd-tb-btn { width: 38px; height: 38px; }
  .rd-visor .rd-counter { min-width: 70px; font-size: 13px; }
}

/* ---------- Carga y error ---------- */
.rd-visor .rd-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--rd-bg);
  z-index: 10;
  transition: opacity .4s ease, visibility .4s;
}
.rd-visor .rd-loader.rd-hidden { opacity: 0; visibility: hidden; }
.rd-visor .rd-loader-txt { font-size: 15px; color: var(--rd-fg-dim); text-align: center; padding: 0 20px; }
.rd-visor .rd-loader-bar { width: min(260px, 70%); height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.rd-visor .rd-loader-bar span { display: block; width: 0; height: 100%; background: var(--rd-accent); transition: width .2s ease; }
.rd-visor .rd-error-link { color: var(--rd-accent); text-decoration: underline; }

/* ---------- Pantalla completa ---------- */
.rd-visor:fullscreen { margin: 0; border-radius: 0; width: 100%; height: 100%; }
.rd-visor:-webkit-full-screen { margin: 0; border-radius: 0; width: 100%; height: 100%; }
.rd-visor.rd-fs-fake {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%; height: 100%;
  margin: 0;
  border-radius: 0;
  z-index: 2147483000;
}
.rd-visor.rd-fs .rd-stage { flex: 1 1 auto; height: auto; min-height: 0; }
html.rd-noscroll, html.rd-noscroll body { overflow: hidden !important; }

@media (prefers-reduced-motion: reduce) {
  .rd-visor .rd-page img, .rd-visor .rd-loader { transition: none; }
}

/* En pantallas táctiles el :hover queda "pegado" tras tocar: mantener el fondo oscuro */
.rd-visor.rd-single .rd-nav:hover:not(:disabled) { background: rgba(0, 0, 0, .5); }

/* ---------- Zoom (deslizador) y vista ampliada ---------- */
.rd-visor .rd-zview {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  overflow: hidden;
  touch-action: none;
}
.rd-visor.rd-zoomed .rd-zview { display: block; }
.rd-visor.rd-zoomed .rd-book { visibility: hidden; }
.rd-visor .rd-zview.rd-can-pan { cursor: grab; }
.rd-visor .rd-zview.rd-dragging { cursor: grabbing; }
.rd-visor .rd-sheet {
  position: absolute;
  top: 0; left: 0;
  display: flex;
  will-change: transform;
  filter: drop-shadow(0 14px 28px rgba(0, 0, 0, .45));
}
.rd-visor .rd-zslot { position: relative; height: 100%; background: #fff; }
.rd-visor .rd-zslot.rd-empty { background: transparent; }
.rd-visor .rd-zslot img {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  border: 0 !important;
  pointer-events: none;
}
.rd-visor .rd-zslot.rd-empty img { display: none; }

.rd-visor .rd-zoomctl { display: flex; align-items: center; gap: 2px; margin-right: 6px; }
.rd-visor .rd-zrange {
  -webkit-appearance: none;
  appearance: none;
  width: 110px;
  height: 22px;
  margin: 0 4px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.rd-visor .rd-zrange:focus-visible { outline: 2px solid var(--rd-accent); outline-offset: 2px; border-radius: 4px; }
.rd-visor .rd-zrange::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .25); }
.rd-visor .rd-zrange::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .25); }
.rd-visor .rd-zrange::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--rd-accent); }
.rd-visor .rd-zrange::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  margin-top: -6px;
  border: 0;
  border-radius: 50%;
  background: var(--rd-fg);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, .25);
}
.rd-visor .rd-zrange::-moz-range-thumb {
  width: 16px; height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--rd-fg);
}
@media (max-width: 760px) { .rd-visor .rd-zrange { width: 72px; } }
@media (max-width: 560px) {
  .rd-visor .rd-zrange, .rd-visor .rd-hide-sm { display: none; }
  .rd-visor .rd-zoomctl { margin-right: 0; }
}
