/* =========================================================
   BRAINVESTO — ARTICLE.CSS
   =========================================================
   Estilos exclusivos de single.php. Depende de tokens.css y
   base.css (Fase 1) — no redefine ningún color, espaciado,
   radius, sombra o peso tipográfico: todo se referencia
   desde las variables ya existentes.

   Esta plantilla es la ÚNICA para todas las entradas de
   Brainvesto. Ningún artículo debe tener un diseño propio.
========================================================= */

/* ---------------------------------------------------
   1. BARRA DE PROGRESO DE LECTURA
   Discreta, no distrae, se posiciona justo debajo del
   header sticky (mismo z-index de referencia que el header).
--------------------------------------------------- */
.reading-progress{
  position: sticky;
  top: var(--header-height);
  left: 0;
  width: 100%;
  height: 3px;
  background: transparent;
  z-index: var(--z-header);
}

.reading-progress__bar{
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.1s ease-out;
}

/* ---------------------------------------------------
   2. BREADCRUMB
   Trasladado a base.css en la Fase 5: el breadcrumb es un
   componente global (lo usan artículos y categorías, y lo
   usarán búsqueda/404 en fases futuras), no algo exclusivo
   de single.php. Las reglas viven ahora en base.css junto
   al resto de componentes compartidos.
--------------------------------------------------- */

/* ---------------------------------------------------
   3. CABECERA DEL ARTÍCULO
--------------------------------------------------- */
.article-header{
  padding: var(--space-6) 0 var(--space-7);
}

.article-header__meta-top{
  margin-top: var(--space-5);
}

.article-header__category{
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--secondary);
  background: var(--secondary-soft);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  transition: background var(--transition-fast);
}
.article-header__category:hover{
  background: var(--secondary);
  color: #fff;
}

.article-header__title{
  font-size: var(--text-2xl);
  letter-spacing: -0.02em;
  margin-top: var(--space-4);
  max-width: 22ch;
}

.article-header__excerpt{
  font-size: var(--text-md);
  color: var(--text);
  max-width: 65ch;
  margin-top: var(--space-4);
}

.article-header__meta{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-5);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-5);
}

.article-header__author{
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--heading);
  font-weight: var(--fw-medium);
}

.article-header__avatar{
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

/* ---------------------------------------------------
   4. IMAGEN DESTACADA
--------------------------------------------------- */
.article-hero{
  margin-bottom: var(--space-8);
}

.article-hero__image{
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.article-hero__image img{
  width: 100%;
  height: auto;
}

/* Alternativa elegante cuando la entrada no tiene imagen
   destacada — nunca se muestra una imagen rota */
.article-hero__placeholder{
  border-radius: var(--radius-lg);
  aspect-ratio: 21 / 9;
  background: linear-gradient(135deg, var(--primary-soft), var(--secondary-soft));
  display: flex;
  align-items: center;
  justify-content: center;
}

.article-hero__placeholder-icon{
  font-size: 3rem;
  opacity: 0.5;
}

/* ---------------------------------------------------
   5. LAYOUT DE DOS COLUMNAS
   Mobile first: una columna; el sidebar pasa a una
   segunda columna solo desde escritorio.
--------------------------------------------------- */
.article-layout{
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
  padding-bottom: var(--space-9);
}

@media (min-width: 1020px){
  .article-layout{
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
  }
}

.article-layout__content{
  min-width: 0; /* evita que el contenido largo desborde el grid */
}

/* ---------------------------------------------------
   6. CUERPO DEL ARTÍCULO — tipografía de contenido
   Único conjunto de reglas tipográficas para el contenido
   generado por the_content(); coherente con base.css.
--------------------------------------------------- */
.article-body{
  max-width: var(--content-max);
}

.article-body > *:first-child{
  margin-top: 0;
}

.article-body h2{
  font-size: var(--text-xl);
  margin-top: var(--space-8);
  margin-bottom: var(--space-4);
  scroll-margin-top: calc(var(--header-height) + var(--space-5));
}

.article-body h3{
  font-size: var(--text-lg);
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
  scroll-margin-top: calc(var(--header-height) + var(--space-5));
}

.article-body p{
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--text);
  margin-bottom: var(--space-5);
}

.article-body ul,
.article-body ol{
  margin: 0 0 var(--space-5) 0;
  padding-left: var(--space-5);
}

.article-body li{
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--text);
  margin-bottom: var(--space-2);
}

