/*
 * Ara Child — LECTOR de manga estilo CAPIBARA / MangaDex.
 * CSS sobre el markup nativo de Madara (manga-single-reading.php +
 * reading-content/content-reading-list.php). NO reescribe plantillas.
 * Cargado SOLO en la página de lectura (ver functions.php).
 *
 * Markup base de Madara:
 *   .c-page-content.reading-content-wrap
 *     #chapter-heading (h1)
 *     #manga-reading-nav-head (.entry-header.header) → manga_nav('header')
 *     .reading-content → .page-break > img.wp-manga-chapter-img
 *     #manga-reading-nav-foot (.entry-header.footer) → manga_nav('footer')
 *     #madara-comments  ·  related  ·  tags
 */

:root { --ara-cyan: #06b6d4; }

/* ====== Header capibara en el lector: estático (scrollea con el contenido) y NEGRO
   (igual que en el detalle; ara-reader.css es solo del lector). ====== */
.ara-nav {
  /* relative (no static): scrollea igual pero da contexto al drawer móvil
     (.ara-nav__menu es absolute; con static el hamburguesa "no funcionaba"). */
  position: relative !important;
  /* Anular el top:32px del admin-bar (es para el header FIXED de home/blog): en un
     header relative ese top suma al margin-top:32px de WP → hueco doble logueado. */
  top: 0 !important;
  background: #09090b !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
/* El padding-top:var(--ara-h) de ara-header.css compensa el header FIXED del resto
   del sitio; acá el header es relative (ocupa su espacio en el flujo) → ese padding
   era una FRANJA vacía de 80px bajo el header (solo desktop; en móvil ya es 0).
   html body = ganarle en especificidad a la regla de ara-header. */
html body .site-content { padding-top: 0 !important; }

/* ====== Breadcrumb del lector + botones de acción (bookmark / contraste) ======
   Los botones viven en .action-icon .action_list_icon (manga-breadcrumb.php), FUERA
   de .reading-content-wrap → se de-cyanizan acá. */
.c-page-breadcrumb { background: #09090b !important; border: 0 !important; box-shadow: none !important; }
.c-page-breadcrumb a, .c-page-breadcrumb .breadcrumb a, .c-page-breadcrumb li { color: #71717a !important; }
.c-page-breadcrumb a:hover { color: #fff !important; }
.action-icon .action_list_icon a,
.action-icon .action_list_icon .c-btn,
.action-icon .action_list_icon .wp-manga-action-button,
.action-icon .action_list_icon .wp-manga-delete-bookmark {
  background: rgba(24,24,27,.92) !important; color: #fff !important;
  border: 1px solid #3f3f46 !important; border-radius: .6rem !important; box-shadow: none !important;
}
.action-icon .action_list_icon a i,
.action-icon .action_list_icon .c-btn i { color: #fff !important; }
.action-icon .action_list_icon a:hover,
.action-icon .action_list_icon .c-btn:hover {
  background: #27272a !important; border-color: #52525b !important; color: #fff !important;
}

/* ====== Fondo general oscuro (mata el gris/blanco de Madara) ====== */
/* zinc-950 #09090b en todo el lector, igual que el resto del sitio (decisión
   2026-07-02: antes era #000 "negro puro capibara" y desentonaba con el header) */
body.chapter-template,
body[class*="single-wp-manga"],
.reading-content-wrap,
.reading-content-wrap .content-area,
.reading-content-wrap .main-col-inner,
.reading-content-wrap .c-blog-post,
.reading-content-wrap .entry-content,
.reading-content-wrap .entry-content_wrap,
.reading-content-wrap .read-container {
  background: #09090b !important;
  background-image: none !important;
  border: 0 !important;
  box-shadow: none !important;
}
body { background: #09090b !important; }
/* contenedores de página al mismo tono (capibara.css ya los pinta --c-bg #09090b,
   pero lo fijamos acá también por si cambia el token global) */
.wrap, .body-wrap, .site-content, .c-page, .c-page-content,
.c-sidebar.c-top-sidebar, .c-sidebar.c-top-second-sidebar {
  background: #09090b !important; background-image: none !important;
  border: 0 !important; box-shadow: none !important;
}

/* el container de Madara es angosto; en el lector lo dejamos respirar */
.reading-content-wrap .container { max-width: 1100px; }

/* sidebar fuera → lector a todo el ancho */
.reading-content-wrap .sidebar-col { display: none !important; }
.reading-content-wrap .main-col { width: 100% !important; max-width: 100% !important; flex: 0 0 100% !important; }

/* ====== Título del capítulo ====== */
#chapter-heading {
  text-align: center; color: #fff;
  font: 800 clamp(1.1rem, 2.2vw, 1.6rem)/1.3 'Plus Jakarta Sans', system-ui, sans-serif;
  text-transform: uppercase; letter-spacing: .01em;
  margin: 1.5rem auto 1rem; padding: 0 1rem; max-width: 900px;
}

/* ====== IMÁGENES estilo CAPIBARA: tamaño natural, centradas, columna contenida,
   separación de 2px entre páginas (object-contain w-auto max-w-full + gap 2px) ====== */
.reading-content {
  background: #09090b !important; text-align: center;
  max-width: 900px; margin: 0 auto;   /* columna contenida; a más ancho se ven gigantes */
}
.reading-content .page-break {
  display: flex; justify-content: center; margin: 0 auto var(--ara-gap, 0px); padding: 0; background: transparent !important;
}
.reading-content .page-break img,
.reading-content .page-break img.wp-manga-chapter-img {
  display: block; width: auto !important; max-width: 100% !important; height: auto !important;
  margin: 0 auto !important;
}

/* ====== NAV de capítulos (arriba y abajo): barra oscura capibara ======
   Madara la pinta con .nav-links + selector de capítulos + prev/next.
   PRIMER PASE — afinar con captura. */
.reading-content-wrap .entry-header { background: transparent !important; padding: 0; margin: 1rem 0; }
/* .nav-links es solo el CONTENEDOR flex (transparente) — el pill lo llevan SOLO los
   botones adentro, si no se ve "uno dentro de otro" (doble contenedor) */
.reading-content-wrap .nav-links,
.reading-content-wrap .wp-manga-nav .nav-links,
.reading-content-wrap .select-pagination {
  display: flex !important; align-items: center; justify-content: center; gap: .5rem; flex-wrap: wrap;
  background: transparent !important; border: 0 !important; box-shadow: none !important;
  padding: 0 !important; margin: 0 auto;
}
/* TODOS los botones del lector → GHOST OSCURO (no el teal/cyan nativo de Madara).
   Cubre prev/next (.btn.next_page), los botones-ícono (bookmark, modo lectura) y
   cualquier .c-btn / .btn. Va con !important porque Madara los pinta de cyan con
   alta especificidad. Los <select> NO se tocan (tienen su propia regla más abajo). */
.reading-content-wrap .nav-links a,
.reading-content-wrap .nav-previous a,
.reading-content-wrap .nav-next a,
.reading-content-wrap .wp-manga-nav a.btn,
.reading-content-wrap .wp-manga-nav .c-btn,
.reading-content-wrap .add-bookmark a,
.reading-content-wrap a.btn,
.reading-content-wrap .c-btn {
  display: inline-flex !important; align-items: center; justify-content: center; gap: .4rem;
  background: rgba(24,24,27,.92) !important; color: #fff !important; text-decoration: none !important;
  border: 1px solid #3f3f46 !important; border-radius: .6rem !important; box-shadow: none !important;
  padding: .55rem 1.1rem !important;
  font: 800 .72rem/1.1 'Plus Jakarta Sans', system-ui, sans-serif;
  text-transform: uppercase; letter-spacing: .05em;
  transition: background .2s ease, border-color .2s ease;
}
.reading-content-wrap .nav-links a:hover,
.reading-content-wrap a.btn:hover,
.reading-content-wrap .c-btn:hover,
.reading-content-wrap .add-bookmark a:hover {
  background: #27272a !important; border-color: #52525b !important; color: #fff !important;
}
/* íconos dentro de los botones (bookmark, contraste) en blanco */
.reading-content-wrap .c-btn i,
.reading-content-wrap a.btn i,
.reading-content-wrap .add-bookmark a i { color: #fff !important; }

/* Flecha de prev/next: la de Madara (pseudo o <i>) se superpone al texto. La
   neutralizamos y ponemos una propia, inline y con su espacio. */
.reading-content-wrap a.prev_page i,
.reading-content-wrap a.next_page i { display: none !important; }
.reading-content-wrap a.prev_page::before {
  content: "‹" !important; position: static !important; inset: auto !important; transform: none !important;
  display: inline-block !important; margin: 0 .25rem 0 0 !important; font-size: 1.2em; line-height: 1; color: inherit;
}
.reading-content-wrap a.prev_page::after { content: none !important; }
.reading-content-wrap a.next_page::after {
  content: "›" !important; position: static !important; inset: auto !important; transform: none !important;
  display: inline-block !important; margin: 0 0 0 .25rem !important; font-size: 1.2em; line-height: 1; color: inherit;
}
.reading-content-wrap a.next_page::before { content: none !important; }
/* selector de capítulos (dropdown) */
.reading-content-wrap .select-pagination,
.reading-content-wrap .c-selectpicker { display: inline-flex; align-items: center; gap: .4rem; }
.reading-content-wrap select,
.reading-content-wrap .selectpicker_nav,
.reading-content-wrap .single-chapter-select {
  background: #09090b !important; color: #e4e4e7 !important;
  border: 1px solid #3f3f46 !important; border-radius: .6rem !important;
  padding: .5rem .8rem !important; font-size: .8rem !important; max-width: 320px;
}

/* ====== "You may also like" al pie (usa .ara-card de ara-cards.css) ====== */
.reading-content-wrap .ara-detail__h2,
.reading-content-wrap .c-blog__heading h4 {
  text-align: left; color: #fff; font-weight: 900; font-style: italic;
  text-transform: uppercase; letter-spacing: -.02em; margin: 2rem 0 1rem;
}
.reading-content-wrap .c-blog__heading { background: none !important; border: 0 !important; padding: 0 !important; }
.reading-content-wrap .c-blog__heading h4 i { display: none !important; }
.reading-content-wrap .ara-rel-grid,
.reading-content-wrap .related-manga {
  /* 5 columnas FIJAS: auto-fit estiraba las cards a todo el ancho con pocas
     relacionadas (2 = gigantes, caso Comic/VCP). Fijo = tamaño normal + grid
     lleno idéntico. */
  display: grid !important; grid-template-columns: repeat(5, 1fr);
  gap: 1.1rem; margin: 0 !important;
}
/* Se sirven 6 relacionados: en DESKTOP 5 (el 6º oculto — misma regla que el
   detalle en ara-detail.css; acá faltaba y el 6º armaba una fila suelta abajo);
   en MÓVIL los 6 (re-mostrado en el media query de abajo). */
body.reading-manga .ara-rel-grid > .ara-card:nth-child(6),
body.reading-manga .related-manga > .ara-card:nth-child(6) { display: none !important; }

/* ====== Comentarios: el mu-plugin (#madara-comments) ya los estiliza ====== */
.reading-content-wrap #madara-comments { max-width: 900px; margin: 2.5rem auto 0; }

/* ============================================================================
   PANEL DE CONFIGURACIÓN DE LECTURA — clon del de CAPIBARA (tokens Tailwind:
   red-500 #ef4444 activo, zinc-800 #27272a, zinc-700 #3f3f46, zinc-900 #18181b,
   gray-300 #d1d5db, gray-400 #9ca3af, gray-100 #f3f4f6). Lo arma ara-reader.js.
   ============================================================================ */

/* botón de apertura (ícono sliders) */
.ara-rs-open {
  display: inline-flex !important; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: .6rem;
  background: rgba(24,24,27,.92); color: #fff; border: 1px solid #3f3f46; cursor: pointer;
  transition: background .2s, border-color .2s; padding: 0;
}
.ara-rs-open:hover { background: #27272a; border-color: #52525b; }
.ara-rs-open svg { width: 20px; height: 20px; }
.ara-rs-open--fixed { position: fixed; top: 86px; right: 18px; z-index: 9998; }
.ara-rs-open.active { background: #ef4444; border-color: #ef4444; color: #fff; }

/* panel INLINE (no modal): se inserta en el flujo, encima de las imágenes, y se
   despliega/colapsa con el ícono de sliders. */
.ara-rs-inline {
  max-width: 1100px; margin: 1rem auto 1.75rem; padding: 0 1rem;
  color: #fff; font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
}
.ara-rs-inline[hidden] { display: none; }
.ara-rs-body { display: flex; flex-wrap: wrap; justify-content: center; gap: 2rem 5rem; }
.ara-rs-group { min-width: 240px; }
.ara-rs-label { display: block; font-size: .875rem; font-weight: 500; color: #f3f4f6; margin-bottom: .5rem; }
.ara-rs-label--mode { color: #9ca3af; margin-bottom: .75rem; }
.ara-rs-label { display: block; font-size: .875rem; font-weight: 500; color: #f3f4f6; margin-bottom: .5rem; }
.ara-rs-label--mode { color: #9ca3af; margin-bottom: .75rem; }

/* Image fit (botones) */
.ara-rs-fits { display: flex; flex-wrap: wrap; gap: .5rem; }
.ara-rs-fits button {
  padding: .375rem .75rem; font-size: .75rem; font-weight: 500; line-height: 1.2;
  border-radius: .375rem; cursor: pointer; transition: all .2s;
  background: #27272a; color: #d1d5db; border: 1px solid #3f3f46;
}
.ara-rs-fits button:hover { background: #3f3f46; }
.ara-rs-fits button.active { background: #ef4444; color: #fff; border-color: #ef4444; box-shadow: 0 1px 2px rgba(0,0,0,.3); }

/* switch "Use double pages" */
.ara-rs-switch { display: flex; align-items: center; gap: .75rem; margin-top: 1rem; cursor: pointer; }
.ara-rs-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.ara-rs-slider { position: relative; width: 44px; height: 24px; flex-shrink: 0; background: #3f3f46; border-radius: 999px; transition: background .2s; }
.ara-rs-slider::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; background: #fff; border-radius: 999px; transition: transform .2s; }
.ara-rs-switch input:checked + .ara-rs-slider { background: #ef4444; }
.ara-rs-switch input:checked + .ara-rs-slider::after { transform: translateX(20px); }
.ara-rs-swlabel { font-size: .875rem; font-weight: 500; color: #f3f4f6; }

/* select "Space between pages" */
.ara-rs-select {
  width: 100%; margin-top: .25rem; background: #27272a; border: 1px solid #3f3f46; color: #fff;
  border-radius: .5rem; padding: .625rem .75rem; cursor: pointer; transition: background .2s; font-size: .875rem;
}
.ara-rs-select:hover { background: #3f3f46; }

/* toggle "Reading mode" */
.ara-rs-mode, .ara-rs-dir { display: inline-flex; border: 1px solid #3f3f46; background: #18181b; border-radius: .5rem; padding: .25rem; }
.ara-rs-mode button, .ara-rs-dir button { padding: .5rem 1rem; font-size: .875rem; font-weight: 500; border-radius: .375rem; background: none; border: 0; color: #9ca3af; cursor: pointer; transition: all .2s; white-space: nowrap; }
.ara-rs-mode button:hover, .ara-rs-dir button:hover { color: #fff; background: #27272a; }
.ara-rs-mode button.active, .ara-rs-dir button.active { background: #ef4444; color: #fff; box-shadow: 0 4px 8px rgba(0,0,0,.3); }

/* ===== Image fit: clases aplicadas a .reading-content ===== */
.reading-content.ara-fit-maxw { max-width: 900px; }
.reading-content.ara-fit-maxw .page-break img { max-width: 100% !important; width: auto !important; height: auto !important; max-height: none !important; }
.reading-content.ara-fit-vw { max-width: 100%; }
.reading-content.ara-fit-vw .page-break img { width: 100% !important; max-width: 100% !important; height: auto !important; max-height: none !important; }
.reading-content.ara-fit-vh { max-width: 100%; }
.reading-content.ara-fit-vh .page-break img { height: 95vh !important; width: auto !important; max-width: 100% !important; max-height: none !important; }
.reading-content.ara-fit-maxh { max-width: 100%; }
.reading-content.ara-fit-maxh .page-break img { max-height: 95vh !important; width: auto !important; max-width: 100% !important; height: auto !important; }
/* "Sin límite" (ara-fit-none) ELIMINADO: con max-width:none una imagen ancha estiraba
   la columna y reventaba el layout (cards de "You may also like" gigantes + el
   panel de config se iba de lado). Todos los modos restantes quedan acotados a 100%. */

/* doble página (v1 best-effort: 2 por fila) */
.reading-content.ara-doble { display: flex !important; flex-wrap: wrap; justify-content: center; align-items: flex-start; }
.reading-content.ara-doble .page-break { width: 48%; margin: 0 1% var(--ara-gap, 0px); }
.reading-content.ara-doble .page-break img { max-width: 100% !important; }
/* Dirección: en doble página, Manga (RTL) invierte el orden de las dos páginas */
.reading-content.ara-doble.ara-rtl { flex-direction: row-reverse; }

/* ============================================================================
   HEADER CAPIBARA del lector (.ara-rh) — reemplaza el header nativo de Madara
   (título h1 + breadcrumb + dropdowns + botones, que se ocultan abajo).
   ============================================================================ */
.ara-rh {
  display: flex; align-items: center; gap: 1rem;
  max-width: 1200px; margin: 1.25rem auto .75rem; padding: 0 1.5rem;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
}
.ara-rh-info { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.ara-rh-num { font-size: clamp(2.4rem, 5vw, 3.8rem); font-weight: 300; color: #fff; line-height: .9; letter-spacing: -.03em; }
.ara-rh-titles { display: flex; flex-direction: column; min-width: 0; }
.ara-rh-series { font-size: clamp(1rem, 2.2vw, 1.5rem); font-weight: 600; color: #fff; line-height: 1.15; }
.ara-rh-chap { font-size: .9rem; color: #a1a1aa; line-height: 1.2; margin-top: .1rem; }
.ara-rh-tools { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.ara-rh-arrow {
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; font-size: 2.2rem; line-height: 1; color: #71717a;
  text-decoration: none !important; border-radius: .7rem; transition: color .2s, background .2s;
}
.ara-rh-arrow:hover { color: #fff; background: rgba(255,255,255,.06); }
.ara-rh-disabled { color: #3f3f46; pointer-events: none; }
/* sliders dentro del header = ícono pelado (estilo capibara), no caja */
.ara-rh-tools .ara-rs-open { background: none !important; border: 0 !important; width: auto !important; height: auto !important; color: #a1a1aa; padding: .35rem; }
.ara-rh-tools .ara-rs-open:hover { background: none !important; color: #fff; }
.ara-rh-tools .ara-rs-open.active { background: none !important; color: #ef4444; }
.ara-rh-tools .ara-rs-open svg { width: 24px; height: 24px; }

/* ocultar el header NATIVO de Madara (lo reemplaza .ara-rh). Queda en el DOM para
   que el JS lea el título y los links prev/next. */
.c-page-breadcrumb,
#chapter-heading,
.reading-content-wrap #chapter-heading,
.reading-content-wrap #manga-reading-nav-head,
.reading-content-wrap .entry-header.header { display: none !important; }

/* ============================================================================
   GUARDS DE OVERFLOW + RESPONSIVE del lector
   ============================================================================ */
/* nada puede empujar la página hacia los lados (red de seguridad) */
.reading-content-wrap { overflow-x: clip; }
.ara-rs-inline, .ara-rh,
.reading-content-wrap .ara-rel-grid,
.reading-content-wrap #madara-comments { max-width: 100%; }
/* título de serie: máx 2 líneas en desktop (los doujin tienen títulos largos) */
.ara-rh-series { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

@media (max-width: 1024px) {
  .ara-rh { padding: 0 1rem; gap: .6rem; }
  .ara-rs-inline { padding: 0 1rem; }
  .ara-rs-body { gap: 1.5rem 2.5rem; }
}

@media (max-width: 640px) {
  /* HEADER del lector: número chico, título 1 línea con ellipsis, flechas chicas */
  .ara-rh { gap: .4rem; margin: .6rem auto .5rem; }
  .ara-rh-info { gap: .55rem; flex: 1; min-width: 0; }
  .ara-rh-num { font-size: 2rem; }
  .ara-rh-titles { flex: 1; min-width: 0; }
  .ara-rh-series { -webkit-line-clamp: 1; white-space: nowrap; text-overflow: ellipsis; font-size: .95rem; }
  .ara-rh-chap { font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ara-rh-arrow { width: 38px; height: 38px; font-size: 1.7rem; border-radius: .5rem; }
  .ara-rh-tools .ara-rs-open svg { width: 22px; height: 22px; }

  /* PANEL config: una columna */
  .ara-rs-inline { margin: .75rem auto 1.25rem; }
  .ara-rs-body { flex-direction: column; gap: 1.5rem; }
  .ara-rs-group { min-width: 0; width: 100%; }
  .ara-rs-fits button { font-size: .72rem; padding: .35rem .6rem; }
  .ara-rs-mode button { padding: .45rem .85rem; font-size: .8rem; }

  /* NAV de abajo (footer): que envuelva, selects al ancho */
  .reading-content-wrap .nav-links { flex-wrap: wrap; }
  .reading-content-wrap select { max-width: 100%; }

  /* relacionados un poco más chicos en mobile */
  .reading-content-wrap .ara-rel-grid,
  .reading-content-wrap .related-manga { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .8rem; }
  /* en móvil los 6 relacionados sí se muestran (2-3 por fila sin huecos) */
  body.reading-manga .ara-rel-grid > .ara-card:nth-child(6),
  body.reading-manga .related-manga > .ara-card:nth-child(6) { display: flex !important; }
  .reading-content-wrap #madara-comments { margin-top: 2rem; }
}
