/*
 * Observatorio de Accesibilidad Digital — Hoja de estilos principal
 * -----------------------------------------------------------------
 * Organización:
 * 1. Variables del sistema visual institucional.
 * 2. Base tipográfica, normalización y utilidades accesibles.
 * 3. Cabecera y navegación.
 * 4. Secciones y componentes de contenido.
 * 5. Adaptación responsive y preferencias del usuario.
 *
 * Convención de clases: nombres de componente con modificadores inspirados en BEM.
 * Las medidas relativas permiten ampliar el texto sin perder contenido ni funcionalidad.
 */

/* 1. Variables institucionales y valores reutilizables. */
:root {
  --una-red: #990000;
  --una-red-dark: #700000;
  --una-blue: #034991;
  --una-blue-dark: #022f5e;
  --una-gray: #585757;
  --ink: #1e293b;
  --muted: #475569;
  --white: #ffffff;
  --surface: #f1f5f9;
  --border: #cbd5e1;
  --focus: #ffbf47;
  --serif: "Merriweather", Georgia, serif;
  --sans: "Inter", Arial, sans-serif;
  --container: 75rem;
  --shadow: 0 1.25rem 3rem rgba(15, 23, 42, 0.12);
}

/* 2. Base global y normalización del modelo de caja. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 3rem;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--white);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--una-blue);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 0.1em;
}

a:hover {
  text-decoration-thickness: 0.16em;
}

/*
 * Foco bicolor: el amarillo se distingue sobre fondos oscuros y el anillo exterior
 * oscuro conserva contraste sobre superficies claras (WCAG 2.4.7 y 1.4.11).
 */
:focus-visible {
  outline: 0.25rem solid var(--focus);
  outline-offset: 0.25rem;
  border-radius: 0.125rem;
  box-shadow: 0 0 0 0.5rem var(--ink);
}

main:focus {
  /* El destino del skip link recibe foco programático sin dibujar un marco en toda la región. */
  outline: none;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.2;
  text-wrap: balance;
}

h1 {
  margin-bottom: 1.5rem;
  font-size: clamp(2.35rem, 6vw, 4.9rem);
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 1.25rem;
  font-size: clamp(1.9rem, 4vw, 3rem);
  letter-spacing: -0.025em;
}

h3 {
  margin-bottom: 0.6rem;
  font-size: clamp(1.15rem, 2vw, 1.35rem);
}

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

