/* "Mapa de vendas" (model 10 of the SeinovFlow Início): js/seinovflow/map.js.
   Colors only through tokens; the light scheme follows by itself.
   Measures of the approved model (card of 577 x 295 on a 1470 px computer, 44 px header):
   a 220 px map on the left, the Top 5 on the right. Below 520 px of card width: the map on top,
   centred, and the Top 5 below. */

.salesmap {
  position: relative;
  container-type: inline-size;
  padding: 7px 20px 16px;
}

.salesmap__body {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  column-gap: 21px;
  align-items: start;
}

/* ----- map ----- */
.salesmap__figure {
  min-width: 0;
}

.salesmap__svg {
  display: block;
  width: 220px;
  height: auto;
  overflow: visible;
  -webkit-tap-highlight-color: transparent;
}

.salesmap__uf {
  stroke: var(--color-surface);
  stroke-width: 1;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  transition: fill var(--duration-base) ease;
}

.salesmap__uf:focus,
.salesmap__uf:focus-visible {
  outline: none; /* the focus shows on the highlight outline */
}

.salesmap__uf--0 { fill: var(--color-map-0); }
.salesmap__uf--1 { fill: var(--color-map-1); }
.salesmap__uf--2 { fill: var(--color-map-2); }
.salesmap__uf--3 { fill: var(--color-map-3); }
.salesmap__uf--4 { fill: var(--color-map-4); }
.salesmap__uf--5 { fill: var(--color-map-5); }

.salesmap__outline {
  fill: none;
  stroke: var(--color-ink);
  stroke-width: 2;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

/* Keyboard focus: a slightly thicker outline (cyan would be lost on the blue states). */
.salesmap__outline.is-focus {
  stroke-width: 2.5;
}

/* ----- Top 5 ----- */
.salesmap__top {
  min-width: 0;
  margin: 11px 0 0;
  padding: 0;
  list-style: none;
}

.salesmap__row {
  display: flex;
  align-items: baseline;
  height: 41px;
  padding-top: 10px;
  white-space: nowrap;
}

.salesmap__row + .salesmap__row {
  border-top: 1px solid var(--color-border);
}

.salesmap__pos {
  flex: none;
  width: 27px;
  font-size: var(--font-size-xs);
  color: var(--color-ink-subtle);
  font-variant-numeric: tabular-nums;
}

.salesmap__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--color-ink);
}

.salesmap__abbr {
  flex: none;
  margin-left: 8px;
  font-size: var(--font-size-xs);
  color: var(--color-ink-subtle);
}

.salesmap__value {
  flex: none;
  margin-left: auto;
  padding-left: 12px;
  font-size: var(--font-size-xs);
  color: var(--color-ink-muted);
  font-variant-numeric: tabular-nums;
}

.salesmap__sales {
  font-weight: 600;
  font-size: var(--font-size-body-lg);
  color: var(--color-ink);
}

.salesmap__empty {
  padding-top: 10px;
  font-size: var(--font-size-caption);
  color: var(--color-ink-subtle);
}

/* ----- balloon ----- */
.salesmap__tip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  padding: 8px 12px 9px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-bg);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  white-space: nowrap;
}

.salesmap__tip-title {
  margin: 0;
  font-weight: 600;
  font-size: var(--font-size-caption);
  line-height: 18px;
  color: var(--color-ink);
}

.salesmap__tip-line {
  margin: 2px 0 0;
  font-size: var(--font-size-xs);
  line-height: 16px;
  color: var(--color-ink-muted);
  font-variant-numeric: tabular-nums;
}

/* ----- narrow card (phones): map on top, Top 5 below -----
   The query measures the inside of .salesmap (without its 2 x 20 px padding or the card border):
   479 px inside = a card of ~520 px. */
@container (max-width: 479px) {
  .salesmap__body {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 8px;
  }

  .salesmap__svg {
    width: min(100%, 280px);
    margin-inline: auto;
  }

  .salesmap__top {
    margin-top: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .salesmap__uf {
    transition: none;
  }
}
