/* Modales, toasts, marqueurs de la carte, bouton de thème. (chargé après 02-game.css, l'ordre compte pour la cascade) */

/* ---------- Modale ---------- */
/* iOS (Safari et Chrome) : 100vh compte la zone sous les barres du navigateur ; on borne avec 100dvh et les encoches */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.modal-card {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-2);
  max-height: 90vh;
  max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
/* WebKit : sans ça, les lignes du menu se tassent et se chevauchent au lieu de faire défiler la carte */
.modal-card > * {
  flex-shrink: 0;
}
#confirmModal {
  z-index: 2100;
} /* au-dessus du menu et des autres fenêtres */
.confirm-card {
  gap: 18px;
}
.confirm-text {
  margin: 0;
  white-space: pre-line;
  font-size: 1rem;
  line-height: 1.45;
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-card h2 {
  margin: 0;
  font: 800 1.6rem var(--cond);
  text-transform: uppercase;
}
.list-item {
  font: inherit;
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 12px 8px;
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius);
  text-align: left;
}
.list-item:hover {
  background: var(--surface-2);
}
.list-item .ic {
  color: var(--muted);
}
.list-item.danger,
.list-item.danger .ic {
  color: var(--danger-text);
}
.log {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
  max-height: 35vh;
  overflow: auto;
}
.log li {
  padding: 6px 0;
  border-bottom: 1px solid var(--surface-2);
}
.log time {
  color: var(--muted);
  margin-right: 8px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Notifications (façon notification système ; maquettes : docs/design/annonces/) ---------- */
#topbar > #toasts {
  display: grid;
  pointer-events: none;
  --notif-bg: rgba(255, 255, 255, 0.86);
  --notif-text: #0e0e0e;
  --notif-sub: #4a4740;
  --notif-head: #8a877f;
  --notif-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.45), 0 0 0 0.5px rgba(0, 0, 0, 0.08);
}
:root[data-theme='dark'] #topbar > #toasts {
  --notif-bg: rgba(30, 31, 33, 0.9);
  --notif-text: #f2efe8;
  --notif-sub: #c9c6bf;
  --notif-head: #8e8a80;
  --notif-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.8), 0 0 0 0.5px rgba(255, 255, 255, 0.08);
}
.notif {
  --i: 0;
  --drag: 0px;
  grid-area: 1 / 1;
  align-self: start;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  background: var(--notif-bg);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  backdrop-filter: blur(18px) saturate(1.6);
  color: var(--notif-text);
  border-radius: var(--radius);
  padding: 8px 12px 11px;
  box-shadow: var(--notif-shadow);
  transform-origin: 50% 0;
  transform: translateY(calc(var(--i) * 9px + var(--drag))) scale(calc(1 - var(--i) * 0.05));
  transition:
    transform 0.32s cubic-bezier(0.2, 0.9, 0.3, 1),
    opacity 0.32s ease;
  animation: notif-in 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.25) both;
}
.notif.behind {
  opacity: 0.8;
}
.notif.behind:nth-child(3) {
  opacity: 0.5;
}
.notif.behind .notif-body,
.notif.behind .notif-head,
.notif.behind .notif-bar {
  opacity: 0;
  transition: opacity 0.2s;
}
.notif.held {
  transition: none;
}
.notif.out {
  opacity: 0;
  transform: translateY(calc(var(--drag) - 30%)) scale(0.96);
  pointer-events: none;
}
.notif.out.up {
  transform: translateY(-140%);
}
@keyframes notif-in {
  0% {
    opacity: 0;
    translate: 0 -120%;
  }
  40% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    translate: 0 0;
  }
}
.notif-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--notif-head);
  margin-bottom: 5px;
}
.notif-body {
  display: flex;
  align-items: center;
  gap: 10px;
}
.notif-ic {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: var(--k);
  color: #fff;
  display: grid;
  place-items: center;
}
.notif-ic .ic {
  width: 19px;
  height: 19px;
}
.notif-ic.initial {
  border-radius: 50%;
  font: 800 16px/1 var(--cond);
}
:root[data-theme='dark'] .notif.k-master .notif-ic {
  background: #eeeae1;
  color: #121314;
}
.notif-tx {
  min-width: 0;
  flex: 1;
  font-size: 0.86rem;
  line-height: 1.28;
}
.notif-tx b {
  display: block;
  font: 700 0.98rem/1.1 var(--cond);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.notif-tx b + span {
  color: var(--notif-sub);
}
.notif-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  background: var(--k);
  transform-origin: 0 50%;
  animation: notif-bar var(--ms) linear forwards;
}
.notif.held .notif-bar {
  animation-play-state: paused;
}
@keyframes notif-bar {
  to {
    transform: scaleX(0);
  }
}
/* petites animations dans l'icône, selon la famille */
.notif.k-zone .notif-ic .ic {
  animation: notif-zone 1.4s ease-in-out 3;
}
@keyframes notif-zone {
  0% {
    transform: scale(1.3);
    opacity: 0.4;
  }
  60%,
  100% {
    transform: scale(0.8);
    opacity: 1;
  }
}
.notif.k-drop .notif-ic .ic {
  animation: notif-drop 0.7s 0.2s both;
}
@keyframes notif-drop {
  0% {
    transform: translateY(-16px);
    animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45);
  }
  55% {
    transform: translateY(0) scale(1.2, 0.8);
  }
  75% {
    transform: translateY(-4px) scale(0.95, 1.05);
  }
  100% {
    transform: none;
  }
}
.notif.k-card .notif-ic {
  animation: notif-flip 0.7s 0.25s both;
}
@keyframes notif-flip {
  0% {
    transform: perspective(120px) rotateY(180deg);
    background: repeating-linear-gradient(45deg, #fff 0 3px, var(--k) 3px 6px);
  }
  49% {
    background: repeating-linear-gradient(45deg, #fff 0 3px, var(--k) 3px 6px);
  }
  50% {
    background: var(--k);
  }
  100% {
    transform: perspective(120px) rotateY(0);
  }
}
.notif.k-danger:not(.behind) .notif-body,
.notif.k-capture:not(.behind) .notif-body {
  animation: notif-shake 0.5s 0.45s;
}
@keyframes notif-shake {
  20% {
    translate: -4px 0;
  }
  40% {
    translate: 4px 0;
  }
  60% {
    translate: -3px 0;
  }
  80% {
    translate: 2px 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .notif,
  .notif *,
  .notif-ic {
    animation-name: none !important;
  }
  .notif .notif-bar {
    animation-name: notif-bar !important;
  }
}

/* ---------- Marqueurs carte : pictos au trait, sans pastille ---------- */
.pin {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  box-shadow:
    0 0 0 2.5px #fff,
    0 1px 4px rgba(0, 0, 0, 0.35);
  margin: 3px;
}
.pin.me {
  background: var(--text);
  box-shadow:
    0 0 0 2.5px #fff,
    0 0 0 8px rgba(14, 14, 14, 0.16);
}
.pin.hunter {
  background: var(--hunter);
}
.pin.tracked {
  background: var(--danger);
  box-shadow:
    0 0 0 2.5px #fff,
    0 0 0 8px rgba(227, 23, 30, 0.18);
}
.pin.spectator {
  background: var(--spectator);
}
.pin.stale {
  opacity: 0.5;
}
.pin-label {
  background: var(--text);
  color: var(--bg);
  border: none;
  box-shadow: none;
  font: 700 11px/1.35 var(--cond);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 1px 6px 0;
  border-radius: 2px;
}
.pin-label::before {
  display: none;
}
.pin-label.rev {
  background: var(--danger);
  color: #fff;
}
.pin-label.rev b {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.pin-label.old {
  background: transparent;
  color: var(--danger);
  text-shadow:
    0 0 3px #fff,
    0 0 3px #fff;
  padding: 0;
}
/* pictos posés sur la carte : un liseré clair pour rester lisibles sur le plan comme sur le satellite */
.pic {
  color: var(--obj);
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  filter: drop-shadow(0 0 1.2px #fff) drop-shadow(0 0 1.2px #fff) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
}
.pic .ic {
  width: 100%;
  height: 100%;
  stroke-width: 2.1;
}
.obj-pin {
  color: var(--obj);
}
.obj-pin b {
  position: absolute;
  left: 68%;
  top: -2px;
  font: 800 13px var(--cond);
  color: var(--text);
  text-shadow:
    0 0 3px #fff,
    0 0 3px #fff;
}
.obj-pin.done {
  color: #9a978e;
}
.reveal-pin {
  color: var(--danger);
  align-items: center;
  justify-content: center;
}
.reveal-pin.old {
  opacity: 0.45;
}
.reveal-pin.fuzzy .ic {
  stroke-dasharray: 2.6 2.6;
}
.reveal-pin.fake {
  color: var(--spectator);
}
.zone-pin {
  color: var(--zone);
  align-items: center;
  justify-content: center;
}
.zone-grab {
  cursor: ew-resize;
}
/* Périmètre dessiné : coins déplaçables (grande zone d'appui, petit rond visible) et « + » au milieu des côtés */
.zone-vertex,
.zone-mid {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
}
.zone-vertex::after {
  content: '';
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--zone);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
.zone-mid .ic {
  width: 16px;
  height: 16px;
  padding: 2px;
  border-radius: 50%;
  background: var(--zone);
  color: #fff;
  opacity: 0.75;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.zone-vertex.fz::after {
  border-color: var(--danger);
}
.zone-mid.fz .ic {
  background: var(--danger);
}
.zone-size {
  position: absolute;
  transform: translate(-50%, -150%);
  white-space: nowrap;
  background: var(--zone);
  color: var(--bg);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 3px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.zone-size.fz {
  background: var(--danger);
}
/* Poubelle : apparaît pendant qu'on glisse un point d'objectif */
.map-trash {
  position: absolute;
  left: 50%;
  bottom: calc(var(--sheet-h) + 18px);
  transform: translateX(-50%);
  z-index: 1001;
  pointer-events: none;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--danger);
  border: 2px solid var(--danger);
  box-shadow: var(--shadow-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.15s,
    background 0.15s,
    color 0.15s;
}
.map-trash .ic {
  width: 30px;
  height: 30px;
}
.map-trash.over {
  background: var(--danger);
  color: #fff;
  transform: translateX(-50%) scale(1.2);
}

/* ---------- Bouton de thème sur l'accueil ---------- */
.theme-toggle {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  background: var(--surface-2);
  color: var(--text);
}

/* Bandeau « nouvelle version disponible » (sos.js) */
.update-bar {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 3000;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 16px;
  border-radius: 999px;
  background: var(--text, #1b1d1f);
  color: var(--bg, #fff);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
