/* =====================================================================
   PAVILLON — carnet de bord de corsaire
   Encre / papier d'os / rouge corsaire. Bebas Neue + Archivo.
   ===================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Archivo:wght@400;500;600;700&display=swap');

:root {
  --ink:    #0E0E10;
  --ink-2:  #1c1c20;
  --paper:  #F2ECD9;
  --paper-2:#E7DFC7;
  --red:    #D42D2D;
  --red-d:  #b21f1f;
  --slate:  #5b5750;
  --sea:    #cdd7d3;
  --line:   rgba(14,14,16,.14);
  --shadow: 0 6px 24px rgba(14,14,16,.18);

  --display: 'Bebas Neue', Impact, sans-serif;
  --body: 'Archivo', system-ui, sans-serif;
  --tab-h: 64px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button { font-family: inherit; cursor: pointer; }
a { color: var(--red-d); }
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }

h1, h2, h3 { font-family: var(--display); font-weight: 400; letter-spacing: .02em; margin: 0; line-height: .98; }

/* ---- App shell ---- */
#app { min-height: 100%; display: flex; flex-direction: column; }
#app[hidden] { display: none; }   /* sinon display:flex écrase l'attribut hidden */

.topbar {
  height: 56px; display: flex; align-items: center; gap: 10px;
  padding: 0 14px; background: var(--ink); color: var(--paper);
  position: sticky; top: 0; z-index: 50;
}
.topbar img { height: 34px; width: 34px; object-fit: contain; }
.topbar .brand { font-family: var(--display); font-size: 26px; letter-spacing: .06em; line-height: 1; }
.topbar .brand small { display: block; font-family: var(--body); font-size: 9px; letter-spacing: .32em;
  color: var(--red); font-weight: 700; margin-top: 2px; }
.topbar .spacer { flex: 1; }
.topbar .pill { font-family: var(--display); font-size: 18px; background: var(--red); color: #fff;
  padding: 2px 10px; border-radius: 2px; letter-spacing: .04em; }

main { flex: 1; position: relative; padding-bottom: var(--tab-h); }
.view { display: none; }
.view.active { display: block; }
.pad { padding: 16px; max-width: 760px; margin: 0 auto; }

/* la carte établit son propre contexte d'empilement, SOUS la barre d'onglets */
#map { position: absolute; inset: 0; bottom: var(--tab-h); background: var(--sea); z-index: 0; }

/* ---- Bottom nav ---- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--tab-h);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--ink); z-index: 1000;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  background: none; border: 0; color: #9a958c; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; font-size: 10px;
  letter-spacing: .12em; text-transform: uppercase; font-weight: 700;
}
.tabbar button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.tabbar button.active { color: var(--paper); }
.tabbar button.pose { color: var(--paper); }
.tabbar button.pose .ring {
  width: 46px; height: 46px; margin-top: -16px; border-radius: 50%;
  background: var(--red); display: grid; place-items: center; box-shadow: var(--shadow);
  border: 3px solid var(--ink);
}
.tabbar button.pose .ring svg { stroke: #fff; width: 24px; height: 24px; }

/* ---- Map ---- */
.legend {
  position: absolute; z-index: 400; right: 10px; bottom: calc(var(--tab-h) + 12px);
  background: var(--paper); border: 1px solid var(--line); border-radius: 4px;
  padding: 8px 10px; box-shadow: var(--shadow); max-width: 52vw; font-size: 12px;
}
.legend b { font-family: var(--display); font-size: 14px; letter-spacing: .06em; display: block; margin-bottom: 4px; }
.legend .row { display: flex; align-items: center; gap: 6px; margin: 2px 0; }
.legend .sw { width: 12px; height: 12px; border-radius: 2px; flex: none; }

.pin { border-radius: 50%; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4);
  background-size: cover; background-position: center; }
.pin.home { background: var(--ink); display: grid; place-items: center; }
.pin.home svg { width: 16px; height: 16px; stroke: var(--red); fill: none; stroke-width: 2; }

.leaflet-popup-content-wrapper { border-radius: 4px; }
.popup { width: 200px; font-family: var(--body); }
.popup img { width: 100%; border-radius: 3px; display: block; margin-bottom: 6px; }
.popup .who { font-family: var(--display); font-size: 20px; letter-spacing: .04em; }
.popup .meta { color: var(--slate); font-size: 12px; margin: 2px 0 6px; }
.popup .votebtn { width: 100%; }

/* ---- Cards / sections ---- */
.section-title { font-family: var(--display); font-size: 30px; letter-spacing: .04em; margin: 6px 0 12px;
  display: flex; align-items: baseline; gap: 10px; }
.section-title .rule { flex: 1; height: 2px; background: var(--ink); opacity: .25; }

.card { background: var(--paper-2); border: 1px solid var(--line); border-radius: 5px; padding: 14px; margin-bottom: 12px; }

.rank { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.rank:last-child { border-bottom: 0; }
.rank .no { font-family: var(--display); font-size: 26px; width: 30px; text-align: right; color: var(--slate); }
.rank .ava { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--ink); background-size: cover; background-position: center; flex: none; display: grid; place-items: center; }
.rank .ava img { width: 26px; }
.rank .name { font-weight: 700; flex: 1; }
.rank .name small { display: block; color: var(--slate); font-weight: 500; font-size: 12px; }
.rank .pts { font-family: var(--display); font-size: 28px; letter-spacing: .03em; }
.rank .pts span { font-family: var(--body); font-size: 11px; color: var(--slate); display: block; text-align: right; letter-spacing: .1em; }