/* Oculta contenido visualmente sin retirarlo del árbol de accesibilidad. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* El enlace de salto permanece fuera de la vista hasta recibir foco de teclado. */
.skip-link {
  position: fixed;
  z-index: 1000;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.8rem 1rem;
  color: var(--ink);
  background: var(--focus);
  font-weight: 700;
  transform: translateY(-180%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

/* 3. Cabecera institucional. */
.institutional-bar {
  color: var(--white);
  background: var(--una-red);
}

.institutional-bar__inner {
  display: flex;
  min-height: 5.5rem;
  align-items: center;
  justify-content: flex-start;
}

.una-brand {
  display: inline-flex;
  padding: 0.5rem;
  margin-left: -0.5rem;
}

.una-brand img {
  width: min(15.75rem, 100%);
  height: auto;
}

/* Barra de identidad secundaria y navegación del Observatorio. */
.identity-bar {
  position: relative;
  z-index: 20;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}

.identity-bar__inner {
  display: grid;
  min-height: 6rem;
  grid-template-columns: minmax(15rem, 1fr) auto auto;
  align-items: center;
  gap: 1rem;
}

.observatory-brand {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 0.9rem;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.25;
  text-decoration: none;
}

.observatory-brand strong {
  display: block;
  color: var(--una-red);
}

.observatory-mark {
  display: grid;
  width: 3rem;
  height: 3rem;
  flex: 0 0 3rem;
  place-items: center;
  color: var(--white);
  background: var(--una-blue);
  border-radius: 50%;
}

.observatory-mark svg {
  width: 2rem;
  fill: currentColor;
}

/* Navegación principal en escritorio. */
.main-nav__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.main-nav a {
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  padding: 0.7rem 0.65rem;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  text-decoration: none;
}

.main-nav a:hover {
  color: var(--una-red);
  text-decoration: underline;
}

/* Control opcional para alternar entre el tema institucional y alto contraste. */
.contrast-toggle {
  display: inline-flex;
  min-width: 3rem;
  min-height: 3rem;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.65rem 0.8rem;
  color: var(--ink);
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 0.25rem;
  font: 700 0.85rem/1 var(--sans);
  cursor: pointer;
}

.contrast-toggle:hover {
  color: var(--una-red);
  border-color: currentColor;
}

.contrast-toggle[aria-pressed="true"] {
  color: #000000;
  background: #ffdd00;
  border-color: #000000;
}

.contrast-toggle__icon {
  width: 1.35rem;
  height: 1.35rem;
  flex: 0 0 auto;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.5;
}

/* El botón se muestra únicamente cuando la navegación cambia al patrón móvil. */
.nav-toggle {
  display: none;
  min-width: 3rem;
  min-height: 3rem;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  padding: 0.65rem 0.8rem;
  color: var(--ink);
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 0.25rem;
  font: 700 1rem/1 var(--sans);
  cursor: pointer;
}

.nav-toggle__icon,
.nav-toggle__icon::before,
.nav-toggle__icon::after {
  display: block;
  width: 1.3rem;
  height: 0.15rem;
  background: currentColor;
  content: "";
}

.nav-toggle__icon {
  position: relative;
}

.nav-toggle__icon::before {
  position: absolute;
  top: -0.4rem;
}

.nav-toggle__icon::after {
  position: absolute;
  top: 0.4rem;
}

/* 4. Sección de presentación principal. */
.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(120deg, #f8fafc 0%, #ffffff 62%, #f3e8e8 100%);
}

.hero__pattern,
.footer-pattern {
  /* Motivo triangular UNA puramente decorativo, generado sin imágenes adicionales. */
  position: absolute;
  inset: auto 0 0;
  height: 1.1rem;
  opacity: 0.16;
  background-image: linear-gradient(135deg, var(--una-red) 25%, transparent 25%), linear-gradient(225deg, var(--una-red) 25%, transparent 25%);
  background-position: 0 0, 1rem 0;
  background-size: 2rem 2rem;
}

.hero__grid {
  position: relative;
  display: grid;
  min-height: 41rem;
  grid-template-columns: minmax(0, 1.25fr) minmax(18rem, 0.75fr);
  align-items: center;
  gap: clamp(2rem, 6vw, 6rem);
  padding-block: clamp(4rem, 9vw, 7rem);
}

.hero__content {
  max-width: 49rem;
}

.eyebrow {
  margin-bottom: 0.8rem;
  color: var(--una-red);
  font-size: 0.875rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  line-height: 1.4;
  text-transform: uppercase;
}

.hero__lead {
  max-width: 42rem;
  margin-bottom: 1rem;
  color: var(--una-blue-dark);
  font-size: clamp(1.1rem, 2.1vw, 1.35rem);
  font-weight: 600;
  line-height: 1.55;
}

.hero__content > p:not(.eyebrow) {
  max-width: 42rem;
}

.button {
  display: inline-flex;
  min-height: 3rem;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1.35rem;
  margin-top: 1rem;
  border: 2px solid transparent;
  border-radius: 0.2rem;
  font-weight: 800;
  line-height: 1.3;
  text-decoration: none;
}

.button--primary {
  color: var(--white);
  background: var(--una-red);
  box-shadow: 0 0.35rem 0 var(--una-red-dark);
}

.button--primary:hover {
  color: var(--white);
  background: var(--una-red-dark);
  text-decoration: underline;
}

/* Ecosistema vectorial conectado con la accesibilidad como núcleo. */
.ecosystem-visual {
  width: min(31rem, 88vw);
  margin-inline: auto;
}

.ecosystem-visual svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.ecosystem-halo {
  fill: var(--una-blue);
  opacity: 0.055;
}

.ecosystem-connections {
  fill: none;
  stroke: var(--una-blue);
  stroke-linecap: round;
  stroke-width: 3;
  opacity: 0.48;
}

.ecosystem-connection--secondary {
  stroke: var(--una-red);
  stroke-dasharray: 5 11;
  stroke-width: 2;
  opacity: 0.42;
}

.ecosystem-data-points {
  fill: var(--focus);
  stroke: var(--white);
  stroke-width: 3;
}

.ecosystem-core__ring {
  fill: var(--una-blue);
  stroke: var(--white);
  stroke-width: 10;
}

.ecosystem-core__surface {
  fill: var(--una-blue-dark);
  stroke: rgba(255,255,255,0.18);
  stroke-width: 2;
}

.ecosystem-core__accent {
  fill: var(--focus);
  stroke: var(--white);
  stroke-width: 4;
}

.ecosystem-core__symbol {
  fill: var(--white);
}

.ecosystem-node__shell {
  fill: var(--white);
  stroke: var(--border);
  stroke-width: 2;
}

.ecosystem-node__surface {
  stroke: var(--white);
  stroke-width: 2;
}

.ecosystem-node__icon {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3.5;
}

.ecosystem-node--blue .ecosystem-node__surface {
  fill: var(--una-blue);
}

.ecosystem-node--blue .ecosystem-node__icon,
.ecosystem-node--red .ecosystem-node__icon {
  stroke: var(--white);
}

.ecosystem-node--red .ecosystem-node__surface {
  fill: var(--una-red);
}

.ecosystem-node--light .ecosystem-node__surface {
  fill: var(--surface);
  stroke: var(--una-blue);
}

.ecosystem-node--light .ecosystem-node__icon {
  stroke: var(--una-blue-dark);
}

/* Reglas compartidas por las secciones de contenido. */
.section {
  padding-block: clamp(4.5rem, 9vw, 7.5rem);
}

.section--light {
  background: var(--white);
}

.section-heading {
  max-width: 52rem;
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
}

/* Una medida de lectura moderada facilita seguir la línea en párrafos extensos. */
.section-heading > p:not(.eyebrow) {
  max-width: 42rem;
}

/* Objetivos institucionales: lista semántica presentada como cuadrícula de tarjetas. */
.objectives-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.objectives-grid li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1rem;
  padding: 1.5rem;
  background: var(--surface);
  border-top: 0.25rem solid var(--una-red);
}

.objectives-grid li:last-child {
  grid-column: 1 / -1;
}

.objectives-grid p,
.component-card p,
.criteria-list p {
  margin-bottom: 0;
}

.objective-number {
  color: var(--una-red);
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 900;
}

/* Componentes operativos sobre una superficie institucional azul. */
.section--blue {
  position: relative;
  color: var(--white);
  background: var(--una-blue-dark);
}

.section-heading--inverse h2,
.section-heading--inverse .eyebrow {
  color: var(--white);
}

.components-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
}

