/* ==========================================================================
   Challenge La Meuse - Feuille de style de l'outil de statistiques
   Basée sur les valeurs relevées sur challengelameuse.sudinfo.be
   (page /classification/). Les éléments marqués "à ajuster" sont des
   choix raisonnables, pas des valeurs relevées.
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700&display=swap");

/* --------------------------------------------------------------------------
   1. Variables
   -------------------------------------------------------------------------- */
:root {
  /* Couleurs relevées */
  --cm-text: #333333;
  --cm-bg: #ffffff;
  --cm-navy: #1b252f;          /* en-têtes de tableau, texte des cellules */
  --cm-accent: #cc3366;        /* liens */
  --cm-white: #ffffff;

  /* Couleurs dérivées (à ajuster) */
  --cm-accent-dark: #a82a55;   /* survol des liens */
  --cm-red: #d9232d;           /* fond rouge des boutons */
  --cm-red-dark: #b01a23;      /* boutons au survol */
  --cm-row-alt: #ddd ;       /* lignes alternées du tableau */
  --cm-border: rgba(128, 128, 128, 0.35);
  --cm-muted: #6b7280;

  /* Thème sombre du site */
  --cm-page-bg: #000000;       /* fond noir de la page */
  --cm-text-on-dark: #e6e8eb;  /* texte clair sur fond noir */
  --cm-muted-on-dark: #aab2bd;
  --cm-panel: #e2e5e9;         /* div gris clair qui contient filtre + tableau */

  /* Polices */
  --cm-font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --cm-font-title: "Barlow Condensed", sans-serif;

  /* Tailles */
  --cm-fs-body: 16px;
  --cm-fs-table: 14.4px;
  --cm-fs-h1: 45px;
  --cm-fs-h2: 32px;
  --cm-fs-h3: 22px;

  /* Formes */
  --cm-radius: 20px;           /* arrondi relevé sur les cellules */
  --cm-radius-sm: 8px;
  --cm-shadow: 0 2px 10px rgba(27, 37, 47, 0.08);

  /* Espacements */
  --cm-space-1: 8px;
  --cm-space-2: 16px;
  --cm-space-3: 24px;
  --cm-space-4: 40px;
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
.cm-stats,
.cm-stats * {
  box-sizing: border-box;
}

.cm-stats {
  font-family: var(--cm-font-body);
  font-size: var(--cm-fs-body);
  font-weight: 400;
  color: var(--cm-text-on-dark);
  background: var(--cm-page-bg);
  line-height: 1.5;
}

.cm-stats a {
  color: var(--cm-accent);
  text-decoration: none;
}

.cm-stats a:hover,
.cm-stats a:focus {
  color: var(--cm-accent-dark);
  text-decoration: underline;
}

.cm-stats h1,
.cm-stats h2,
.cm-stats h3 {
  font-family: var(--cm-font-title);
  font-weight: 500;
  line-height: 1.1;
  margin: 0 0 var(--cm-space-2);
}

.cm-stats h1 { font-size: var(--cm-fs-h1); }
.cm-stats h2 { font-size: var(--cm-fs-h2); color: var(--cm-white); }
.cm-stats h3 { font-size: var(--cm-fs-h3); color: var(--cm-white); }

/* --------------------------------------------------------------------------
   3. Mise en page
   -------------------------------------------------------------------------- */
.cm-container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--cm-space-2);
}

