/**
 * Estilos editoriales para entradas individuales (Single Post) en Marlon Academy Lite.
 * Incluye soporte nativo para las clases BEM del Editor Clásico (.post__*, .toc*, .reference-list*)
 * y los componentes académicos (.mal-*).
 */

/* ==========================================================================
   1. LAYOUT PRINCIPAL (GRID FLUIDO)
   ========================================================================== */

.site-main.mal-single-main {
  box-sizing: border-box;
  display: grid;
  gap: var(--space-2xl);
  align-items: start;
  width: 100%;
  max-width: var(--mal-container-max);
  padding: var(--mal-page-pad-top) var(--mal-container-pad-x) var(--mal-page-pad-bottom);
  margin: 0 auto;
}

.site-main.mal-layout-has-sidebar {
  grid-template-columns: 280px minmax(0, 1fr);
}

@media (max-width: 1100px) {
  .site-main.mal-layout-has-sidebar {
    grid-template-columns: 1fr;
  }

  .site-main.mal-layout-has-sidebar .mal-article-content {
    margin-right: auto;
    margin-left: auto;
  }
}

/* ==========================================================================
   2. COLUMNA IZQUIERDA: TOC STICKY + METADATOS + COMPARTIR
   ========================================================================== */

.mal-sidebar-left {
  position: sticky;
  top: calc(var(--header-h) + var(--wp-admin-bar-h) + 2rem);
  max-height: calc(100vh - var(--header-h) - var(--wp-admin-bar-h) - 4rem);
  padding: var(--space-lg);
  overflow-y: auto;
  scrollbar-width: thin;
  background-color: var(--mal-bg-card);
  border: 1px solid var(--mal-border);
  border-radius: var(--radius-lg);
}

@media (max-width: 1100px) {
  .mal-sidebar-left {
    display: none;
  }
}

.mal-toc-title {
  margin: 0 0 var(--space-lg);
  font-family: var(--font-heading);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--mal-text-main);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#mal-toc-nav ul {
  position: relative;
  padding: 0;
  margin: 0;
  list-style: none;
  border-left: 2px solid var(--mal-border);
}

#mal-toc-nav li {
  position: relative;
  margin-bottom: var(--space-md);
}

#mal-toc-nav a {
  display: block;
  padding-left: var(--space-md);
  font-size: var(--fs-sm);
  line-height: 1.4;
  color: var(--mal-text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

#mal-toc-nav a:hover,
#mal-toc-nav a.is-active,
#mal-toc-nav a[aria-current="true"] {
  font-weight: var(--fw-semibold);
  color: var(--mal-primary);
}

#mal-toc-nav a::before {
  position: absolute;
  top: 6px;
  left: -6px;
  width: 10px;
  height: 10px;
  content: "";
  background-color: var(--mal-text-muted);
  border-radius: 50%;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

#mal-toc-nav a.is-active::before,
#mal-toc-nav a[aria-current="true"]::before {
  background-color: var(--mal-primary);
  transform: scale(1.2);
}

#mal-toc-nav a:focus-visible,
.mal-share-btn:focus-visible,
.mal-nav-link:focus-within {
  outline: 2px solid var(--mal-focus-ring);
  outline-offset: 2px;
}

/* Metadatos en Sidebar */
.mal-sidebar-meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.mal-sidebar-meta.has-top-border {
  padding-top: var(--space-md);
  margin-top: var(--space-lg);
  border-top: 1px solid var(--mal-border);
}

.mal-sidebar-meta-item {
  font-size: var(--fs-xs);
  line-height: 1.4;
  color: var(--mal-text-muted);
}

/* Botones de compartir */
.mal-share-sidebar {
  display: flex;
  gap: 10px;
  padding-top: var(--space-lg);
  margin-top: var(--space-lg);
  border-top: 1px solid var(--mal-border);
}

.mal-share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--mal-text-muted);
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--mal-border);
  border-radius: 50%;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.mal-share-btn svg {
  flex: none;
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.mal-share-btn:hover {
  color: var(--mal-on-gold);
  background-color: var(--mal-brand-gold);
  border-color: var(--mal-brand-gold);
}

.mal-aria-live {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  white-space: nowrap;
  border: 0;
  clip-path: inset(50%);
}

/* ==========================================================================
   3. COLUMNA DERECHA: CABECERA Y CUERPO DEL ARTÍCULO
   ========================================================================== */

.mal-article-content {
  width: 100%;
  max-width: 720px;
}

.mal-article-category a {
  display: inline-block;
  padding: var(--space-2xs) var(--space-sm);
  margin-bottom: var(--space-lg);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--mal-on-gold);
  letter-spacing: 0.03em;
  text-decoration: none;
  background-color: var(--mal-brand-gold);
  border-radius: var(--radius-sm);
}

