/*
 * Nexora — single.css
 * Diseño editorial premium para entradas del blog (single post).
 * Hereda los design tokens del tema (--nx-*) y los aliasa a los
 * nombres que usa single.php (--ink, --border, --muted, --muted2)
 * para que el markup existente quede correctamente estilizado.
 * ──────────────────────────────────────────────────────────────
 */

/* ═══════════════════════════════════════════════════
   0. ALIAS DE TOKENS (compat con single.php)
═══════════════════════════════════════════════════ */
.single-layout,
.single-layout * {
  --ink:     var(--nx-ink);
  --medium:  var(--nx-medium);
  --muted:   var(--nx-muted);
  --muted2:  var(--nx-xmuted);
  --border:  var(--nx-border);
  --primary: var(--nx-primary);
}

/* Container fallback (single.php usa .container, el tema usa .nx-container) */
body.single .container,
body.page .container,
body.archive .container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 40px;
}

/* ═══════════════════════════════════════════════════
   1. BARRA DE PROGRESO DE LECTURA (signature)
═══════════════════════════════════════════════════ */
.nx-read-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  z-index: 200;
  background: linear-gradient(90deg, var(--nx-primary) 0%, #8b8cff 100%);
  box-shadow: 0 0 10px rgba(91, 92, 255, .5);
  transition: width .1s linear;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════
   2. LAYOUT (contenido + sidebar)
═══════════════════════════════════════════════════ */
.single-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 56px;
  align-items: start;
  padding: 56px 0 80px;
}
.single-content { min-width: 0; }

/* ═══════════════════════════════════════════════════
   3. CABECERA DEL ARTÍCULO
═══════════════════════════════════════════════════ */
.single-header {
  max-width: 760px;
  margin: 0 0 36px;
}
.single-header .nx-cat-badge,
.single-header .hc-cat-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 13px;
  border-radius: 999px;
  background: var(--nx-primary-bg);
  color: var(--nx-primary);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .01em;
  text-transform: none;
  margin-bottom: 18px;
  transition: background .18s, color .18s;
}
.single-header .nx-cat-badge:hover,
.single-header .hc-cat-badge:hover {
  background: var(--nx-primary);
  color: #fff;
}
.single-header h1 {
  font-size: clamp(32px, 4.6vw, 52px);
  font-weight: 900;
  line-height: 1.08;
  letter-spacing: -.035em;
  color: var(--nx-ink);
  margin: 0 0 22px;
}

/* Meta: fecha · lectura · autor */
.single-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  font-size: 14px;
  color: var(--nx-muted);
}
.single-meta > span {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
}
.single-meta > span:first-child { padding-left: 0; }
.single-meta > span:not(:first-child)::before {
  content: "";
  position: absolute;
  left: -2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--nx-xmuted);
}
.single-meta strong { color: var(--nx-medium); font-weight: 700; }
.single-meta .blog-reading { color: var(--nx-primary); font-weight: 600; }

/* ═══════════════════════════════════════════════════
   4. IMAGEN DESTACADA
═══════════════════════════════════════════════════ */
.single-thumb {
  margin: 0 0 44px;
  border-radius: var(--nx-radius-xl);
  overflow: hidden;
  box-shadow: var(--nx-shadow-lg);
  background: var(--nx-bg-gray);
}
.single-thumb img {
  display: block;
  width: 100%;
  height: auto;
}

/* ═══════════════════════════════════════════════════
   5. CONTENIDO EDITORIAL (.entry-content)
═══════════════════════════════════════════════════ */
.entry-content {
  max-width: 740px;
  font-size: 18px;
  line-height: 1.72;
  color: var(--nx-medium);
  letter-spacing: -.003em;
}

/*
 * Ritmo vertical (flujo descendente con margin-bottom):
 * - Separación entre párrafos CLARAMENTE mayor que el interlineado
 *   → la lectura "respira" y cada párrafo se lee como bloque aparte.
 * - Los encabezados se AGRUPAN con el texto que sigue (poco margen abajo)
 *   y se separan de la sección anterior (mucho margen arriba).
 */
.entry-content > * { margin-top: 0; }
.entry-content p,
.entry-content ul,
.entry-content ol,
.entry-content blockquote,
.entry-content pre,
.entry-content figure,
.entry-content table,
.entry-content .nx-table-scroll {
  margin-bottom: 1.9em;
}
.entry-content > *:last-child { margin-bottom: 0; }

