/* ==================================================
   Shared components (loaded on every page)
   section_head, card, team_badge, match_row,
   form badges, updated_label
================================================== */

/* ── Section header ─────────────────────────────────────────── */
.section_head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.section_title {
  display: flex;
  align-items: center;
  column-gap: 10px;
  font-size: var(--fs-lg);
  font-weight: 700;
  line-height: 1.25;
}

.section_title::before {
  content: "";
  flex-shrink: 0;
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: var(--brand);
}

.section_link {
  display: inline-flex;
  align-items: center;
  column-gap: 6px;
  min-height: 44px;
  flex-shrink: 0;
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--brand);
  text-decoration: none;
}

.section_link:hover {
  color: var(--brand-hover);
}

.section_link i {
  font-size: 11px;
}

/* ── Card ───────────────────────────────────────────────────── */
.card {
  background: var(--dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card_subhead {
  background: var(--surface-sunken);
  padding: 10px 16px;
  font-size: var(--fs-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

/* ── Team badge (crest or initials) ─────────────────────────── */
.team_badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
}

.team_badge img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Dark crests (crest_dark in helpers.php) get a light outline so they stay visible */
.team_badge--dark img {
  filter: drop-shadow(0 0 1px rgba(230, 233, 240, 0.85)) drop-shadow(0 0 4px rgba(230, 233, 240, 0.25));
}

.team_badge--sm {
  width: 24px;
  height: 24px;
}

.team_badge--initials {
  border-radius: 50%;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
}

.team_badge--sm.team_badge--initials {
  font-size: 8px;
}

/* ── Match row (result or fixture) ──────────────────────────── */
/* Used by the homepage and the matches hub (plstats_match_row()). */
.match_row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px minmax(0, 1fr);
  align-items: center;
  column-gap: var(--space-2);
  min-height: 60px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  text-decoration: none;
  transition: background 0.15s;
}

a.match_row:hover {
  background: rgba(255, 255, 255, 0.02);
}

.match_side {
  display: flex;
  align-items: center;
  column-gap: var(--space-2);
  min-width: 0;
  font-size: var(--fs-md);
  line-height: 1.25;
  /* Wrap at spaces; a single long word is hyphenated, never cut or truncated */
  overflow-wrap: break-word;
  -webkit-hyphens: auto;
  hyphens: auto;
}

.match_side--home {
  justify-content: flex-end;
  text-align: right;
}

.match_side.is_winner {
  font-weight: 700;
  color: var(--text-primary);
}

.match_side.is_loser {
  color: var(--text-secondary);
}

.match_mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  row-gap: 2px;
}

.match_score {
  font-size: var(--fs-xl);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.01em;
}

.match_status {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.match_time {
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  color: var(--brand);
  font-size: var(--fs-md);
  font-weight: 700;
}

.match_status_extra {
  display: none;
}

/* ── Form badges (W / D / L) ────────────────────────────────── */
.form_badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 800;
}

.form_badge + .form_badge {
  margin-left: 3px;
}

.form_win {
  background: var(--win-soft);
  color: var(--win);
}

.form_draw {
  background: var(--draw-soft);
  color: var(--draw);
}

.form_loss {
  background: var(--loss-soft);
  color: var(--loss-text);
}

/* ── Visually hidden (still read by screen readers and crawlers) ── */
.visually_hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media screen and (min-width: 820px) {
  .visually_hidden_desktop {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }
}

/* ── Breadcrumbs ────────────────────────────────────────────── */
.breadcrumbs {
  margin-bottom: var(--space-3);
  font-size: 13px;
  color: var(--text-secondary);
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  list-style: none;
  padding: 0;
  margin: 0;
}

.breadcrumbs li {
  display: inline-flex;
  align-items: center;
}

.breadcrumb_sep {
  margin: 0 8px;
  font-size: 9px;
  opacity: 0.7;
}

.breadcrumbs a {
  display: inline-flex;
  align-items: center;
  color: var(--text-secondary);
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: var(--brand);
}

.breadcrumbs [aria-current="page"] {
  color: var(--text-primary);
  font-weight: 600;
}

/* ── KPI cards ── */
.kpi_grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
}


.kpi_card {
  display: block;
  background: var(--dark);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  text-decoration: none;
}

.kpi_label {
  margin: 0 !important;
  font-size: var(--fs-xs) !important;
  line-height: 1.3 !important;
  font-weight: 600;
  color: var(--text-secondary);
}