.article-body a{
  color: var(--secondary);
  text-decoration: underline;
  text-decoration-color: var(--secondary-soft);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--transition-fast);
}
.article-body a:hover{
  text-decoration-color: var(--secondary);
}

.article-body strong{
  color: var(--heading);
  font-weight: var(--fw-semibold);
}

.article-body img{
  border-radius: var(--radius-md);
  margin: var(--space-6) 0;
}

.article-body figure{
  margin: var(--space-6) 0;
}

.article-body figcaption{
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-align: center;
  margin-top: var(--space-2);
}

/* Video embebido — mantiene proporción 16:9 de forma
   responsive (WordPress envuelve embeds en .wp-embed-responsive
   o el bloque de video con figure/iframe) */
.article-body iframe,
.article-body video{
  width: 100%;
  border-radius: var(--radius-md);
  aspect-ratio: 16 / 9;
  height: auto;
}

.article-body blockquote{
  margin: var(--space-6) 0;
  padding: var(--space-5) var(--space-6);
  border-left: 4px solid var(--primary);
  background: var(--surface);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: var(--text-md);
  font-style: italic;
  color: var(--heading);
}

.article-body blockquote p:last-child{
  margin-bottom: 0;
}

.article-body table{
  margin: var(--space-6) 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-size: var(--text-sm);
}

