:root {
  --panel-bg: rgba(255, 255, 255, 0.94);
  --panel-border: rgba(23, 23, 23, 0.08);
  --text-strong: #111111;
  --text-soft: #7e756c;
  --text-faint: #a79f96;
  --shadow: 0 20px 45px rgba(34, 34, 34, 0.12);
  --warm-bg: #f4f1eb;
}

html,
body,
main,
#observablehq-center,
#observablehq-main,
#observablehq-main > *,
.app {
  margin: 0;
}

body {
  font-family: "Instrument Sans", "Helvetica Neue", sans-serif;
  background: var(--warm-bg);
}

main,
#observablehq-center,
#observablehq-main,
#observablehq-main > * {
  max-width: none !important;
  padding: 0 !important;
}

.app {
  position: relative;
  height: 100vh;
  overflow: hidden;
}

#mapa {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.credito {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.credito__logo {
  width: 0.95rem;
  height: 0.95rem;
  display: block;
  flex: 0 0 auto;
}

.credito__text {
  font-size: 0.7rem;
  line-height: 1;
  font-weight: 500;
  color: var(--text-soft);
  white-space: nowrap;
}

.header {
  position: absolute;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  z-index: 10;
  max-width: 24rem;
  padding: 1.5rem 0.95rem 0.95rem;
  border: 1px solid var(--panel-border);
  border-radius: 0.35rem;
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.header__eyebrow {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--text-strong);
  text-align: center;
  line-height: 1.05;
}

.header__subtitle {
  margin-top: 0.5rem;
  font-size: 0.86rem;
  line-height: 1.28;
  font-weight: 400;
  color: var(--text-strong);
  text-align: center;
}

.header__detail {
  margin-top: 0.45rem;
  color: var(--text-soft);
  font-size: 0.72rem;
  line-height: 1.32;
  text-align: center;
  text-wrap: pretty;
  font-style: italic;
}

.header__toggle {
  display: none;
}

.header__collapsible {
  display: block;
}

.header__timestamp {
  margin-top: 0.6rem;
  font-size: 0.67rem;
  line-height: 1.2;
  font-weight: 400;
  color: var(--text-soft);
  text-align: center;
}

.header__eleccion {
  display: inline;
  min-width: 0;
}

.header__eleccion form,
.header__eleccion .inputs-3a86ea,
.header__eleccion .inputs-3a86ea-select {
  display: inline;
  min-height: 0;
  margin: 0;
  min-width: 0;
}

.header__eleccion select {
  display: inline;
  width: auto;
  max-width: 100%;
  margin: 0 0.1rem;
  padding: 0 0 5px 0;
  border: 0;
  border-bottom: 1px dotted rgba(0, 0, 0, 0.14);
  border-radius: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  box-shadow: none;
  vertical-align: baseline;
  text-align: center;
  text-align-last: center;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: none;
  cursor: pointer;
  transition:
    color 120ms ease,
    border-bottom-color 120ms ease;
}

.header__eleccion select:focus {
  outline: none;
  border-bottom-color: rgba(0, 0, 0, 0.32);
}

.header__eleccion select:hover {
  color: #000;
  border-bottom-color: rgba(0, 0, 0, 0.24);
}

.header__controls {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.control__description {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.78rem;
  line-height: 1.3;
  text-align: center;
}

.legend {
  position: relative;
  width: 100%;
  max-width: 20rem;
  margin: 0 auto;
  padding: 0.55rem 0 0 0;
}

.legend__axis {
  color: var(--text-soft);
  font-size: 0.7rem;
  line-height: 1.15;
  font-weight: 600;
}

.legend__axis--top {
  margin: 0 0 1.2rem 0;
  text-align: center;
}

.legend__axis--side {
  position: absolute;
  left: 3.5rem;
  top: 50%;
  /* width: 8.8rem; */
  transform: translate(-50%, -50%) rotate(-90deg);
  transform-origin: center;
  text-align: center;
  white-space: nowrap;
}

.legend__grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.12rem;
  width: 9.4rem;
  margin: 0 auto;
}

.legend__swatch {
  aspect-ratio: 1;
  border-radius: 0.1rem;
  cursor: default;
  box-sizing: border-box;
  border: 1px solid transparent;
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease;
}

