/* Following — the favourites screen (bottom-nav slot).
 *
 * Leans on the shared vocabulary: `.app-header` chrome, `.tab-filter-pill`
 * (standings.css), `.squad-row` anatomy (team-overview.css), `.card`,
 * `.empty-state` and the skeleton shimmer. This file only owns the page
 * scaffold and the pieces with no prior art: the branded card grid, pill
 * counts, the directory filter and the country accordion.
 */

@layer pages {
  .following {
    padding: 12px 12px calc(72px + env(safe-area-inset-bottom));
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  /* JS toggles visibility with [hidden] on elements this file gives a
 * display value — the attribute must always win. */
  .following [hidden] {
    display: none;
  }

  /* ── pills ────────────────────────────────────────────────────────── */

  .following-pill-count {
    margin-left: 6px;
    font-size: 0.72rem;
    opacity: 0.75;
    font-family: var(--font-body);
  }

  /* ── lists ────────────────────────────────────────────────────────── */

  .following-panel {
    display: flex;
    flex-direction: column;
  }

  .following-list {
    display: flex;
    flex-direction: column;
  }

  .following-skeleton {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .following-skeleton__row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
  }

  .following-skeleton__circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .following-skeleton__bars {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  /* Recurring bug, fixed at the source here: the circular photo treatment
 * (border-radius + object-fit: cover + grey backdrop) belongs to player
 * HEADSHOTS only. Crests and league logos in Tendencia / directory rows
 * keep their own silhouette at 44×44. */
  .following-row .squad-row__photo--crest {
    border-radius: 0;
    object-fit: contain;
    background: none;
  }

  /* ── card grid (Equipos / Jugadores / Ligas) ──────────────────────── */

  .following-list--cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  /* The fold: past VISIBLE_CARDS the overflow hides until "Ver más". */
  .following-list--collapsed .sg-card--overflow {
    display: none;
  }

  .following-more {
    margin-top: 10px;
    width: 100%;
    padding: 10px;
    background: none;
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-full);
    color: var(--color-text-secondary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
  }

  .following-more:active {
    background: var(--color-surface-sunken);
  }

  /* The tile. `--sg-c` is the brand hex stamped per card; the mix leans it
 * toward a FIXED dark anchor so white text + shadow stay readable — same
 * color-mix idiom as the mercado kit tint.
 *
 * DELIBERADAMENTE theme-invariant (decisión de producto 2026-07-23, tras
 * probar y descartar texto oscuro sobre kits claros): la tile de marca se ve
 * IGUAL en dark y en light — ancla oscura + texto blanco siempre, como el
 * lienzo negro de Kicks. NO "corregir" hacia tokens del tema. */
  .sg-card {
    position: relative;
    border-radius: var(--radius-lg);
    background: linear-gradient(
      158deg,
      color-mix(in oklab, var(--sg-c, var(--color-surface)) 82%, #0b0e15) 0%,
      color-mix(in oklab, var(--sg-c, var(--color-surface)) 58%, #0b0e15) 100%
    );
    overflow: hidden;
  }

  .sg-card__link {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 14px 12px;
    min-height: 118px;
    color: #fff;
    text-decoration: none;
  }

  .sg-card__crest-wrap {
    display: flex;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
  }

  .sg-card__crest {
    max-width: 44px;
    max-height: 44px;
    object-fit: contain;
    filter: drop-shadow(0 1px 4px rgb(0 0 0 / 35%));
  }

  .sg-card__initials {
    display: flex;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgb(255 255 255 / 18%);
    font-family: var(--font-title);
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
  }

  .sg-card__name {
    font-family: var(--font-title);
    font-weight: 700;
    font-size: 1.02rem;
    line-height: 1.2;
    text-shadow: 0 1px 3px rgb(0 0 0 / 30%);
    overflow-wrap: anywhere;
  }

  .sg-card__sub {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-body);
    font-size: 0.76rem;
    color: rgb(255 255 255 / 78%);
    min-width: 0;
  }

  .sg-card__sub-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sg-card__sub-icon {
    width: 14px;
    height: 14px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 2px rgb(0 0 0 / 30%));
  }

  .sg-card__sub-icon--flag {
    width: 18px;
    height: 13px;
    object-fit: cover;
    border-radius: 2px;
  }

  /* ── follow/unfollow re-bucketing ─────────────────────────────────── */

  .sg-card--exit {
    opacity: 0;
    transform: scale(0.94);
    transition:
      opacity 0.28s ease,
      transform 0.28s ease;
    pointer-events: none;
  }

  .sg-card--enter {
    animation: sg-card-enter 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  }

  @keyframes sg-card-enter {
    from {
      opacity: 0;
      transform: scale(0.9);
    }

    to {
      opacity: 1;
      transform: scale(1);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .sg-card--exit {
      transition: none;
    }

    .sg-card--enter {
      animation: none;
    }
  }

  /* Player variant */

  .sg-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
  }

  .sg-card__portrait-wrap {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    background: rgb(255 255 255 / 85%);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sg-card__portrait {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .sg-card--player .sg-card__initials {
    width: 48px;
    height: 48px;
    background: transparent;

    /* El portrait-wrap es SIEMPRE claro (blanco 85%) — la inicial va oscura
       theme-invariant, en cualquier tema y con cualquier kit. */
    color: var(--color-on-accent);
  }

  .sg-card__club {
    width: 24px;
    height: 24px;
    object-fit: contain;
    filter: drop-shadow(0 1px 3px rgb(0 0 0 / 35%));
  }

  .sg-card__name--split {
    display: flex;
    flex-direction: column;
  }

  .sg-card__firstname {
    font-weight: 400;
    font-size: 0.9rem;
    opacity: 0.92;
  }

  .sg-card__firstname:empty {
    display: none;
  }

  .sg-card__surname {
    font-weight: 700;
    font-size: 1.05rem;
  }

  /* ── empty states ─────────────────────────────────────────────────── */

  .following-empty {
    padding: 28px 16px;
  }

  .following-empty__cta {
    margin-top: 12px;
    padding: 8px 18px;
    background: var(--color-accent);
    color: var(--color-bg);
    border: none;
    border-radius: var(--radius-full);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
  }

  /* ── sections (suggestions / explore) ─────────────────────────────── */

  .following-section .card {
    padding-bottom: 4px;
  }

  /* ── scope pills (Todas / Países / Internacional) ─────────────────── */

  .following-scope {
    display: flex;
    gap: 6px;
    margin: 4px 0 8px;
  }

  .following-scope__pill {
    flex: 1;
    min-width: 0;
    padding: 7px 10px;
    background: var(--color-surface-sunken);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-full);
    color: var(--color-text-muted);
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    cursor: pointer;
    transition:
      color 0.15s ease,
      background 0.15s ease,
      border-color 0.15s ease;
  }

  .following-scope__pill:hover {
    color: var(--color-text);
  }

  .following-scope__pill.is-active {
    background: color-mix(in srgb, var(--color-accent) 16%, transparent);
    border-color: color-mix(in srgb, var(--color-accent) 45%, transparent);
    color: var(--color-accent);
  }

  /* ── country accordion (explore) ──────────────────────────────────── */

  .following-filter {
    width: 100%;
    margin: 4px 0 8px;
    padding: 10px 14px;
    background: var(--color-surface-sunken);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-full);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 0.88rem;
  }

  .following-filter::placeholder {
    color: var(--color-text-muted);
  }

  .following-filter:focus {
    outline: none;
    border-color: var(--color-accent);
  }

  .following-explore__no-results {
    padding: 14px 4px;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-family: var(--font-body);
  }

  .following-explore {
    display: flex;
    flex-direction: column;
  }

  .following-country__summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 4px;
    cursor: pointer;
    list-style: none;
    border-bottom: 1px solid var(--color-border-subtle);
  }

  .following-country__summary::-webkit-details-marker {
    display: none;
  }

  .following-country__flag {
    font-size: 1rem;
    flex-shrink: 0;
  }

  .following-country__name {
    flex: 1;
    min-width: 0;
    font-size: 0.88rem;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .following-country__count {
    font-size: 0.72rem;
    color: var(--color-text-subtle);
    font-family: var(--font-body);
  }

  .following-country__chevron {
    color: var(--color-text-subtle);
    transition: transform 0.15s ease;
    flex-shrink: 0;
  }

  .following-country[open] .following-country__chevron {
    transform: rotate(180deg);
  }

  .following-country__leagues {
    padding: 2px 0 6px;
  }
}
