/**
 * Grouvel - Styles de la page Coupe du Monde 2026 (coupe-monde.html)
 * Couvre : header/boutons, onglets, cartes de match, tableaux de groupe,
 * tableau de la phase finale, dark mode, responsive et impression.
 */

:root { color-scheme: light dark; }
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-family, "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  background: var(--color-bg-gradient);
  color: var(--color-text-primary);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* === Header (repris de news.css) === */
header { text-align: center; padding: 36px 16px 12px; }
h1 { font-size: 2.6rem; margin: 0; color: var(--color-text-primary); }
header p {
  margin: 0.8em auto 1.6em;
  max-width: 680px;
  color: var(--color-text-secondary);
  font-size: 1.05rem;
}
.header-actions {
  display: flex; gap: 0.8em; justify-content: center; align-items: center;
  margin-top: 12px; flex-wrap: wrap;
}
a.back, button.refresh {
  display: inline-flex; align-items: center; gap: 0.4em;
  padding: 0.6em 1.5em; border-radius: 8px;
  background: var(--color-primary); color: #fff;
  text-decoration: none; font-weight: 600;
  transition: all 0.25s ease-in-out; box-shadow: var(--shadow-sm);
  border: none; cursor: pointer; font-family: inherit; font-size: inherit;
}
a.back:hover, button.refresh:hover:not(:disabled) {
  background: var(--color-primary-hover); transform: translateY(-2px);
}
button.refresh:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
button.refresh.loading .refresh-icon { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main {
  flex: 1; width: 100%; max-width: 1040px;
  margin: 0 auto; padding: 0 16px 40px;
}

.notice {
  text-align: center; margin: 0 0 1.2em; font-size: 0.95rem;
  color: var(--color-text-secondary);
}
.notice.err { color: var(--color-error); }

/* === Onglets === */
.wc-tabs {
  display: flex; gap: 0.5em; justify-content: center; flex-wrap: wrap;
  margin-bottom: 1.6em;
}
.wc-tab {
  display: inline-flex; align-items: center; gap: 0.4em;
  padding: 0.7em 1.3em; border-radius: var(--radius-pill);
  border: 1.5px solid transparent;
  background: var(--color-bg-white); color: var(--color-text-primary);
  font-size: 1rem; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: all 0.2s ease;
}
.wc-tab:hover { transform: translateY(-2px); border-color: var(--color-primary); }
.wc-tab.active {
  background: var(--color-primary); color: #fff; border-color: var(--color-primary);
}

.wc-panel { animation: fadeIn 0.25s ease; }
.wc-panel[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.wc-hint {
  text-align: center; color: var(--color-text-secondary);
  font-size: 0.9rem; margin: 0 auto 1.4em; max-width: 720px;
}

/* === Filtres (onglet Résultats) === */
.wc-filters {
  display: flex; flex-wrap: wrap; gap: 0.8em;
  justify-content: space-between; align-items: center; margin-bottom: 1.4em;
}
.wc-filter-status { display: flex; gap: 0.4em; flex-wrap: wrap; }
.filter-toggle {
  padding: 0.5em 1em; border-radius: 8px;
  border: 1.5px solid var(--color-text-disabled);
  background: transparent; color: var(--color-text-primary);
  font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: all 0.2s ease;
}
.filter-toggle:hover { border-color: var(--color-primary); background: var(--color-primary-light); }
.filter-toggle.selected { border-color: var(--color-primary); background: var(--color-primary); color: #fff; }
.wc-team-filter select {
  padding: 0.55em 0.9em; border-radius: 8px;
  border: 1.5px solid var(--color-text-disabled);
  background: var(--color-bg-white); color: var(--color-text-primary);
  font-size: 16px; font-family: inherit; cursor: pointer; max-width: 100%;
}

/* === Résultats : en-tête de date === */
.wc-date-head {
  font-size: 1.15rem; color: var(--color-text-primary);
  margin: 1.6em 0 0.8em; padding-bottom: 0.3em;
  border-bottom: 2px solid var(--color-primary-light);
}
.wc-date-head:first-child { margin-top: 0; }
.wc-results { display: grid; gap: 1em; }

/* === Carte de match === */
.wc-match {
  background: var(--color-bg-white);
  border-radius: 16px; padding: 1em 1.2em;
  border: 1px solid rgba(128,128,128,0.12);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.wc-match:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.wc-match.is-upcoming { opacity: 0.92; }

.wc-match-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.7em; font-size: 0.82rem;
}
.wc-match-ctx { color: var(--color-text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.wc-status {
  padding: 0.2em 0.7em; border-radius: var(--radius-pill);
  font-weight: 700; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em;
}
.wc-status.done { background: var(--color-success-bg); color: var(--color-success, #0a7c28); }
.wc-status.soon { background: var(--color-primary-light); color: var(--color-primary); }

.wc-match-body {
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: 0.8em;
}
.wc-team { display: flex; align-items: center; gap: 0.55em; min-width: 0; }
.wc-team-right { justify-content: flex-end; text-align: right; }
.wc-team-name {
  font-weight: 600; font-size: 1.05rem; color: var(--color-text-primary);
  overflow: hidden; text-overflow: ellipsis;
}
.wc-team-tbd .wc-team-name { color: var(--color-text-muted); font-weight: 500; font-style: italic; font-size: 0.92rem; }
.wc-flag { font-size: 1.6rem; line-height: 1; flex-shrink: 0; }

.wc-score {
  display: flex; flex-direction: column; align-items: center;
  min-width: 78px; gap: 0.15em;
}
.wc-score-line { display: flex; align-items: baseline; gap: 0.15em; }
.wc-score-num {
  font-size: 1.8rem; font-weight: 800; color: var(--color-text-primary); line-height: 1;
}
.wc-score-sep { font-size: 1.2rem; color: var(--color-text-muted); }
.wc-score-ht { font-size: 0.7rem; color: var(--color-text-muted); white-space: nowrap; }
.wc-kickoff {
  font-size: 0.9rem; font-weight: 700; color: var(--color-primary);
  white-space: nowrap;
}

.wc-match-foot {
  display: flex; justify-content: center; gap: 1em; flex-wrap: wrap;
  margin-top: 0.7em; font-size: 0.8rem; color: var(--color-text-muted);
}
.wc-time { font-weight: 600; }
.wc-time-local { font-weight: 400; opacity: 0.8; }
.wc-kickoff-local { font-size: 0.7rem; color: var(--color-text-muted); margin-top: 0.15em; white-space: nowrap; }
.wc-tz-note { margin: -0.4em 0 1.2em; }

/* Buteurs */
.wc-scorers {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 0.5em;
  margin-top: 0.7em; padding-top: 0.7em;
  border-top: 1px dashed rgba(128,128,128,0.2);
  font-size: 0.82rem; color: var(--color-text-secondary);
}
.wc-scorer-col { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.15em; }
.wc-scorer-right { text-align: right; }
.wc-scorers-ball { align-self: start; }

/* === Onglet Groupes === */
.wc-groups {
  display: grid; gap: 1.2em;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
.wc-group {
  background: var(--color-bg-white); border-radius: 16px;
  padding: 1.1em 1.2em; box-shadow: var(--shadow-sm);
  border: 1px solid rgba(128,128,128,0.12);
}
.wc-group-title {
  margin: 0 0 0.7em; font-size: 1.15rem; color: var(--color-text-primary);
}
.wc-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 0.9rem; }
.wc-table th, .wc-table td {
  padding: 0.5em 0.25em; text-align: center;
}
/* Colonnes chiffrées : largeur fixe pour aligner les 12 groupes à l'identique */
.wc-table th:not(.wc-th-team), .wc-table td:not(.wc-td-team) {
  width: 2.2em; white-space: nowrap;
}
.wc-th-pts, .wc-td-pts { width: 2.4em; }
.wc-table thead th {
  font-size: 0.75rem; color: var(--color-text-muted);
  font-weight: 700; border-bottom: 2px solid rgba(128,128,128,0.15);
}
.wc-th-team, .wc-td-team { text-align: left !important; }
.wc-td-team { display: flex; align-items: center; gap: 0.5em; }
.wc-td-team .wc-flag { font-size: 1.25rem; flex-shrink: 0; }
.wc-td-team span:last-child { min-width: 0; overflow-wrap: anywhere; line-height: 1.15; }
.wc-table tbody tr { border-bottom: 1px solid rgba(128,128,128,0.08); }
.wc-table tbody tr:last-child { border-bottom: none; }
.wc-qualif { background: var(--color-success-bg); }
.wc-qualif .wc-td-pts { color: var(--color-success, #0a7c28); }
.wc-th-pts, .wc-td-pts { font-weight: 800; }

/* === Onglet Phase finale === */
.wc-bracket { display: grid; gap: 1.6em; }
.wc-bracket-round { display: grid; gap: 0.9em; }
.wc-bracket-title {
  margin: 0; font-size: 1.25rem; color: var(--color-text-primary);
  text-align: center; padding-bottom: 0.3em;
}
.wc-bracket-round .wc-match { max-width: 560px; margin: 0 auto; width: 100%; }

/* === Onglet Déplacements (carte) === */
.wc-map-select { display: block; margin: 0 auto 1.2em; max-width: 360px; }
.wc-map-select select { width: 100%; }
.wc-map-layout {
  display: grid; grid-template-columns: 1.6fr 1fr; gap: 1.2em; align-items: start;
}
.wc-map {
  background: var(--color-bg-white); border-radius: 16px; overflow: hidden;
  box-shadow: var(--shadow-sm); border: 1px solid rgba(128,128,128,0.12);
}
.wc-map-svg { display: block; width: 100%; height: auto; }
.wc-map-sea { fill: #e8f1fb; }
.wc-map-land { fill: #eef2e9; stroke: #c9cfc2; stroke-width: 1; }
.wc-map-dot { fill: #b6bcc6; }
.wc-map-route {
  stroke: var(--color-primary); stroke-width: 3; stroke-linecap: round;
  stroke-dasharray: 2 9; opacity: 0.9;
}
.wc-map-stop { fill: var(--color-primary); stroke: #fff; stroke-width: 2; }
.wc-map-stop-num { fill: #fff; font-size: 13px; font-weight: 800; text-anchor: middle; }
.wc-map-stop-label {
  fill: var(--color-text-primary); font-size: 14px; font-weight: 700; text-anchor: middle;
  paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round;
}

.wc-map-summary {
  background: var(--color-bg-white); border-radius: 16px; padding: 1.1em 1.2em;
  box-shadow: var(--shadow-sm); border: 1px solid rgba(128,128,128,0.12);
}
.wc-map-hint { color: var(--color-text-secondary); font-size: 0.92rem; margin: 0; }
.wc-map-total { display: flex; align-items: center; gap: 0.7em; margin-bottom: 0.9em; }
.wc-map-total-flag { font-size: 2.2rem; line-height: 1; }
.wc-map-total > div { display: flex; flex-direction: column; }
.wc-map-total strong { font-size: 1.05rem; color: var(--color-text-primary); }
.wc-map-total-km { font-size: 1.6rem; font-weight: 800; color: var(--color-primary); line-height: 1.1; }
.wc-map-total-sub { font-size: 0.78rem; color: var(--color-text-muted); }
.wc-map-legs { list-style: none; margin: 0; padding: 0; }
.wc-map-leg {
  display: flex; justify-content: space-between; align-items: center; gap: 0.6em;
  padding: 0.45em 0; border-bottom: 1px solid rgba(128,128,128,0.1);
}
.wc-map-leg:last-child { border-bottom: none; }
.wc-map-leg-city { font-weight: 600; color: var(--color-text-primary); }
.wc-map-leg-km { font-size: 0.85rem; color: var(--color-text-muted); font-weight: 600; white-space: nowrap; }
.wc-map-leg-start .wc-map-leg-km { color: var(--color-success, #0a7c28); }

.wc-map-ranking { margin-top: 1.4em; }
.wc-map-rank-title { font-size: 1.15rem; color: var(--color-text-primary); margin: 0 0 0.7em; text-align: center; }
.wc-map-rank {
  list-style: none; margin: 0 auto; padding: 0; max-width: 560px;
  background: var(--color-bg-white); border-radius: 14px; overflow: hidden;
  box-shadow: var(--shadow-sm); border: 1px solid rgba(128,128,128,0.12);
}
.wc-map-rank li {
  display: flex; align-items: center; gap: 0.7em; padding: 0.55em 1em;
  border-bottom: 1px solid rgba(128,128,128,0.08); cursor: pointer; transition: background 0.15s ease;
}
.wc-map-rank li:last-child { border-bottom: none; }
.wc-map-rank li:hover { background: var(--color-primary-light); }
.wc-map-rank-sel { background: var(--color-primary-light); }
.wc-map-rank-pos { width: 1.6em; text-align: center; font-weight: 800; color: var(--color-text-muted); }
.wc-map-rank-flag { font-size: 1.35rem; }
.wc-map-rank-name { flex: 1; font-weight: 600; color: var(--color-text-primary); }
.wc-map-rank-km { font-weight: 700; color: var(--color-primary); white-space: nowrap; }

/* Stats globales : matchs par pays / par ville */
.wc-venue-stats { margin-top: 1.6em; }
.wc-stats-title { font-size: 1.15rem; color: var(--color-text-primary); margin: 0 0 0.9em; text-align: center; }
.wc-stats-title span { font-weight: 400; font-size: 0.85rem; color: var(--color-text-muted); display: block; }
.wc-country-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.9em; margin-bottom: 1.4em;
}
.wc-country-card {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  background: var(--color-bg-white); border-radius: 14px; padding: 1em 0.8em;
  box-shadow: var(--shadow-sm); border: 1px solid rgba(128,128,128,0.12);
}
.wc-country-flag { font-size: 2.4rem; line-height: 1; }
.wc-country-name { font-weight: 700; color: var(--color-text-primary); margin-top: 0.2em; }
.wc-country-count { font-size: 1.8rem; font-weight: 800; color: var(--color-primary); line-height: 1.1; margin-top: 0.15em; }
.wc-country-sub { font-size: 0.78rem; color: var(--color-text-muted); }

.wc-city-stats {
  list-style: none; margin: 0 auto; padding: 1em 1.2em; max-width: 620px;
  background: var(--color-bg-white); border-radius: 14px;
  box-shadow: var(--shadow-sm); border: 1px solid rgba(128,128,128,0.12);
}
.wc-city-row { display: flex; align-items: center; gap: 0.7em; padding: 0.35em 0; }
.wc-city-name { flex: 0 0 38%; font-weight: 600; color: var(--color-text-primary); font-size: 0.92rem; }
.wc-city-bar { flex: 1; height: 12px; background: var(--color-bg-light); border-radius: var(--radius-pill); overflow: hidden; }
.wc-city-bar-fill {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--color-primary), #34c759);
  border-radius: var(--radius-pill);
}
.wc-city-count { flex: 0 0 1.8em; text-align: right; font-weight: 800; color: var(--color-text-primary); }
.wc-stats-total { text-align: center; font-size: 0.9rem; color: var(--color-text-secondary); margin: 1em 0 0; }

.wc-empty {
  text-align: center; padding: 2em 1em; color: var(--color-text-secondary);
  background: var(--color-bg-white); border-radius: 14px;
  border: 1px dashed rgba(128,128,128,0.3);
}

.source-note {
  margin-top: 2em; font-size: 0.85rem; text-align: center; color: var(--color-text-muted);
}
footer {
  text-align: center; padding: 20px 10px 28px;
  font-size: 0.9rem; color: var(--color-text-disabled);
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Carte en mode sombre */
@media (prefers-color-scheme: dark) {
  .wc-map-sea { fill: #16213e; }
  .wc-map-land { fill: #2c2c40; stroke: #3c3c50; }
  .wc-map-dot { fill: #565d72; }
  .wc-map-stop { stroke: #1e1e2e; }
  .wc-map-stop-label { stroke: #1e1e2e; }
}

/* === Responsive === */
@media (max-width: 640px) {
  header { padding-top: 28px; padding-bottom: 8px; }
  h1 { font-size: 2rem; }
  main { padding: 0 12px 32px; }
  .wc-tab { padding: 0.6em 1em; font-size: 0.9rem; min-height: 44px; }
  .filter-toggle { min-height: 44px; }
  .wc-filters { justify-content: center; }
  .wc-team-filter, .wc-team-filter select { width: 100%; }
  .wc-team-name { font-size: 0.95rem; }
  .wc-flag { font-size: 1.4rem; }
  .wc-score { min-width: 64px; }
  .wc-score-num { font-size: 1.5rem; }
  .wc-groups { grid-template-columns: 1fr; }
  .wc-table { font-size: 0.85rem; }
  .wc-table th, .wc-table td { padding: 0.45em 0.3em; }
  .wc-map-layout { grid-template-columns: 1fr; }
  .wc-map-stop-label { font-size: 18px; }
}

/* === Impression (pour reporter les scores dans l'album) === */
@media print {
  body { background: #fff; color: #000; }
  .header-actions, .wc-tabs, .wc-filters, button, .refresh, a.back { display: none !important; }
  .wc-panel[hidden] { display: block !important; }
  .wc-match, .wc-group { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .wc-team-name, .wc-score-num { color: #000; }
  main { max-width: none; }
}
