/* ============================================================
   LunaToons Reader Style — reader.css v2.0.0
   ============================================================ */

:root {
  --lrs-bg:        #0d0d0d;
  --lrs-surface:   #1a1a1a;
  --lrs-surface2:  #242424;
  --lrs-border:    rgba(255,255,255,0.08);
  --lrs-text:      #e8e8e8;
  --lrs-muted:     #888;
  --lrs-accent:    #00c89a;
  --lrs-accent2:   #4dd9b8;
  --lrs-radius:    12px;
  --lrs-radius-sm: 8px;
  --lrs-nav-h:     56px;
}

/* ── Reset ── */
body.lrs-active {
  background: var(--lrs-bg) !important;
  color: var(--lrs-text) !important;
}

body.lrs-active .th,
body.lrs-active #footer,
body.lrs-active .readingnav,
body.lrs-active .headpost,
body.lrs-active .ts-breadcrumb,
body.lrs-active .chaptertags,
body.lrs-active #comments,
body.lrs-active .postarea .bixbox,
body.lrs-active .chapterbody .bixbox { display: none !important; }

body.lrs-active .mainholder,
body.lrs-active #content.readercontent,
body.lrs-active .wrapper {
  background: var(--lrs-bg) !important;
  max-width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}

body.lrs-active .chapterbody,
body.lrs-active .postarea,
body.lrs-active article.hentry {
  background: var(--lrs-bg) !important;
  padding: 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
  border: none !important;
}

/* ════════════════════════════════
   BARRA DE PROGRESO DE LECTURA
   Hermosa, degradado animado
════════════════════════════════ */
#lrs-progress-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 99999;
  background: rgba(255,255,255,0.05);
  pointer-events: none;
}

#lrs-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00c89a 0%, #4dd9b8 50%, #00e5b0 100%);
  background-size: 200% 100%;
  transition: width 0.15s linear;
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px rgba(0, 200, 154, 0.6), 0 0 2px rgba(0, 200, 154, 0.4);
  animation: lrs-shimmer 2s linear infinite;
}

@keyframes lrs-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Punto brillante en el extremo de la barra */
#lrs-progress-fill::after {
  content: '';
  position: absolute;
  right: -1px; top: -2px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #4dd9b8;
  box-shadow: 0 0 6px 2px rgba(0, 200, 154, 0.8);
  opacity: 0;
  transition: opacity 0.3s;
}

#lrs-progress-fill.lrs-progress-active::after { opacity: 1; }

/* ════════════════════════════════
   TOPBAR
════════════════════════════════ */
#lrs-topbar {
  position: fixed;
  top: 3px; left: 0; right: 0;
  z-index: 10000;
  height: var(--lrs-nav-h);
  background: rgba(13,13,13,0.95);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--lrs-border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  transition: transform 0.25s ease, opacity 0.25s ease;
  box-sizing: border-box;
}

#lrs-topbar.lrs-hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

#lrs-topbar-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--lrs-muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70vw;
}

.lrs-manga-name {
  color: #888;
  font-weight: 400;
  text-decoration: none;
  transition: color .15s;
}
.lrs-manga-name:hover { color: var(--lrs-accent); }
.lrs-sep-dot    { color: #444; margin: 0 6px; }
.lrs-chapter-name { color: #e8e8e8; font-weight: 600; }

/* ════════════════════════════════
   IMÁGENES DEL CAPÍTULO
════════════════════════════════ */
body.lrs-active .entry-content.maincontent {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  padding-top: calc(var(--lrs-nav-h) + 16px + 3px) !important;
  padding-bottom: 100px !important;
  background: var(--lrs-bg) !important;
  margin: 0 !important;
  min-height: 100vh;
}

body.lrs-active .entry-content.maincontent img {
  display: block !important;
  max-width: 720px !important;
  width: 100% !important;
  height: auto !important;
  margin: 0 auto !important;
  padding: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

body.lrs-active .entry-content.maincontent img + img { margin-top: 2px !important; }

/* ════════════════════════════════
   NAVBAR INFERIOR
════════════════════════════════ */
#lrs-navbar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(26,26,26,0.98);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--lrs-border);
  border-radius: 40px;
  padding: 8px 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  transition: transform 0.25s ease, opacity 0.25s ease;
  white-space: nowrap;
}

#lrs-navbar.lrs-hidden {
  transform: translateX(-50%) translateY(calc(100% + 30px));
  opacity: 0;
  pointer-events: none;
}

.lrs-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--lrs-surface2);
  border: 1px solid var(--lrs-border);
  color: var(--lrs-text);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, color 0.2s, transform 0.15s;
  box-sizing: border-box;
  flex-shrink: 0;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.lrs-nav-btn:hover {
  background: var(--lrs-accent);
  color: #000;
  border-color: var(--lrs-accent);
  transform: scale(1.08);
}

.lrs-nav-btn.disabled {
  opacity: 0.3;
  pointer-events: none;
}

.lrs-nav-btn svg {
  width: 18px; height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#lrs-btn-chapters {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  height: 40px;
  border-radius: 20px;
  background: var(--lrs-surface2);
  border: 1px solid var(--lrs-border);
  color: var(--lrs-text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
}

#lrs-btn-chapters:hover {
  background: var(--lrs-accent);
  color: #000;
  border-color: var(--lrs-accent);
}

#lrs-btn-chapters svg {
  width: 15px; height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

