/* ===== P6 — CARTE DE GRAND LINE ===== */

/* Bouton header */
.map-header-btn {
  background: none;
  border: 1px solid rgba(200,148,10,0.4);
  color: var(--gold, #c89408);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  transition: border-color .2s, color .2s, transform .15s;
}
.map-header-btn:hover { border-color: var(--gold, #c89408); transform: scale(1.08); }

/* Modal plein écran */
.map-modal {
  position: fixed; inset: 0; z-index: 9990;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: rgba(3,7,14,0.92);
  backdrop-filter: blur(3px);
  padding: 16px;
  animation: jmFadeIn .25s ease;
}
.map-modal.hidden { display: none; }
@keyframes jmFadeIn { from { opacity: 0; } to { opacity: 1; } }

.map-modal-head {
  width: 100%; max-width: 1100px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 10px;
}
.map-modal-title {
  font-family: 'Cinzel Decorative', cursive;
  font-size: clamp(1.1rem, 3vw, 1.6rem);
  color: var(--gold-bright, #ffd84d);
  letter-spacing: .04em;
  text-shadow: 0 0 16px rgba(200,148,8,0.5);
}
#map-progress {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: .82rem; color: rgba(232,213,176,0.7);
  letter-spacing: .04em; margin-top: 2px;
}
#map-progress strong { color: var(--gold-bright, #ffd84d); }
.map-close-btn {
  flex: 0 0 auto;
  background: none; border: 1.5px solid rgba(200,148,10,0.5);
  color: var(--gold, #c89408); border-radius: 50%;
  width: 38px; height: 38px; font-size: 1.1rem; cursor: pointer;
  transition: background .2s, transform .15s;
}
.map-close-btn:hover { background: rgba(200,148,10,0.15); transform: rotate(90deg); }

/* Fenêtre de visualisation (zoom/pan gérés en JS) */
.map-stage {
  position: relative;
  width: 100%; max-width: 1100px;
  overflow: hidden;
  border: 2px solid rgba(200,148,10,0.35);
  border-radius: 10px;
  box-shadow: 0 0 40px rgba(0,0,0,0.6), inset 0 0 60px rgba(0,0,0,0.4);
  cursor: grab;
  touch-action: none;          /* pan/pinch gérés à la main */
}
.map-stage.jm-grabbing { cursor: grabbing; }

/* Carte = image de fond + overlay SVG (l'élément zoomé/déplacé) */
#map-canvas {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  transform-origin: 0 0;
  will-change: transform;
  background-color: #0b1f33;
  background-image: linear-gradient(rgba(4,10,20,0.42), rgba(4,10,20,0.42)), url('../images/carte.jpeg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* Contrôles de zoom */
.map-zoom-ctrls {
  position: absolute; right: 10px; bottom: 10px; z-index: 6;
  display: flex; flex-direction: column; gap: 6px;
}
.map-zoom-ctrls button {
  width: 34px; height: 34px;
  background: rgba(10,20,34,0.85);
  border: 1.5px solid rgba(200,148,10,0.5);
  color: var(--gold-bright, #ffd84d);
  border-radius: 8px; font-size: 1.1rem; line-height: 1;
  cursor: pointer; font-family: 'Barlow Condensed', sans-serif;
  transition: background .15s, transform .1s;
}
.map-zoom-ctrls button:hover  { background: rgba(200,148,10,0.25); transform: scale(1.06); }
.map-zoom-ctrls button:active { transform: scale(0.95); }

.jm-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

/* Pastilles d'îles */
.jm-pin { cursor: pointer; outline: none; }
.jm-halo { fill: transparent; }
.jm-dot  { stroke-width: 2; transition: r .15s; }

.jm-pin--off .jm-dot { fill: #2a3340; stroke: rgba(232,213,176,0.35); }
.jm-pin--off .jm-lock { font-size: 9px; opacity: .8; }

.jm-pin--on .jm-dot {
  fill: #b8860b; stroke: var(--gold-bright, #ffd84d);
  filter: drop-shadow(0 0 5px rgba(255,216,77,0.7));
}
.jm-pin--on .jm-flag { font-size: 11px; }
.jm-flag, .jm-lock { dominant-baseline: middle; pointer-events: none; }

.jm-pin:hover .jm-dot, .jm-pin:focus .jm-dot { r: 12; }
.jm-pin:focus .jm-halo { fill: rgba(255,216,77,0.18); }

/* Île courante (dernière débloquée) : pulse + bateau */
.jm-pin--here .jm-halo {
  fill: rgba(255,216,77,0.22);
  animation: jmPulse 1.8s ease-in-out infinite;
}
@keyframes jmPulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }
.jm-boat { font-size: 20px; animation: jmBoat 2.4s ease-in-out infinite; }
@keyframes jmBoat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

/* Tooltip */
.jm-tip {
  position: absolute; transform: translate(-50%, calc(-100% - 14px));
  background: #0a1422; border: 1.5px solid rgba(200,148,10,0.55);
  border-radius: 8px; padding: 7px 11px;
  pointer-events: none; z-index: 5;
  display: flex; flex-direction: column; gap: 2px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.6);
  white-space: nowrap;
  font-family: 'Barlow Condensed', sans-serif;
}
.jm-tip-arc { font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: rgba(232,213,176,0.5); }
.jm-tip strong { font-size: .98rem; color: var(--gold-bright, #ffd84d); }
.jm-tip-state { font-size: .76rem; color: rgba(232,213,176,0.7); }
.jm-tip-state--on { color: #5fd98a; }

.map-hint {
  width: 100%; max-width: 1100px; margin-top: 8px;
  text-align: center; font-family: 'Barlow Condensed', sans-serif;
  font-size: .72rem; color: rgba(232,213,176,0.4); letter-spacing: .04em;
}

@media (prefers-reduced-motion: reduce) {
  .jm-pin--here .jm-halo, .jm-boat, .map-modal { animation: none; }
}

/* ── Dossier d'arc (B carnet de capture + E compteur communauté) ── */
.map-dossier {
  position: absolute; inset: 0; z-index: 10;
  background: linear-gradient(180deg, #07111f, #03070e);
  border-radius: 10px;
  overflow-y: auto;
  padding: 16px 18px 24px;
  animation: jmFadeIn .2s ease;
}
.map-dossier.hidden { display: none; }

.jm-dossier-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.jm-dossier-back {
  flex: 0 0 auto;
  background: rgba(200,148,10,0.12); color: var(--gold-bright, #ffd84d);
  border: 1.5px solid rgba(200,148,10,0.45); border-radius: 20px;
  padding: 6px 14px; font-family: 'Barlow Condensed', sans-serif; font-size: .9rem;
  cursor: pointer; transition: background .15s;
}
.jm-dossier-back:hover { background: rgba(200,148,10,0.25); }
.jm-dossier-arc { font-family: 'Barlow Condensed', sans-serif; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: rgba(232,213,176,0.5); }
.jm-dossier-title { font-family: 'Cinzel Decorative', cursive; font-size: 1.35rem; color: var(--gold-bright, #ffd84d); line-height: 1.1; }

.jm-dossier-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 16px; font-family: 'Barlow Condensed', sans-serif; font-size: .92rem; }
.jm-dossier-capture { color: #ffd84d; font-weight: 700; }
.jm-dossier-community { color: rgba(232,213,176,0.7); }

.jm-dossier-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.jm-char {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  background: rgba(255,255,255,0.03); border: 1px solid rgba(200,148,10,0.18);
  border-radius: 8px; padding: 8px 6px;
}
.jm-char img, .jm-char-noimg { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; object-position: center top; border-radius: 6px; display: block; }
.jm-char-noimg { display: flex; align-items: center; justify-content: center; font-size: 1.9rem; background: #0a1422; color: rgba(232,213,176,0.3); }
.jm-char-name { font-family: 'Barlow Condensed', sans-serif; font-size: .76rem; text-align: center; line-height: 1.05; color: var(--text2, #e8d5b0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* Capturé = net & cliquable · Non capturé = silhouette sombre */
.jm-char--on { border-color: rgba(200,148,10,0.5); cursor: pointer; transition: transform .12s, box-shadow .12s; }
.jm-char--on:hover, .jm-char--on:focus { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,0.5); outline: none; }
.jm-char--off { cursor: default; }
.jm-char--off img { filter: grayscale(1) brightness(0.3); opacity: .8; }
.jm-char--off .jm-char-name { color: rgba(232,213,176,0.4); letter-spacing: .18em; }

.jm-dossier-empty { grid-column: 1 / -1; text-align: center; color: rgba(232,213,176,0.5); padding: 30px 0; font-family: 'Barlow Condensed', sans-serif; }

/* ── Fiche personnage (clic sur un perso capturé) ── */
.map-charsheet {
  position: absolute; inset: 0; z-index: 11;
  background: linear-gradient(180deg, #081627, #03070e);
  border-radius: 10px; overflow-y: auto;
  padding: 16px 18px 24px;
  animation: jmFadeIn .2s ease;
}
.map-charsheet.hidden { display: none; }
.jm-cs-head { margin-bottom: 14px; }
.jm-cs-back {
  background: rgba(200,148,10,0.12); color: var(--gold-bright, #ffd84d);
  border: 1.5px solid rgba(200,148,10,0.45); border-radius: 20px;
  padding: 6px 14px; font-family: 'Barlow Condensed', sans-serif; font-size: .9rem;
  cursor: pointer; transition: background .15s;
}
.jm-cs-back:hover { background: rgba(200,148,10,0.25); }
.jm-cs-body { display: flex; gap: 18px; flex-wrap: wrap; }
.jm-cs-media { flex: 0 0 200px; }
.jm-cs-media img, .jm-cs-noimg {
  width: 200px; height: 200px; object-fit: cover; object-position: center top; border-radius: 10px;
  border: 2px solid rgba(200,148,10,0.4); display: block;
}
.jm-cs-noimg { display: flex; align-items: center; justify-content: center; font-size: 4rem; background: #0a1422; color: rgba(232,213,176,0.3); }
.jm-cs-main { flex: 1; min-width: 240px; }
.jm-cs-name { font-family: 'Cinzel Decorative', cursive; font-size: 1.55rem; color: var(--gold-bright, #ffd84d); line-height: 1.1; }
.jm-cs-epithet { font-family: 'Barlow Condensed', sans-serif; font-style: italic; color: rgba(232,213,176,0.75); margin: 2px 0 14px; font-size: 1rem; }
.jm-cs-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.jm-cs-row { display: flex; flex-direction: column; gap: 1px; padding: 6px 0; border-bottom: 1px solid rgba(200,148,10,0.12); }
.jm-cs-key { font-family: 'Barlow Condensed', sans-serif; font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: rgba(232,213,176,0.5); }
.jm-cs-val { font-family: 'Barlow Condensed', sans-serif; font-size: .98rem; color: var(--text2, #e8d5b0); }
.jm-cs-emoji { margin-top: 16px; font-size: 1.55rem; letter-spacing: 4px; line-height: 1.6; }

@media (prefers-reduced-motion: reduce) { .map-dossier, .map-charsheet { animation: none; } }
@media (max-width: 700px) {
  .jm-cs-media { flex: 0 0 100%; }
  .jm-cs-media img, .jm-cs-noimg { width: 100%; height: auto; aspect-ratio: 1 / 1; }
  .jm-cs-rows { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .map-modal { padding: 8px; }
  .map-modal-title { font-size: 1.1rem; }
  .jm-dossier-grid { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
}