.component-card {
  position: relative;
  overflow: hidden;
  padding: 2rem;
  color: var(--ink);
  background: var(--white);
  border-bottom: 0.35rem solid var(--una-red);
  box-shadow: 0 1rem 2rem rgba(0,0,0,0.15);
}

.component-card::after {
  position: absolute;
  top: -2rem;
  right: -2rem;
  width: 6rem;
  height: 6rem;
  opacity: 0.08;
  background: linear-gradient(135deg, transparent 50%, var(--una-red) 50%);
  content: "";
}

.component-card__number {
  display: inline-block;
  margin-bottom: 2rem;
  color: var(--una-red);
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.15em;
}

/* Subbloque destacado para explicar el alcance progresivo. */
.scope-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1.5rem;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  margin-top: 1.25rem;
  color: var(--ink);
  background: #e8f2fc;
  border-left: 0.4rem solid var(--focus);
}

.scope-card h3 {
  color: var(--una-blue-dark);
}

.scope-card p {
  margin-bottom: 0;
}

.scope-card__icon {
  display: grid;
  width: 3.5rem;
  height: 3.5rem;
  place-items: center;
  color: var(--white);
  background: var(--una-blue);
}

.scope-card__icon svg {
  width: 2rem;
  fill: currentColor;
}

/* Recursos y criterios básicos de accesibilidad. */
.section--resources {
  background: var(--surface);
}