.records { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.record { background: var(--ink); color: var(--paper); border-radius: 5px; padding: 12px; }
.record .k { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--red); font-weight: 700; }
.record .v { font-family: var(--display); font-size: 30px; letter-spacing: .03em; margin-top: 4px; }
.record .who { font-size: 12px; color: #c9c4ba; }
.record.wide { grid-column: 1 / -1; }
.bar { height: 8px; background: rgba(255,255,255,.15); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.bar > div { height: 100%; background: var(--red); }

.challenge { display: flex; gap: 12px; align-items: flex-start; }
.challenge .mark { font-family: var(--display); font-size: 22px; color: var(--red); width: 26px; flex: none; }
.challenge .body { flex: 1; }
.challenge .title { font-weight: 700; }
.challenge .desc { color: var(--slate); font-size: 13px; margin: 2px 0; }
.challenge .won { font-size: 12px; font-weight: 700; }
.challenge .open { font-size: 12px; color: var(--red-d); font-weight: 700; }
.tagpts { font-family: var(--display); font-size: 18px; background: var(--ink); color: var(--paper); padding: 1px 8px; border-radius: 2px; }

/* ---- Buttons / forms ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--red); color: #fff; border: 0; border-radius: 4px; padding: 13px 16px;
  font-family: var(--display); font-size: 20px; letter-spacing: .05em; width: 100%; }
.btn:hover { background: var(--red-d); }
.btn[disabled] { background: var(--slate); opacity: .6; }
.btn.ghost { background: transparent; color: var(--ink); border: 2px solid var(--ink); }
.btn.dark { background: var(--ink); }

label { display: block; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; color: var(--slate); margin: 12px 0 5px; }

/* Sélecteur de mode segmenté (pose) */
.seg { display: flex; gap: 6px; margin: 4px 0 12px; }
.seg button { flex: 1; padding: 10px; border: 1px solid var(--line); background: var(--paper);
  border-radius: 6px; font-weight: 700; color: var(--slate); font-family: var(--body); }
.seg button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--paper); font-family: var(--body); font-size: 16px; color: var(--ink);
}
textarea { resize: vertical; min-height: 60px; }
.hint { font-size: 12px; color: var(--slate); margin-top: 6px; }
.error { color: var(--red-d); font-weight: 600; font-size: 14px; margin: 8px 0; }

/* ---- Pose sheet ---- */
.sheet { position: fixed; inset: 0; bottom: 0; z-index: 2000; background: rgba(14,14,16,.5);
  display: none; align-items: flex-end; }
.sheet.open { display: flex; }
.sheet .panel { background: var(--paper); width: 100%; max-width: 760px; margin: 0 auto;
  border-radius: 14px 14px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow: auto; animation: rise .22s ease; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.sheet .grab { width: 40px; height: 4px; background: var(--line); border-radius: 2px; margin: 0 auto 8px; }
.photo-drop { border: 2px dashed var(--line); border-radius: 6px; aspect-ratio: 4/3; display: grid; place-items: center;
  background: var(--paper-2); overflow: hidden; position: relative; text-align: center; color: var(--slate); }
.photo-drop img { width: 100%; height: 100%; object-fit: cover; }
.photo-drop input { position: absolute; inset: 0; opacity: 0; }
.gps { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-top: 10px; }
.gps .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--slate); }
.gps .dot.ok { background: #2E8B57; } .gps .dot.err { background: var(--red); }

.result { text-align: center; padding: 8px 0; }
.result .big { font-family: var(--display); font-size: 64px; color: var(--red); line-height: 1; }
.result .lines { display: inline-block; text-align: left; margin: 10px 0; }
.result .lines div { display: flex; justify-content: space-between; gap: 30px; font-size: 14px; padding: 3px 0; }

/* ---- Auth hero ---- */
.auth { min-height: 100vh; background: var(--ink); color: var(--paper); display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 28px; text-align: center; }
.auth .flag { width: min(58vw, 240px); }
.auth .name { width: min(72vw, 320px); margin: 14px 0 4px; }
.auth .tag { font-size: 11px; letter-spacing: .34em; text-transform: uppercase; color: var(--red); font-weight: 700; }
.auth form { width: 100%; max-width: 360px; margin-top: 18px; text-align: left; }
.auth label { color: #b8b3a9; }
.auth .switch { margin-top: 14px; font-size: 13px; color: #b8b3a9; }
.auth .switch button { background: none; border: 0; color: var(--paper); font-weight: 700; text-decoration: underline; }
.codebox { background: var(--paper); color: var(--ink); border-radius: 5px; padding: 14px; margin-top: 12px; }
.codebox .code { font-family: var(--display); font-size: 34px; letter-spacing: .14em; color: var(--red-d); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 34px; height: 34px; border-radius: 4px; border: 2px solid transparent; }
.swatch.sel { border-color: var(--ink); }

.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 14px); transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 11px 16px; border-radius: 4px; z-index: 3000;
  font-size: 14px; box-shadow: var(--shadow); max-width: 90vw; }

.empty { text-align: center; color: var(--slate); padding: 40px 16px; }
.empty svg { width: 40px; height: 40px; stroke: var(--slate); fill: none; stroke-width: 1.5; opacity: .6; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