.mal-article-category a:hover {
  background-color: var(--mal-brand-gold-hover);
}

.mal-article-title {
  margin: 0 0 var(--space-md);
  font-family: var(--font-heading);
  font-size: var(--fs-2xl);
  line-height: 1.2;
  color: var(--mal-text-main);
}

/* Metadatos (Exclusivo móvil/tableta) */
.mal-article-meta {
  display: none;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: var(--space-xl);
}

.mal-meta-item,
.mal-meta-separator {
  font-size: var(--fs-sm);
  color: var(--mal-text-muted);
}

@media (max-width: 1100px) {
  .mal-article-meta.mal-show-mobile-flex {
    display: flex;
  }
}

.mal-article-thumbnail {
  width: 100%;
  margin: 0 0 var(--space-2xl);
  overflow: hidden;
  border-radius: var(--radius-lg);
}

.mal-article-thumbnail img {
  display: block;
  width: 100%;
  height: auto;
}

/* Tipografía base del cuerpo */
.mal-post-body,
.post__body {
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: 1.75;
  color: var(--mal-text-main);
}

.mal-post-body p,
.mal-post-body li,
.post__p {
  margin-top: 0;
  margin-bottom: var(--space-md);
  color: var(--mal-text-main);
}

.mal-post-body h2,
.mal-post-body h3,
.mal-post-body h4,
.post__h2 {
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-md);
  font-family: var(--font-heading);
  line-height: 1.3;
  color: var(--mal-text-main);
}

.mal-post-body h2,
.post__h2 {
  scroll-margin-top: calc(var(--header-h) + var(--wp-admin-bar-h) + 2rem);
}