.article-body th{
  text-align: left;
  background: var(--surface);
  color: var(--heading);
  font-weight: var(--fw-bold);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.article-body td{
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.article-body tr:last-child td{
  border-bottom: none;
}

/* Código — en línea y en bloque */
.article-body code{
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  color: var(--heading);
}

.article-body pre{
  background: var(--heading);
  color: #fff;
  border-radius: var(--radius-md);
  padding: var(--space-5);
  overflow-x: auto;
  margin: var(--space-6) 0;
}

.article-body pre code{
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
}

/* Cards dentro del contenido del artículo (reutiliza .card
   de base.css, no se redefine aquí) */
.article-body .card{
  margin: var(--space-6) 0;
}

/* ---------------------------------------------------
   7. CALLOUTS
   Cuatro variantes, cada una con su color documentado
   en la Fase 1 (primary, secondary, accent, danger).
--------------------------------------------------- */
.callout{
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin: var(--space-6) 0;
  border: 1px solid transparent;
}

.callout__icon{
  font-size: 1.3rem;
  line-height: 1;
  flex-shrink: 0;
}

.callout__title{
  font-weight: var(--fw-bold);
  font-size: var(--text-sm);
  margin-bottom: var(--space-1);
}

.callout__body{
  font-size: var(--text-sm);
  color: var(--text);
  line-height: var(--leading-normal);
}

.callout__body p:last-child{
  margin-bottom: 0;
}

/* Definición — color principal */
.callout--definicion{
  background: var(--primary-soft);
  border-color: rgba(21, 128, 61, 0.18);
}
.callout--definicion .callout__title{ color: var(--primary); }

/* Consejo — color secundario */
.callout--consejo{
  background: var(--secondary-soft);
  border-color: rgba(37, 99, 235, 0.18);
}
.callout--consejo .callout__title{ color: var(--secondary); }

/* Importante — color de acento */
.callout--importante{
  background: var(--accent-soft);
  border-color: rgba(245, 158, 11, 0.25);
}
.callout--importante .callout__title{ color: #B45309; }

/* Advertencia — color de alerta suave (--danger, ya
   documentado en tokens.css como color de estado) */
.callout--advertencia{
  background: var(--danger-soft);
  border-color: rgba(220, 38, 38, 0.18);
}
.callout--advertencia .callout__title{ color: var(--danger); }

/* ---------------------------------------------------
   8. ARTÍCULOS RELACIONADOS
--------------------------------------------------- */
.related-articles{
  margin-top: var(--space-9);
  padding-top: var(--space-8);
  border-top: 1px solid var(--border);
}

.related-articles__title{
  font-size: var(--text-xl);
  margin-bottom: var(--space-5);
}

.related-articles__grid{
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
}

@media (min-width: 640px){
  .related-articles__grid{
    grid-template-columns: repeat(3, 1fr);
  }
}

.related-article-card{
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.related-article-card__image{
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary-soft), var(--secondary-soft));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  overflow: hidden;
}

.related-article-card__image img{
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.related-article-card__category{
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.related-article-card__title{
  font-size: var(--text-base);
  margin-bottom: 0;
}

/* ---------------------------------------------------
   9. SIDEBAR
--------------------------------------------------- */
.article-sidebar{
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

@media (min-width: 1020px){
  .article-sidebar{
    position: sticky;
    top: calc(var(--header-height) + var(--space-5));
  }
}

/* --- Tabla de contenidos --- */
.toc{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
}

.toc__toggle{
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-base);
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
}

.toc__toggle-icon{
  transition: transform var(--transition-fast);
}

/* En escritorio la TOC permanece siempre visible: el botón
   se comporta como una etiqueta estática, sin funcionalidad
   de colapso (evita ocultar contenido útil cuando ya hay
   espacio de sobra en el sidebar) */
@media (min-width: 1020px){
  .toc__toggle{
    cursor: default;
    pointer-events: none;
  }
  .toc__toggle-icon{
    display: none;
  }
}

.toc__list{
  margin-top: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

/* En móvil, la TOC se comporta como sección desplegable
   (colapsada por defecto, controlada por article.js) */
@media (max-width: 1019px){
  .toc__list{
    max-height: 0;
    overflow: hidden;
    margin-top: 0;
    transition: max-height var(--transition-base);
  }
  .toc.is-open .toc__list{
    max-height: 600px;
    margin-top: var(--space-4);
  }
  .toc.is-open .toc__toggle-icon{
    transform: rotate(180deg);
  }
}

.toc__item{
  list-style: none;
}

.toc__item--level-3{
  padding-left: var(--space-4);
}

.toc__item a{
  display: block;
  font-size: var(--text-sm);
  color: var(--text);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.toc__item a:hover{
  background: var(--background);
  color: var(--primary);
}

/* Enlace de la sección actualmente visible (clase añadida
   por article.js mediante IntersectionObserver) */
.toc__item a.is-active{
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: var(--fw-semibold);
}

/* --- Newsletter del sidebar --- */
.sidebar-newsletter{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
}

.sidebar-newsletter__title{
  font-size: var(--text-md);
  margin-bottom: var(--space-2);
}

.sidebar-newsletter__text{
  font-size: var(--text-sm);
  color: var(--text);
  margin-bottom: var(--space-4);
}

.sidebar-newsletter__form{
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.sidebar-newsletter__input{
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  font-size: var(--text-sm);
  background: var(--background);
}
.sidebar-newsletter__input:focus-visible{
  border-color: var(--primary);
}

/* --- Herramienta relacionada (reutiliza .card de base.css) --- */
.sidebar-tool .card__icon{
  margin-bottom: var(--space-4);
}

/* ---------------------------------------------------
   10. COMENTARIOS — versión básica (Fase 4)
   El sistema visual avanzado se construye en la Fase 9;
   aquí solo se garantiza coherencia con la identidad de
   Brainvesto (colores, radius, espaciado, tipografía).
--------------------------------------------------- */
.article-comments{
  margin-top: var(--space-9);
  padding-top: var(--space-8);
  border-top: 1px solid var(--border);
  max-width: var(--content-max);
}

.comments-area__title{
  font-size: var(--text-xl);
  margin-bottom: var(--space-5);
}

.comment-list{
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  margin: 0 0 var(--space-6) 0;
  padding: 0;
}

.comment-list .comment{
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
}

.comment-list .comment-author img{
  border-radius: var(--radius-full);
}

.comments-area__closed-notice{
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.comment-form__group{
  margin-bottom: var(--space-4);
}

.comment-form__group label{
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--heading);
  margin-bottom: var(--space-2);
}

.comment-form__input,
.comment-form__textarea{
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-family: var(--font-base);
  font-size: var(--text-base);
  background: var(--background);
  color: var(--text);
}

.comment-form__input:focus-visible,
.comment-form__textarea:focus-visible{
  border-color: var(--primary);
}
