/* =========================================================
   Teams view + ficha de equipo
   ========================================================= */

.teams-view {
  position: relative;
  z-index: 2;
  padding: 0 20px 26px;
}

.teams-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 0 4px 16px;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(16, 26, 44, .03), 0 18px 40px -26px rgba(16, 26, 44, .25);
}
.teams-head h2 {
  margin: 0 0 4px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 28px;
  letter-spacing: -0.03em;
}
.teams-head p { margin: 0; color: var(--muted); font-size: 14.5px; }

.teams-grid {
  list-style: none;
  margin: 0;
  padding: 0 4px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}
.teams-grid li { animation: rise .5s cubic-bezier(.2, .7, .2, 1) both; opacity: 0; transform: translateY(12px); }

/* ---------- Crest ---------- */
.crest {
  position: relative;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  flex: none;
  border-radius: 50%;
  background:
    radial-gradient(120% 120% at 30% 20%, rgba(255, 255, 255, .22), transparent 55%),
    var(--crest);
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(13, 22, 38, .08), 0 10px 22px -12px rgba(13, 22, 38, .6);
  overflow: hidden;
}
.crest::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  border: 1.5px dashed rgba(255, 255, 255, .35);
}
.crest__mono {
  position: relative;
  font-family: var(--display);
  font-weight: 800;
  font-size: 25px;
  letter-spacing: -0.03em;
  color: #fff;
}
.crest__mono.is-3 { font-size: 20px; }
.crest__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #fff;
}
.crest--xl { width: 150px; height: 150px; border-width: 5px; }
.crest--xl::before { inset: 9px; border-width: 2px; }
.crest--xl .crest__mono { font-size: 50px; }
.crest--xl .crest__mono.is-3 { font-size: 40px; }

