/* ========== MAP CONTAINER ========== */
.map-page { padding: 0; max-width: 100%; }

.map-wrapper {
  position: relative;
  width: 100%;
  background: #060d1a;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}

.map-svg {
  width: 100%;
  display: block;
  cursor: grab;
}
.map-svg:active { cursor: grabbing; }

/* ========== COUNTRY PATHS ========== */
.country {
  fill: #1d2d44;
  stroke: #0a0f1e;
  stroke-width: 0.5px;
  transition: fill 0.15s ease;
  cursor: pointer;
}
.country:hover { fill: #3a4f6a; }
.country.selected {
  fill: #3b82f6 !important;
  stroke: #fff;
  stroke-width: 2px;
  opacity: 1 !important;
  animation: mapSelected 2s ease-in-out infinite;
}
.country.correct {
  fill: var(--success) !important;
  stroke: #6ee7b7;
  stroke-width: 1.5px;
  animation: mapCorrect 0.5s ease;
}
.country.wrong {
  fill: var(--error) !important;
  stroke: #fca5a5;
  stroke-width: 1.5px;
  animation: mapWrong 0.4s ease;
}
.country.target {
  fill: var(--warning) !important;
  stroke: #fcd34d;
  stroke-width: 2px;
  animation: mapTarget 1.2s ease-in-out infinite;
}
.country.dimmed { fill: #111e30; opacity: 0.6; }
g.country-marker.dimmed circle { cursor: default !important; }
.country.continent-active { fill: #1d3555; }
.country.africa-color:hover { fill: rgba(249,115,22,0.5); }
.country.americas-color:hover { fill: rgba(34,197,94,0.5); }
.country.asia-color:hover { fill: rgba(236,72,153,0.5); }
.country.europe-color:hover { fill: rgba(99,102,241,0.5); }
.country.oceania-color:hover { fill: rgba(6,182,212,0.5); }

/* Graticule (grid lines) */
.graticule {
  fill: none;
  stroke: rgba(255, 255, 255, 0.04);
  stroke-width: 0.5px;
}
.sphere { fill: #060d1a; }
.borders {
  fill: none;
  stroke: #0a0f1e;
  stroke-width: 1px;
  pointer-events: none;
}

/* ========== MAP TOOLTIP ========== */
.map-tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: opacity 0.1s ease;
  white-space: normal;
  max-width: 220px;
  overflow-wrap: break-word;
}
.map-tooltip .fi { width: 28px !important; height: 19px !important; background-size: cover !important; border-radius: 2px; flex-shrink: 0; }
.map-tooltip-name { color: var(--text-primary); }
.map-tooltip.hidden { opacity: 0; }

/* ========== MAP INFO PANEL ========== */
.map-info-panel {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 240px;
  background: rgba(26, 34, 52, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-lg);
  animation: panelSlideIn 0.25s ease;
  z-index: 200;
}
@keyframes panelSlideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

.map-info-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.map-info-close {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  flex-shrink: 0;
  transition: all var(--transition);
}
.map-info-close:hover { background: var(--border-hover); color: var(--text-primary); }

.map-info-flag { margin-bottom: 0.75rem; }
.map-info-flag .fi { width: 100% !important; height: 70px !important; background-size: contain !important; background-repeat: no-repeat !important; background-position: center !important; border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); display: block; }

.map-info-name { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.15rem; word-break: break-word; overflow-wrap: break-word; }
.map-info-name-en { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.map-info-details { display: flex; flex-direction: column; gap: 0.4rem; }
.map-info-row { display: flex; justify-content: space-between; font-size: 0.8rem; }
.map-info-row-label { color: var(--text-muted); }
.map-info-row-value { font-weight: 600; text-align: right; }

.map-info-details-btn {
  display: block;
  width: 100%;
  margin-top: 0.9rem;
  padding: 0.45rem 0.75rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.map-info-details-btn:hover { filter: brightness(1.1); }

/* ========== MAP CONTROLS ========== */
.map-controls {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  z-index: 200;
}
.map-ctrl-btn {
  width: 36px; height: 36px;
  background: rgba(26, 34, 52, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  backdrop-filter: blur(8px);
}
.map-ctrl-btn:hover { background: var(--bg-surface); color: var(--text-primary); border-color: var(--border-hover); }

/* ========== LEFT PANEL (continent + label buttons) ========== */
.map-left-panel {
  position: absolute;
  top: 1rem;
  left: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  z-index: 200;
}

/* ========== CONTINENT FILTER BUTTONS ========== */
.map-continent-btns {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.map-continent-btn {
  padding: 0.4rem 0.75rem;
  background: rgba(26, 34, 52, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  backdrop-filter: blur(8px);
  white-space: nowrap;
}
.map-continent-btn:hover { color: var(--text-primary); border-color: var(--border-hover); }
.map-continent-btn.active-africa { color: var(--africa); border-color: var(--africa); background: rgba(249,115,22,0.15); }
.map-continent-btn.active-americas { color: var(--americas); border-color: var(--americas); background: rgba(34,197,94,0.15); }
.map-continent-btn.active-asia { color: var(--asia); border-color: var(--asia); background: rgba(236,72,153,0.15); }
.map-continent-btn.active-europe { color: var(--europe); border-color: var(--europe); background: rgba(99,102,241,0.15); }
.map-continent-btn.active-oceania { color: var(--oceania); border-color: var(--oceania); background: rgba(6,182,212,0.15); }
.map-continent-btn.active-all { color: var(--accent-light); border-color: var(--accent); background: rgba(79,99,255,0.15); }

/* ========== MAP SEARCH BAR ========== */
.map-search-bar {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  z-index: 300;
}
.map-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 1rem;
  background: rgba(26, 34, 52, 0.95);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: var(--font);
  backdrop-filter: blur(10px);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.map-search-input::placeholder { color: var(--text-muted); }
.map-search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,99,255,0.18); }

.map-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: rgba(20, 28, 45, 0.98);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.map-search-results.hidden { display: none; }

.map-search-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  transition: background var(--transition);
}
.map-search-item:hover { background: rgba(79,99,255,0.12); }
.map-search-flag { width: 22px !important; height: 15px !important; background-size: cover !important; border-radius: 2px; flex-shrink: 0; }
.map-search-item-name { font-size: 0.82rem; font-weight: 600; flex: 1; }
.map-search-item-capital { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }

/* ========== QUIZ MAP OVERLAY ========== */
.quiz-map-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 100%;
}
.quiz-map-question-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.quiz-map-prompt {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.quiz-map-prompt-label { font-size: 0.82rem; color: var(--text-muted); font-weight: 500; }
.quiz-map-prompt-value { font-size: 1.25rem; font-weight: 700; }
.quiz-map-prompt .fi { display: block; width: 72px !important; height: 48px !important; background-size: cover !important; border-radius: 4px; }

/* Nightmare map bar : grille 3 colonnes pour centrer le prompt */
#nightmareMapBar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
#nightmareMapBar .quiz-map-prompt {
  justify-content: center;
}
#nightmareMapBar .quiz-map-prompt > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
#nightmareMapBar #mapFeedback {
  justify-self: end;
}

/* Steps en mode map : horizontaux, compacts, sans marge basse */
.nightmare-steps--map {
  margin-bottom: 0.5rem;
  flex-wrap: nowrap;
}
.nightmare-steps--map .nightmare-step {
  padding: 0.4rem 0.75rem;
  flex-direction: row;
  gap: 0.4rem;
}
.nightmare-steps--map .nightmare-step-label {
  font-size: 0.75rem;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.quiz-map-feedback {
  font-size: 1rem;
  font-weight: 700;
  padding: 0.4rem 1rem;
  border-radius: var(--radius-full);
  transition: all 0.3s ease;
}
.quiz-map-feedback.correct { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.quiz-map-feedback.wrong { background: var(--error-bg); color: var(--error); border: 1px solid var(--error-border); }
.quiz-map-feedback.empty { opacity: 0; }

.map-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  font-size: 1rem;
  color: var(--text-secondary);
  gap: 0.75rem;
}
.map-loading-spinner {
  font-size: 2rem;
  animation: spin 1.5s linear infinite;
  display: inline-block;
}

/* ========== QUIZ MAP PROGRESS ========== */
.quiz-map-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

/* ========== ANIMATIONS ========== */
@keyframes mapSelected {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}
@keyframes mapCorrect {
  0% { filter: brightness(1); }
  40% { filter: brightness(1.5); }
  100% { filter: brightness(1); }
}
@keyframes mapWrong {
  0%, 100% { transform: none; }
  25% { filter: brightness(1.3); }
}
@keyframes mapTarget {
  0%, 100% { opacity: 1; filter: brightness(1); }
  50% { opacity: 0.7; filter: brightness(1.4); }
}

/* ========== MAP LABELS ========== */
.map-labels-g { pointer-events: none; }
.map-label-name {
  font-size: 9px;
  fill: #e2e8f0;
  font-family: var(--font);
  font-weight: 600;
  paint-order: stroke;
  stroke: #060d1a;
  stroke-width: 2.5px;
  stroke-linejoin: round;
}
.map-label-capital {
  font-size: 7.5px;
  fill: #94a3b8;
  font-family: var(--font);
  font-weight: 500;
  paint-order: stroke;
  stroke: #060d1a;
  stroke-width: 2px;
  stroke-linejoin: round;
}

/* ========== LABEL TOGGLE BUTTONS ========== */
.map-label-btns {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.map-label-btn {
  padding: 0.3rem 0.65rem;
  background: rgba(26, 34, 52, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  backdrop-filter: blur(8px);
  white-space: nowrap;
}
.map-label-btn:hover { color: var(--text-primary); border-color: var(--border-hover); }
.map-label-btn.active { color: var(--accent-light); border-color: var(--accent); background: rgba(79,99,255,0.15); }

/* ========== RESPONSIVE MAP ========== */
@media (max-width: 768px) {
  .map-info-panel { width: 220px; padding: 0.9rem; }
  .map-left-panel { display: none; }
  .quiz-map-question-bar { padding: 0.75rem 1rem; }
  #quizMapWrapper { min-height: 55vw; }
}

@media (max-width: 540px) {
  .map-info-panel {
    width: calc(100% - 1.5rem);
    max-width: 300px;
    top: auto;
    bottom: 3.5rem;
    right: 0.75rem;
    left: auto;
    padding: 0.75rem;
    max-height: 50vh;
    overflow-y: auto;
  }
  .map-search-bar {
    width: calc(100% - 2rem);
    max-width: 240px;
  }
  .map-controls {
    bottom: 0.75rem;
    left: 0.75rem;
  }
  .map-ctrl-btn { width: 32px; height: 32px; font-size: 0.9rem; }
  .map-info-name { font-size: 0.95rem; }
  .map-info-flag .fi { height: 55px !important; }
  .quiz-map-prompt-value { font-size: 1rem; }
  .quiz-map-prompt .fi { width: 56px !important; height: 37px !important; }
}

@media (max-width: 380px) {
  .map-search-bar { max-width: 200px; }
  .map-info-panel { max-width: calc(100% - 1rem); right: 0.5rem; }
}