#lrs-zoom-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--lrs-muted);
  min-width: 36px;
  text-align: center;
  letter-spacing: 0.04em;
}

.lrs-sep {
  width: 1px;
  height: 24px;
  background: var(--lrs-border);
  margin: 0 2px;
  flex-shrink: 0;
}

/* ════════════════════════════════
   PANEL DE CAPÍTULOS
════════════════════════════════ */
#lrs-chapters-panel {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 20000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

#lrs-chapters-panel.lrs-open {
  opacity: 1;
  pointer-events: all;
}

#lrs-panel-backdrop {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

#lrs-panel-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 700px;
  max-height: 82vh;
  background: var(--lrs-surface);
  border-radius: var(--lrs-radius) var(--lrs-radius) 0 0;
  border: 1px solid var(--lrs-border);
  border-bottom: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 1, 0.23, 1);
  box-shadow: 0 -8px 40px rgba(0,0,0,0.5);
  box-sizing: border-box;
}

#lrs-chapters-panel.lrs-open #lrs-panel-content {
  transform: translateY(0);
}

/* Handle visual para arrastrar */
#lrs-panel-content::before {
  content: '';
  display: block;
  width: 40px;
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}

#lrs-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 12px;
  border-bottom: 1px solid var(--lrs-border);
  flex-shrink: 0;
}

.lrs-panel-header-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

#lrs-panel-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--lrs-text);
  margin: 0;
}

#lrs-panel-total {
  font-size: 12px;
  color: var(--lrs-muted);
  font-weight: 500;
}

#lrs-panel-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--lrs-surface2);
  border: 1px solid var(--lrs-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--lrs-muted);
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

#lrs-panel-close:hover { background: #333; color: var(--lrs-text); }
#lrs-panel-close svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }

#lrs-manga-link {
  display: block;
  padding: 10px 20px;
  font-size: 12px;
  color: var(--lrs-accent2);
  text-decoration: none;
  border-bottom: 1px solid var(--lrs-border);
  flex-shrink: 0;
  transition: color 0.2s;
}
#lrs-manga-link:hover { color: var(--lrs-accent); }

/* ── Grid de capítulos en el panel ── */
#lrs-chapters-grid {
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  /* Altura fija para que el scroll funcione siempre */
  height: calc(82vh - 110px);
  min-height: 200px;
  box-sizing: border-box;
}

#lrs-chapters-grid::-webkit-scrollbar { width: 4px; }
#lrs-chapters-grid::-webkit-scrollbar-track { background: transparent; }
#lrs-chapters-grid::-webkit-scrollbar-thumb { background: var(--lrs-surface2); border-radius: 4px; }

/* ── Cards en el panel ── */
.lrs-chapter-card {
  width: calc(25% - 8px);
  display: block;
  border-radius: var(--lrs-radius-sm);
  overflow: hidden;
  border: 2px solid var(--lrs-border);
  text-decoration: none;
  background: var(--lrs-surface2);
  position: relative;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
  flex-shrink: 0;
}

.lrs-chapter-card:hover {
  border-color: var(--lrs-accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,200,154,0.25);
}

.lrs-chapter-card.lrs-current {
  border-color: var(--lrs-accent);
  box-shadow: 0 0 0 1px var(--lrs-accent), 0 4px 16px rgba(0,200,154,.3);
}

/* Thumbnail cuadrado sin aspect-ratio (compatibilidad máxima) */
.lrs-chapter-thumb-wrap {
  position: relative;
  width: 100%;
  padding-top: 75%;
  background: var(--lrs-surface);
  overflow: hidden;
}

.lrs-chapter-thumb {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.lrs-chapter-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 28px 8px 8px;
  background: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.65) 50%, rgba(0,0,0,0.92) 100%);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lrs-chapter-num  { font-size: 11px; font-weight: 700; color: #fff; display: block; line-height: 1.2; }
.lrs-chapter-dt   { font-size: 10px; color: rgba(255,255,255,0.6); display: block; }

/* Loading y spinner */
.lrs-loading {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
  color: var(--lrs-muted);
  font-size: 13px;
  gap: 10px;
}

.lrs-spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--lrs-border);
  border-top-color: var(--lrs-accent);
  border-radius: 50%;
  animation: lrs-spin 0.7s linear infinite;
}

@keyframes lrs-spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════
   RESPONSIVE
════════════════════════════════ */
@media (max-width: 768px) {
  body.lrs-active .entry-content.maincontent img { max-width: 100% !important; }
  #lrs-navbar { bottom: 12px; padding: 6px 10px; gap: 6px; }
  .lrs-nav-btn { width: 36px; height: 36px; }
  #lrs-btn-chapters { height: 36px; padding: 0 12px; font-size: 12px; }
  .lrs-chapter-card { width: calc(33.333% - 7px); }
}

@media (max-width: 480px) {
  #lrs-topbar-title { font-size: 11px; max-width: 80vw; }
  .lrs-chapter-card { width: calc(50% - 5px); }
  #lrs-btn-chapters { padding: 0 10px; }
  #lrs-panel-content { max-height: 90vh; }
  #lrs-chapters-grid { height: calc(90vh - 110px); }
}

/* Firefox: fondo más opaco */
@-moz-document url-prefix() {
  #lrs-topbar  { background: rgba(13,13,13,0.98); }
  #lrs-navbar  { background: rgba(26,26,26,1); }
  #lrs-panel-backdrop { background: rgba(0,0,0,0.85); }
}