.kpi_value {
  margin: 4px 0 0 !important;
  font-size: 24px !important;
  line-height: 1.15 !important;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.kpi_card--highlight {
  background: var(--brand-soft);
  border-color: rgba(57, 169, 151, 0.35);
}

.kpi_card--highlight .kpi_value {
  color: var(--brand);
}

/* ── Fact chip (entity headers) ────────────────────────────── */
.fact_chip {
  display: inline-flex;
  align-items: center;
  column-gap: 8px;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--surface-raised);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
}

/* ── Table note (small text under a table or list) ─────────── */
.table_note {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 12px !important;
  line-height: 18px !important;
}

/* ── Updated label ──────────────────────────────────────────── */
.updated_label {
  display: inline-flex;
  align-items: center;
  column-gap: 8px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

.updated_label::before {
  content: "";
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
}

/* ==================================================
   Shared match list (mobile) / match table (desktop),
   result badges, rating pills, link tiles
   (player and team pages)
================================================== */

/* ── Result badge and rating pill ───────────────────────────── */
.result_badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: 800;
}

.result_badge--sm {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  font-size: var(--fs-xs);
}

.result_win {
  background: var(--win-soft);
  color: var(--win);
}

.result_draw {
  background: var(--draw-soft);
  color: var(--draw);
}

.result_loss {
  background: var(--loss-soft);
  color: var(--loss-text);
}

.rating_pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 800;
}

.rating_high {
  background: var(--brand-soft);
  color: var(--brand);
}

.rating_low {
  background: rgba(231, 76, 60, 0.14);
  color: var(--loss-text);
}

.match_tag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--surface-raised);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-primary);
  white-space: nowrap;
  vertical-align: 1px;
}

/* ── Recent matches: mobile list ────────────────────────────── */
.match_list_row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto 44px;
  align-items: center;
  column-gap: var(--space-3);
  min-height: 64px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  text-decoration: none;
}

.match_list_row:last-child {
  border-bottom: none;
}

.match_list_row:hover {
  background: rgba(255, 255, 255, 0.02);
}

.match_list_info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.match_list_opponent {
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: break-word;
}

.match_list_meta {
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--text-secondary);
}

.match_list_meta .match_tag:first-child {
  margin-left: 0;
}

.match_list_score {
  font-size: 16px;
  font-weight: 800;
}

.match_list_row .rating_pill {
  justify-self: end;
}

/* Desktop table is hidden on mobile */
.match_table_card {
  display: none;
}

/* ── More stats: link tiles ─────────────────────────────────── */
.link_tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.link_tile {
  display: flex;
  align-items: center;
  column-gap: 10px;
  min-height: 56px;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--dark);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
}

.link_tile i {
  width: 24px;
  text-align: center;
  color: var(--brand);
}

.link_tile:hover {
  border-color: rgba(57, 169, 151, 0.35);
}

@media screen and (min-width: 820px) {
  /* Recent matches: table instead of the list */
  .match_list,
  .match_list_note {
    display: none;
  }

  .match_table_card {
    display: block;
  }

  .match_table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-md);
  }

  .match_table thead th {
    padding: 10px 16px;
    background: var(--surface-sunken);
    font-size: var(--fs-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    text-align: left;
  }

  .match_table abbr {
    text-decoration: none;
  }

  .match_table td,
  .match_table tbody th {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    font-weight: 400;
    text-align: left;
    vertical-align: middle;
  }

  .match_table .mt_match a {
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
  }

  .match_table .mt_match a:hover {
    color: var(--brand);
  }

  .match_table .mt_muted {
    color: var(--text-secondary);
  }

  .match_table .mt_c {
    text-align: center;
  }

  .match_table .mt_r {
    text-align: right;
  }
}

/* ── Mini table (homepage snapshot, team page position) ─────────────────────────────────────────── */
.mini_table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-md);
}

.mini_table thead th {
  background: var(--surface-sunken);
  padding: 10px 8px;
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  text-align: left;
}

.mini_table abbr {
  text-decoration: none;
}

.mini_table td,
.mini_table tbody th {
  padding: 8px;
  border-top: 1px solid var(--border);
  font-weight: 400;
  text-align: left;
  vertical-align: middle;
}

.mini_table .mt_pos {
  width: 34px;
  padding-left: 16px;
  color: var(--text-secondary);
}

.mini_table .mt_team a {
  display: flex;
  align-items: center;
  column-gap: 10px;
  min-height: 28px;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  overflow-wrap: break-word;
}

.mini_table .mt_team a:hover {
  color: var(--brand);
}

.mini_table .mt_num {
  width: 44px;
  text-align: right;
}

.mini_table .mt_pts {
  font-weight: 800;
}

