/* =====================================================================
   PROFIL, REPLAY ET SURVOL 3D — sortis de css/design.css le 03/11/2026
   pour être chargés AUSSI par la page publique d'une activité
   (activite.html), qui n'a pas les feuilles de l'app. Chargé après
   design.css dans index.html : l'ordre de la cascade est inchangé.
   ===================================================================== */
/* ------------------------------------------------------------
   PROFIL & REPLAY (cf. js/replay.js) — le profil d'altitude sert de
   barre de temps. Pente : rampe divergente bleu ↔ rouge, gris au plat,
   validée (outil dataviz) sur chaque fond. En sombre, la pente forte est
   la plus LUMINEUSE : c'est elle qui doit ressortir du fond.
   ------------------------------------------------------------ */
:root {
  --grade-0: #9ec5f4; --grade-1: #3987e5; --grade-2: #184f95; --grade-3: #5c5b56;
  --grade-4: #9e1f1f; --grade-5: #e66767; --grade-6: #f6b6a6;
}
[data-theme="light"] {
  --grade-0: #104281; --grade-1: #2a78d6; --grade-2: #86b6ef; --grade-3: #a9a8a1;
  --grade-4: #f2a08a; --grade-5: #e34948; --grade-6: #9e1f1f;
}

.rp-read { font-variant-numeric: tabular-nums; text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--text); font-size: var(--fs-xs); text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-chart { position: relative; display: grid; grid-template-columns: 40px 1fr; grid-template-rows: 120px auto; gap: 4px 6px; outline: none; }
.rp-chart.is-flat { grid-template-columns: 1fr; grid-template-rows: 26px auto; }
.rp-chart.is-compact { grid-template-rows: 64px auto; }
.rp-chart.is-compact.is-flat { grid-template-rows: 22px auto; }
.rp-chart:focus-visible .rp-plot { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.rp-y { position: relative; }
.rp-y-lab { position: absolute; right: 0; transform: translateY(-50%); font-size: 10.5px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-plot { position: relative; cursor: crosshair; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.rp-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.rp-grid { position: absolute; left: 0; right: 0; border-top: 1px solid color-mix(in srgb, var(--text) 9%, transparent); }
.rp-track { position: absolute; left: 0; right: 0; top: 50%; height: 6px; margin-top: -3px; border-radius: 3px; background: var(--surface-3); }
.rp-done { position: absolute; left: 0; bottom: 0; height: 3px; border-radius: 2px; background: var(--accent); pointer-events: none; }
.rp-chart.is-flat .rp-done { top: 50%; bottom: auto; height: 6px; margin-top: -3px; border-radius: 3px; }
.rp-cur, .rp-hover { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px solid var(--accent); transform: translateX(-1px); pointer-events: none; }
.rp-hover { border-left: 1px solid var(--text-2); }
.rp-dot { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--surface), 0 0 0 6px color-mix(in srgb, var(--accent) 28%, transparent); pointer-events: none; }
.rp-tip {
  position: absolute; top: 4px; margin-left: 8px; z-index: 2; pointer-events: none;
  display: flex; flex-direction: column; gap: 1px; padding: 7px 10px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text-2);
  font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap; box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
}
.rp-tip.is-left { transform: translateX(calc(-100% - 16px)); }
.rp-tip[hidden] { display: none; }
.rp-tip b { color: var(--text); font-weight: 600; }
.rp-tip span { color: var(--text-3); }
.rp-x { grid-column: -2; position: relative; height: 14px; }
.rp-x-lab { position: absolute; top: 0; transform: translateX(-50%); font-size: 10.5px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-x-lab:first-child { transform: none; }
.rp-x-lab:last-child { transform: translateX(-100%); }
.rp-ctrl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rp-ctrl [data-rp-play] { display: inline-flex; align-items: center; gap: 6px; }
.rp-speed { font-variant-numeric: tabular-nums; min-width: 52px; }
.rp-legend { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--text-3); }
.rp-leg-bar { position: relative; display: inline-flex; gap: 2px; padding-bottom: 12px; }
.rp-leg-bar > i { width: 20px; height: 8px; border-radius: 2px; }
.rp-leg-ticks { position: absolute; left: 0; right: 0; bottom: 0; height: 11px; }
.rp-leg-ticks em { position: absolute; transform: translateX(-50%); font-style: normal; font-variant-numeric: tabular-nums; }
.rp-leg-end { padding-bottom: 12px; }

/* Barre compacte sous la carte plein écran. */
.rp-bar { flex: none; display: flex; align-items: center; gap: 10px; }
.rp-bar-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.rp-bar .rp-read { text-align: left; min-height: 1.2em; }
.rp-bar .rp-chart { grid-template-columns: 34px 1fr; }
/* Téléphone : le profil prend toute la largeur, les boutons passent dessous. */
@media (max-width: 640px) {
  .rp-bar { flex-wrap: wrap; justify-content: space-between; }
  .rp-bar-main { flex-basis: 100%; order: -1; }
}

/* Courbe d'allure : repère du même instant. */
.pp-box { position: relative; }
.pp-cursor { position: absolute; width: 0; border-left: 2px solid var(--accent); transform: translateX(-1px); pointer-events: none; }
/* Courbe d'allure dessinée par D3 (js/d3charts.js) : pas de cadre, la
   figure fait toute la largeur ; agrandie, elle prend la hauteur donnée. */
.pp-box.is-d3 .mc.d3c { margin: 0; }
.cz-body .pp-box.is-d3 { max-width: none; }
.d3c-pace .pp-band.is-focused rect:first-child { opacity: .2; }

.tmap-card-acts { display: inline-flex; gap: 14px; }

/* Commandes posées SUR la vignette de carte (cf. TraceMap.card) : en haut
   à droite — le zoom est à gauche, la légende et l'attribution en bas.
   Pastilles claires, comme la légende : la carte est claire dans les deux
   thèmes. `z-index: 1` suffit : `.trace-map` enferme les z-index de
   Leaflet dans son propre contexte (z-index: 0). Cible tactile ≥ 36 px. */
.tmap-frame { position: relative; }
.tmap-over { position: absolute; top: 10px; right: 10px; z-index: 1; display: flex; gap: 6px; }
.tmap-over-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px;
  border: 0; border-radius: 999px; cursor: pointer;
  background: rgba(255, 255, 255, 0.95); color: #111827;
  font: inherit; font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.01em;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.tmap-over-btn svg { width: 16px; height: 16px; flex: none; }
.tmap-over-btn:hover { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.32); transform: translateY(-1px); }
.tmap-over-btn:focus-visible { outline: 2px solid var(--brand-green); outline-offset: 2px; }
/* Vignette étroite : icônes seules, libellé en infobulle (title). */
@container (max-width: 360px) { .tmap-over-btn span { display: none; } .tmap-over-btn { width: 36px; padding: 0; justify-content: center; } }
@media (max-width: 380px) { .tmap-over-btn span { display: none; } .tmap-over-btn { width: 36px; padding: 0; justify-content: center; } }
.tmap-full-acts { display: inline-flex; align-items: center; gap: 8px; }

