/* ================================================================== *
 * Tema SING — hoja de estilos principal
 * ================================================================== */

:root {
  --bg: #ffffff;
  --surface: #f7f9fc;
  --surface-2: #eef2f8;
  --text: #1b2431;
  --muted: #5b6675;
  --border: #e3e9f2;
  --accent: #2f4a91;
  --accent-strong: #243a72;
  --accent-soft: #eaf0fb;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 50, 0.05), 0 8px 24px rgba(20, 30, 50, 0.06);
  --shadow-hover: 0 2px 4px rgba(20, 30, 50, 0.06), 0 16px 32px rgba(20, 30, 50, 0.1);
  --fs-100: 0.8125rem;
  --fs-200: 0.875rem;
  --fs-300: 0.9375rem;
  --fs-400: 1rem;
  --fs-500: 1.125rem;
  --fs-600: 1.375rem;
  --fs-700: 1.75rem;
  --fs-800: 2.25rem;
  --container: 1140px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-400);
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
}

img {
  max-width: 100%;
  height: auto;
}

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

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  color: var(--text);
}

.container {
  width: min(var(--container), 100% - 2.5rem);
  margin-inline: auto;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  top: 1rem;
}

/* ---------- Cabecera y navegación ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 66px;
  width: min(1360px, 100% - 2.5rem);
}

.brand {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex: 0 0 auto;
}

.brand-copy {
  display: none;
  flex-direction: column;
  gap: 0.1rem;
  line-height: 1.2;
  white-space: nowrap;
}

.brand-name {
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0;
}

.brand-sub {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0;
}

@media (min-width: 1340px) {
  .brand-copy {
    display: flex;
  }
}

.brand:hover {
  text-decoration: none;
  color: var(--accent);
}

.brand-logo {
  display: block;
  height: 54px;
  width: auto;
}

.brand-logo--footer {
  height: 45px;
  opacity: 0.92;
}

.site-nav {
  margin-left: auto;
}

.nav-list {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-item {
  position: relative;
  flex: 0 0 auto;
}

.nav-link {
  display: inline-block;
  padding: 0.45rem 0.5rem;
  color: var(--text);
  font-size: var(--fs-300);
  border-radius: 8px;
  white-space: nowrap;
}

.nav-link:hover {
  background: var(--surface);
  text-decoration: none;
  color: var(--accent);
}

.nav-link.is-active,
.nav-item.is-active > .nav-link {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.submenu a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

.has-children {
  display: flex;
  align-items: center;
}

.nav-caret {
  border: 0;
  background: none;
  padding: 0.35rem 0.25rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.nav-caret span {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted);
}

.submenu {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  min-width: 230px;
  margin: 0;
  padding: 0.4rem;
  list-style: none;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  display: none;
  z-index: 60;
}

/* Puente invisible para que el hover no se pierda al bajar al submenú */
.nav-item.has-children > .submenu::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -12px;
  height: 12px;
}

.submenu a {
  display: block;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  color: var(--text);
  font-size: var(--fs-300);
}

.submenu a:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
  text-decoration: none;
}

.nav-item.has-children:hover > .submenu,
.nav-item.has-children:focus-within > .submenu,
.nav-item.has-children.submenu-open > .submenu {
  display: block;
}

.nav-toggle {
  display: none;
  margin-left: auto;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
}

.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  position: relative;
}

.nav-toggle-bars::before,
.nav-toggle-bars::after {
  content: "";
  position: absolute;
  left: 0;
}

.nav-toggle-bars::before {
  top: -6px;
}

.nav-toggle-bars::after {
  top: 6px;
}

.search-button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  width: 38px;
  height: 38px;
  cursor: pointer;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.search-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.search-icon {
  display: block;
  width: 18px;
  height: 18px;
}

/* ---------- Diálogo de búsqueda ---------- */

.search-dialog {
  width: min(640px, calc(100% - 2rem));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-hover);
}

.search-dialog::backdrop {
  background: rgba(15, 23, 38, 0.45);
}

.search-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.search-dialog-head h2 {
  margin: 0;
  font-size: var(--fs-500);
}

.search-close {
  border: 0;
  background: var(--surface);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 1.2rem;
  cursor: pointer;
}

.search-hint {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: var(--fs-200);
}