.mini_table th.mt_num:last-of-type,
.mini_table td.mt_pts {
  padding-right: 16px;
}

.mini_table .mt_form {
  display: none;
  white-space: nowrap;
  text-align: right;
  padding-right: 16px;
}

.mini_table .mt_extra {
  display: none;
}

/* Narrow phones: give team names more room */
@media screen and (max-width: 419.98px) {
  .match_row {
    grid-template-columns: minmax(0, 1fr) 60px minmax(0, 1fr);
    column-gap: 6px;
    padding: 12px 10px;
  }

  .match_side {
    column-gap: 6px;
    font-size: 13px;
  }

  .match_row .team_badge {
    width: 24px;
    height: 24px;
  }

  .match_score {
    font-size: var(--fs-lg);
  }

  .match_time {
    padding: 5px 6px;
    font-size: 13px;
  }
}

@media screen and (max-width: 819.98px) {
  .breadcrumbs a {
    min-height: 32px;
  }
}

@media screen and (min-width: 820px) {
  .section_title {
    font-size: var(--fs-xl);
  }

  .kpi_grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: var(--space-3);
  }


  .kpi_card {
    border-radius: var(--radius-lg);
    padding: 14px 16px;
  }

  .kpi_label {
    font-size: 13px !important;
  }

  .kpi_value {
    font-size: 30px !important;
  }

  .card--lg {
    border-radius: var(--radius-xl);
  }

  .match_status_extra {
    display: inline;
  }
}

/* ============================================
   Page summary: one or two plain sentences
   written from the data (team, player, table, match)
   ============================================ */
.page_summary {
  max-width: 72ch;
  margin: var(--space-4) 0 0;
  font-size: var(--fs-md);
  line-height: 1.6;
  color: var(--text-secondary);
}

@media screen and (min-width: 820px) {
  .page_summary {
    font-size: var(--fs-base);
  }
}

/* ── Leader list (homepage top scorers, stats hub and stats pages) ────────────────────────────────────────────── */
.scorer_list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.scorer_row {
  display: flex;
  align-items: center;
  column-gap: 12px;
  min-height: 60px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.scorer_row:last-child {
  border-bottom: none;
}

.scorer_rank {
  width: 16px;
  flex-shrink: 0;
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-secondary);
}

.scorer_avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.scorer_info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.scorer_name {
  font-size: var(--fs-md);
  line-height: 1.35;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  overflow-wrap: break-word;
}

a.scorer_name:hover {
  color: var(--brand);
}

.scorer_meta {
  margin-top: 2px;
  font-size: var(--fs-sm);
  line-height: 1.35;
  color: var(--text-secondary);
}

.scorer_goals {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
}

.scorer_goals_value {
  font-size: var(--fs-xl);
  font-weight: 800;
  line-height: 1.1;
}

.scorer_goals_label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.scorer_crest {
  display: inline-flex;
  flex-shrink: 0;
}

.scorer_crest .team_badge {
  width: 32px;
  height: 32px;
}

/* ============================================
   Head-to-head record: left wins · draws · right wins
   (match page context and /h2h/ pages)
   ============================================ */
.h2h_record_nums {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
}

.h2h_rec {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  text-align: center;
}

.h2h_rec--left {
  align-items: flex-start;
  text-align: left;
}

.h2h_rec--right {
  align-items: flex-end;
  text-align: right;
}

.h2h_rec_value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
}

.h2h_rec--left .h2h_rec_value {
  color: var(--brand);
}

.h2h_rec_label {
  margin-top: 2px;
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-secondary);
  overflow-wrap: break-word;
}

.h2h_bar {
  display: flex;
  gap: 3px;
  height: 8px;
  margin-top: var(--space-3);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.h2h_bar_part {
  min-width: 0;
  height: 100%;
}

.h2h_bar_part--left {
  background: var(--brand);
}

.h2h_bar_part--draw {
  background: var(--surface-raised);
}

.h2h_bar_part--right {
  background: var(--text-secondary);
}

/* ── Crest + name, inline (match lists, tables, card headers) ── */
.with_badge {
  display: inline-flex;
  align-items: center;
  column-gap: 8px;
  min-width: 0;
}

.with_badge > span:not(.team_badge) {
  min-width: 0;
  overflow-wrap: break-word;
}

.match_list_opponent.with_badge {
  display: flex;
}

/* Recent-match tables: dates and small figures stay on one line (crests take room) */
.match_table td {
  white-space: nowrap;
}

.match_table .mt_match .with_badge {
  column-gap: 8px;
}
