/* =========================================================
   RACP — Hoja de estilo para HTML generado con Pandoc
   Revista Argentina de Coloproctología
   Versión 3 — ajuste fino de escala y espaciado
   ========================================================= */

:root {
  --racp-text: #231f20;
  --racp-accent: #2e96a1;
  --racp-muted: #6b6b6b;
  --racp-rule: #d6d6d6;
  --racp-serif: "Minion Pro", Georgia, "Times New Roman", serif;
  --racp-sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

html {
  background: #ffffff;
  color: var(--racp-text);
}

body {
  max-width: 830px;
  margin: 0 auto;
  padding: 40px 28px 68px;
  background: #ffffff;
  color: var(--racp-text);
  font-family: var(--racp-serif);
  font-size: 14.5px;
  line-height: 1.48;
  hyphens: none;
  overflow-wrap: break-word;
  text-rendering: optimizeLegibility;
}

/* =========================================================
   LIMPIEZA EDITORIAL
   ========================================================= */

#title-block-header + div[data-custom-style="Body Text"],
#title-block-header + div[data-custom-style="Body Text"] + div[data-custom-style="Body Text"],
#title-block-header + div[data-custom-style="Body Text"] + div[data-custom-style="Body Text"] + div[data-custom-style="Body Text"] {
  display: none;
}

p:empty,
p:has(> br:only-child),
p:has(> strong:only-child > br:only-child),
p:has(> span:only-child > br:only-child) {
  display: none;
}

/* =========================================================
   TÍTULO Y AUTORES
   ========================================================= */

#title-block-header {
  margin: 0 0 12px;
}

#title-block-header .title {
  margin: 0;
  color: var(--racp-text);
  font-family: var(--racp-sans);
  font-size: 24px;
  line-height: 1.14;
  font-weight: 400;
  letter-spacing: -0.01em;
}

[data-custom-style="Autores RACP"] {
  margin-top: 10px;
}

[data-custom-style="Autores RACP"] p {
  margin: 0 0 5px;
  font-size: 14.5px;
  line-height: 1.32;
}

[data-custom-style="Afiliaciones RACP"] {
  margin: 0;
}

[data-custom-style="Afiliaciones RACP"] p {
  margin: 0;
  font-size: 12.2px;
  line-height: 1.34;
}

/* =========================================================
   METADATOS
   ========================================================= */

[data-custom-style="Correspondencia RACP"] {
  margin: 0;
  padding: 1px 0 1px 10px;
  border-left: 2px solid var(--racp-accent);
}

[data-custom-style="Correspondencia RACP"] + [data-custom-style="Correspondencia RACP"] {
  margin-top: -1px;
}

[data-custom-style="Afiliaciones RACP"] + [data-custom-style="Correspondencia RACP"] {
  margin-top: 12px;
}

[data-custom-style="Correspondencia RACP"] p {
  margin: 0;
  font-size: 12.2px;
  line-height: 1.32;
}

[data-custom-style="Fechas RACP"] p {
  margin: 2px 0;
  color: var(--racp-muted);
  font-size: 11.8px;
  line-height: 1.3;
  font-style: italic;
}

[data-custom-style="DOI RACP"] p {
  margin: 7px 0 2px;
  font-family: var(--racp-sans);
  font-size: 12px;
  line-height: 1.35;
}

[data-custom-style="Como citar RACP"] p {
  margin: 5px 0 18px;
  font-size: 12px;
  line-height: 1.4;
  font-style: italic;
}

a,
a:visited {
  color: var(--racp-accent);
  text-decoration: none;
}

a:hover,
a:focus {
  text-decoration: underline;
}

/* =========================================================
   RESUMEN Y PALABRAS CLAVE
   ========================================================= */

[data-custom-style="Título Resumen RACP"] {
  margin-top: 19px;
  padding-top: 10px;
  border-top: 1px solid var(--racp-accent);
}

[data-custom-style="Título Resumen RACP"] p {
  margin: 0 0 6px;
  color: var(--racp-accent);
  font-family: var(--racp-sans);
  font-size: 12px;
  line-height: 1.18;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

[data-custom-style="Resumen RACP"] p,
[data-custom-style="Palabras clave RACP"] p {
  margin: 0 0 5px;
  font-family: var(--racp-sans);
  font-size: 12.3px;
  line-height: 1.42;
}

[data-custom-style="Palabras clave RACP"] {
  padding-bottom: 10px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--racp-accent);
}

/* Separación no colapsable: funciona también sin ABSTRACT y cuando una
   editorial comienza directamente con un párrafo, sin heading intermedio. */
[data-custom-style="Palabras clave RACP"] + h1:not(.title),
[data-custom-style="Palabras clave RACP"] + h2,
[data-custom-style="Palabras clave RACP"] + p,
[data-custom-style="Palabras clave RACP"] + figure,
[data-custom-style="Palabras clave RACP"] + table {
  margin-top: 0;
  padding-top: 24px;
}

