/* ==========================================================================
   charts.css — gráficos (SVG e barras em HTML)
   Marcas finas, grade em linha fina sólida, rótulos seletivos.
   ========================================================================== */

.chart {
  position: relative;
  width: 100%;
  min-width: 0;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart .grid line {
  stroke: var(--grid);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.chart .axis line,
.chart .axis path {
  stroke: var(--axis);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.chart text {
  fill: var(--ink-3);
  font-family: var(--font-ui);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart .axis-title {
  fill: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
}

.chart .ref line {
  stroke: var(--ink-3);
  stroke-width: 1;
  opacity: 0.6;
}

.chart .ref text {
  fill: var(--ink-2);
}

.chart .quadrant {
  fill: var(--ink-3);
  font-size: 11px;
  opacity: 0.7;
  letter-spacing: 0.04em;
}

/* pontos do gráfico de dispersão */

.chart .pt {
  cursor: pointer;
  transition: opacity 0.2s;
}

.chart .pt .ring {
  fill: none;
  stroke: var(--surface);
  stroke-width: 2;
}

.chart .pt .halo {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  opacity: 0;
  transition: opacity 0.15s;
}

.chart .pt .body {
  transition: transform 0.2s var(--ease);
}

.chart .pt.is-hot .halo,
.chart .pt:focus .halo {
  opacity: 1;
}

.chart .pt.is-hot .body,
.chart .pt:focus .body {
  transform: scale(1.35);
}

.chart .pt:focus {
  outline: none;
}

.chart.is-dimmed .pt:not(.is-hot) {
  opacity: 0.35;
}

/* inclinação (temporada 1 → 2) */

.chart .slope-item {
  cursor: pointer;
  transition: opacity 0.2s;
}

.chart .slope-item .line {
  stroke-width: 2;
  stroke-linecap: round;
  fill: none;
}

.chart .slope-item .hit {
  stroke: transparent;
  stroke-width: 16;
  fill: none;
}

.chart .slope-item .dot {
  stroke: var(--surface);
  stroke-width: 2;
}

.chart .slope-item text {
  fill: var(--ink-2);
  font-size: 12px;
}

.chart .slope-item text.val {
  fill: var(--ink);
  font-weight: 600;
}

.chart.is-dimmed .slope-item:not(.is-hot) {
  opacity: 0.18;
}

.chart .slope-item:focus {
  outline: none;
}

.chart .col-title {
  fill: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
}

/* barras horizontais em HTML */

.bars {
  display: grid;
  gap: 6px;
}

.bars {
  --label-w: 210px;
}

.bar-row {
  display: grid;
  grid-template-columns: var(--label-w) minmax(0, 1fr) 64px;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: default;
  transition: background 0.15s;
}

.bar-row.is-clickable {
  cursor: pointer;
}

.bar-row:hover,
.bar-row:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.bar-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 13px;
}

.bar-label .txt {
  min-width: 0;
}

.bar-label b {
  display: block;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-label small {
  display: block;
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  position: relative;
  height: 18px;
}

.bar-fill {
  position: absolute;
  left: 0;
  top: 3px;
  height: 12px;
  border-radius: 0 4px 4px 0;
  background: var(--s1);
  transition: width 0.5s var(--ease);
}

.bar-row:hover .bar-fill {
  filter: brightness(1.15);
}

.bar-ref {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 1px;
  background: var(--ink-3);
  opacity: 0.55;
}

.bar-value {
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.bar-axis {
  display: grid;
  grid-template-columns: var(--label-w, 210px) minmax(0, 1fr) 64px;
  gap: 12px;
  padding: 0 8px;
  font-size: 11px;
  color: var(--ink-3);
}

.bar-axis .ticks {
  position: relative;
  height: 14px;
}

.bar-axis .ticks span {
  position: absolute;
  transform: translateX(-50%);
  font-variant-numeric: tabular-nums;
}

/* grupos de barras do comparador */

.cmp-metric {
  display: grid;
  grid-template-columns: minmax(140px, 220px) minmax(0, 1fr);
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--hair);
}

.cmp-metric:first-of-type {
  border-top: 0;
}

.cmp-metric h4 {
  font-size: 13px;
  font-weight: 600;
}

.cmp-metric p {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
}

.cmp-bars {
  display: grid;
  gap: 6px;
}

.cmp-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  align-items: center;
  gap: 10px;
}

.cmp-bar .bar-track {
  height: 14px;
}

.cmp-bar .bar-fill {
  top: 2px;
  height: 10px;
}

.cmp-head {
  display: grid;
  grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.cmp-deck {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--hair);
  background: var(--surface-2) center 25% / cover no-repeat;
  /* a arte fica só dentro da borda: o degradê (inset: 0) não cobre a faixa de 1px */
  background-clip: padding-box;
  min-height: 150px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  cursor: pointer;
}

.cmp-deck::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(14, 14, 15, 0.05) 10%, rgba(14, 14, 15, 0.92) 85%);
}

.cmp-deck::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: var(--slot);
}

