/* =====================================================================
   APG · app.css — mise en page fidèle à la maquette demo-situation-bulles.
   Squelette stable : carte de fond + barre d'onglets toujours présentes (§8.6).
   Bord-à-bord PWA : 100dvh + safe-area (§6.7).
   ===================================================================== */

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: var(--lg-font-body); color: var(--lg-text);
  background: #cfd3cb; overscroll-behavior: none;
}

/* Carte plein écran, en fond. */
#map { position: fixed; inset: 0; z-index: 0; height: 100dvh; width: 100vw; }

/* Couche d'interface (les enfants réactivent les events). */
.app-shell { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
.app-shell > * { pointer-events: auto; }

/* ----- Barre d'état (heure · ville · météo) ----- */
.statusbar {
  position: fixed; top: calc(env(safe-area-inset-top) + 4px); left: 0; right: 0; z-index: 7;
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 22px; font-size: 13px; font-weight: 600; color: var(--lg-text);
  text-shadow: 0 1px 2px rgba(255,255,255,.6);
}
.statusbar__right { opacity: .82; }

/* ----- Slot proactif (une bulle à la fois, §8.6) ----- */
.zone-haute {
  position: fixed; top: calc(env(safe-area-inset-top) + 40px); left: 12px; right: 12px; z-index: 7;
  display: flex; flex-direction: column; gap: 10px;
}

/* ----- Bulle (teaser) ----- */
.bulle {
  position: relative; overflow: hidden;
  padding: 13px; border-radius: 18px;
  display: flex; gap: 12px; align-items: center; cursor: pointer;
  animation: bulle-in .44s cubic-bezier(.32,.72,0,1);
}
@keyframes bulle-in { from { opacity: 0; transform: translateY(-24px); } to { opacity: 1; transform: none; } }
.bulle__icone { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 13px; background: var(--lg-accent-soft); display: grid; place-items: center; font-size: 21px; }
.bulle--securite .bulle__icone { background: #f6d6da; }
.bulle__txt { flex: 1 1 auto; min-width: 0; }
.bulle__titre { font-weight: 700; font-size: 14px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bulle__teaser { font-size: 12px; color: var(--lg-text-soft); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bulle__chev { flex: 0 0 auto; color: var(--lg-accent); font-size: 20px; opacity: .55; }
.bulle__close {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--lg-line); background: rgba(0,0,0,.03); color: var(--lg-text-soft);
  display: grid; place-items: center; font-size: 15px; cursor: pointer;
}
.bulle__progress { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--lg-accent); opacity: .7; transform-origin: left; }
.bulle__progress--run { animation: shrink 8s linear forwards; }
@keyframes shrink { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* Pastille réouvrable. */
.pastille {
  align-self: flex-end; width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center; font-size: 20px; cursor: pointer;
  animation: bulle-in .32s cubic-bezier(.32,.72,0,1);
}

/* ----- FAB recentrer ----- */
.fab {
  position: fixed; right: 16px; bottom: calc(var(--lg-tab-h) + env(safe-area-inset-bottom) + 18px); z-index: 5;
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
}
.fab svg { width: 22px; height: 22px; stroke: var(--lg-accent); fill: none; stroke-width: 2; }

/* ----- Barre d'onglets (toujours visible) ----- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; height: var(--lg-tab-h);
  display: flex; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-radius: 0; border-top: 1px solid var(--lg-glass-border);
}
.tabbar__item {
  flex: 1; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--lg-text-soft); font-family: var(--lg-font-body); font-size: 10.5px; font-weight: 600;
}
.tabbar__item svg { width: 23px; height: 23px; stroke: currentColor; fill: none; stroke-width: 1.9; }
.tabbar__item[aria-selected="true"] { color: var(--lg-accent); }

/* ----- Voile + Feuille modale (peek / full / closed) ----- */
.voile {
  position: fixed; left: 0; right: 0; top: 0; bottom: var(--lg-tab-h); z-index: 9;
  background: rgba(35,15,25,1); opacity: 0; transition: opacity .32s ease;
}
.feuille {
  position: fixed; left: 0; right: 0; bottom: var(--lg-tab-h); z-index: 10;
  height: calc(100dvh - var(--lg-tab-h) - 26px);
  border-radius: 26px 26px 0 0; display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(100%); transition: transform .42s cubic-bezier(.32,.72,0,1);
}
.feuille__grab { flex: 0 0 auto; padding: 9px 20px 8px; cursor: grab; touch-action: none; user-select: none; }
.feuille__poignee { display: block; width: 42px; height: 5px; border-radius: 3px; margin: 0 auto 12px; background: rgba(80,55,70,.28); }
.feuille__eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--lg-accent); }
.feuille__titre { font-family: var(--lg-font-title); font-weight: 600; font-size: 23px; line-height: 1.12; letter-spacing: -.01em; margin: 2px 0 0; }
.feuille__hint { font-size: 11px; color: var(--lg-text-soft); margin-top: 9px; }
.feuille__corps { flex: 1 1 auto; overflow-y: auto; padding: 6px 20px 26px; }
.feuille__corps::-webkit-scrollbar { width: 0; }

/* ----- Contenu de feuille (styles maquette) ----- */
.lede { font-size: 15px; line-height: 1.5; margin: 14px 0 4px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.stat { background: rgba(0,0,0,.03); border: 1px solid var(--lg-line); border-radius: 14px; padding: 12px; }
.stat .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--lg-text-soft); }
.stat .v { font-family: var(--lg-font-title); font-size: 20px; font-weight: 600; margin-top: 3px; line-height: 1.1; }
.stat .v small { font-family: var(--lg-font-body); font-size: 11.5px; color: var(--lg-text-soft); font-weight: 600; display: block; margin-top: 3px; }
.sec { margin-top: 20px; }
.sec h3 { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--lg-text-soft); margin: 0 0 8px; font-weight: 700; }
.anecdote { border-left: 3px solid var(--lg-accent); padding: 8px 0 8px 12px; border-radius: 0 10px 10px 0; background: linear-gradient(90deg, var(--lg-accent-soft), transparent); font-size: 13.5px; line-height: 1.5; }
.kv { display: flex; justify-content: space-between; font-size: 14px; padding: 7px 0; border-bottom: 1px solid var(--lg-line); }
.kv span:first-child { color: var(--lg-text-soft); }
.src { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--lg-accent-strong); text-decoration: none; padding: 9px 12px; border-radius: 12px; background: rgba(157,47,82,.07); margin-top: 8px; font-weight: 600; }
.src::after { content: '›'; margin-left: auto; font-size: 16px; }
.btn { display: block; width: 100%; text-align: center; border: 0; cursor: pointer; font-family: var(--lg-font-body); font-weight: 700; font-size: 14.5px; padding: 14px; border-radius: 15px; margin-top: 16px; background: var(--lg-accent); color: #fff; box-shadow: 0 10px 22px -10px var(--lg-accent); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: rgba(0,0,0,.04); color: var(--lg-text); box-shadow: none; margin-top: 8px; }
.plist .pl { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--lg-line); }
.plist .pl .n { font-family: var(--lg-font-title); font-size: 16px; font-weight: 600; }
.plist .pl .m { font-size: 12.5px; color: var(--lg-text-soft); margin-top: 1px; }
.plist .pl .d { font-size: 12px; font-weight: 700; color: var(--lg-accent-strong); background: rgba(157,47,82,.08); padding: 5px 9px; border-radius: 9px; white-space: nowrap; }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 13px; background: rgba(0,0,0,.05); margin: 16px 0 6px; }
.seg button { flex: 1; border: 0; cursor: pointer; font-family: var(--lg-font-body); font-weight: 600; font-size: 12.5px; padding: 9px 6px; border-radius: 10px; color: var(--lg-text-soft); background: none; }
.seg button[aria-pressed="true"], .seg button.on { background: #fff; color: var(--lg-accent); box-shadow: 0 2px 8px -3px rgba(0,0,0,.25); }
.news { padding: 13px 0; border-bottom: 1px solid var(--lg-line); }
.news .h { font-weight: 600; font-size: 14.5px; line-height: 1.3; }
.news .c { font-size: 13px; color: var(--lg-text-soft); line-height: 1.45; margin: 3px 0 6px; }
.news .so { font-size: 11.5px; color: var(--lg-accent-strong); font-weight: 600; }
.news a { color: inherit; text-decoration: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.lien-inline { border: 0; background: none; cursor: pointer; color: var(--lg-accent-strong); font-weight: 600; font-size: 13px; padding: 0; }

/* ----- Panneau d'onglet (Infos / Profil), carte ancrée bas ----- */
.panneau {
  position: fixed; left: 10px; right: 10px; bottom: calc(var(--lg-tab-h) + env(safe-area-inset-bottom) + 10px); z-index: 6;
  padding: 16px 18px; max-height: 56dvh; overflow-y: auto; border-radius: 18px;
}
.panneau__titre { font-family: var(--lg-font-title); font-size: 20px; margin: 0 0 10px; }

/* ----- Overlay navigation / coach ----- */
.nav-overlay {
  position: fixed; left: 10px; right: 10px; top: calc(env(safe-area-inset-top) + 10px); z-index: 8; padding: 16px 18px; border-radius: 18px;
}
.nav-overlay__instruction { font-family: var(--lg-font-title); font-size: 20px; line-height: 1.2; }
.nav-overlay__metrics { display: flex; gap: 18px; margin-top: 12px; flex-wrap: wrap; }
.nav-metric .k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--lg-text-soft); }
.nav-metric .v { font-family: var(--lg-font-title); font-size: 21px; font-weight: 600; line-height: 1.1; }
.nav-overlay__actions { display: flex; gap: 8px; margin-top: 14px; }

