/* Team History tab — layout wrapper + narrative card + positions chart
   (SVG) + milestones timeline. Trophy cabinet lives in
   `components/trophies.css` as it's reused by the future league-history
   hall-of-fame view. */

@layer components {
  .team-history {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 0 24px;
  }

  /* ---- Positions chart (SVG) ------------------------------------- */

  /* Header = logo liga + nombre. Sustituye el h3 suelto para que el usuario
     sepa a qué competición corresponde la progresión. */
  .team-history__positions-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 16px;
  }

  .team-history__positions-logo {
    width: 20px;
    height: 20px;
    object-fit: contain;
    flex-shrink: 0;
  }

  .team-history__positions-header .card-title {
    margin: 0;
  }

  /* Editions selector trigger — full-width pill inside the card with
     bottom margin to separate it from the year list. Scoped here so it
     overrides the shared `.standings-league-trigger` width-fit pattern
     (which makes sense in the standings header but cramps the editions
     card body). */
  .team-history__editions-selector .select-trigger {
    width: 100%;
    margin-bottom: 12px;
  }

  /* Editions card — pill switcher de competición + lista por edición
     (year grande izquierda · stage + winner flag derecha). Ediciones de
     campeonato destacadas con fondo accent; edición en curso con italic. */

  .team-history__ed-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
  }

  .team-history__ed-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-size: 12px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition:
      background 120ms,
      color 120ms,
      border-color 120ms;
  }

  .team-history__ed-pill:hover {
    color: var(--color-text);
  }

  .team-history__ed-pill.active {
    background: color-mix(in srgb, var(--color-accent) 16%, transparent);
    color: var(--color-text);
    border-color: var(--color-accent);
  }

  .team-history__ed-pill-logo {
    width: 16px;
    height: 16px;
    object-fit: contain;
    flex-shrink: 0;
  }

  .team-history__editions {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .team-history__editions[hidden] {
    display: none;
  }

  .team-history__edition {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--color-surface);
  }

  /* Timeline "Resultado en cada Mundial": emblema de la edición a la
     izquierda; a la derecha, arriba "<País> <año>" y abajo la clasificación. */
  .wc-editions {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .wc-edition {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--color-surface);
  }

  .wc-edition__logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    flex-shrink: 0;
    /* Badge claro uniforme para que TODOS los emblemas (claros y oscuros)
       lean igual de nítidos. El de Catar (logo oscuro) se vería mejor con su
       variante clara — pendiente. */
    background: rgb(255 255 255 / 92%);
    border-radius: 6px;
    padding: 2px;
  }

  .wc-edition__main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
  }

  .wc-edition__name {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .wc-edition__finish {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
  }

  .wc-edition--champion {
    background: color-mix(in srgb, var(--color-accent) 18%, var(--color-surface));
    border: 1px solid color-mix(in srgb, var(--color-accent) 35%, transparent);
  }

  .wc-edition--champion .wc-edition__finish {
    color: var(--color-accent);
    font-weight: 700;
  }

  .team-history__edition-year {
    font-family: var(--font-title);
    font-weight: 800;
    font-size: 16px;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
    min-width: 50px;
    flex-shrink: 0;
  }

  .team-history__edition-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
  }

  .team-history__edition-stage {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
  }

  .team-history__edition-winner {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--color-text-muted);
  }

  .team-history__edition-winner-label {
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-size: 9px;
    font-weight: 700;
    color: var(--color-text-subtle);
  }

  .team-history__edition-winner-flag {
    width: 14px;
    height: 10px;
    border-radius: 2px;
    object-fit: cover;
    box-shadow: 0 1px 2px rgb(0 0 0 / 30%);
  }

  .team-history__edition-winner-name {
    color: var(--color-text-secondary);
    font-weight: 600;
  }

  .team-history__edition--champion {
    background: color-mix(in srgb, var(--color-accent) 18%, var(--color-surface));
    border: 1px solid color-mix(in srgb, var(--color-accent) 35%, transparent);
  }

  .team-history__edition--champion .team-history__edition-year,
  .team-history__edition--champion .team-history__edition-stage {
    color: var(--color-text);
  }

  .team-history__edition--champion .team-history__edition-winner-name {
    color: var(--color-accent);
    font-weight: 700;
  }

  /* Runner-up dentro de champion row — neutralizar el accent verde (el
     rival batido no debe leer como "highlight positivo"). */
  .team-history__edition--champion
    .team-history__edition-winner--runnerup
    .team-history__edition-winner-name {
    color: var(--color-text-secondary);
    font-weight: 600;
  }

  .team-history__edition--in-progress .team-history__edition-stage em {
    color: var(--color-accent);
    font-style: italic;
    font-weight: 700;
  }

  .team-history__chart {
    width: 100%;
    display: block;
    overflow: visible;
  }

  .team-history__chart-axis {
    stroke: var(--color-surface-border);
    stroke-width: 1;
    stroke-dasharray: 2 3;
  }

  .team-history__chart-label {
    font-size: 10px;
    fill: var(--color-text-muted);
    font-family: var(--font-body);
  }

  /* X-axis season labels are rotated -55° to fit 14+ entries without
     overlap. Smaller font keeps the tick block tight. */
  .team-history__chart-label--x {
    font-size: 9px;
  }

  .team-history__chart-label--current {
    fill: var(--color-accent);
    font-weight: 700;
  }

  .team-history__chart-area {
    fill: color-mix(in srgb, var(--color-accent) 18%, transparent);
  }

  .team-history__chart-line {
    fill: none;
    stroke: var(--color-accent);
    stroke-width: 2.25;
    stroke-linejoin: round;
    stroke-linecap: round;
  }

  .team-history__chart-value {
    font-size: 10px;
    font-weight: 700;
    fill: var(--color-text);
    font-family: var(--font-title);
  }

  .team-history__chart-dot {
    stroke: var(--color-bg);
    stroke-width: 1.5;
  }

  .team-history__chart-dot--champions {
    fill: var(--color-zone-champions);
  }

  .team-history__chart-dot--europa {
    fill: var(--color-zone-europa);
  }

  .team-history__chart-dot--conference {
    fill: var(--color-zone-conference);
  }

  .team-history__chart-dot--relegation {
    fill: var(--color-zone-relegation);
  }

  .team-history__chart-dot--mid {
    fill: var(--color-accent);
  }

  /* ---- Milestones timeline -------------------------------------- */

  .team-history__milestones {
    position: relative;
    list-style: none;
    padding: 0 0 0 18px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .team-history__milestones::before {
    content: "";
    position: absolute;
    left: 5px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: linear-gradient(to bottom, var(--color-accent), transparent);
    border-radius: 1px;
  }

  .team-history__milestone {
    display: grid;
    grid-template-columns: 54px 1fr;
    gap: 10px;
    padding: 8px 0;
    position: relative;
  }

  .team-history__milestone::before {
    content: "";
    position: absolute;
    left: -15px;
    top: 13px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-accent);
    border: 2px solid var(--color-bg);
  }

  .team-history__milestone-year {
    font-family: var(--font-title);
    font-size: 14px;
    font-weight: 800;
    color: var(--color-accent);
    font-variant-numeric: tabular-nums;
  }

  .team-history__milestone-label {
    font-size: 13px;
    color: var(--color-text);
    line-height: 1.4;
  }
}