/* Bandeau de titre : fond noir comme le site, filet discret en dessous */
.cm-hero {
  background: var(--cm-page-bg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  padding: var(--cm-space-4) 0;
}

.cm-hero h1 {
  color: var(--cm-white);
  margin: 0;
}

.cm-hero p {
  color: rgba(255, 255, 255, 0.8);
  margin: var(--cm-space-1) 0 0;
}

/* Logo + titre côte à côte dans le bandeau */
.cm-hero__inner {
  display: flex;
  align-items: center;
  gap: var(--cm-space-3);
}

.cm-logo {
  flex-shrink: 0;
  display: block;
  line-height: 0;
}

.cm-logo img {
  display: block;
  height: 96px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  border-radius: var(--cm-radius);          /* coins arrondis */
  border: 2px solid rgba(255, 255, 255, 0.18);
  background: var(--cm-white);               /* fond blanc derrière un logo transparent */
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.cm-logo:hover img,
.cm-logo:focus img {
  transform: scale(1.04);
  border-color: var(--cm-red);
}

.cm-section {
  padding: var(--cm-space-4) 0;
}

.cm-grid {
  display: grid;
  gap: var(--cm-space-3);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

/* --------------------------------------------------------------------------
   4. Cartes et chiffres clés
   -------------------------------------------------------------------------- */
.cm-card {
  background: var(--cm-navy);
  color: var(--cm-text-on-dark);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--cm-radius);
  padding: var(--cm-space-3);
}

.cm-stat {
  text-align: center;
}

.cm-stat__value {
  font-family: var(--cm-font-title);
  font-size: 48px;
  font-weight: 600;
  line-height: 1;
  color: var(--cm-accent);
}

.cm-stat__label {
  margin-top: var(--cm-space-1);
  font-size: var(--cm-fs-table);
  color: var(--cm-muted-on-dark);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* --------------------------------------------------------------------------
   5. Tableaux (reprend le style du classement)
   -------------------------------------------------------------------------- */
.cm-table-wrap {
  overflow-x: auto; /* défilement horizontal sur mobile */
}

.cm-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 4px;
  font-size: var(--cm-fs-table);
  color: var(--cm-text);
}

.cm-table th {
  background: var(--cm-navy);
  color: var(--cm-white);
  font-weight: 700;
  text-align: left;
  padding: 12px 16px;
  white-space: nowrap;
}

.cm-table td {
  background: var(--cm-bg);
  color: var(--cm-navy);
  font-weight: 400;
  padding: 12px 16px;
  border-top: 1px solid var(--cm-border);
  border-bottom: 1px solid var(--cm-border);
}

/* Arrondis aux extrémités de chaque ligne (20px relevés sur le site) */
.cm-table th:first-child,
.cm-table td:first-child {
  border-radius: var(--cm-radius) 0 0 var(--cm-radius);
}

.cm-table th:last-child,
.cm-table td:last-child {
  border-radius: 0 var(--cm-radius) var(--cm-radius) 0;
}

.cm-table td:first-child { border-left: 1px solid var(--cm-border); }
.cm-table td:last-child  { border-right: 1px solid var(--cm-border); }

.cm-table tbody tr:nth-child(even) td { background: var(--cm-row-alt); }
.cm-table tbody tr:hover td { background: #eceff3; }

.cm-table .cm-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Podium (à ajuster) */
.cm-rank {
  font-family: var(--cm-font-title);
  font-weight: 600;
  font-size: 18px;
}
.cm-rank--1 { color: #c9a227; }
.cm-rank--2 { color: #8a9099; }
.cm-rank--3 { color: #a8693b; }

/* --------------------------------------------------------------------------
   6. Boutons, filtres, formulaires (à ajuster)
   -------------------------------------------------------------------------- */
.cm-btn {
  display: inline-block;
  font-family: var(--cm-font-body);
  font-size: var(--cm-fs-body);
  font-weight: 600;
  color: var(--cm-white);
  background: var(--cm-red);
  text-align: center;
  border: 0;
  border-radius: var(--cm-radius);
  padding: 10px 24px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease;
}

/* Boutons rouges, texte blanc : !important pour passer devant tout autre style
   (bouton <button> ou lien <a class="cm-btn">) */
.cm-stats .cm-btn,
.cm-stats a.cm-btn,
.cm-stats button.cm-btn {
  background: var(--cm-red) !important;
  color: var(--cm-white) !important;
  text-decoration: none !important;
}

.cm-stats .cm-btn:hover,
.cm-stats .cm-btn:focus,
.cm-stats a.cm-btn:hover,
.cm-stats a.cm-btn:focus,
.cm-stats button.cm-btn:hover,
.cm-stats button.cm-btn:focus {
  background: var(--cm-red-dark) !important;
  color: var(--cm-white) !important;
  text-decoration: none !important;
}

.cm-btn--dark { background: var(--cm-navy); }
.cm-btn--dark:hover { background: #0f161d; }

.cm-select,
.cm-input {
  font-family: var(--cm-font-body);
  font-size: var(--cm-fs-body);
  color: var(--cm-navy);
  background: var(--cm-bg);
  border: 1px solid var(--cm-border);
  border-radius: var(--cm-radius);
  padding: 9px 16px;
}

.cm-select:focus,
.cm-input:focus {
  outline: 2px solid var(--cm-accent);
  outline-offset: 1px;
}

.cm-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cm-space-1);
  margin-bottom: var(--cm-space-3);
}

/* Div gris clair qui regroupe le filtre et le tableau */
.cm-panel {
  background: var(--cm-panel);
  border-radius: var(--cm-radius);
  padding: var(--cm-space-3);
}

/* Barre de filtre, à l'intérieur du div gris */
.cm-filterbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cm-space-2);
  margin-bottom: var(--cm-space-2);
  font-size: var(--cm-fs-table);
}

.cm-filterbar__label {
  font-weight: 700;
  color: var(--cm-navy);
}

.cm-filterbar .cm-input {
  flex: 1 1 240px;
  min-width: 0;
  background: var(--cm-bg);
}

.cm-filterbar__count {
  color: var(--cm-text);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   7. Graphiques (conteneur pour Chart.js)
   -------------------------------------------------------------------------- */
.cm-chart {
  position: relative;
  width: 100%;
  height: 320px; /* hauteur définie, nécessaire pour Chart.js */
}

/* Palette des séries Chart.js, lisible sur fond noir :
   ["#cc3366", "#5bc0eb", "#e0a030", "#6a994e", "#c792ea"] */

/* --------------------------------------------------------------------------
   7b. Pied de page (copyright)
   -------------------------------------------------------------------------- */
.cm-footer {
  padding: var(--cm-space-3) 0;
}

.cm-footer p {
  margin: 0;
  text-align: left;
  font-size: 13px;
  color: var(--cm-muted-on-dark); /* gris, lisible sur fond noir */
}

/* --------------------------------------------------------------------------
   8. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  :root {
    --cm-fs-h1: 34px;
    --cm-fs-h2: 26px;
  }
  .cm-hero { padding: var(--cm-space-3) 0; }
  .cm-hero__inner { gap: var(--cm-space-2); }
  .cm-logo img { height: 64px; max-width: 110px; border-radius: 14px; }
  .cm-section { padding: var(--cm-space-3) 0; }
  .cm-card { padding: var(--cm-space-2); }

  /* Formulaire : champs et bouton pleine largeur */
  .cm-filters .cm-input,
  .cm-filters .cm-btn {
    flex: 1 1 100%;
  }

  /* Texte des boutons (Voir mes résultats / Effacer) centré */
  .cm-filters .cm-btn,
  .cm-stats a.cm-btn {
    display: block;
    text-align: center;
  }

  .cm-panel { padding: var(--cm-space-2); }

  /* Graphique un peu moins haut */
  .cm-chart { height: 260px; }

  /* Tableau : chaque résultat devient une carte */
  .cm-table-wrap { overflow-x: visible; }

  .cm-table,
  .cm-table tbody {
    display: block;
  }

  .cm-table thead { display: none; }

  .cm-table tbody tr {
    display: block;
    background: var(--cm-bg);
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius);
    box-shadow: var(--cm-shadow);
    padding: 8px 0;
    margin-bottom: var(--cm-space-2);
  }

  .cm-table tbody tr td,
  .cm-table tbody tr:nth-child(even) td,
  .cm-table tbody tr:hover td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 6px 16px;
    text-align: right;
  }

  /* Libellé de chaque valeur, repris de l'attribut data-label */
  .cm-table td::before {
    content: attr(data-label);
    flex-shrink: 0;
    font-weight: 700;
    text-align: left;
    color: var(--cm-muted);
  }

  /* Le nom de la course sert de titre à la carte */
  .cm-table td[data-label="Course"] {
    font-family: var(--cm-font-title);
    font-size: 20px;
    font-weight: 600;
  }
}