/* ------------------------------------------------------------
   SURVOL 3D (cf. js/fly3d.js) — plein écran, comme la carte agrandie.
   La scène (relief + satellite) est sombre et chargée : le HUD est une
   carte opaque, lisible sur n'importe quelle image.
   ------------------------------------------------------------ */
#fly3d { position: fixed; inset: 0; z-index: 530; background: var(--bg); display: flex; flex-direction: column; gap: 10px; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); }
.f3-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.f3-title { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-md); font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f3-stage { position: relative; flex: 1; min-height: 0; border-radius: var(--r-md); overflow: hidden; background: #0b0f14; }
/* Sélecteur renforcé : maplibre-gl.css, chargé après, pose `position: relative` sur le conteneur. */
#fly3d .f3-map { position: absolute; inset: 0; }
/* Panneaux posés sur la carte : verre dépoli sombre — le fond transparaît,
   flouté, et le texte reste lisible sur n'importe quelle image. Sans
   `backdrop-filter`, le fond plus opaque suffit. */
.f3-hud, .f3-wait, .f3-hint, .f3-mark > span, #fly3d .maplibregl-ctrl-group {
  background: rgba(13, 17, 23, .78); border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .28);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .f3-hud, .f3-wait, .f3-hint, .f3-mark > span, #fly3d .maplibregl-ctrl-group {
    background: rgba(13, 17, 23, .52); -webkit-backdrop-filter: blur(14px) saturate(1.5); backdrop-filter: blur(14px) saturate(1.5);
  }
}
.f3-hud {
  position: absolute; top: 12px; left: 12px; z-index: 2; pointer-events: none;
  display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border-radius: 16px;
  color: #eef1f5; font-variant-numeric: tabular-nums; max-width: calc(100% - 84px);
}
.f3-km { font-size: var(--fs-2xl, 26px); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.f3-alt { font-size: var(--fs-sm); font-weight: 600; color: #ffffff; }
.f3-row { font-size: var(--fs-xs); color: #c3cad5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f3-wait { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 2; display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; color: #e8eaee; font-size: var(--fs-xs); }
.f3-wait[hidden] { display: none; }
.f3-foot { flex: none; display: flex; flex-direction: column; gap: 8px; }
.f3-ctrl { display: flex; align-items: center; gap: 8px; }
.f3-ctrl [data-f3-play] { display: inline-flex; align-items: center; gap: 6px; }
.f3-opt { display: inline-flex; align-items: center; gap: 6px; }
.f3-opt[aria-pressed="true"] { color: var(--brand-green); border-color: color-mix(in srgb, var(--brand-green) 45%, var(--border)); }
/* Téléphone : Tour et Vue libre en icônes seules, la ligne tient sans déborder. */
@media (max-width: 480px) { .f3-opt > span { display: none; } }
.f3-hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 2; max-width: calc(100% - 28px); padding: 6px 12px; border-radius: var(--r-md); color: #e8eaee; font-size: var(--fs-xs); text-align: center; pointer-events: none; }
.f3-hint[hidden] { display: none; }
.f3-sum { margin-left: auto; font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
/* Repères : l'étiquette flotte au-dessus des toits, une tige la relie au
   point posé sur le sol. */
.f3-mark { --mk: #1fb57a; display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.f3-mark > span { padding: 3px 9px; border-radius: 999px; color: #fff; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.f3-mark > b { width: 2px; height: 22px; background: linear-gradient(rgba(255, 255, 255, .95), rgba(255, 255, 255, .25)); }
.f3-mark > i { width: 12px; height: 12px; margin-top: -2px; border-radius: 50%; border: 2px solid #fff; background: var(--mk); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mk) 35%, transparent), 0 1px 4px rgba(0, 0, 0, .5); }
.f3-mark.is-end { --mk: #f0a82d; }
.f3-mark.is-cp { --mk: #4f8cff; }
/* Le coureur : une pastille cerclée de blanc, dont l'onde bat. */
.f3-pos { width: 20px; height: 20px; pointer-events: none; }
.f3-pos > i {
  position: absolute; inset: 0; border-radius: 50%; background: #ff7a1a; border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
}
.f3-pos::before {
  content: ""; position: absolute; inset: -8px; border-radius: 50%; background: rgba(255, 122, 26, .45);
  animation: f3-pulse 1.8s ease-out infinite;
}
@keyframes f3-pulse { from { transform: scale(.45); opacity: .9; } to { transform: scale(1.35); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .f3-pos::before { animation: none; transform: scale(.9); opacity: .5; } }
/* Boutons de la carte (zoom, boussole) : même verre que le reste. */
#fly3d .maplibregl-ctrl-group { border-radius: 14px; overflow: hidden; }
#fly3d .maplibregl-ctrl-group button { width: 36px; height: 36px; background-color: transparent; }
#fly3d .maplibregl-ctrl-group button + button { border-top: 1px solid rgba(255, 255, 255, .12); }
#fly3d .maplibregl-ctrl-group button:hover { background-color: rgba(255, 255, 255, .1); }
#fly3d .maplibregl-ctrl-group .maplibregl-ctrl-icon { filter: invert(1) brightness(1.6); }
#fly3d .maplibregl-ctrl-top-right { top: 2px; right: 2px; }
#fly3d .maplibregl-ctrl-attrib { font-size: 10px; }
/* Export vidéo (cf. js/flyvideo.js) : la carte prend la taille du film, sous
   un écran opaque qui montre le film en train de se calculer. */
#fly3d .f3-map.is-rec { position: fixed; inset: auto; left: 0; top: 0; }
.fv-screen { position: fixed; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); overflow: auto; background: var(--bg); }
.fv-card { display: flex; flex-direction: column; gap: 14px; width: min(100%, 460px); max-height: 100%; }
.fv-card.fv-work.is-wide, .fv-card.fv-done.is-wide { width: min(100%, 860px); }
.fv-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: var(--fs-lg); font-weight: 700; }
.fv-field { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.fv-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.fv-field small { color: var(--text-3); font-size: var(--fs-xs); margin-left: 4px; }
.fv-note { margin: 0; font-size: var(--fs-sm); color: var(--text-2); }
.fv-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.fv-actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.fv-preview, .fv-video { display: block; align-self: center; max-width: 100%; max-height: calc(100vh - 170px); max-height: calc(100dvh - 170px); min-height: 0; border-radius: var(--r-md); background: #0b0f14; }
.fv-bar { height: 8px; border-radius: 999px; background: var(--sunk); overflow: hidden; }
.fv-bar > i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--brand-green); transition: width .2s linear; }

/* Encoche du téléphone : même règle que dans design.css (#tmap-full), répétée
   ici parce que ce fichier est chargé APRÈS lui et que #fly3d y redéfinit
   son `padding`. */
#fly3d { padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