/* Lead: primer párrafo más prominente */
.entry-content > p:first-of-type {
  font-size: 20px;
  line-height: 1.68;
  color: var(--nx-ink);
  margin-bottom: 2em;
}

/* Drop cap en el primer párrafo */
.entry-content > p:first-of-type::first-letter {
  float: left;
  font-size: 3.6em;
  line-height: .82;
  font-weight: 900;
  color: var(--nx-primary);
  margin: 6px 12px 0 0;
  letter-spacing: -.02em;
}

/* Encabezados */
.entry-content h2,
.entry-content h3,
.entry-content h4 {
  color: var(--nx-ink);
  letter-spacing: -.025em;
  scroll-margin-top: 90px;
}
.entry-content h2 {
  position: relative;
  font-size: clamp(24px, 3vw, 30px);
  font-weight: 800;
  line-height: 1.25;
  margin: 2.9em 0 .85em;
  padding-top: .9em;
  border-top: 1px solid var(--nx-border-light);
}
.entry-content h2::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  width: 44px;
  height: 3px;
  border-radius: 3px;
  background: var(--nx-primary);
}
.entry-content h3 {
  font-size: clamp(19px, 2.2vw, 22px);
  font-weight: 800;
  line-height: 1.35;
  margin: 2.4em 0 .6em;
}
.entry-content h4 {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
  margin: 2em 0 .5em;
}
/* El primer bloque no necesita aire superior */
.entry-content > h2:first-child,
.entry-content > h3:first-child,
.entry-content > h4:first-child { margin-top: 0; }

/* Enlaces */
.entry-content a {
  color: var(--nx-primary);
  text-decoration: underline;
  text-decoration-color: rgba(91, 92, 255, .35);
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
  font-weight: 600;
  transition: text-decoration-color .18s, color .18s;
}
.entry-content a:hover {
  color: var(--nx-primary-h);
  text-decoration-color: var(--nx-primary);
}

/* Negrita / cursiva */
.entry-content strong { color: var(--nx-ink); font-weight: 700; }
.entry-content em { font-style: italic; }

/* Listas */
.entry-content ul,
.entry-content ol {
  margin-left: 0;
  padding-left: 4px;
  list-style: none;
}
.entry-content ul li,
.entry-content ol li {
  position: relative;
  padding-left: 30px;
  margin-top: .85em;
  line-height: 1.6;
}
.entry-content ul li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: .62em;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--nx-primary);
  transform: rotate(45deg);
}
.entry-content ol { counter-reset: nx-ol; }
.entry-content ol li::before {
  counter-increment: nx-ol;
  content: counter(nx-ol);
  position: absolute;
  left: 0;
  top: .15em;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--nx-primary);
  background: var(--nx-primary-bg);
  border-radius: 6px;
}
.entry-content li > ul,
.entry-content li > ol { margin-top: .4em; }

/* Blockquote */
.entry-content blockquote {
  margin: 1.8em 0;
  padding: 22px 26px;
  border-left: 4px solid var(--nx-primary);
  border-radius: 0 var(--nx-radius-md) var(--nx-radius-md) 0;
  background: var(--nx-primary-bg);
  font-size: 19px;
  font-style: italic;
  line-height: 1.6;
  color: var(--nx-ink);
}
.entry-content blockquote p { margin: 0; }
.entry-content blockquote cite {
  display: block;
  margin-top: 10px;
  font-size: 14px;
  font-style: normal;
  font-weight: 700;
  color: var(--nx-muted);
}

/* Código inline + bloques */
.entry-content code {
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: .86em;
  background: var(--nx-bg-gray);
  color: var(--nx-primary-h);
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid var(--nx-border-light);
}
.entry-content pre {
  margin: 1.8em 0;
  padding: 20px 22px;
  background: #0F0F1A;
  border-radius: var(--nx-radius-md);
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.65;
}
.entry-content pre code {
  background: none;
  border: none;
  color: #E4E4F0;
  padding: 0;
  font-size: 14px;
}

/* Imágenes dentro del contenido */
.entry-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--nx-radius-lg);
  box-shadow: var(--nx-shadow-md);
}
.entry-content figure { margin: 2em 0; }
.entry-content figcaption {
  margin-top: 10px;
  font-size: 13.5px;
  color: var(--nx-xmuted);
  text-align: center;
}