.section {
  padding: 3rem 0 4rem;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.section-head h2 {
  margin: 0;
  font-size: var(--fs-700);
  letter-spacing: -0.01em;
}

.link-more {
  font-size: var(--fs-300);
  white-space: nowrap;
}

/* ---------- Tarjetas ---------- */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 1.25rem;
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card-media {
  display: block;
  aspect-ratio: 16 / 10;
  background: var(--surface-2);
  overflow: hidden;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-body {
  padding: 1rem 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.card-date {
  font-size: var(--fs-100);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card-title {
  margin: 0;
  font-size: var(--fs-500);
  line-height: 1.35;
}

.card-title a {
  color: var(--text);
}

.card-title a:hover {
  color: var(--accent);
}

.card-summary {
  margin: 0;
  font-size: var(--fs-300);
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Páginas ---------- */

.page {
  padding: 2.5rem 0 5rem;
}

.page-head h1 {
  margin: 0 0 1rem;
  font-size: clamp(1.75rem, 3vw, var(--fs-800));
  letter-spacing: -0.02em;
}

.page-meta {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: var(--fs-200);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.article-banner {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border-radius: var(--radius);
  margin: 1.5rem 0;
}

/* ---------- Texto enriquecido ---------- */

.prose {
  font-size: var(--fs-400);
}

.prose h2 {
  margin: 2.2rem 0 0.8rem;
  font-size: var(--fs-600);
}

.prose :is(h2, h3),
.years-md :is(h2, h3) {
  scroll-margin-top: 90px;
}

.prose h3 {
  margin: 1.8rem 0 0.6rem;
  font-size: var(--fs-500);
}

.prose p {
  margin: 0 0 1rem;
}

.prose ul,
.prose ol {
  margin: 0 0 1rem;
  padding-left: 1.4rem;
}

.prose li {
  margin-bottom: 0.35rem;
}

.prose img {
  border-radius: var(--radius-sm);
}

/* Iconos pequeños y badges: sin esquinas redondeadas ni recorte visual */
.prose img[src*="/icons/"],
.prose img[src*="/badges/"] {
  border-radius: 0;
}

.prose video,
.prose audio,
.section-content video {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1rem auto;
  border-radius: var(--radius-sm);
  background: #000;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: var(--fs-300);
}

.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.7rem;
  text-align: left;
  vertical-align: top;
}

.prose th {
  background: var(--surface);
}

.prose blockquote {
  margin: 1.25rem 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  color: var(--muted);
}

.prose code {
  background: var(--surface-2);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
  font-size: 0.9em;
}

/* ---------- Índices con contenido incrustado ---------- */

.inline-section {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.inline-title {
  margin: 0 0 1.25rem;
  font-size: var(--fs-700);
  letter-spacing: -0.01em;
}

/* ---------- Solapas por años ---------- */

.years-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0.5rem 0 1.75rem;
}

.year-tab {
  padding: 0.3rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: var(--fs-200);
  cursor: pointer;
}

.year-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.year-tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

/* ---------- Prensa: bloques data + titular ---------- */

/* A data pertence ao titular que vai debaixo: pouco espazo entre ambos
   e máis separación entre bloques consecutivos. */
.years-md > p {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: var(--fs-300);
}

.years-md > h3 {
  margin: 0 0 1.75rem;
}

/* ---------- Fichas (entries-md) ---------- */

.entries-md h3 {
  margin: 2rem 0 0;
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: var(--fs-400);
  line-height: 1.4;
}

.entries-md h3 + p {
  margin: 0;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: #fff;
  font-size: var(--fs-300);
  line-height: 1.7;
}

.entries-md h3 + p strong {
  color: #2a3a5c;
}

.entries-md h3 + p img {
  max-height: 40px;
  max-width: 100%;
  vertical-align: middle;
}

.entries-md h3 + p + p {
  margin-top: 0.5rem;
}

/* ---------- Logos e imágenes en índices de colaboraciones/actividades ---------- */

.logos-md img {
  max-height: 84px;
  max-width: 240px;
  width: auto;
  height: auto;
  vertical-align: middle;
}

.logos-md h3 {
  margin: 1.75rem 0 0.35rem;
  font-size: var(--fs-500);
}

.logos-md h4 {
  margin: 1.4rem 0 0.4rem;
  font-size: var(--fs-400);
}

.logos-md p {
  margin: 0.4rem 0;
}

/* Groups e Institutions: directorio a varias columnas, sin cambiar el markdown */

:is(.page-groups, .inline-groups, .page-institutions, .inline-institutions, .page-member-of, .inline-member-of) .logos-md {
  column-count: 2;
  column-gap: 3.5rem;
}

:is(.page-groups, .inline-groups, .page-institutions, .inline-institutions, .page-member-of, .inline-member-of) .logos-md > :is(p, h3, h4) {
  break-inside: avoid;
}

:is(.page-groups, .inline-groups) .logos-md > p:has(img) {
  break-after: avoid;
}

:is(.page-groups, .inline-groups) .logos-md > h3 {
  margin-top: 0.75rem;
  break-after: avoid;
}

:is(.page-groups, .inline-groups) .logos-md > h4 + h4 {
  break-before: avoid;
}

:is(.page-institutions, .inline-institutions, .page-member-of, .inline-member-of) .logos-md > h4 {
  margin: 0.35rem 0 0.15rem;
  break-after: avoid;
}

:is(.page-groups, .inline-groups, .page-institutions, .inline-institutions, .page-member-of, .inline-member-of) .logos-md > h4 {
  margin-top: 0.35rem;
}

@media (max-width: 1199px) {
  :is(.page-groups, .inline-groups, .page-institutions, .inline-institutions, .page-member-of, .inline-member-of) .logos-md {
    column-count: 2;
    column-gap: 2rem;
  }
}

@media (max-width: 767px) {
  :is(.page-groups, .inline-groups, .page-institutions, .inline-institutions, .page-member-of, .inline-member-of) .logos-md {
    column-count: 1;
  }
}

/* Cuando el JS agrupa cada entrada, se usa un flujo compacto a columnas */

.page-groups .section-content,
.page-institutions .section-content,
.page-member-of .section-content {
  max-width: none;
}

.logos-md.collab-grid {
  display: block;
  column-count: 3;
  column-gap: 2.5rem;
}

.collab-grid .collab-card {
  break-inside: avoid;
  margin: 0 0 2rem;
  min-width: 0;
}

.collab-grid .collab-card > :first-child {
  margin-top: 0;
}

.collab-grid .collab-card img {
  max-width: 100%;
}

@media (max-width: 1199px) {
  .logos-md.collab-grid {
    column-count: 2;
    column-gap: 2rem;
  }
}

@media (max-width: 767px) {
  .logos-md.collab-grid {
    column-count: 1;
  }
}

/* Colaboradores externos y otras listas de personas */

.people-md p em {
  font-size: var(--fs-200);
  font-style: normal;
  color: var(--muted);
}

.people-md p img:not(:first-of-type) {
  max-height: 20px;
  width: auto;
  margin: 0 4px 0 0;
  vertical-align: middle;
}

/* ---------- Personas (listados con foto, p. ej. PhD Students) ---------- */

.people-md {
  column-count: 2;
  column-gap: 1.5rem;
}

.people-md h3 {
  break-after: avoid;
}

.people-md h3 + p {
  break-inside: avoid;
  margin-bottom: 1.25rem;
}

.people-md p img:first-of-type {
  float: left;
  width: 84px;
  height: auto;
  max-height: none;
  object-fit: initial;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin: 0 12px 8px 0;
}

/* ---------- Perfiles de miembros ---------- */

.profile-md {
  max-width: 82ch;
}

.profile-md > p:first-child img {
  float: left;
  max-width: 170px;
  max-height: none;
  margin: 0 1.5rem 1rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.profile-md p {
  font-size: var(--fs-300);
}

.profile-md p img {
  max-height: 22px;
  width: auto;
  vertical-align: middle;
  margin-right: 4px;
  border-radius: 0;
}

/* ---------- Pie ---------- */

.site-footer {
  margin-top: 4rem;
  padding: 3rem 0 1.5rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 2.5rem;
}

.footer-about .brand {
  margin: 0 0 0.75rem;
}

.footer-text {
  color: var(--muted);
  font-size: var(--fs-300);
  max-width: 52ch;
}

.footer-title {
  margin: 0 0 0.75rem;
  font-size: var(--fs-200);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.footer-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-list li {
  margin-bottom: 0.35rem;
}

.footer-list a {
  color: var(--text);
  font-size: var(--fs-300);
}

.footer-list a:hover {
  color: var(--accent);
}

.footer-bottom {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--fs-200);
}

.footer-institutional {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.footer-logos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
}

.footer-logos img {
  max-height: 42px;
  width: auto;
}

.footer-social {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--muted);
  font-size: var(--fs-200);
}

.footer-social a {
  display: inline-flex;
}

.footer-social img {
  width: 24px;
  height: 24px;
}

@media (max-width: 767px) {
  .footer-institutional {
    justify-content: center;
    text-align: center;
  }

  .footer-logos {
    justify-content: center;
    gap: 1rem;
  }
}

.footer-bottom p {
  margin: 0;
}

/* ---------- Paginación ---------- */

.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 2.5rem;
}

.page-link {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: var(--fs-300);
}

.page-link:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.page-info {
  color: var(--muted);
  font-size: var(--fs-200);
}

/* ---------- Responsive ---------- */

@media (max-width: 1199px) {
  .nav-toggle {
    display: inline-block;
  }

  .brand-logo {
    height: 42px;
  }

  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.25rem 1.25rem;
    box-shadow: var(--shadow);
  }

  .site-header.nav-open .site-nav {
    display: block;
  }

  .nav-list {
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
  }

  .has-children {
    flex-wrap: wrap;
  }

  .nav-item {
    border-bottom: 1px solid var(--surface-2);
  }

  .submenu {
    position: static;
    display: none;
    box-shadow: none;
    border: 0;
    padding: 0 0 0.5rem 0.75rem;
    min-width: 0;
  }

  .nav-item.has-children.submenu-open > .submenu {
    display: block;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }
}

@media (max-width: 767px) {
  .profile-md > p:first-child img {
    float: none;
    display: block;
    margin: 0 0 1rem;
  }

  .people-md {
    column-count: 1;
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }
}
