/* ============================================================
   VIGIE — thème "nature / sérieux", mobile-first
   ============================================================ */

:root {
  --bg:        #151d15;
  --bg-soft:   #1c2a1c;
  --bg-panel:  #1f2a1ff2;
  --text:      #e8e6dc;
  --text-dim:  #a9b0a0;
  --accent:    #8a9a5b;
  --accent-2:  #a7b86f;

  --chasse:    #c0392b;
  --promeneur: #6b8e5a;
  --vtt:       #e0b341;
  --chien:     #e8e6dc;

  --radius:    14px;
  --shadow:    0 10px 30px rgba(0, 0, 0, 0.45);
  --safe-b:    env(safe-area-inset-bottom, 0px);
  --safe-t:    env(safe-area-inset-top, 0px);

  --font-title: 'Oswald', system-ui, sans-serif;
  --font-body:  'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:  'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }

/* ============================================================
   CADRE APPAREIL — plein écran sur mobile, maquette sur desktop
   ============================================================ */

.device {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

/* Sur grand écran : on présente la démo dans un téléphone centré,
   pour qu'un support commercial ouvert sur un laptop reste crédible. */
@media (min-width: 620px) {
  body {
    background:
      radial-gradient(120% 90% at 50% -10%, #1b261b 0%, #0b0f0b 70%),
      #0b0f0b;
    padding: 20px;
  }
  .device {
    width: 400px;
    height: min(860px, calc(100dvh - 40px));
    border-radius: 34px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow:
      0 40px 90px rgba(0, 0, 0, 0.6),
      0 0 0 10px #0e130e,
      0 0 0 11px rgba(255, 255, 255, 0.05);
  }
}

/* ============================================================
   ÉCRAN D'ACCUEIL
   ============================================================ */

.splash {
  position: absolute;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  background:
    radial-gradient(120% 80% at 50% 0%, #223022 0%, var(--bg) 60%),
    var(--bg);
  animation: fade-in 0.5s ease;
}

.splash.leaving { animation: fade-out 0.45s ease forwards; }

.splash-inner { max-width: 420px; }

.splash-logo {
  width: 104px;
  height: 104px;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.5));
  animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.splash-title {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: clamp(3.2rem, 16vw, 5rem);
  letter-spacing: 0.14em;
  margin: 12px 0 4px;
  color: var(--text);
}

.splash-tagline {
  font-size: 1.1rem;
  color: var(--accent-2);
  margin: 0 0 32px;
  font-weight: 500;
}

.btn-enter {
  background: var(--accent);
  color: #13180f;
  border: none;
  border-radius: 999px;
  padding: 16px 40px;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, background 0.15s ease;
}
.btn-enter:active { transform: scale(0.96); }
.btn-enter:hover { background: var(--accent-2); }

.splash-note {
  margin-top: 28px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  text-transform: uppercase;
}

/* ============================================================
   APP + CARTE
   ============================================================ */

.app { position: absolute; inset: 0; }

#map {
  position: absolute;
  inset: 0;
  background: var(--bg-soft);
  z-index: 1;
}

/* Rendu sombre des tuiles OSM pour coller à l'ambiance */
.leaflet-tile-pane {
  filter: brightness(0.82) saturate(0.85) contrast(0.96) hue-rotate(-6deg);
}

.leaflet-container { background: var(--bg-soft); font-family: var(--font-body); }
.leaflet-control-attribution {
  background: rgba(21, 29, 21, 0.75) !important;
  color: var(--text-dim) !important;
  font-size: 10px;
}
.leaflet-control-attribution a { color: var(--accent-2) !important; }
.leaflet-bar a {
  background: var(--bg-panel) !important;
  color: var(--text) !important;
  border-color: rgba(255,255,255,0.08) !important;
}
.leaflet-bar a:hover { background: var(--bg-soft) !important; }

/* ============================================================
   TOPBAR
   ============================================================ */

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + var(--safe-t)) 14px 10px;
  background: linear-gradient(to bottom, rgba(21,29,21,0.92), rgba(21,29,21,0));
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand { display: flex; align-items: center; gap: 9px; }
.brand-logo { width: 34px; height: 34px; }
.brand-name {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 1.4rem;
  letter-spacing: 0.12em;
}

.role-switch {
  display: flex;
  background: var(--bg-panel);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 3px;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.role-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 999px;
  transition: color 0.2s, background 0.2s;
  white-space: nowrap;
}
.role-btn.is-active { background: var(--accent); color: #13180f; }

/* ============================================================
   LÉGENDE
   ============================================================ */

.legend {
  position: absolute;
  left: 12px;
  bottom: calc(18px + var(--safe-b));
  z-index: 500;
  background: var(--bg-panel);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 10px 12px;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  max-width: 60vw;
}
.legend-toggle {
  display: none;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0;
}
.legend-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
}
.legend-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text);
}
.legend-list em { color: var(--text-dim); font-style: normal; font-size: 0.72rem; }

.dot {
  width: 13px; height: 13px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.25);
}
.dot-chasse    { background: var(--chasse); }
.dot-promeneur { background: var(--promeneur); }
.dot-vtt       { background: var(--vtt); }
.dot-chien     { background: transparent; border: 2px solid var(--chien); box-shadow: none; }

/* ============================================================
   BOUTON SIGNALER (FAB)
   ============================================================ */

.fab {
  position: absolute;
  right: 16px;
  bottom: calc(20px + var(--safe-b));
  z-index: 600;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--accent);
  color: #13180f;
  border: none;
  border-radius: 999px;
  padding: 14px 20px 14px 16px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, background 0.15s ease;
}
.fab:active { transform: scale(0.95); }
.fab:hover { background: var(--accent-2); }
.fab-plus { font-size: 1.5rem; line-height: 1; font-weight: 400; }