/* ----- Bandeau RGPD ----- */
.rgpd {
  position: fixed; left: 10px; right: 10px; bottom: calc(var(--lg-tab-h) + env(safe-area-inset-bottom) + 16px); z-index: 9;
  padding: 14px 16px; font-size: 13px; display: flex; gap: 10px; align-items: center; border-radius: 16px;
}
.rgpd__txt { flex: 1 1 auto; }

/* ----- Indicateur d'état (hors-ligne / éco) ----- */
.etat-pill {
  position: fixed; top: calc(env(safe-area-inset-top) + 40px); left: 50%; transform: translateX(-50%); z-index: 6;
  padding: 4px 12px; font-size: 12px; font-weight: 600;
}

/* ----- Bouton engrenage (ouvre les réglages) ----- */
.gear {
  position: fixed; top: calc(env(safe-area-inset-top) + 36px); left: 12px; z-index: 7;
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
}
.gear svg { width: 21px; height: 21px; stroke: var(--lg-accent); fill: none; stroke-width: 2; }

/* ----- Panneau latéral gauche (réglages) ----- */
.drawer-voile {
  position: fixed; inset: 0; z-index: 11; background: rgba(35,15,25,.45);
  opacity: 0; pointer-events: none; transition: opacity .3s ease;
}
.drawer-voile.is-open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 12;
  width: min(86vw, 340px); border-radius: 0 24px 24px 0;
  padding: calc(env(safe-area-inset-top) + 18px) 18px calc(env(safe-area-inset-bottom) + 22px);
  display: flex; flex-direction: column; overflow-y: auto;
  transform: translateX(-104%); transition: transform .36s cubic-bezier(.32,.72,0,1);
}
.drawer.is-open { transform: translateX(0); }
.drawer__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.drawer__titre { font-family: var(--lg-font-title); font-size: 24px; font-weight: 600; margin: 0; }
.drawer__close { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--lg-line); background: rgba(0,0,0,.03); color: var(--lg-text-soft); font-size: 17px; cursor: pointer; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