/* =========================================================
   CUERPO DEL ARTÍCULO
   ========================================================= */

p {
  margin: 0 0 9px;
}

[data-custom-style="Body Text"] p {
  margin: 0 0 9px;
}

h1:not(.title) {
  margin: 25px 0 8px;
  color: var(--racp-text);
  font-family: var(--racp-serif);
  font-size: 16px;
  line-height: 1.2;
  font-weight: 700;
}

h2 {
  margin: 18px 0 6px;
  color: var(--racp-text);
  font-family: var(--racp-serif);
  font-size: 14.3px;
  line-height: 1.22;
  font-weight: 700;
}

/* =========================================================
   FIGURAS
   ========================================================= */

figure {
  margin: 25px 0 27px;
  text-align: center;
}

figure img {
  display: block;
  width: auto;
  max-width: 100% !important;
  height: auto !important;
  margin: 0 auto 7px;
}

figcaption {
  margin: 0;
  color: var(--racp-text);
  font-family: var(--racp-serif);
  font-size: 12.2px;
  line-height: 1.36;
  text-align: left;
}

figcaption p {
  margin: 0;
}

figcaption strong,
figcaption [data-custom-style="Strong"] {
  font-weight: 700;
}

/* =========================================================
   TABLAS
   ========================================================= */

table {
  width: 100% !important;
  margin: 10px 0 27px;
  border-collapse: collapse;
  border-spacing: 0;
  color: var(--racp-text);
  font-family: var(--racp-serif);
  font-size: 11.8px;
  line-height: 1.28;
  font-variant-numeric: tabular-nums;
}

table caption {
  margin: 0 0 7px;
  padding: 0;
  caption-side: top;
  color: var(--racp-text);
  font-family: var(--racp-serif);
  font-size: 12.2px;
  line-height: 1.36;
  text-align: left;
}

table caption p {
  margin: 0;
}

th,
td {
  padding: 5px 6px;
  vertical-align: top;
  border: 0;
  border-bottom: 1px solid #dddddd;
}

thead th {
  font-weight: 700;
  border-top: 1.4px solid var(--racp-text);
  border-bottom: 1.4px solid var(--racp-text);
}

tbody tr:last-child td {
  border-bottom: 1.4px solid var(--racp-text);
}

th:first-child,
td:first-child {
  text-align: left;
}

th:not(:first-child),
td:not(:first-child) {
  text-align: center;
}

table p,
[data-custom-style="Tabla RACP"] p,
[data-custom-style="Encabezado tabla RACP"] p {
  margin: 0;
}

table[data-custom-style="a"] tbody tr:first-child td {
  font-weight: 700;
  border-top: 1.4px solid var(--racp-text);
  border-bottom: 1.4px solid var(--racp-text);
}

/* =========================================================
   REFERENCIAS
   ========================================================= */

#referencias + ol,
#references + ol {
  margin-top: 0;
  padding-left: 1.5em;
  font-size: 12.2px;
  line-height: 1.38;
}

#referencias + ol > li,
#references + ol > li {
  margin: 0 0 5px;
  padding-left: 0.12em;
}

#referencias + ol [data-custom-style="Referencias RACP"] p,
#references + ol [data-custom-style="Referencias RACP"] p {
  margin: 0;
}

/* Figuras multipanel, subtítulo y enlace audiovisual */
.figure-images.multi-2,
.figure-images.multi-3,
.figure-images.multi-4 {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
}

.figure-images.multi-2 img,
.figure-images.multi-3 img,
.figure-images.multi-4 img {
  max-width: calc(50% - 5px) !important;
}

.article-subtitle p {
  margin: 6px 0 10px;
  font-size: 13px;
  font-style: italic;
}

.video-link p {
  margin: 8px 0 12px;
  font-family: var(--racp-sans);
  font-size: 12.5px;
}

/* =========================================================
   BLOQUES FINALES
   ========================================================= */

[data-custom-style="Título final RACP"] p {
  margin: 16px 0 4px;
  color: var(--racp-accent);
  font-size: 13px;
  line-height: 1.22;
  font-weight: 700;
}

[data-custom-style="Texto final RACP"] p,
[data-custom-style="Declaración RACP"] p {
  margin: 0 0 4px;
  font-size: 12.2px;
  line-height: 1.38;
}

[data-custom-style="Etiqueta final RACP"] {
  color: var(--racp-accent);
  font-weight: 700;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 700px) {
  body {
    padding: 22px 15px 42px;
    font-size: 14px;
  }

  #title-block-header .title {
    font-size: 21px;
  }

  h1:not(.title) {
    font-size: 15.5px;
  }

  table {
    display: block;
    overflow-x: auto;
    width: 100% !important;
    -webkit-overflow-scrolling: touch;
  }

  th,
  td {
    min-width: 78px;
  }

  th:first-child,
  td:first-child {
    min-width: 135px;
  }

  .figure-images.multi-2 img,
  .figure-images.multi-3 img,
  .figure-images.multi-4 img {
    max-width: 100% !important;
  }
}
