/* Trail Desert Agafay 2026 — GPS. Thème clair à fort contraste (lisible en plein soleil). */
@font-face { font-family: "Chivo"; src: url(/fonts/Chivo_900Black_Italic.ttf) format("truetype"); font-weight: 900; font-style: italic; font-display: swap; }
@font-face { font-family: "Manrope"; src: url(/fonts/Manrope_600SemiBold.ttf) format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Manrope"; src: url(/fonts/Manrope_800ExtraBold.ttf) format("truetype"); font-weight: 800; font-display: swap; }

:root {
  --orange: #D65B1D; --orange-dk: #A8321A; --ink: #0B0D0E; --ink-2: #3A3F43; --paper: #FFFFFF; --sand: #F6EFE6; --line: #E3D8CA;
  --red: #D7263D; --ok: #2E7D32; --warn: #E09A00;
  --display: "Chivo", "Arial Black", system-ui, sans-serif;
  --text: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --bar-h: 74px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); font-family: var(--text); font-weight: 600; font-size: 17px; line-height: 1.4; -webkit-text-size-adjust: 100%; }
body { overscroll-behavior-y: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
a { color: inherit; }
.ic { display: inline-block; vertical-align: middle; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.km-u { font-family: var(--text); font-weight: 800; font-style: normal; font-size: .42em; margin-left: .12em; letter-spacing: 0; }

/* ---------- Démarrage ---------- */
.boot { min-height: 100vh; display: grid; place-content: center; text-align: center; background: var(--orange); color: #fff; }
.boot-logo { font-family: var(--display); font-weight: 900; font-style: italic; font-size: 44px; line-height: .95; }
.boot-logo span { color: var(--ink); }
.boot-sub { margin-top: 12px; font-weight: 800; letter-spacing: .2em; }

/* ---------- En-tête ---------- */
.top { position: sticky; top: 0; z-index: 1000; background: var(--ink); color: #fff; padding: calc(var(--safe-t) + 10px) 16px 10px; display: flex; align-items: center; gap: 10px; min-height: 60px; }
.top .brand { flex: 1; min-width: 0; font-family: var(--display); font-weight: 900; font-style: italic; font-size: 20px; line-height: 1; letter-spacing: -.01em; }
.top .brand small { display: block; font-family: var(--text); font-style: normal; font-weight: 800; font-size: 11px; letter-spacing: .18em; color: #F2B33D; margin-top: 4px; }
.lang { display: flex; border: 2px solid #fff; border-radius: 10px; overflow: hidden; flex: none; }
.lang button { min-width: 44px; min-height: 40px; font-weight: 800; font-size: 15px; color: #fff; }
.lang button[aria-pressed="true"] { background: #fff; color: var(--ink); }
.icon-btn { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px; flex: none; }
.top .icon-btn { margin-left: -8px; }

/* ---------- Accueil ---------- */
.home { padding: 0 16px calc(var(--bar-h) + var(--safe-b) + 24px); max-width: 720px; margin: 0 auto; }
.hero { margin: 0 -16px; background: var(--orange); color: #fff; padding: 22px 16px 20px; }
.hero h1 { margin: 0; font-family: var(--display); font-weight: 900; font-style: italic; font-size: clamp(38px, 11vw, 60px); line-height: .92; letter-spacing: -.02em; }
.hero h1 span { color: var(--ink); }
.hero p { margin: 10px 0 0; font-weight: 800; font-size: 15px; }
.notice { margin: 14px 0 0; padding: 12px 14px; border-radius: 12px; background: #FFF4D6; border: 2px solid #F2B33D; font-size: 15px; display: flex; gap: 10px; }
.group-title { margin: 26px 0 10px; display: flex; align-items: baseline; gap: 10px; font-family: var(--display); font-weight: 900; font-style: italic; font-size: 26px; line-height: 1; }
.group-title small { font-family: var(--text); font-style: normal; font-weight: 800; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--orange-dk); }
.race-card { display: flex; align-items: stretch; width: 100%; text-align: left; margin: 0 0 10px; border-radius: 14px; overflow: hidden; background: var(--paper); border: 2px solid var(--ink); text-decoration: none; min-height: 92px; }
.race-card:active { transform: scale(.99); }
.race-card .dist { width: 104px; flex: none; display: flex; align-items: center; justify-content: center; color: #fff; font-family: var(--display); font-weight: 900; font-style: italic; font-size: 40px; line-height: 1; }
.race-card .dist.light { color: var(--ink); }
.race-card .body { flex: 1; padding: 10px 12px; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.race-card .name { font-weight: 800; font-size: 19px; line-height: 1.15; }
.race-card .meta { margin-top: 4px; font-size: 14.5px; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 2px 10px; }
.race-card .meta b { color: var(--ink); font-weight: 800; }
.race-card .tag { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; padding: 2px 8px; border-radius: 6px; background: var(--sand); align-self: flex-start; }
.race-card .chev { width: 34px; display: grid; place-items: center; color: var(--ink); }
.foot-note { margin: 28px 0 0; font-size: 13.5px; color: var(--ink-2); text-align: center; }
.foot-note a { font-weight: 800; }

/* ---------- Barre d'actions (bas, usage à une main) ---------- */
.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100; background: var(--paper); border-top: 2px solid var(--ink); padding: 8px 10px calc(8px + var(--safe-b)); display: flex; gap: 8px; }
.bar button, .bar a { flex: 1; min-height: 56px; border-radius: 14px; display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 800; font-size: 17px; text-decoration: none; border: 2px solid var(--ink); background: var(--paper); }
.bar .primary { flex: 1.5; background: var(--ink); color: #fff; }
.bar .primary.on { background: var(--ok); border-color: var(--ok); }
.bar .sos { background: var(--red); border-color: var(--red); color: #fff; flex: .9; }

/* ---------- Vue course ---------- */
.course { position: fixed; inset: 0; display: flex; flex-direction: column; padding-bottom: calc(var(--bar-h) + var(--safe-b)); }
.course .top { position: relative; }
.race-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; border-radius: 8px; color: #fff; font-family: var(--display); font-weight: 900; font-style: italic; font-size: 22px; line-height: 1; flex: none; }
.race-chip.light { color: var(--ink); }
.course .title { flex: 1; min-width: 0; font-weight: 800; font-size: 16px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.course .title small { display: block; font-size: 12.5px; color: #CFCFCF; font-weight: 600; }
.map-wrap { position: relative; flex: 1; min-height: 160px; background: #E9DCC9; }
#map { position: absolute; inset: 0; }
.map-btns { position: absolute; right: 10px; top: 10px; z-index: 500; display: flex; flex-direction: column; gap: 8px; }
.map-btn { width: 50px; height: 50px; border-radius: 12px; background: var(--paper); border: 2px solid var(--ink); display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.map-btn[aria-pressed="true"] { background: var(--ink); color: #fff; }
.layer-label { font-size: 10px; font-weight: 800; line-height: 1; margin-top: -4px; }
.offroute { position: absolute; left: 10px; right: 70px; top: 10px; z-index: 500; background: var(--warn); color: var(--ink); border: 2px solid var(--ink); border-radius: 12px; padding: 8px 12px; font-weight: 800; font-size: 15px; display: none; }
.offroute.show { display: block; }
.gps-err { position: absolute; left: 10px; right: 70px; bottom: 10px; z-index: 500; background: var(--paper); border: 2px solid var(--red); border-radius: 12px; padding: 8px 12px; font-size: 14.5px; display: none; }
.gps-err.show { display: block; }

.stats { display: grid; grid-template-columns: 1fr 1fr 1.35fr; background: var(--paper); border-top: 2px solid var(--ink); }
.stat { padding: 6px 10px 7px; border-right: 1px solid var(--line); min-width: 0; }
.stat:last-child { border-right: 0; }
.stat .k { font-size: 11.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .v { font-family: var(--display); font-weight: 900; font-style: italic; font-size: 28px; line-height: 1.05; white-space: nowrap; }
.stat .v small { font-family: var(--text); font-style: normal; font-size: 13px; font-weight: 800; margin-left: 2px; }
.stat .v.next { font-size: 22px; display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; }
.stats .hint { grid-column: 1 / -1; padding: 10px 12px; font-size: 15px; display: flex; gap: 8px; align-items: center; }

.profile { position: relative; height: 164px; background: var(--paper); border-top: 1px solid var(--line); touch-action: none; user-select: none; -webkit-user-select: none; }
.profile canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.profile .ppoi { position: absolute; top: 2px; transform: translateX(-50%); width: 22px; height: 22px; pointer-events: none; display: grid; place-items: center; background: #fff; border-radius: 50%; box-shadow: 0 0 0 1.5px rgba(11,13,14,.25); }
.profile .ppoi { width: 20px; height: 20px; }
.profile .ppoi.cpg { height: auto; background: none; box-shadow: none; border-radius: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.profile .ppoi.cpg b { background: var(--orange); color: #fff; font-size: 11.5px; font-weight: 800; line-height: 19px; padding: 0 5px; border-radius: 5px; }
.profile .ppoi.cpg i { display: flex; gap: 1px; background: #fff; border-radius: 10px; padding: 1px 2px; box-shadow: 0 0 0 1.5px rgba(11,13,14,.25); }
.profile .ppoi.cpg span { width: 16px; height: 16px; display: grid; place-items: center; }
.profile .tip { position: absolute; top: 52px; transform: translateX(-50%); background: var(--ink); color: #fff; border-radius: 8px; padding: 3px 8px; font-size: 13px; font-weight: 800; white-space: nowrap; pointer-events: none; display: none; }

/* Marqueurs carte */
.poi-mk { display: flex; flex-direction: column; align-items: center; pointer-events: auto; }
.poi-mk .bdg { background: #fff; border: 2.5px solid var(--ink); border-radius: 50%; width: 32px; height: 32px; display: grid; place-items: center; box-shadow: 0 2px 4px rgba(0,0,0,.35); }
.poi-mk .cpl { background: var(--orange); color: #fff; border: 2.5px solid #fff; border-radius: 8px; padding: 1px 7px; font-weight: 800; font-size: 14px; box-shadow: 0 2px 4px rgba(0,0,0,.4); white-space: nowrap; }
.poi-mk .svc { display: flex; gap: 2px; margin-top: 2px; }
.poi-mk .svc span { background: #fff; border-radius: 50%; width: 20px; height: 20px; display: grid; place-items: center; box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.km-mk { background: var(--paper); color: var(--ink); border: 2px solid var(--ink); border-radius: 10px; font-size: 11px; font-weight: 800; padding: 0 4px; text-align: center; line-height: 16px; white-space: nowrap; }
.me-mk { width: 24px; height: 24px; border-radius: 50%; background: #1A73E8; border: 4px solid #fff; box-shadow: 0 0 0 2px #1A73E8, 0 2px 8px rgba(0,0,0,.5); }
.me-mk.stale { background: #8A8F93; box-shadow: 0 0 0 2px #8A8F93; }
.cur-mk { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 5px solid var(--ink); box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.sf-mk { background: var(--ink); color: #fff; border: 2.5px solid #fff; border-radius: 8px; padding: 2px 7px; font-weight: 800; font-size: 12.5px; white-space: nowrap; box-shadow: 0 2px 4px rgba(0,0,0,.4); }
.leaflet-container { font-family: var(--text); background: #E9DCC9; }
.leaflet-popup-content { font-family: var(--text); font-weight: 600; font-size: 15px; margin: 10px 14px; }
.leaflet-popup-content b { font-weight: 800; }
.leaflet-control-attribution { font-size: 10px !important; }

/* ---------- Feuilles (Infos, SOS) ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 2000; background: rgba(11,13,14,.55); display: none; }
.sheet-bg.open { display: block; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow: auto; background: var(--paper); border-radius: 20px 20px 0 0; padding: 8px 16px calc(20px + var(--safe-b)); -webkit-overflow-scrolling: touch; max-width: 720px; margin: 0 auto; }
.sheet-head { position: sticky; top: -8px; background: var(--paper); display: flex; align-items: center; gap: 10px; padding: 8px 0 10px; z-index: 1; }
.sheet-head h2 { flex: 1; margin: 0; font-family: var(--display); font-weight: 900; font-style: italic; font-size: 28px; line-height: 1; }
.sheet-head .icon-btn { border: 2px solid var(--ink); }
.sheet h3 { margin: 22px 0 8px; font-size: 13px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--orange-dk); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fact { border: 2px solid var(--ink); border-radius: 12px; padding: 8px 12px; }
.fact .k { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.fact .v { font-family: var(--display); font-weight: 900; font-style: italic; font-size: 30px; line-height: 1.05; }
.fact .v small { font-family: var(--text); font-style: normal; font-size: 14px; font-weight: 800; }
.fact .s { font-size: 13.5px; color: var(--ink-2); }
.desc { margin: 12px 0 0; font-size: 16px; }
.poi-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.poi-list li { border-bottom: 1px solid var(--line); }
.poi-list button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 2px; text-align: left; min-height: 56px; }
.poi-list .km { width: 64px; flex: none; font-family: var(--display); font-weight: 900; font-style: italic; font-size: 22px; }
.poi-list .nm { flex: 1; font-weight: 800; }
.poi-list .nm small { display: block; font-weight: 600; color: var(--ink-2); font-size: 14px; }
.poi-list .ics { display: flex; gap: 4px; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.legend div { display: flex; align-items: center; gap: 10px; min-height: 36px; font-size: 15.5px; }
.legend .cpb { background: var(--orange); color: #fff; border-radius: 6px; padding: 0 6px; font-weight: 800; font-size: 13px; }
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 56px; border-radius: 14px; border: 2px solid var(--ink); font-weight: 800; font-size: 17px; text-decoration: none; background: var(--paper); margin-top: 8px; }
.btn.dark { background: var(--ink); color: #fff; }
.btn.orange { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn[disabled] { opacity: .55; }
.off-state { font-size: 14.5px; margin-top: 8px; color: var(--ink-2); }
.off-state.ok { color: var(--ok); font-weight: 800; }
.progress { height: 10px; border-radius: 6px; background: var(--sand); overflow: hidden; margin-top: 8px; display: none; }
.progress > i { display: block; height: 100%; width: 0; background: var(--orange); transition: width .2s; }
.check { display: flex; gap: 12px; align-items: center; min-height: 48px; font-size: 16px; }
.check input { width: 26px; height: 26px; accent-color: var(--ink); }

/* SOS */
.sos-sheet .sheet-head h2 { color: var(--red); }
.tel { display: flex; align-items: center; gap: 14px; text-decoration: none; border: 2.5px solid var(--ink); border-radius: 16px; padding: 10px 16px; margin-top: 10px; min-height: 72px; }
.tel.primary { background: var(--red); border-color: var(--red); color: #fff; }
.tel .l { flex: 1; font-weight: 800; font-size: 17px; line-height: 1.1; min-width: 0; }
.tel .n { font-family: var(--display); font-weight: 900; font-style: italic; font-size: 32px; line-height: 1; white-space: nowrap; }
.tel.primary { flex-wrap: wrap; } .tel.primary .n { font-size: clamp(24px, 8vw, 34px); }
.coords { margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: var(--sand); font-size: 15px; }
.coords b { font-family: var(--display); font-style: italic; font-weight: 900; font-size: 22px; display: block; letter-spacing: .01em; }

/* Challenge / sans tracé */
.page { padding: 16px 16px calc(var(--bar-h) + var(--safe-b) + 24px); max-width: 720px; margin: 0 auto; }
.big-dist { font-family: var(--display); font-weight: 900; font-style: italic; font-size: 76px; line-height: .9; }
.stage-card { display: flex; gap: 12px; align-items: center; text-decoration: none; border: 2px solid var(--ink); border-radius: 14px; padding: 10px 12px; margin-top: 10px; min-height: 80px; }
.stage-card .d { width: 76px; height: 60px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-family: var(--display); font-weight: 900; font-style: italic; font-size: 30px; flex: none; }
.stage-card .t { flex: 1; font-weight: 800; }
.stage-card .t small { display: block; font-weight: 600; color: var(--ink-2); }
.empty-track { margin-top: 16px; padding: 18px; border-radius: 14px; border: 2px dashed var(--ink-2); text-align: center; font-weight: 800; }

.toast { position: fixed; left: 50%; bottom: calc(var(--bar-h) + var(--safe-b) + 14px); transform: translateX(-50%); z-index: 3000; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 800; font-size: 15px; max-width: calc(100% - 32px); display: none; text-align: center; }
.toast.show { display: block; }

@media (min-width: 900px) {
  .course { flex-direction: column; }
  .profile { height: 170px; }
}
@media (max-height: 640px) { .stat .v { font-size: 22px; } }

.bar .sos:only-child { flex: 1; }
