/* Figtree (SIL Open Font License, cf. assets/vendor/fonts/OFL.txt), police variable hébergée sur le site */
@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-display: swap;
  font-weight: 300 900;
  src: url(../vendor/fonts/figtree-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-display: swap;
  font-weight: 300 900;
  src: url(../vendor/fonts/figtree-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light;
  --bg:            #f4f6fa;
  --card:          #ffffff;
  --surface:       #ffffff;           /* surface des graphiques (sert d'écart entre les marques) */
  --line:          #e8ecf2;
  --line-strong:   #d6dce6;
  --grid:          #eef1f6;
  --accent:        #7461f0;
  --accent-soft:   #f0edfe;
  --accent-2:      #c686f8;
  --accent-3:      #4fd1ea;
  --text:          #1b1d29;
  --text-2:        #5f6b80;
  --text-3:        #809fb8;
  --good:          #12a150;
  --good-soft:     #e6f6ed;
  --bad:           #d9344a;
  --bad-soft:      #fdecee;
  --strava:        #fc5200;
  --tip-bg:        #1b1d29;
  --empty-cell:    #eef1f6;

  /* Couleurs par sport (validées sur fond blanc, toujours accompagnées d'un libellé) */
  --run:    #7461f0;
  --trail:  #e0558f;
  --hike:   #c98500;
  --swim:   #0f9fb8;
  --other:  #8494a8;

  /* Rampe séquentielle (calendrier), du plus faible au plus fort */
  --seq-1:  #e4dffd;
  --seq-2:  #c3b9fa;
  --seq-3:  #a291f6;
  --seq-4:  #7461f0;
  --seq-5:  #4b36c9;

  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 8px rgba(16, 24, 40, 0.04);
  --font: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ---------- En-tête ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 32px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.athlete { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 15px; }
.athlete:hover { text-decoration: none; }
.athlete img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.athlete-mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-3), var(--accent), var(--accent-2));
}
.athlete-mark svg { width: 20px; height: 20px; }
.athlete-city { display: block; color: var(--text-3); font-size: 12px; font-weight: 500; }

.topbar-right { display: flex; align-items: center; gap: 16px; color: var(--text-3); font-size: 13px; }