.legend__swatch:hover {
  border-color: rgba(17, 17, 17, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.legend__swatch--active {
  border-color: rgba(17, 17, 17, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.legend__hint {
  margin: 0.45rem auto 0;
  max-width: 16rem;
  min-height: 3em;
  color: var(--text-faint);
  font-size: 0.65rem;
  line-height: 1.5;
  text-align: center;
}

.legend__hint em {
  display: block;
}

.maplibregl-ctrl-bottom-right {
  right: 1rem;
  bottom: 1rem;
}

.maplibregl-ctrl-group {
  overflow: hidden;
  border-radius: 0.45rem;
  box-shadow: 0 10px 30px rgba(34, 34, 34, 0.12);
}

.maplibregl-popup {
  max-width: 19rem;
  z-index: 40;
}

.maplibregl-popup-content {
  padding: 0;
  border-radius: 0.4rem;
  box-shadow: 0 16px 40px rgba(15, 15, 15, 0.2);
}

.maplibregl-popup-close-button {
  top: 0.28rem;
  right: 0rem;
  width: .7rem;
  height: .7rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 1rem;
  line-height: 1;
  color: var(--text-soft);
}

.maplibregl-popup-close-button:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-strong);
}

.maplibregl-popup-tip {
  border-top-color: rgba(255, 255, 255, 0.96) !important;
}

.popup-card {
  min-width: 14rem;
  padding: 0.8rem 0.85rem 0.85rem;
  background: rgba(255, 255, 255, 0.96);
}

.popup-card__eyebrow {
  color: var(--text-soft);
  font-size: 0.65rem;
  font-weight: 700;
  /* letter-spacing: 0.04em; */
  text-transform: uppercase;
}

.popup-card__title {
  margin-top: 0.18rem;
  color: var(--text-strong);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.2;
}

.popup-card__body {
  margin-top: 0.65rem;
  color: var(--text-soft);
  font-size: 0.79rem;
  line-height: 1.45;
  text-wrap: pretty;
}

.popup-card__value,
.popup-card__percent,
.popup-card__category {
  color: var(--text-soft);
  font-weight: 700;
}

.popup-card__percent {
  color: var(--text-strong);
}

.popup-card__value,
.popup-card__percent {
  font-variant-numeric: tabular-nums;
}

@media (max-width: 720px) {
  .header {
    top: 0.75rem;
    left: 0.75rem;
    right: 0.75rem;
    max-width: none;
    padding: 0.9rem 0.82rem 0.9rem;
    overflow: hidden;
  }

  .header__eyebrow {
    font-size: 1.3rem;
  }

  .header__subtitle {
    font-size: 0.8rem;
    text-wrap: balance;
  }

  .header__eleccion {
    display: block;
    width: 100%;
    margin-top: 0.4rem;
  }

  .header__eleccion form,
  .header__eleccion .inputs-3a86ea,
  .header__eleccion .inputs-3a86ea-select {
    display: block;
    width: 100% !important;
  }

  .header__eleccion select {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0.2rem 1.15rem 0.35rem 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    text-align-last: center;
  }

  .header__detail {
    font-size: 0.69rem;
    font-style: italic;
  }

  .header__collapsible {
    max-height: min(60vh, 20rem);
    margin-top: 0.5rem;
    padding-bottom: 2.35rem;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    opacity: 1;
    transform: translateY(0);
    transition:
      opacity 180ms ease,
      transform 220ms ease,
      max-height 220ms ease;
  }

  .header__toggle {
    display: inline-flex;
    position: absolute;
    bottom: 0.35rem;
    left: 50%;
    z-index: 2;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--text-soft);
    font: inherit;
    cursor: pointer;
    transform: translateX(-50%);
    transition:
      background-color 120ms ease,
      color 120ms ease,
      box-shadow 120ms ease;
  }

  .header__toggle_icon {
    display: block;
    width: 0.5rem;
    height: 0.5rem;
    border-left: 1.5px solid currentColor;
    border-top: 1.5px solid currentColor;
    transform: translateY(0.08rem) rotate(45deg);
    transition: transform 160ms ease;
  }

  .header__toggle:hover,
  .header__toggle:focus-visible {
    outline: none;
    color: var(--text-strong);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
  }

  .header--collapsed {
    padding-bottom: 3.15rem;
  }

  .header--collapsed .header__collapsible {
    max-height: 0;
    margin-top: 0;
    padding-bottom: 0;
    opacity: 0;
    overflow: hidden;
    transform: translateY(-0.35rem);
    pointer-events: none;
  }

  .header--collapsed .header__toggle_icon {
    transform: translateY(-0.08rem) rotate(225deg);
  }

  .header--dit.header--scrollable:not(.header--at-bottom)::after {
    content: "";
    position: sticky;
    bottom: -1.5rem;
    display: block;
    width: calc(100% + 1.64rem);
    margin-left: -0.82rem;
    margin-bottom: -0.9rem;
    background: linear-gradient(
      to bottom,
      rgba(244, 241, 235, 0),
      rgba(244, 241, 235, 0.84) 92%,
      rgba(244, 241, 235, 0.98) 100%
    );
    pointer-events: none;
  }

  .header--collapsed::after {
    display: none;
  }

  .header__timestamp {
    font-size: 0.63rem;
  }

  .credito {
    left: 1.5rem;
    bottom: 1.5rem;
    padding: 0.38rem 0.5rem;
    gap: 0.38rem;
  }

  .credito__text {
    font-size: 0.64rem;
  }

  .legend {
    max-width: 18rem;
    padding-left: 1rem;
  }

  .legend__axis--top {
    margin-left: 1.45rem;
  }

  .legend__axis--side {
    left: 3.5rem;
    width: 7.8rem;
  }
}