/* ============================================================
   AIDE AU PLACEMENT
   ============================================================ */

.place-hint {
  position: absolute;
  top: calc(64px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  z-index: 650;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--accent);
  color: #13180f;
  padding: 11px 16px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 24px);
  animation: rise 0.3s ease;
}
.place-cancel {
  border: none;
  background: rgba(0,0,0,0.18);
  color: #13180f;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 5px 10px;
  border-radius: 999px;
}
#map.placing { cursor: crosshair; }

/* ============================================================
   BOTTOM SHEET (signalement)
   ============================================================ */

.sheet-backdrop {
  position: absolute;
  inset: 0;
  z-index: 900;
  background: rgba(0,0,0,0.5);
  animation: fade-in 0.25s ease;
}

.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 950;
  background: var(--bg-soft);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 10px 18px calc(20px + var(--safe-b));
  box-shadow: 0 -12px 40px rgba(0,0,0,0.5);
  animation: slide-up 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  max-width: 520px;
  margin: 0 auto;
}
.sheet.leaving { animation: slide-down 0.25s ease forwards; }

.sheet-handle {
  width: 42px; height: 5px;
  background: rgba(255,255,255,0.22);
  border-radius: 999px;
  margin: 4px auto 14px;
}

.sheet-title {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 1.4rem;
  letter-spacing: 0.02em;
  margin: 0 0 16px;
}

.type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.type-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  background: var(--bg);
  border: 2px solid rgba(255,255,255,0.07);
  border-radius: var(--radius);
  padding: 14px;
  text-align: left;
  transition: border-color 0.15s, transform 0.1s, background 0.15s;
}
.type-card:active { transform: scale(0.98); }
.type-card.is-selected {
  border-color: var(--accent);
  background: #243024;
}
.type-dot {
  width: 18px; height: 18px; border-radius: 50%;
  margin-bottom: 4px;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.2);
}
.type-dot.dot-chien { background: transparent; border: 3px solid var(--chien); box-shadow: none; }
.type-name { font-weight: 600; font-size: 0.95rem; color: var(--text); }
.type-desc { font-size: 0.76rem; color: var(--text-dim); }

.chien-option {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 2px 4px;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}
.chien-option input {
  width: 20px; height: 20px;
  accent-color: var(--accent);
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.btn-ghost, .btn-primary {
  flex: 1;
  border: none;
  border-radius: 12px;
  padding: 15px;
  font-size: 0.98rem;
  font-weight: 600;
  transition: transform 0.1s, opacity 0.15s, background 0.15s;
}
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid rgba(255,255,255,0.12);
}
.btn-primary { background: var(--accent); color: #13180f; }
.btn-primary:active, .btn-ghost:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================================================
   MARQUEURS
   ============================================================ */

.vigie-marker {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 3px solid #13180f;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  position: relative;
}
.vigie-marker.m-chasse    { background: var(--chasse); }
.vigie-marker.m-promeneur { background: var(--promeneur); }
.vigie-marker.m-vtt       { background: var(--vtt); }
.vigie-marker.m-chien     { background: #2a352a; border-color: var(--chien); }

.vigie-marker.is-fresh::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid currentColor;
  animation: pulse 2s ease-out infinite;
}
.vigie-marker.m-chasse.is-fresh    { color: var(--chasse); }
.vigie-marker.m-promeneur.is-fresh { color: var(--promeneur); }
.vigie-marker.m-vtt.is-fresh       { color: var(--vtt); }

.vigie-marker .dog-badge {
  position: absolute;
  right: -6px; bottom: -6px;
  font-size: 11px;
  line-height: 1;
  background: #13180f;
  border-radius: 50%;
  padding: 2px;
}

.vigie-marker.stale { opacity: 0.55; }

/* Popups */
.leaflet-popup-content-wrapper {
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,0.08);
}
.leaflet-popup-tip { background: var(--bg-soft); }
.leaflet-popup-content { margin: 12px 14px; font-size: 0.88rem; }
.leaflet-popup-close-button { color: var(--text-dim) !important; }

.popup-type {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
}
.popup-type .dot { width: 11px; height: 11px; }
.popup-label { margin: 2px 0 6px; color: var(--text); }
.popup-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.popup-chien { color: var(--accent-2); font-weight: 500; }

/* ============================================================
   TOAST
   ============================================================ */

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(92px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 1100;
  background: #2a352a;
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 32px);
  text-align: center;
  animation: rise 0.3s ease;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes rise     { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slide-up   { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes slide-down { from { transform: translateY(0); } to { transform: translateY(100%); } }

@keyframes pulse {
  0%   { transform: scale(1);   opacity: 0.8; }
  100% { transform: scale(2.2); opacity: 0; }
}

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

/* ============================================================
   RESPONSIVE — petits écrans
   ============================================================ */

@media (max-width: 380px) {
  .role-btn { font-size: 0.72rem; padding: 7px 10px; }
  .brand-name { font-size: 1.2rem; }
  .fab-label { display: none; }
  .fab { padding: 14px; }
  .fab-plus { font-size: 1.7rem; }
}

/* Légende repliable quand la hauteur est faible (paysage mobile) */
@media (max-height: 480px) {
  .legend-toggle { display: block; margin-bottom: 8px; }
  .legend.collapsed .legend-list { display: none; }
  .legend.collapsed { padding-bottom: 10px; }
}