/* ---------- Team card ---------- */
.tcard {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 6px;
  padding: 26px 18px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(16, 26, 44, .03), 0 14px 30px -24px rgba(16, 26, 44, .35);
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.tcard:hover { transform: translateY(-3px); box-shadow: 0 1px 2px rgba(16, 26, 44, .03), 0 22px 40px -24px rgba(16, 26, 44, .45); }
.tcard:focus-visible { outline: 2px solid var(--navy); outline-offset: 3px; }
.tcard--gold   { background: var(--gold-bg);   border-color: var(--gold-line);   --medal: var(--gold); }
.tcard--silver { background: var(--silver-bg); border-color: var(--silver-line); --medal: var(--silver); }
.tcard--bronze { background: var(--bronze-bg); border-color: var(--bronze-line); --medal: var(--bronze); }

.tcard .crest { margin-bottom: 8px; }
.tcard__rank {
  position: absolute;
  top: 14px;
  left: 16px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.03em;
  color: var(--medal, var(--muted-2));
}
.tcard__name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--ink);
}
.tcard__meta {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
}
.tcard__meta .flag { width: 20px; height: 13px; }
.tcard__pts {
  margin-top: 6px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.tcard__pts small { margin-left: 4px; font-family: var(--font); font-weight: 400; font-size: 12px; color: var(--muted); }
.tcard__best {
  margin-top: 4px;
  padding-top: 10px;
  width: 100%;
  border-top: 1px solid rgba(13, 22, 38, .07);
  font-size: 12.5px;
  color: var(--muted);
}
.tcard__best b { color: var(--ink-2); font-weight: 600; }

/* ---------- Team hero ---------- */
.ph__team-link {
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(13, 22, 38, .25);
  text-underline-offset: 3px;
}
.ph__team-link:hover { text-decoration-color: currentColor; }

.ph__rk.th__players li {
  grid-template-columns: 40px minmax(0, 1fr) 56px 96px;
  gap: 12px;
  padding: 11px 16px;
  cursor: pointer;
  transition: background .15s;
  animation: rise .45s cubic-bezier(.2, .7, .2, 1) both;
  opacity: 0;
  transform: translateY(8px);
}
.ph__rk.th__players li:hover { background: var(--head); }
.ph__rk.th__players li:hover strong { text-decoration: underline; text-decoration-color: #c3c9d3; text-underline-offset: 3px; }
.ph__rk.th__players li:focus-visible { outline: 2px solid var(--navy); outline-offset: -2px; }
.th__av { width: 40px; height: 40px; font-size: 14px; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(13, 22, 38, .08); }
.th__who { display: grid; gap: 3px; min-width: 0; }
.th__who strong { font-size: 14.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.th__who span { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.th__who .flag { width: 18px; height: 12px; }
.th__rank {
  justify-self: center;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--head);
  font-family: var(--display);
  font-weight: 800;
  font-size: 14px;
  color: var(--ink-2);
}
.th__rank.is-gold { background: var(--gold-row); color: var(--gold-ink); }
.th__rank.is-silver { background: var(--silver-row); color: #5e6774; }
.th__rank.is-bronze { background: var(--bronze-row); color: var(--bronze-ink); }
.th__pts { text-align: right; font-family: var(--display); font-weight: 700; font-size: 16px; color: var(--ink); font-variant-numeric: tabular-nums; }
.th__pts small { font-family: var(--font); font-weight: 400; font-size: 12px; color: var(--muted-2); }

.ph__rk.th__stats li { grid-template-columns: minmax(0, 1fr) auto; padding: 13px 16px; }
.th__stats span { color: var(--muted); }
.th__stats b { color: var(--ink); font-weight: 600; text-align: right; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .teams-view { padding: 0 12px 18px; }
  .teams-head { flex-direction: column; align-items: stretch; padding: 16px; }
  .teams-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tcard { padding: 22px 10px 14px; }
  .tcard .crest { width: 58px; height: 58px; }
  .tcard__rank { font-size: 17px; top: 10px; left: 12px; }
  .tcard__name { font-size: 15.5px; }
  .tcard__meta { font-size: 11.5px; }
  .tcard__pts { font-size: 21px; }
  .tcard__best { font-size: 11.5px; }
  .crest--xl { width: 88px; height: 88px; border-width: 4px; }
  .crest--xl .crest__mono { font-size: 30px; }
  .crest--xl .crest__mono.is-3 { font-size: 24px; }
  .ph__rk.th__players li { grid-template-columns: 34px minmax(0, 1fr) 46px 74px; gap: 8px; padding: 10px 12px; }
  .th__av { width: 34px; height: 34px; font-size: 12px; }
}

/* Filtro por pais */
.teams-chips { margin: 0 4px 16px; }
.teams-chips .chip { gap: 8px; height: 36px; padding: 0 14px; font-size: 13.5px; }
.teams-chips .flag { width: 20px; height: 13px; }

/* Con logo real (assets/teams/<id>.png, fondo transparente): sin circulo de color */
.crest:has(.crest__img) {
  background: transparent;
  border: 0;
  box-shadow: none;
  overflow: visible;
}
.crest:has(.crest__img)::before,
.crest:has(.crest__img) .crest__mono { display: none; }
.crest .crest__img {
  object-fit: contain;
  background: transparent;
  filter: drop-shadow(0 6px 12px rgba(13, 22, 38, .25));
  border-radius: 22%;
}

.teams-search { margin: 0 4px 12px; width: auto; background: var(--surface); }

/* Tarjetas de equipo con lineas fijas (iguales en todas) */
.tcard { grid-template-rows: auto auto auto auto auto 1fr; }
.tcard__name { width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcard__meta { max-width: 100%; white-space: nowrap; }
.tcard__meta > span:last-child { margin-left: -2px; }
.tcard__cc { display: none; }
.tcard__best { display: grid; gap: 2px; align-self: end; }
.tcard__best small { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2); }
.tcard__best > span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 900px) {
  .tcard__cn { display: none; }
  .tcard__cc { display: inline; }
  .tcard__name { font-size: 15px; }
  .tcard__meta { font-size: 12px; gap: 5px; }
}

@media (max-width: 900px) {
  .teams-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: 0; margin-right: 0; padding: 2px 4px 4px; -webkit-overflow-scrolling: touch; }
  .teams-chips::-webkit-scrollbar { display: none; }
  .teams-chips .chip { flex: none; }
}

/* Buscador + desplegable de pais (igual que en las otras pestañas) */
.teams-head { align-items: center; }
.teams-tools { display: flex; align-items: center; gap: 10px; flex: 0 1 560px; }
.teams-head + .teams-grid { margin-top: 0; }
.teams-head { margin-bottom: 18px; }
.teams-tools .search-row { flex: 1; margin: 0; }
.teams-tools .search--card { margin: 0; background: var(--surface); }
.teams-country select { height: 44px; min-width: 200px; }
@media (max-width: 900px) {
  .teams-tools { flex: none; width: 100%; flex-direction: column; align-items: stretch; gap: 10px; }
  .teams-country, .teams-country select { width: 100%; }
  #view-teams:not(.filters-open) .teams-country { display: none; }
  #view-teams.filters-open .teams-country { animation: rise .25s ease both; }
}

/* movil/tablet: cabecera "All teams" alineada a la izquierda como en las otras pestañas */
@media (max-width: 900px) {
  .teams-head { align-items: stretch; text-align: left; }
}
