/* ============================================================
   Portal público (EP025): cascarón sin sesión sobre el mismo
   sistema visual de la herramienta. Alto contraste y colores
   distinguibles para daltonismo (verde institucional, dorado,
   vino, azul).
   ============================================================ */

body.portal-publico {
  background: #fbf9f8;
  /* gobmx.js pone margin-top: 70px en línea al detectar un <nav>; se suma
     al padding-top de 80px del framework y deja una franja en blanco */
  margin: 0 !important;
}

/* --portal-gob y --portal-top (alto del encabezado fijo de GobMX y de esta
   barra) los mide portal.js; los valores de aquí son el respaldo */
.portal-topnav {
  background: #13322B;
  color: #fff;
  position: sticky;
  top: var(--portal-gob, 88px);
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.portal-topnav-inner {
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.portal-menu-btn {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 0.5rem;
  display: inline-flex;
  align-items: center;
}

.portal-menu-btn:hover { background: rgba(255, 255, 255, 0.12); }
.portal-menu-btn:focus-visible { outline: 2px solid #D4AF37; outline-offset: 2px; }

.portal-topnav .brand {
  font-family: 'Noto Serif', serif;
  font-size: 1.6rem;
  font-weight: 900;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}

.portal-topnav .brand span {
  font-family: 'Public Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  color: #D4AF37;
  margin-left: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* --- Barra lateral colapsable con las secciones del portal --- */
.portal-cuerpo {
  display: flex;
  align-items: flex-start;
}

.portal-contenido {
  flex: 1;
  min-width: 0;
}

.portal-sidebar {
  flex: 0 0 24rem;
  width: 24rem;
  background: #13322B;
  position: sticky;
  top: calc(var(--portal-gob, 88px) + var(--portal-top, 50px));
  height: calc(100vh - var(--portal-gob, 88px) - var(--portal-top, 50px));
  overflow-x: hidden;
  overflow-y: auto;
  transition: flex-basis 0.2s ease, width 0.2s ease, visibility 0.2s;
}

.portal-menu-cerrado .portal-sidebar {
  flex-basis: 0;
  width: 0;
  visibility: hidden;
}

.portal-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  width: 24rem;
  padding: 1.25rem 1rem;
}

.portal-nav a {
  color: #d1d5db;
  text-decoration: none;
  font-size: 1.5rem;
  font-weight: 300;
  padding: 0.8rem 1rem;
  border-radius: 0.5rem;
  border-left: 3px solid transparent;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.portal-nav a .material-symbols-outlined { font-size: 1.8rem; }
.portal-nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.portal-nav a.active { color: #fff; font-weight: 400; background: rgba(255, 255, 255, 0.12); border-left-color: #D4AF37; }
.portal-nav a:focus-visible { outline: 2px solid #D4AF37; outline-offset: -2px; }

.portal-sidebar-fondo { display: none; }

/* En pantallas angostas la barra arranca cerrada y se abre encima del contenido */
@media (max-width: 1023px) {
  .portal-sidebar,
  .portal-menu-cerrado .portal-sidebar {
    position: fixed;
    left: 0;
    bottom: 0;
    height: auto;
    width: 24rem;
    z-index: 150;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0.2s;
  }

  .portal-menu-movil .portal-sidebar {
    transform: none;
    visibility: visible;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.3);
  }

  .portal-menu-movil .portal-sidebar-fondo {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(27, 28, 28, 0.5);
    z-index: 90;
  }
}

.portal-acceso {
  margin-left: auto;
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 0.4rem 0.8rem;
  border-radius: 0.5rem;
  font-size: 1.5rem;
  font-weight: 300;
}

.portal-acceso .material-symbols-outlined { font-size: 1.8rem; }

.portal-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem 1.5rem;
  min-height: 70vh;
}

.portal-header { align-items: flex-start; }

.portal-periodo {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.portal-periodo select { min-width: 12rem; }

.portal-aviso { margin-bottom: 1rem; }

.portal-footer {
  margin-left: 0;
  text-align: center;
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.portal-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(28rem, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.portal-card {
  background: #fff;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  padding: 1.25rem 1.5rem;
}

.portal-card h3 {
  margin: 0 0 0.75rem 0;
  font-size: 1.05rem;
  color: #13322B;
}

.portal-card .nota {
  color: #5c5c5c;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* Títulos de sección dentro del contenido: mismo aspecto que el título de
   la página (.page-header h1); el h1 del framework GobMX mide 54 px y el
   h2 38 px, y quedarían más grandes que ese título */
.portal-main > h1,
.portal-texto h1 {
  font-family: 'Noto Serif', serif;
  font-size: 2.25rem;
  color: #42001d;
  margin: 2.5rem 0 1rem 0;
}

.portal-main > .callout + h1,
.portal-texto h1:first-child { margin-top: 0; }

/* Texto corrido (metodología): ancho de lectura y secciones separadas */
.portal-texto { max-width: 80ch; }
.portal-texto p { margin: 0 0 1rem 0; }

/* Título de tarjeta que abre la gráfica ampliada en el modal */
.portal-card h3 .grafica-ampliar {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.portal-card h3 .grafica-ampliar .material-symbols-outlined {
  font-size: 1.1rem;
  vertical-align: -0.15em;
  margin-left: 0.25rem;
  color: #611232;
}

.portal-card h3 .grafica-ampliar:hover,
.portal-card h3 .grafica-ampliar:focus-visible {
  text-decoration: underline;
}

.portal-card h3 .grafica-ampliar:focus-visible {
  outline: 2px solid #611232;
  outline-offset: 3px;
  border-radius: 0.25rem;
}

.modal-window.grafica-modal { max-width: 1100px; }
.grafica-modal .modal-body { padding: 1.25rem 1.5rem; }
.grafica-modal .nota { color: #5c5c5c; font-size: 0.85rem; margin: 0.5rem 0 0 0; }
.grafica-modal .nota:empty { display: none; }

.kpi-card .kpi-value.chico { font-size: 1.8rem; }

.portal-tabla { width: 100%; }
.portal-tabla td.num, .portal-tabla th.num { text-align: right; font-variant-numeric: tabular-nums; }

.portal-chip {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: #e8f0ec;
  color: #13322B;
  font-size: 0.85rem;
  margin: 0 0.25rem 0.25rem 0;
}

.portal-provisional {
  background: #ffdea3;
  color: #5d4200;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
}

/* Gráficas (amCharts 5): el contenedor lleva altura fija */
.grafica { width: 100%; min-height: 160px; }
.grafica canvas, .grafica svg { font-family: 'Public Sans', sans-serif; }

/* Menú de descarga (plugin Exporting): discreto hasta pasar el cursor */
.grafica .am5exporting-menu { opacity: 0.55; }
.grafica:hover .am5exporting-menu, .grafica .am5exporting-menu-open { opacity: 1; }
.grafica .am5exporting-icon { background: #fff; border-radius: 4px; }

/* Paginador del catálogo: centrado, con el conteo encima de los botones */
.portal-paginacion {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.portal-paginacion .pagination { justify-content: center; flex-wrap: wrap; }

/* Catálogo y comparador */
.portal-filtros {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.portal-filtros label { display: block; font-size: 0.8rem; font-weight: 600; color: #5c5c5c; margin-bottom: 0.2rem; }

.version-card {
  background: #fff;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.version-card .co2 { font-size: 1.6rem; font-weight: 900; color: #13322B; white-space: nowrap; }
.version-card .co2 small { font-size: 0.75rem; font-weight: 500; color: #5c5c5c; }

.comparador-barra {
  position: sticky;
  bottom: 0;
  background: #13322B;
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.comparador-tabla td.mejor { background: #dcfce7; font-weight: 700; }

/* Fichas: etiqueta y valor en la misma línea de base. El framework GobMX
   agranda los <dd>, así que aquí se fijan tamaño, alto de línea y márgenes */
.ficha-seccion { margin-bottom: 1rem; }
.ficha-seccion dl {
  display: grid;
  grid-template-columns: minmax(9rem, max-content) 1fr;
  column-gap: 1rem;
  row-gap: 0;
  align-items: stretch;
  margin: 0;
}
/* Etiqueta y valor estiran a la misma altura: el separador de la fila
   queda parejo aunque el valor ocupe varios renglones */
.ficha-seccion dt,
.ficha-seccion dd {
  margin: 0;
  padding: 0.35rem 0;
  line-height: 1.35;
  border-bottom: 1px solid #f0eeee;
  text-align: left;
  overflow-wrap: anywhere;
}
.ficha-seccion dt { color: #5c5c5c; font-size: 0.85rem; font-weight: 500; padding-top: 0.45rem; }
.ficha-seccion dd { font-size: 1rem; font-weight: 600; color: #1b1c1c; }
.ficha-seccion dt:nth-last-of-type(1),
.ficha-seccion dd:last-child { border-bottom: 0; }

@media (max-width: 720px) {
  .portal-main { padding: 1rem; }
  .portal-grid-2 { grid-template-columns: 1fr; }
  .ficha-seccion dl { grid-template-columns: 1fr; }
}
