/* Trophies — shared component for team-history trophy cabinet and
   (future) league-history hall-of-fame. Contract: consumers supply
   `entries[]` with `{detailId, logo, name, champCount, subCount,
   champYears, subYears}`. The markup lives in `components/trophies/`.

   Does NOT style the hero "insignia" card — that stays close to the
   consumer because the team/league flavor diverges (team colors vs
   competition crest treatment). */

@layer components {
  /* ---- Insignia hero (team colors gradient) --------------------- */
  .trophies-hero {
    background: linear-gradient(
      135deg,
      color-mix(in srgb, var(--team-color-1) 40%, var(--color-bg)),
      color-mix(in srgb, var(--team-color-2) 25%, var(--color-bg))
    );
    border: 1px solid color-mix(in srgb, var(--team-color-1) 35%, transparent);
    border-radius: 14px;
    padding: 18px 16px 14px;
    margin: 0 16px 16px;
    position: relative;
    overflow: hidden;
  }

  .trophies-hero::before {
    content: "";
    position: absolute;
    top: -40%;
    right: -20%;
    width: 60%;
    height: 120%;
    background: radial-gradient(ellipse, var(--team-glow), transparent 70%);
    pointer-events: none;
  }

  .trophies-hero__badge {
    font-family: var(--font-title);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgb(255 255 255 / 60%);
    margin-bottom: 12px;
    position: relative;
  }

  .trophies-hero__main {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
    position: relative;
  }

  .trophies-hero__logo {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 8px rgb(0 0 0 / 40%));
  }

  .trophies-hero__logo img {
    width: 64px;
    height: 64px;
    object-fit: contain;
  }

  .trophies-hero__body {
    flex: 1;
    min-width: 0;
  }

  .trophies-hero__tag {
    margin: 0 0 2px;
    font-size: 11px;
    color: rgb(255 255 255 / 55%);
    letter-spacing: 0.04em;
  }

  .trophies-hero__name {
    margin: 0;
    font-family: var(--font-title);
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    line-height: 1.1;
    text-shadow: 0 1px 3px rgb(0 0 0 / 30%);
  }

  .trophies-hero__stats {
    display: flex;
    gap: 0;
    position: relative;
    border-top: 1px solid rgb(255 255 255 / 10%);
    padding-top: 12px;
  }

  .trophies-hero__stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex: 1;
  }

  .trophies-hero__stat + .trophies-hero__stat {
    border-left: 1px solid rgb(255 255 255 / 10%);
  }

  .trophies-hero__stat-value {
    font-family: var(--font-title);
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    font-variant-numeric: tabular-nums;
  }

  .trophies-hero__stat-label {
    font-size: 10px;
    font-weight: 600;
    color: rgb(255 255 255 / 40%);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  /* ---- Podium (1st/2nd/3rd cards) ------------------------------- */
  .trophies-podium {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 8px;
    padding: 20px 16px 0;
  }

  .trophies-podium__card {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100px;
    background: transparent;
    border: 0;
    padding: 0;
    color: inherit;
    font: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.12s ease;
  }

  .trophies-podium__card:hover,
  .trophies-podium__card:focus-visible {
    transform: translateY(-2px);
    outline: none;
  }

  .trophies-podium__rank {
    margin-bottom: 6px;
    font-family: var(--font-title);
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text-muted);
  }

  .trophies-podium__logo {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
  }

  .trophies-podium__logo img {
    width: 36px;
    height: 36px;
    object-fit: contain;
  }

  .trophies-podium__card--gold .trophies-podium__logo,
  .trophies-podium__card--gold .trophies-podium__logo img {
    width: 44px;
    height: 44px;
  }

  .trophies-podium__name {
    width: 100%;
    margin-bottom: 4px;
    font-family: var(--font-title);
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text);
    text-transform: uppercase;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .trophies-podium__count {
    margin-bottom: 6px;
    font-family: var(--font-title);
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
  }

  .trophies-podium__card--gold .trophies-podium__count {
    font-size: 22px;
    color: #d4af37;
  }

  .trophies-podium__card--silver .trophies-podium__count {
    color: #c0c0c0;
  }

  .trophies-podium__card--bronze .trophies-podium__count {
    color: #cd7f32;
  }

  .trophies-podium__sub {
    margin-bottom: 4px;
    font-size: 10px;
    color: var(--color-text-subtle);
    font-weight: 500;
  }

  .trophies-podium__bar {
    width: 100%;
    border-radius: 6px 6px 0 0;
  }

  .trophies-podium__bar--gold {
    height: 64px;
    background: linear-gradient(180deg, #d4af37, rgb(212 175 55 / 20%));
  }

  .trophies-podium__bar--silver {
    height: 48px;
    background: linear-gradient(180deg, #c0c0c0, rgb(192 192 192 / 15%));
  }

  .trophies-podium__bar--bronze {
    height: 36px;
    background: linear-gradient(180deg, #cd7f32, rgb(205 127 50 / 15%));
  }

  /* ---- Ranked list (4+ with relative bars) --------------------- */
  .trophies-ranked {
    border-top: 1px solid var(--color-surface-border);
    padding: 4px 0;
    margin-top: 12px;
  }

  .trophies-ranked__row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    width: 100%;
    background: transparent;
    border: 0;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.12s ease;
  }

  .trophies-ranked__row:hover,
  .trophies-ranked__row:focus-visible {
    background: color-mix(in srgb, var(--color-text) 3%, transparent);
    outline: none;
  }

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

  .trophies-ranked__pos {
    width: 22px;
    flex-shrink: 0;
    font-family: var(--font-title);
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text-muted);
    text-align: center;
  }

  .trophies-ranked__logo {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  /* stylelint-disable-next-line no-descending-specificity */
  .trophies-ranked__logo img {
    width: 28px;
    height: 28px;
    object-fit: contain;
  }

  .trophies-ranked__info {
    flex: 1;
    min-width: 0;
  }

  .trophies-ranked__name {
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .trophies-ranked__bar-wrap {
    height: 4px;
    background: var(--color-surface-sunken);
    border-radius: 2px;
    overflow: hidden;
  }

  .trophies-ranked__bar {
    height: 100%;
    background: linear-gradient(
      90deg,
      var(--color-accent),
      color-mix(in srgb, var(--color-accent) 30%, transparent)
    );
    border-radius: 2px;
  }

  .trophies-ranked__count {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
    min-width: 48px;
  }

  .trophies-ranked__count-champ {
    font-family: var(--font-title);
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
    line-height: 1;
  }

  .trophies-ranked__count-sub {
    font-size: 10px;
    font-weight: 500;
    color: var(--color-text-subtle);
    font-variant-numeric: tabular-nums;
  }

  .trophies-ranked__chevron {
    flex-shrink: 0;
    color: var(--color-text-muted);
  }

  /* ---- "Ver más" progressive disclosure ------------------------ */
  .trophies-more {
    border: 0;
    background: transparent;
    padding: 0;
    margin: 0;
  }

  .trophies-more > summary {
    list-style: none;
    cursor: pointer;
    margin: 8px 16px 0;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--color-surface);
    border: 1px solid var(--color-surface-border);
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
  }

  .trophies-more > summary::-webkit-details-marker {
    display: none;
  }

  .trophies-more > summary::after {
    content: "▾";
    font-size: 10px;
    transition: transform 0.15s ease;
  }

  .trophies-more[open] > summary {
    color: var(--color-accent);
    border-color: color-mix(in srgb, var(--color-accent) 30%, var(--color-surface-border));
  }

  .trophies-more[open] > summary::after {
    transform: rotate(180deg);
  }

  /* ---- Detail dialog (bottom sheet) ---------------------------- */
  .trophies-dialog {
    position: fixed;
    inset: auto 0 0;
    margin: 0 auto;
    max-width: 460px;
    width: 100%;
    max-height: 70vh;
    padding: 0;
    border: 0;
    border-radius: 20px 20px 0 0;
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: 0 -4px 24px rgb(0 0 0 / 40%);
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0);
    transform: translateY(0);
    transition:
      transform 0.3s ease-in-out,
      overlay 0.3s ease-in-out allow-discrete,
      display 0.3s ease-in-out allow-discrete;
  }

  .trophies-dialog:not([open]) {
    transform: translateY(100%);
  }

  @starting-style {
    .trophies-dialog[open] {
      transform: translateY(100%);
    }
  }

  .trophies-dialog::backdrop {
    background: rgb(0 0 0 / 50%);
    backdrop-filter: blur(2px);
    opacity: 1;
    transition:
      opacity 0.3s ease-in-out,
      overlay 0.3s ease-in-out allow-discrete,
      display 0.3s ease-in-out allow-discrete;
  }

  .trophies-dialog:not([open])::backdrop {
    opacity: 0;
  }

  @starting-style {
    .trophies-dialog[open]::backdrop {
      opacity: 0;
    }
  }

  /* Bottom-sheet en TODOS los viewports — memoria
     feedback_bottom_sheet_and_seasons. Desktop preview centered se eliminó
     2026-05-09 tras audit team-detail. `max-width: 460px; margin: 0 auto`
     ya centra horizontalmente al pie en pantallas anchas. */

  /* Reduced-motion — instant open/close, no slide */
  @media (prefers-reduced-motion: reduce) {
    .trophies-dialog,
    .trophies-dialog::backdrop {
      transition: none;
    }

    .trophies-dialog:not([open]) {
      transform: translateY(0);
    }

    @starting-style {
      .trophies-dialog[open] {
        transform: translateY(0);
      }

      .trophies-dialog[open]::backdrop {
        opacity: 1;
      }
    }
  }

  .trophies-dialog__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-surface-border);
  }

  /* stylelint-disable-next-line no-descending-specificity */
  .trophies-dialog__head img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    flex-shrink: 0;
  }

  .trophies-dialog__title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-family: var(--font-title);
    font-size: 15px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .trophies-dialog__close {
    min-width: 44px;
    min-height: 44px;
    padding: 10px 12px;
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: var(--color-text-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
  }

  .trophies-dialog__close:hover {
    background: var(--color-surface-sunken);
    color: var(--color-text);
  }

  .trophies-dialog__body {
    padding: 14px 16px 18px;
    overflow-y: auto;
    max-height: calc(100vh - 140px);
    scrollbar-width: none;
  }

  .trophies-dialog__body::-webkit-scrollbar {
    display: none;
  }

  .trophies-dialog__section + .trophies-dialog__section {
    margin-top: 14px;
  }

  .trophies-dialog__section h5 {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin: 0 0 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
  }

  .trophies-dialog__section h5 .trophies-dialog__count {
    font-family: var(--font-title);
    font-size: 14px;
    color: var(--color-text);
  }

  .trophies-dialog__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }

  .trophies-chip {
    padding: 4px 9px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }

  .trophies-chip--champion {
    background: color-mix(in srgb, var(--color-accent) 20%, transparent);
    color: var(--color-accent);
  }

  .trophies-chip--runnerup {
    background: color-mix(in srgb, #c0c0c0 16%, transparent);
    border: 1px solid color-mix(in srgb, #c0c0c0 22%, transparent);
    color: #c8cdd8;
  }

  .trophies-dialog__empty {
    margin: 0;
    font-size: 12px;
    color: var(--color-text-subtle);
    font-style: italic;
  }
}