.cmp-deck > * {
  position: relative;
}

.cmp-deck b {
  font-size: 16px;
}

.cmp-deck small {
  font-size: 12px;
  color: var(--ink-2);
}

.cmp-deck .remove {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--hair-2);
  background: rgba(14, 14, 15, 0.7);
  display: grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
}

.curve-row {
  display: grid;
  grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr));
  gap: 12px;
}

/* curva de mana (mini histograma) */

.curve {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  align-items: end;
  gap: 4px;
  height: 124px;
  padding-top: 26px;
}

.curve-col {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
}

.curve-col .bar {
  width: 100%;
  max-width: 24px;
  border-radius: 4px 4px 0 0;
  background: var(--slot, var(--s1));
  min-height: 2px;
  transition: filter 0.2s;
}

.curve-col:hover .bar {
  filter: brightness(1.2);
}

.curve-col .cap {
  position: absolute;
  font-size: 10px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.curve-col .lbl {
  font-size: 10px;
  color: var(--ink-3);
  margin-top: 4px;
}

/* halteres (jogadores T1 × T2) */

.dumbbell {
  display: grid;
  gap: 2px;
}

.db-row {
  display: grid;
  grid-template-columns: var(--db-cols);
  align-items: center;
  gap: 12px;
  padding: 5px 8px;
  border-radius: 8px;
  transition: background 0.15s;
}

.db-row:hover,
.db-row:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.db-row .name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.db-track {
  position: relative;
  height: 18px;
}

.db-track .base {
  position: absolute;
  left: 0;
  right: 0;
  top: 8.5px;
  height: 1px;
  background: var(--grid);
}

.db-track .link {
  position: absolute;
  top: 8px;
  height: 2px;
  background: var(--ink-3);
  opacity: 0.6;
}

.db-track .dot {
  position: absolute;
  top: 4px;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--surface);
}

.db-row .vals {
  font-size: 12px;
  color: var(--ink-2);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* abas dentro do painel do gráfico */

.chart-tabs {
  margin-bottom: 14px;
}

.chart-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--ink-3);
}

.chart-note b {
  color: var(--ink);
  font-weight: 600;
}

.table-toggle {
  margin-top: 12px;
}

.table-toggle summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-2);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.table-toggle summary::-webkit-details-marker {
  display: none;
}

.table-toggle summary::before {
  content: "▸";
  transition: transform 0.2s;
}

.table-toggle[open] summary::before {
  transform: rotate(90deg);
}

.table-toggle .table-wrap {
  margin-top: 10px;
  max-height: 340px;
  overflow: auto;
}

.axis-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 640px) {
  .bars {
    --label-w: 124px;
  }

  .bar-row,
  .bar-axis {
    grid-template-columns: var(--label-w) minmax(0, 1fr) 52px;
    gap: 8px;
  }

  .cmp-metric {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .db-row {
    gap: 8px;
  }
}

/* rótulos escondidos no gráfico de inclinação aparecem no hover */
.chart .slope-item .is-off {
  opacity: 0;
  transition: opacity 0.15s;
}

.chart .slope-item.is-hot .is-off,
.chart .slope-item:focus .is-off {
  opacity: 1;
}

.dumbbell {
  --db-cols: 180px minmax(0, 1fr) 92px;
}

@media (max-width: 640px) {
  .dumbbell {
    --db-cols: 104px minmax(0, 1fr) 78px;
  }
}

/* rótulos dos eixos legíveis por cima das linhas */
.chart text.halo {
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.bar-thumb {
  width: 38px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  /* eixo das barras: só 0%, 50% e 100% para não amontoar */
  .bar-axis .ticks span:nth-child(even) {
    display: none;
  }
}

/* mapa de calor: espaço no torneio por estilo */
.heat-table td.heat {
  font-weight: 600;
  border-left: 2px solid var(--surface);
  transition: filter 0.15s;
}

.heat-table td.heat:hover,
.heat-table td.heat:focus {
  filter: brightness(1.2);
  outline: none;
}

.style-icon {
  font-size: 16px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

/* duplas de estilos: nomes compostos quebram linha em vez de cortar */
#style-combos {
  --label-w: 260px;
}

#style-combos .bar-label b {
  white-space: normal;
  line-height: 1.3;
}

@media (max-width: 640px) {
  #style-combos {
    --label-w: 150px;
  }
}