.hero { padding: 28px 32px 4px; }
.hero h1 {
  margin: 0;
  font-size: 40px; line-height: 1.1; font-weight: 800; letter-spacing: -0.02em;
}
.hero h1 .grad {
  background: linear-gradient(90deg, var(--accent-3), var(--accent) 45%, var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { margin: 6px 0 0; color: var(--text-2); font-size: 15px; }

/* ---------- Barre d'outils ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px 24px;
  padding: 20px 32px;
}

/* Contrôle segmenté (onglets, mesure) */
.tabs, .seg {
  display: inline-flex; flex-wrap: wrap; gap: 2px;
  padding: 3px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.tabs a, .seg button {
  padding: 7px 16px;
  border: 0; border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font: 600 13px/1.2 var(--font);
  cursor: pointer;
}
.tabs a:hover, .seg button:hover { color: var(--text); text-decoration: none; background: var(--bg); }
.tabs a.active, .seg button[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.seg button { padding: 4px 10px; font-size: 12px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters[hidden] { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--text-2);
  font: 600 13px/1.2 var(--font);
  cursor: pointer;
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip[aria-pressed="true"] { color: var(--text); border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--c, var(--accent)); }

.select select, .search {
  appearance: none;
  padding: 7px 32px 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235f6b80' fill='none' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--text);
  font: 600 13px/1.2 var(--font);
}
.search { background-image: none; padding-right: 12px; min-width: 240px; }
.select select:focus-visible, .search:focus-visible, .chip:focus-visible, .tabs a:focus-visible, .seg button:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------- Cartes ---------- */

.view { flex: 1; padding: 0 32px 32px; }

.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 16px;
}
.panel-title { margin: 0; font-size: 16px; font-weight: 700; }
.panel-sub { color: var(--text-3); font-size: 13px; font-weight: 500; }

.chart-box { position: relative; flex: 1; min-height: 220px; }
.chart-box canvas { position: absolute; inset: 0; }

.empty { padding: 32px 0; color: var(--text-3); text-align: center; }
.loading { padding: 80px 0; text-align: center; color: var(--text-2); }

/* ---------- Tableau de bord ---------- */

.dash {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 20px;
}
.kpi-row { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.a-month  { grid-column: span 8; min-height: 340px; }
.a-donut  { grid-column: span 4; }
.a-map    { grid-column: span 8; min-height: 480px; }
.a-recent { grid-column: span 4; }
.a-week   { grid-column: span 8; min-height: 320px; }
.a-cal    { grid-column: span 4; }

.kpi-card { gap: 6px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-icon {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
}
.kpi-icon svg { width: 18px; height: 18px; }
.kpi-label { color: var(--text-2); font-size: 13px; font-weight: 600; }
.kpi-value { font-size: 30px; line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; }
.kpi-value small { font-size: 15px; color: var(--text-3); margin-left: 4px; font-weight: 600; letter-spacing: 0; }
.kpi-delta { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: 12px; }
.pill.up { color: var(--good); background: var(--good-soft); }
.pill.down { color: var(--bad); background: var(--bad-soft); }

/* KPI du détail d'activité */
.kpi { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }

.donut-wrap { display: flex; flex-direction: column; gap: 18px; flex: 1; justify-content: center; }
.donut-wrap .chart-box { min-height: 180px; height: 180px; flex: none; }
.donut-center {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none;
}
.donut-center b { font-size: 22px; font-weight: 800; }
.donut-center span { color: var(--text-3); font-size: 12px; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.legend li { display: grid; grid-template-columns: 8px 1fr auto 40px; gap: 10px; align-items: baseline; font-size: 13px; color: var(--text-2); font-weight: 600; }
.legend .val { color: var(--text); font-weight: 700; white-space: nowrap; text-align: right; }
.legend .pct { color: var(--text-3); font-size: 12px; text-align: right; }

.map-panel { padding: 0; overflow: hidden; }
.map-panel .panel-head { margin: 0; padding: 16px 20px; }
.map-panel .map { top: 58px; }
.map-badge { color: var(--text-3); font-size: 13px; font-weight: 500; }
.map { position: absolute; inset: 0; background: #eef1f6; }

.recent { list-style: none; margin: 0 -8px; padding: 0; display: grid; gap: 2px; }
.recent a {
  display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: center;
  padding: 8px; border-radius: var(--radius-sm); color: var(--text);
}
.recent a:hover { background: var(--bg); text-decoration: none; }
.recent .ico {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  background: color-mix(in srgb, var(--c) 12%, white);
}
.recent .ico .dot { width: 10px; height: 10px; }
.recent .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.recent .meta { display: block; color: var(--text-3); font-size: 12px; font-weight: 500; }
.recent .num { font-weight: 700; text-align: right; white-space: nowrap; }

/* calendrier */
.cal { display: flex; flex-direction: column; gap: 10px; }
.cal-grid { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; }
.cal-cell { aspect-ratio: 1; border-radius: 3px; background: var(--empty-cell); }
.cal-cell.out { visibility: hidden; }
.cal-months { display: flex; justify-content: space-between; color: var(--text-3); font-size: 11px; font-weight: 500; }
.cal-scale { display: flex; align-items: center; gap: 3px; justify-content: flex-end; color: var(--text-3); font-size: 11px; }
.cal-scale i { width: 10px; height: 10px; border-radius: 3px; }
.cal-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.cal-stats span { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg); color: var(--text-2); font-size: 12px; font-weight: 600; }
.cal-stats b { display: block; color: var(--text); font-size: 20px; font-weight: 800; }

/* ---------- Liste des activités ---------- */

.list-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  padding: 10px 12px;
  text-align: left; white-space: nowrap;
  color: var(--text-3); font-size: 12px; font-weight: 600;
  background: var(--bg);
}
table.data th:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
table.data th:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
table.data th[data-sort] { cursor: pointer; }
table.data th[data-sort]:hover { color: var(--text); }
table.data th.sorted { color: var(--accent); }
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover td { background: #fafbfd; }
table.data td.name { white-space: normal; min-width: 200px; font-weight: 700; }
table.data td.name a { color: var(--text); }

.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--c, var(--accent)) 10%, white);
  color: var(--text); font-size: 12px; font-weight: 600; white-space: nowrap;
}
.pr { color: #b7791f; font-weight: 700; font-size: 12px; }
a.pr { color: #b7791f; }

.more { margin: 16px auto 0; display: block; }
.btn {
  padding: 8px 18px; border: 0; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff; font: 700 13px/1.2 var(--font); cursor: pointer;
}
.btn:hover { background: #5f4be0; text-decoration: none; }

/* ---------- Détail d'une activité ---------- */

.detail { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; }
.detail-head { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: flex-start; }
.detail-head h2 { margin: 6px 0 8px; font-size: 30px; line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; }
.detail-head .meta { color: var(--text-2); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.back { color: var(--text-3); font-size: 13px; font-weight: 600; }
.strava-btn { color: #fff; background: var(--strava); padding: 9px 16px; border-radius: var(--radius-sm); font-weight: 700; white-space: nowrap; }
.strava-btn:hover { background: #e04900; text-decoration: none; }

.detail-kpis { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.detail-kpis .kpi-value { font-size: 26px; }
.detail-map { min-height: 440px; padding: 0; overflow: hidden; }
.detail-side { display: flex; flex-direction: column; gap: 20px; }
.detail-charts { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; }
.detail-charts .panel { min-height: 280px; }
.desc { white-space: pre-line; color: var(--text-2); margin: 0; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 10px 20px; margin: 0; font-size: 13px; }
.facts dt { color: var(--text-3); font-weight: 500; }
.facts dd { margin: 0; font-weight: 600; }

/* ---------- Carte plein écran ---------- */

.fullmap { position: relative; height: calc(100vh - 290px); min-height: 480px; }
.map-legend {
  position: absolute; z-index: 500; left: 16px; bottom: 16px;
  display: flex; flex-wrap: wrap; gap: 12px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--card); box-shadow: var(--shadow); font-size: 12px; font-weight: 600; color: var(--text-2);
}
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Records ---------- */

.records { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.records .span { grid-column: 1 / -1; }
.feats { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.feat { padding: 16px; border-radius: var(--radius); background: var(--bg); color: var(--text); display: block; }
a.feat:hover { background: var(--accent-soft); text-decoration: none; }
.feat .kpi-value { font-size: 26px; }
.feat .meta { color: var(--text-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 6px; }

/* ---------- Analyse ---------- */

.analysis { display: grid; gap: 32px; }
.an-sport-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin-bottom: 14px; }
.an-sport-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.an-sport-head .dot { width: 10px; height: 10px; }
.an-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; align-items: start; }
.an-wide { grid-column: span 2; }
.an-card .panel-head { margin-bottom: 10px; }
.an-value { font-size: 26px; line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.an-value small { margin-left: 6px; color: var(--text-3); font-size: 13px; font-weight: 600; letter-spacing: 0; }
.an-pills { margin: 6px 0 4px; min-height: 4px; }
.pill.flat { color: var(--accent); background: var(--accent-soft); }
.an-note { margin-top: 4px; color: var(--text-3); font-size: 12px; font-weight: 500; }
.an-line { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-weight: 600; }
.an-line b { font-weight: 800; font-variant-numeric: tabular-nums; }
.an-gap { margin-top: 8px; }
.an-row + .an-row { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.an-chart { flex: none; height: 130px; min-height: 130px; margin-top: 12px; }

.an-dist + .an-dist { margin-top: 16px; }
.an-box { position: relative; height: 22px; margin: 8px 0 6px; }
.an-box i { position: absolute; display: block; }
.an-whisker { top: 10px; height: 2px; background: var(--line-strong); }
.an-iqr { top: 3px; height: 16px; border-radius: 4px; background: var(--seq-2); }
.an-med { top: 0; width: 3px; height: 22px; margin-left: -1px; border-radius: 2px; background: var(--seq-5); }
.an-ticks { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.an-ticks span { display: flex; flex-direction: column; }
.an-ticks small { color: var(--text-3); font-size: 11px; font-weight: 500; }

.an-pred { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-bottom: 8px; }
.an-pred-item { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--bg); }
.an-pred-item .an-value { font-size: 22px; margin-top: 2px; }
.an-foot { margin: 0; color: var(--text-3); font-size: 12px; }

/* ---------- Leaflet ---------- */

.leaflet-container { font: 12px/1.4 var(--font); background: #eef1f6; }
.leaflet-bar { border: 0 !important; box-shadow: var(--shadow) !important; }
.leaflet-bar a { color: var(--text) !important; border-color: var(--line) !important; }
.leaflet-control-layers { border: 0 !important; box-shadow: var(--shadow) !important; border-radius: var(--radius-sm) !important; }
.leaflet-control-attribution { background: rgba(255, 255, 255, 0.8) !important; color: var(--text-3) !important; }
.leaflet-control-attribution a { color: var(--text-2) !important; }
.leaflet-tooltip.track-tip {
  background: var(--tip-bg); color: #fff; border: 0; border-radius: var(--radius-sm); box-shadow: none; padding: 8px 10px;
}
.leaflet-tooltip.track-tip::before { display: none; }

/* ---------- Infobulle HTML (calendrier) ---------- */

.tooltip {
  position: fixed; z-index: 1000; pointer-events: none;
  padding: 8px 12px; max-width: 280px;
  background: var(--tip-bg); border-radius: var(--radius-sm);
  color: #fff; font-size: 12px;
}
.tooltip b { font-size: 13px; }

/* ---------- Pied de page ---------- */

.footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px;
  padding: 18px 32px; color: var(--text-3); font-size: 12px;
}
.footer a { color: var(--text-2); }
.strava-link { color: var(--strava) !important; font-weight: 700; }

/* ---------- Mentions légales ---------- */

.legal { display: grid; gap: 20px; max-width: 900px; }
.legal .panel { display: block; font-size: 15px; line-height: 1.6; }
.legal h2 { margin: 0 0 10px; font-size: 18px; font-weight: 700; }
.legal h3 { margin: 18px 0 6px; font-size: 15px; font-weight: 700; }
.legal p { margin: 0 0 10px; color: var(--text-2); }
.legal ul { margin: 0 0 10px; padding-left: 20px; color: var(--text-2); }
.legal li { margin-bottom: 6px; }
.legal strong { color: var(--text); }
.legal code { padding: 1px 5px; border-radius: 4px; background: var(--bg); font-size: 13px; }

/* ---------- Responsive ---------- */

@media (max-width: 1200px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .a-month, .a-map, .a-week { grid-column: span 12; }
  .a-donut, .a-recent, .a-cal { grid-column: span 6; }
  .a-month { order: 1; } .a-donut { order: 2; } .a-cal { order: 3; }
  .a-map { order: 4; } .a-recent { order: 5; } .a-week { order: 6; }
  .a-recent { grid-column: span 12; }
  .an-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .topbar, .hero, .toolbar, .view, .footer { padding-left: 16px; padding-right: 16px; }
  .topbar-right .sync { display: none; }
  .hero { padding-top: 20px; }
  .hero h1 { font-size: 30px; }
  .dash, .kpi-row { gap: 12px; }
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .a-donut, .a-cal { grid-column: span 12; }
  .detail, .records { grid-template-columns: minmax(0, 1fr); }
  .a-map { min-height: 380px; }
  .detail-map { min-height: 320px; }
  .panel { padding: 16px; }
  .kpi-value { font-size: 24px; }
  .kpi-icon { display: none; }
  .search { min-width: 0; width: 100%; }
  .fullmap { height: calc(100vh - 300px); }
  .detail-charts { grid-template-columns: minmax(0, 1fr); }
  .tabs a { padding: 6px 10px; }
  .an-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .an-wide { grid-column: auto; }
  .analysis { gap: 24px; }
  .an-ticks { font-size: 11px; }
}