/* ─── Tablas ───────────────────────────────────────
   En móvil la tabla NO se aplasta: el contenedor hace
   scroll horizontal y las columnas mantienen un ancho
   cómodo, así las palabras nunca se parten.            */
.nx-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--nx-border);
  border-radius: var(--nx-radius-md);
  box-shadow: var(--nx-shadow-sm);
  scrollbar-width: thin;
  scrollbar-color: var(--nx-border) transparent;
}
.nx-table-scroll::-webkit-scrollbar { height: 7px; }
.nx-table-scroll::-webkit-scrollbar-thumb {
  background: var(--nx-border);
  border-radius: 4px;
}
.entry-content table {
  width: 100%;
  min-width: 560px;          /* fuerza scroll antes que aplastar columnas */
  border-collapse: collapse;
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  background: #fff;
}
/* Tabla sin wrapper (fallback si el JS no corre) */
.entry-content > table {
  display: block;
  overflow-x: auto;
  border: 1px solid var(--nx-border);
  border-radius: var(--nx-radius-md);
}
.entry-content thead th {
  background: var(--nx-bg-gray);
  color: var(--nx-ink);
  font-weight: 700;
  text-align: left;
  font-size: 14px;
}
.entry-content th,
.entry-content td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--nx-border-light);
  vertical-align: top;
  word-break: normal;
  overflow-wrap: normal;
  hyphens: none;            /* evita cortes tipo "implement-ación" */
}
.entry-content th:not(:last-child),
.entry-content td:not(:last-child) {
  border-right: 1px solid var(--nx-border-light);
}
.entry-content tbody tr:last-child td { border-bottom: none; }
.entry-content tbody tr:hover { background: var(--nx-bg-gray); }

/* Regla horizontal */
.entry-content hr {
  border: none;
  height: 1px;
  margin: 2.4em 0;
  background: linear-gradient(90deg, transparent, var(--nx-border), transparent);
}

/* ═══════════════════════════════════════════════════
   6. TAGS / NAVEGACIÓN / PIE DEL ARTÍCULO
═══════════════════════════════════════════════════ */
.hc-cat-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--nx-bg-gray);
  border: 1px solid var(--nx-border);
  color: var(--nx-medium);
  font-size: 12.5px;
  font-weight: 600;
  transition: all .18s;
}
.hc-cat-badge:hover {
  border-color: var(--nx-primary);
  color: var(--nx-primary);
  background: var(--nx-primary-bg);
}

/* Botones (compat .btn / .btn-outline del single.php) */
.single-content .btn,
.single-content .btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: var(--nx-radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: 1.5px solid var(--nx-border);
  background: #fff;
  color: var(--nx-ink);
  transition: border-color .18s, color .18s, background .18s, transform .18s;
  line-height: 1.4;
}
.single-content .btn-outline:hover {
  border-color: var(--nx-primary);
  color: var(--nx-primary);
  background: var(--nx-primary-bg);
  transform: translateY(-1px);
}

/* Navegación prev/next como tarjetas */
.hc-pagination {
  display: flex;
  gap: 16px;
  margin-top: 48px;
  padding-top: 28px;
  border-top: 1px solid var(--nx-border);
}
.hc-pagination .btn-outline {
  max-width: 48%;
  white-space: normal;
  text-align: left;
  line-height: 1.35;
}

/* ═══════════════════════════════════════════════════
   7. SIDEBAR
═══════════════════════════════════════════════════ */
.blog-sidebar {
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.sidebar-widget {
  padding: 24px;
  background: #fff;
  border: 1px solid var(--nx-border);
  border-radius: var(--nx-radius-lg);
  box-shadow: var(--nx-shadow-sm);
}
.widget-title {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--nx-ink);
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--nx-border-light);
}

/* Recientes */
.sidebar-widget ul li a:hover { color: var(--nx-primary) !important; }

/* Categorías (wp_list_categories) */
.sidebar-widget ul.wp-block-categories,
.sidebar-widget > ul,
.sidebar-widget ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidebar-widget ul li { margin-top: 0; }
.sidebar-widget > ul > li:not(:last-child) { margin-bottom: 4px; }
.sidebar-widget a[href*="category"],
.sidebar-widget .cat-item a {
  display: inline-flex;
  font-size: 14px;
  color: var(--nx-medium);
  padding: 6px 0;
}
.sidebar-widget .cat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--nx-border-light);
}
.sidebar-widget .cat-item:last-child { border-bottom: none; }
.sidebar-widget .cat-item a:hover { color: var(--nx-primary); }

