/* Vista Comparar — análisis histórico equipo vs equipo. Mobile-first. */

.compare-view {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---------- Header ---------- */
.compare-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.compare-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  line-height: 1.1;
  color: var(--ink);
  margin: 0;
}
.compare-subtitle {
  color: var(--ink-2);
  font-size: 0.95rem;
  margin: 0;
}

/* ---------- Selectores ---------- */
.compare-controls {
  width: 100%;
}
/* Toggle de modo Equipos | Jugadores. */
.compare-mode { display: flex; justify-content: center; margin-bottom: 14px; }

/* Toggle Histórico / Mundial 2026 bajo los selectores. */
.compare-edition {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}

/* "¿Quién ganaría?" — pronóstico del motor para el cruce hipotético. */
.compare-matchup { padding: 16px; }
.compare-matchup__title { margin: 0 0 4px; font-family: var(--font-display); font-weight: 800; font-size: 1rem; }
.compare-matchup__cap { margin: 0 0 12px; font-size: .82rem; color: var(--ink-2); }
.compare-matchup__bars { display: flex; flex-direction: column; gap: 10px; }
.cm-bar__head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.cm-bar__label { font-size: .85rem; font-weight: 600; color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-bar__val { font-family: var(--font-display); font-weight: 800; font-variant-numeric: tabular-nums; }
.cm-bar__track { height: 9px; border-radius: var(--r-pill); background: var(--surface-sunk); overflow: hidden; }
.cm-bar__fill { display: block; height: 100%; border-radius: var(--r-pill); transition: width var(--t) var(--ease); }
.cm-bar--home .cm-bar__fill { background: var(--brand-1); }
.cm-bar--home .cm-bar__val { color: var(--brand-1); }
.cm-bar--draw .cm-bar__fill { background: var(--ink-3); }
.cm-bar--draw .cm-bar__val { color: var(--ink-2); }
.cm-bar--away .cm-bar__fill { background: var(--blue); }
.cm-bar--away .cm-bar__val { color: var(--blue); }
.compare-matchup__meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 12px 0 0; font-size: .82rem; color: var(--ink-2); }
.cm-conf { font-weight: 600; }
.cm-conf--alta { color: var(--win); }
.cm-conf--media { color: var(--warn); }
.cm-conf--baja { color: var(--ink-3); }
.compare-matchup__ai { margin-top: 12px; }
.compare-matchup__aibox { background: var(--surface-soft); border: 1px solid var(--hairline); border-radius: var(--r-md); padding: 10px 12px; }
.compare-matchup__ailabel { margin: 0 0 4px; font-weight: 700; font-size: .8rem; color: var(--brand-1); }
.compare-matchup__aibox p { margin: 4px 0; font-size: .84rem; line-height: 1.5; color: var(--ink-2); }
.compare-matchup__aibox li { font-size: .84rem; line-height: 1.5; color: var(--ink-2); margin-left: 16px; }
.compare-selectors {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.compare-vs {
  align-self: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink-3);
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
}
.compare-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 0;
  min-width: 0;
}
.compare-field__label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.compare-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.compare-select:hover {
  border-color: var(--brand-1);
}
.compare-select:focus-visible {
  outline: 2px solid var(--brand-1);
  outline-offset: 2px;
}

/* ---------- Hint / resultado ---------- */
.compare-result {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.compare-hint {
  color: var(--ink-3);
  font-size: 0.95rem;
  margin: 4px 0;
  text-align: center;
}
.compare-skeleton {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- Tarjeta de récords (cabecera + tabla comparativa) ---------- */
.compare-records {
  padding: 18px 14px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
}
/* Cabecera: equipo A | vs | equipo B */
.compare-records__head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}
.compare-records__vs {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--ink-3);
  font-size: 0.8rem;
  text-transform: uppercase;
}
.compare-records__caption {
  text-align: center;
  font-size: 0.72rem;
  color: var(--ink-3);
  margin: 10px 0 4px;
}
.compare-team {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.compare-team__crest {
  width: 56px;
  height: 56px;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  object-fit: contain;
  background: var(--surface-soft);
}
.compare-team__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
  text-align: center;
  margin: 0;
  line-height: 1.15;
}