.mal-post-body a,
.post__a {
  color: var(--mal-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.mal-post-body a:hover,
.post__a:hover {
  color: var(--mal-primary-hover);
}

.mal-post-body img,
.post__img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}

/* ==========================================================================
   4. CLASES BEM DEL EDITOR CLÁSICO (.post__*, .toc*, .reference-list*)
   ========================================================================== */

/* Párrafo introductorio destacado */
.post__p--lead {
  font-size: clamp(1.15rem, 1.08rem + 0.35vw, 1.32rem);
  line-height: 1.65;
  color: var(--mal-text-main);
}

/* Tabla de contenidos interna (.toc):
   En escritorio (>1100px) se oculta si existe la barra lateral sticky para no duplicar */
@media (min-width: 1101px) {
  .mal-has-sidebar-toc .post__body .toc {
    display: none;
  }
}

.post__body .toc {
  padding: var(--space-lg);
  margin: var(--space-xl) 0;
  background-color: var(--mal-bg-card);
  border: 1px solid var(--mal-border);
  border-left: 4px solid var(--mal-brand-gold);
  border-radius: var(--radius-md);
}

.toc__p--title {
  margin: 0 0 var(--space-sm) !important;
  font-family: var(--font-heading);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--mal-text-main);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.toc__ul {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding-left: var(--space-lg);
  margin: 0;
}

.toc__li {
  margin: 0;
  font-size: var(--fs-sm);
}

.toc__a {
  font-weight: var(--fw-semibold);
  color: var(--mal-primary);
  text-decoration: none;
}

.toc__a:hover {
  color: var(--mal-primary-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Bloque destacado de definición / idea clave */
.post__blockquote--highlight {
  padding: var(--space-lg);
  margin: var(--space-xl) 0;
  color: var(--mal-text-main);
  background-color: var(--mal-bg-callout);
  border: 1px solid var(--mal-border);
  border-left: 4px solid var(--mal-brand-gold);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* Cita textual académica */
.mal-post-body blockquote,
.post__blockquote {
  padding: var(--space-md) var(--space-lg);
  margin: var(--space-xl) 0;
  font-style: italic;
  color: var(--mal-text-main);
  background-color: var(--mal-bg-card);
  border-left: 4px solid var(--mal-primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.post__p--quote-text {
  margin-bottom: 0 !important;
}

/* Figuras e ilustraciones */
.post__figure {
  margin: var(--space-xl) 0;
  overflow: hidden;
  background-color: var(--mal-bg-card);
  border: 1px solid var(--mal-border);
  border-radius: var(--radius-lg);
}

/* Llamado final a la reflexión / debate */
.post__p--cta {
  padding: var(--space-lg);
  margin-top: var(--space-xl);
  background-color: var(--mal-bg-card);
  border: 1px solid var(--mal-border);
  border-radius: var(--radius-md);
}

/* Superíndices de citas en texto (#citation-1, etc.) */
.post__a--citation {
  display: inline-block;
  padding: 0 2px;
  font-weight: var(--fw-bold);
  color: var(--mal-primary);
  text-decoration: none !important;
  scroll-margin-top: calc(var(--header-h) + var(--wp-admin-bar-h) + 2.5rem);
}

.post__a--citation:hover {
  color: var(--mal-primary-hover);
  text-decoration: underline !important;
}

.post__sup {
  font-size: 0.75em;
  line-height: 0;
}

/* Lista de referencias bibliográficas (.reference-list) */
.reference-list {
  padding-top: var(--space-xl);
  margin-top: var(--space-2xl);
  border-top: 1px solid var(--mal-border);
}

.reference-list__title {
  margin: 0 0 var(--space-md) !important;
  font-family: var(--font-heading);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: var(--mal-text-main);
}

.reference-list__ol {
  padding-left: var(--space-lg);
  margin: 0;
}

.reference-list__li {
  margin-bottom: var(--space-sm);
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--mal-text-muted);
  overflow-wrap: anywhere;
  scroll-margin-top: calc(var(--header-h) + var(--wp-admin-bar-h) + 2.5rem);
}

.reference-list__a {
  color: var(--mal-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.reference-list__a:hover {
  color: var(--mal-primary-hover);
}

.reference-list__a--backlink {
  display: inline-block;
  margin-left: var(--space-xs);
  font-weight: var(--fw-bold);
  text-decoration: none !important;
  transition: transform 0.15s ease, color 0.15s ease;
}

.reference-list__a--backlink:hover {
  transform: translateY(-2px);
}

/* ==========================================================================
   5. APÉNDICE ACADÉMICO (CITACIÓN APA/BIBTEX, NOTAS Y AUTOR)
   ========================================================================== */

.mal-article-appendix {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  padding-top: var(--space-xl);
  margin: var(--space-2xl) 0;
  border-top: 1px solid var(--mal-border);
}

.mal-citation-box {
  overflow: hidden;
  border: 1px solid var(--mal-border);
  border-radius: var(--radius-lg);
}

.mal-citation-intro {
  padding: var(--space-md) var(--space-lg);
  margin: 0;
  font-size: var(--fs-sm);
  font-style: italic;
  color: var(--mal-text-muted);
  background-color: var(--mal-bg-page);
}

.mal-citation-header {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-lg);
  background-color: var(--mal-bg-card);
  border-top: 1px solid var(--mal-border);
  border-bottom: 1px solid var(--mal-border);
}

.mal-citation-title {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0 !important;
  font-size: var(--fs-sm);
  color: var(--mal-text-main);
}

.mal-citation-title .mal-icon-info {
  color: var(--mal-primary);
}

.mal-citation-tabs {
  display: inline-flex;
  overflow: hidden;
  background-color: var(--mal-bg-page);
  border: 1px solid var(--mal-border);
  border-radius: var(--radius-md);
}

button.mal-citation-tab {
  padding: 0.35rem 1rem;
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  line-height: 1.4;
  color: var(--mal-text-muted);
  cursor: pointer;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

button.mal-citation-tab:hover {
  color: var(--mal-text-main);
  background-color: var(--mal-bg-callout);
}

button.mal-citation-tab.is-active {
  color: var(--mal-on-gold);
  background-color: var(--mal-brand-gold);
}

button.mal-citation-tab:focus-visible {
  outline: 2px solid var(--mal-focus-ring);
  outline-offset: -2px;
}

.mal-citation-panels {
  padding: var(--space-lg);
  background-color: var(--mal-bg-page);
}

.mal-citation-panel {
  font-size: var(--fs-sm);
  line-height: 1.65;
  color: var(--mal-text-main);
  overflow-wrap: anywhere;
}

.mal-citation-panel[hidden] {
  display: none !important;
}

.mal-citation-panel pre {
  padding: var(--space-md);
  margin: 0;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: var(--fs-xs);
  line-height: 1.55;
  color: var(--mal-text-main);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  background-color: var(--mal-bg-card);
  border: 1px solid var(--mal-border);
  border-radius: var(--radius-sm);
}

.mal-citation-panel pre code {
  padding: 0;
  font-family: inherit;
  color: inherit;
  background: transparent;
}

.mal-citation-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-md);
}

button.mal-copy-citation-btn {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.45rem 0.9rem;
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  line-height: 1.4;
  color: var(--mal-text-main);
  cursor: pointer;
  background-color: var(--mal-bg-card);
  border: 1px solid var(--mal-border);
  border-radius: var(--radius-sm);
  box-shadow: none;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

button.mal-copy-citation-btn:hover {
  color: var(--mal-text-main);
  background-color: var(--mal-bg-callout);
  border-color: var(--mal-primary);
}

/* Caja de Notas */
.mal-notes-box {
  padding: var(--space-lg);
  background-color: var(--mal-bg-hero);
  border: 1px solid var(--mal-border);
  border-radius: var(--radius-md);
}

.mal-notes-box h3 {
  margin: 0 0 var(--space-xs) 0 !important;
  font-size: var(--fs-sm);
  color: var(--mal-text-main);
}

.mal-notes-box p {
  margin: 0 0 var(--space-md) 0;
  font-size: var(--fs-sm);
  color: var(--mal-text-muted);
}

.mal-notes-box p:last-child {
  margin-bottom: 0;
}

/* Caja de Autor */
.mal-author-box {
  display: flex;
  gap: var(--space-lg);
  padding: var(--space-lg);
  background-color: var(--mal-bg-card);
  border: 1px solid var(--mal-border);
  border-radius: var(--radius-md);
}

.mal-author-avatar {
  flex-shrink: 0;
}

.mal-author-avatar img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 50%;
}

.mal-author-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.mal-author-name {
  margin: 0 0 var(--space-2xs) 0 !important;
  font-size: var(--fs-md);
  color: var(--mal-primary);
}

.mal-author-desc {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--mal-text-main);
}

@media (max-width: 540px) {
  .mal-author-box {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}

/* ==========================================================================
   6. PIE DEL ARTÍCULO, NAVEGACIÓN Y COMENTARIOS
   ========================================================================== */

.mal-article-footer {
  padding-top: var(--space-xl);
  margin-top: 3.5rem;
  border-top: 1px solid var(--mal-border);
}

.mal-post-navigation {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-lg);
  margin-bottom: var(--space-2xl);
}

.mal-nav-link {
  position: relative;
  flex: 1;
  min-width: 240px;
  padding: var(--space-lg);
  background: var(--mal-bg-card);
  border: 1px solid var(--mal-border);
  border-radius: var(--radius-md);
  transition: border-color 0.2s ease;
}

.mal-nav-link:hover {
  border-color: var(--mal-brand-gold);
}

.mal-nav-label {
  display: block;
  margin-bottom: var(--space-xs);
  font-size: var(--fs-xs);
  color: var(--mal-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mal-nav-link a {
  display: block;
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  color: var(--mal-text-main);
  text-decoration: none;
}

.mal-nav-link a::before {
  position: absolute;
  inset: 0;
  content: "";
}

.mal-single-main .comments-area,
.mal-single-main #comments {
  color: var(--mal-text-main);
}

.mal-single-main .comment-reply-title,
.mal-single-main .comments-title {
  font-family: var(--font-heading);
  color: var(--mal-text-main);
}

.mal-single-main .comment-respond label,
.mal-single-main .comment-notes,
.mal-single-main .logged-in-as,
.mal-single-main .comment-form-cookies-consent {
  color: var(--mal-text-muted);
}

.mal-single-main .comment-respond input[type="text"],
.mal-single-main .comment-respond input[type="email"],
.mal-single-main .comment-respond input[type="url"],
.mal-single-main .comment-respond textarea {
  box-sizing: border-box;
  width: 100%;
  padding: var(--space-sm);
  color: var(--mal-text-main);
  background-color: var(--mal-bg-card);
  border: 1px solid var(--mal-border);
  border-radius: var(--radius-md);
}

.mal-single-main .comment-respond input[type="submit"] {
  padding: var(--space-xs) var(--space-lg);
  font-weight: var(--fw-bold);
  color: var(--mal-on-gold);
  cursor: pointer;
  background-color: var(--mal-brand-gold);
  border: 0;
  border-radius: var(--radius-md);
}

.mal-single-main .comment-respond input[type="submit"]:hover {
  background-color: var(--mal-brand-gold-hover);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto !important;
  }

  #mal-toc-nav a,
  #mal-toc-nav a::before,
  .mal-share-btn,
  .reference-list__a--backlink {
    transition: none;
  }
}