/* Search form */
.sidebar-widget form,
.sidebar-widget .search-form {
  display: flex;
  gap: 8px;
}
.sidebar-widget input[type="search"],
.sidebar-widget input[type="text"] {
  flex: 1;
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--nx-ink);
  border: 1px solid var(--nx-border);
  border-radius: var(--nx-radius-sm);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.sidebar-widget input[type="search"]:focus,
.sidebar-widget input[type="text"]:focus {
  border-color: var(--nx-primary);
  box-shadow: 0 0 0 3px var(--nx-primary-bg);
}
.sidebar-widget button[type="submit"],
.sidebar-widget input[type="submit"] {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--nx-primary);
  border: none;
  border-radius: var(--nx-radius-sm);
  cursor: pointer;
  transition: background .18s;
}
.sidebar-widget button[type="submit"]:hover,
.sidebar-widget input[type="submit"]:hover { background: var(--nx-primary-h); }

/* ═══════════════════════════════════════════════════
   8. COMENTARIOS
═══════════════════════════════════════════════════ */
.single-content .comments-area,
.single-content #comments {
  margin-top: 56px;
  padding-top: 40px;
  border-top: 1px solid var(--nx-border);
}
.single-content .comments-title,
.single-content .comment-reply-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--nx-ink);
  margin-bottom: 24px;
}
.single-content .comment-list { list-style: none; margin: 0; padding: 0; }
.single-content .comment-body {
  padding: 20px;
  margin-bottom: 16px;
  background: var(--nx-bg-gray);
  border-radius: var(--nx-radius-md);
}
.single-content .comment-author .fn { font-weight: 700; color: var(--nx-ink); }
.single-content .comment-metadata a { color: var(--nx-xmuted); font-size: 13px; }
.single-content .comment-form input[type="text"],
.single-content .comment-form input[type="email"],
.single-content .comment-form input[type="url"],
.single-content .comment-form textarea {
  width: 100%;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 15px;
  color: var(--nx-ink);
  border: 1px solid var(--nx-border);
  border-radius: var(--nx-radius-sm);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.single-content .comment-form input:focus,
.single-content .comment-form textarea:focus {
  border-color: var(--nx-primary);
  box-shadow: 0 0 0 3px var(--nx-primary-bg);
}
.single-content .comment-form .form-submit input,
.single-content .comment-form .submit {
  width: auto;
  padding: 12px 24px;
  color: #fff;
  font-weight: 600;
  background: var(--nx-primary);
  border-color: var(--nx-primary);
  cursor: pointer;
}
.single-content .comment-form .form-submit input:hover { background: var(--nx-primary-h); }

/* ═══════════════════════════════════════════════════
   9. RESPONSIVE
═══════════════════════════════════════════════════ */
@media (max-width: 980px) {
  .single-layout {
    grid-template-columns: 1fr;
    gap: 40px;
    padding: 36px 0 64px;
  }
  .blog-sidebar { position: static; }
}

@media (max-width: 640px) {
  body.single .container,
  body.page .container,
  body.archive .container { padding: 0 20px; }

  .entry-content { font-size: 17px; line-height: 1.7; }
  .entry-content p,
  .entry-content ul,
  .entry-content ol,
  .entry-content blockquote,
  .entry-content pre,
  .entry-content figure,
  .entry-content .nx-table-scroll { margin-bottom: 1.7em; }
  .entry-content > p:first-of-type { font-size: 18px; }
  .entry-content > p:first-of-type::first-letter {
    font-size: 3em;
    margin: 4px 8px 0 0;
  }
  .entry-content h2 { margin-top: 2.4em; }
  .entry-content h3 { margin-top: 2em; }
  .single-thumb { border-radius: var(--nx-radius-lg); }
  .hc-pagination { flex-direction: column; }
  .hc-pagination .btn-outline { max-width: 100%; }
}

/* Accesibilidad: respeta reduce-motion */
@media (prefers-reduced-motion: reduce) {
  .nx-read-progress { transition: none; }
}