/* Tabla comparativa: valor A | métrica | valor B */
.compare-table {
  display: flex;
  flex-direction: column;
  margin-top: 6px;
}
.compare-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--hairline);
}
.compare-row:last-child { border-bottom: 0; }
.compare-row__val {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.compare-row__val--a { text-align: right; }
.compare-row__val--b { text-align: left; }
.compare-row__val.is-better { color: var(--win); font-weight: 800; }
.compare-row__label {
  font-size: 0.74rem;
  color: var(--ink-3);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* ---------- Tarjeta de figuras (jugadores con foto) ---------- */
.compare-players { padding: 16px 14px; }
.compare-players__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  margin: 0 0 12px;
}
.compare-players__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 560px) { .compare-players__grid { grid-template-columns: 1fr 1fr; } }
.compare-players__team {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink-2);
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--hairline);
}
.compare-players__empty { font-size: 0.82rem; color: var(--ink-3); }
.compare-players__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.compare-players__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 4px;
  border-radius: var(--r-sm);
}
.compare-players__row.is-clickable { cursor: pointer; transition: background var(--t-fast) var(--ease); }
.compare-players__row.is-clickable:hover { background: var(--surface-soft); }
.compare-players__row.is-clickable:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 1px; }
.compare-players__photo {
  width: 36px;
  height: 36px;
  border-radius: var(--r-pill);
  object-fit: cover;
  background: var(--surface-sunk);
  flex: 0 0 auto;
}
.compare-players__info { display: flex; flex-direction: column; min-width: 0; }
.compare-players__name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.compare-players__meta {
  font-size: 0.72rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* ---------- Tarjeta resumen H2H ---------- */
.compare-summary {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 14px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
}
.compare-summary__title,
.compare-meetings__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  margin: 0;
}
.compare-summary__empty {
  color: var(--ink-2);
  font-size: 0.92rem;
  margin: 0;
  padding: 8px 0;
}

/* Barra G/E/P */
.compare-gepbar {
  display: flex;
  width: 100%;
  height: 14px;
  border-radius: var(--r-pill);
  overflow: hidden;
  background: var(--surface-sunk);
}
.compare-gepbar__seg {
  height: 100%;
  transition: width var(--t-slow) var(--ease);
}
.compare-gepbar__seg--win {
  background: var(--win);
}
.compare-gepbar__seg--draw {
  background: var(--draw);
}
.compare-gepbar__seg--loss {
  background: var(--loss);
}

/* Badges */
.compare-badges {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.compare-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 6px;
  border-radius: var(--r-sm);
  background: var(--surface-soft);
  border: 1px solid var(--hairline);
  text-align: center;
}
.compare-badge__value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.35rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.compare-badge__label {
  font-size: 0.7rem;
  color: var(--ink-3);
  line-height: 1.2;
}
.compare-badge--win .compare-badge__value {
  color: var(--win);
}
.compare-badge--draw .compare-badge__value {
  color: var(--draw);
}
.compare-badge--loss .compare-badge__value {
  color: var(--loss);
}

/* Totales */
.compare-totals {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}
.compare-totals__item {
  font-size: 0.9rem;
  color: var(--ink-2);
}
.compare-totals__item strong {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ---------- Lista de meetings ---------- */
.compare-meetings {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 14px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
}
.compare-meetings__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.compare-meeting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--hairline);
}
.compare-meeting:last-child {
  border-bottom: 0;
}
.compare-meeting__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.compare-meeting__comp {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.compare-meeting__date {
  font-size: 0.78rem;
  color: var(--ink-3);
}
.compare-meeting__score {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- Tablet / escritorio ---------- */
@media (min-width: 640px) {
  .compare-selectors {
    flex-direction: row;
    align-items: flex-end;
  }
  .compare-vs {
    padding-bottom: 12px;
  }
  .compare-team__crest {
    width: 64px;
    height: 64px;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .compare-select,
  .compare-gepbar__seg {
    transition: none;
  }
}

/* Fila de % campeón 2026 en la tabla comparativa */
.compare-row--champ {
  border-top: 2px solid var(--hairline);
  margin-top: 2px;
  padding-top: 10px;
}
.compare-row--champ .compare-row__val { color: var(--brand-1); font-weight: 800; }
.compare-row--champ .compare-row__val.is-better { color: var(--brand-2); }