.resources-layout,
.governance-layout,
.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(2.5rem, 7vw, 6rem);
  align-items: start;
}

.resources-intro {
  position: sticky;
  top: 2rem;
}

.text-link {
  display: inline-block;
  margin-top: 1rem;
  color: var(--una-blue-dark);
  font-weight: 800;
}

.criteria-list {
  display: grid;
  gap: 0.75rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.criteria-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1rem;
  padding: 1.25rem;
  background: var(--white);
  border: 1px solid var(--border);
}

.check {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  color: var(--white);
  background: var(--una-red);
  border-radius: 50%;
  font-weight: 900;
}

/* Gobernanza y equipo de trabajo. */
.section--governance {
  background: var(--white);
}

.team-card {
  padding: clamp(1.5rem, 4vw, 2.5rem);
  background: var(--ink);
  border-top: 0.4rem solid var(--una-red);
  box-shadow: var(--shadow);
}

.team-card h3,
.team-card dt,
.team-card dd {
  color: var(--white);
}

.team-card dl,
.team-card dd {
  margin: 0;
}

.team-card dl > div {
  padding-block: 1.1rem;
  border-top: 1px solid #64748b;
}

.team-card dt {
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Pie de página y declaración de accesibilidad. */
.site-footer {
  position: relative;
  padding-block: clamp(4rem, 8vw, 6rem) 2rem;
  color: var(--white);
  background: var(--una-red-dark);
}

.site-footer .footer-pattern {
  top: 0;
  bottom: auto;
  opacity: 0.25;
  background-image: linear-gradient(135deg, var(--white) 25%, transparent 25%), linear-gradient(225deg, var(--white) 25%, transparent 25%);
}

.site-footer h2,
.site-footer .eyebrow,
.site-footer a {
  color: var(--white);
}

.footer-address {
  padding: 1.5rem;
  color: var(--ink);
  background: var(--white);
  border-left: 0.35rem solid var(--focus);
  font-style: normal;
}

.accessibility-statement {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  padding-top: 2rem;
  margin-top: 3rem;
  border-top: 1px solid rgba(255,255,255,0.45);
  font-size: 0.88rem;
}

.accessibility-statement p {
  max-width: 42rem;
  margin-bottom: 0;
}

.accessibility-statement a {
  flex: 0 0 auto;
  font-weight: 800;
}

/*
 * Prueba de alto contraste. Se conserva el mismo DOM y se modifican únicamente
 * variables y superficies visuales para mantener estructura, foco y navegación.
 */
html[data-contrast="high"] {
  --una-red: #ffdd00;
  --una-red-dark: #000000;
  --una-blue: #00c8ff;
  --una-blue-dark: #000000;
  --una-gray: #ffffff;
  --ink: #ffffff;
  --muted: #ffffff;
  --surface: #0a0a0a;
  --border: #ffffff;
  --focus: #ffdd00;
  --shadow: none;
  color-scheme: dark;
}

html[data-contrast="high"] body,
html[data-contrast="high"] .institutional-bar,
html[data-contrast="high"] .identity-bar,
html[data-contrast="high"] .hero,
html[data-contrast="high"] .section--light,
html[data-contrast="high"] .section--resources,
html[data-contrast="high"] .section--governance,
html[data-contrast="high"] .section--blue,
html[data-contrast="high"] .component-card,
html[data-contrast="high"] .scope-card,
html[data-contrast="high"] .criteria-list li,
html[data-contrast="high"] .team-card,
html[data-contrast="high"] .site-footer,
html[data-contrast="high"] .footer-address {
  color: #ffffff;
  background: #000000;
}

html[data-contrast="high"] .institutional-bar,
html[data-contrast="high"] .identity-bar,
html[data-contrast="high"] .component-card,
html[data-contrast="high"] .criteria-list li,
html[data-contrast="high"] .team-card,
html[data-contrast="high"] .footer-address {
  border-color: #ffffff;
}

html[data-contrast="high"] .hero__lead,
html[data-contrast="high"] .scope-card h3,
html[data-contrast="high"] .text-link {
  color: #ffffff;
}

html[data-contrast="high"] a:not(.button):hover,
html[data-contrast="high"] .observatory-brand strong {
  color: #ffdd00;
}

html[data-contrast="high"] .button--primary,
html[data-contrast="high"] .check {
  color: #000000;
  background: #ffdd00;
}

html[data-contrast="high"] .observatory-mark,
html[data-contrast="high"] .scope-card__icon {
  color: #ffffff;
  background: #000000;
  border: 2px solid #ffffff;
}

html[data-contrast="high"] .contrast-toggle {
  color: #000000;
  background: #ffdd00;
  border-color: #ffffff;
}

html[data-contrast="high"] .contrast-toggle[aria-pressed="true"] {
  box-shadow: inset 0 0 0 2px #000000;
}

/* En anchos intermedios se mantiene el nombre accesible y se muestra solo el icono. */
@media (max-width: 75rem) {
  .contrast-toggle {
    padding-inline: 0.65rem;
  }

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

/*
 * Prueba de navegación persistente: solo la barra blanca permanece visible.
 * Se limita a escritorios con altura suficiente para no reducir excesivamente
 * el área útil. El espacio de desplazamiento evita ocultar destinos y focos.
 */
@media (min-width: 64.0625rem) and (min-height: 45rem) {
  html {
    scroll-padding-top: 7rem;
  }

  .identity-bar {
    position: sticky;
    z-index: 100;
    top: 0;
    box-shadow: 0 0.75rem 1.8rem rgba(15, 23, 42, 0.1);
  }

  main[id],
  section[id],
  article[id],
  footer[id] {
    scroll-margin-top: 7rem;
  }
}

/*
 * 5. Adaptación responsive.
 * A partir de 64 rem la navegación se convierte en un control desplegable.
 */
@media (max-width: 64rem) {
  .identity-bar__inner {
    grid-template-columns: minmax(0, 1fr) auto auto;
    padding-block: 0.7rem;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .main-nav {
    grid-column: 1 / -1;
  }

  .main-nav__list {
    display: none;
    align-items: stretch;
    padding-block: 0.5rem;
    border-top: 1px solid var(--border);
  }

  .main-nav__list[data-open="true"] {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main-nav a {
    min-height: 2.75rem;
    padding: 0.75rem;
  }

  .hero__grid {
    grid-template-columns: minmax(0, 1.15fr) minmax(14rem, 0.65fr);
  }

  .components-grid {
    grid-template-columns: 1fr;
  }
}

/* Teléfonos y pantallas estrechas: todos los bloques pasan a una sola columna. */
@media (max-width: 46rem) {
  .institutional-bar__inner {
    min-height: 5rem;
  }

  .observatory-brand {
    font-size: 0.95rem;
  }

  .identity-bar__inner {
    gap: 0.5rem;
  }

  .nav-toggle__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .main-nav__list[data-open="true"],
  .hero__grid,
  .objectives-grid,
  .resources-layout,
  .governance-layout,
  .footer-grid {
    grid-template-columns: 1fr;
  }

  .hero__grid {
    min-height: auto;
  }

  .hero__visual {
    order: -1;
  }

  .ecosystem-visual {
    width: min(22rem, 94vw);
  }

  .objectives-grid li:last-child {
    grid-column: auto;
  }

  .resources-intro {
    position: static;
  }

  .scope-card {
    grid-template-columns: 1fr;
  }

  .accessibility-statement {
    flex-direction: column;
  }
}

/* Ajuste defensivo para dispositivos extremadamente estrechos o texto ampliado. */
@media (max-width: 23rem) {
  .observatory-mark {
    width: 2.5rem;
    height: 2.5rem;
    flex-basis: 2.5rem;
  }

  .observatory-brand {
    font-size: 0.82rem;
  }
}

/* Respeta la preferencia del sistema de reducir animaciones y desplazamiento suave. */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Refuerzo para los modos de alto contraste administrados por el sistema operativo. */
@media (forced-colors: active) {
  .observatory-mark,
  .check,
  .scope-card__icon,
  .ecosystem-visual {
    border: 2px solid CanvasText;
  }

  .button,
  .component-card,
  .team-card,
  .footer-address {
    border: 2px solid CanvasText;
  }
}
