/* ──────────────────────────────────────────────
   UPSCALE — Map Master Game CSS
────────────────────────────────────────────── */

/* ── Home page ── */
.mm-page { max-width: 900px; margin: 0 auto; padding: 32px 16px 60px; }

.mm-category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 40px;
}

.mm-cat-card {
  padding: 32px 24px;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  display: block;
  transition: transform var(--transition-base), box-shadow var(--transition-base);
  border-radius: var(--radius-lg);
}
.mm-cat-card:hover { transform: translateY(-4px); }

.mm-cat-glow {
  position: absolute; top: -30px; right: -30px;
  width: 120px; height: 120px;
  border-radius: 50%; opacity: 0.12; filter: blur(30px);
  pointer-events: none;
}
.mm-cat-card.indigo .mm-cat-glow { background: var(--indigo); }
.mm-cat-card.gold   .mm-cat-glow { background: var(--gold); }
.mm-cat-card.emerald .mm-cat-glow { background: var(--emerald); }
.mm-cat-card.purple .mm-cat-glow { background: var(--purple); }
.mm-cat-card.rose   .mm-cat-glow { background: var(--rose); }
.mm-cat-card.amber  .mm-cat-glow { background: var(--amber); }

.mm-cat-top-bar {
  height: 3px; border-radius: 3px 3px 0 0;
  position: absolute; top: 0; left: 0; right: 0;
}
.mm-cat-card.indigo  .mm-cat-top-bar { background: var(--indigo); }
.mm-cat-card.gold    .mm-cat-top-bar { background: var(--gold); }
.mm-cat-card.emerald .mm-cat-top-bar { background: var(--emerald); }
.mm-cat-card.purple  .mm-cat-top-bar { background: var(--purple); }
.mm-cat-card.rose    .mm-cat-top-bar { background: var(--rose); }
.mm-cat-card.amber   .mm-cat-top-bar { background: var(--amber); }

.mm-cat-lock {
  position: absolute; inset: 0;
  border-radius: var(--radius-lg);
  background: var(--scrim-bg);
  backdrop-filter: blur(3px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px; z-index: 3;
}

.mm-cat-icon { font-size: 40px; margin-bottom: 14px; }
.mm-cat-name { font-family: var(--font-display); font-size: 20px; font-weight: 700; margin-bottom: 6px; color: var(--text-primary); }
.mm-cat-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; line-height: 1.5; }

.mm-cat-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.mm-cat-stat {
  font-size: 12px; padding: 3px 10px;
  border-radius: var(--radius-full);
  background: rgba(var(--overlay-rgb), 0.06);
  color: var(--text-muted);
}
.mm-in-progress-badge {
  font-size: 10px; font-weight: 700; padding: 3px 8px;
  border-radius: var(--radius-full);
  background: rgba(var(--gold-rgb), 0.2); color: var(--gold);
  border: 1px solid rgba(var(--gold-rgb), 0.3);
  animation: pulseBadge 2s ease-in-out infinite;
}
@keyframes pulseBadge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ── Game page layout ── */
.mm-game-page {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ── */
.mm-header {
  flex-shrink: 0;
  z-index: 500;
  margin: 14px auto 0;
  width: min(1100px, calc(100% - 28px));
  padding: 12px 18px;
  display: flex; align-items: center; gap: 16px;
  background: #fff;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-card);
}
.mm-header-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mm-header-center { flex: 1; display: flex; justify-content: center; }
.mm-header-right { display: flex; align-items: center; }

.mm-logo {
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
  display: flex; align-items: center; gap: 8px;
}
.mm-logo .clay { flex: none; }

.mm-category-chip {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--m-map-master-tint);
  border: 0;
  color: var(--m-map-master-text);
  white-space: nowrap;
}

.mm-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--ink-2);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.mm-close:hover { background: var(--m-map-master-tint); color: var(--ink); }

/* Progress pips */
.mm-progress { display: flex; gap: 6px; align-items: center; }
.mm-pip {
  width: 28px; height: 5px; border-radius: 3px;
  background: rgba(var(--overlay-rgb), 0.1);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}
.mm-pip.done   { background: var(--accent); }
.mm-pip.active { background: var(--color-bolt); box-shadow: 0 0 7px rgba(212,154,96,0.5); }

.mm-q-counter {
  font-size: 13px; font-weight: 700;
  color: var(--text-muted); white-space: nowrap;
}

/* ── Body: two-column ── */
.mm-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 0;
  min-height: 0;
  overflow: hidden;
}

/* ── Map ── */
.mm-map-wrap {
  position: relative;
  background: #080C18;
}
#mm-map {
  width: 100%;
  height: calc(100vh - 58px);
  background: #080C18 !important;
}
/* Map tile background is a deliberate "dark ocean" map style, independent
   of the app theme (like a map product's own light/dark map skin) — but a
   near-black square still needs to not clash with a paper-toned UI shell,
   so light theme gets a softer ink-toned "ocean" instead of pure near-black. */
[data-theme="light"] .mm-map-wrap,
[data-theme="light"] #mm-map,
[data-theme="light"] .leaflet-container {
  background: #DCE6EC !important;
}

/* Override leaflet default blue focus */
.leaflet-container {
  background: #080C18 !important;
  font-family: var(--font-body);
}
.leaflet-control-zoom a {
  background: var(--bg-surface) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border-subtle) !important;
}
.leaflet-control-zoom a:hover {
  background: rgba(30, 40, 70, 0.95) !important;
  color: var(--text-primary) !important;
}
[data-theme="light"] .leaflet-control-zoom a {
  background: rgba(255, 255, 255, 0.9) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border-subtle) !important;
}
[data-theme="light"] .leaflet-control-zoom a:hover {
  background: #FFFFFF !important;
  color: var(--text-primary) !important;
}

.mm-map-instruction {
  position: absolute;
  bottom: 16px; left: 50%; transform: translateX(-50%);
  padding: 8px 16px;
  background: var(--scrim-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  backdrop-filter: blur(8px);
  white-space: nowrap;
  pointer-events: none;
  z-index: 400;
  transition: opacity var(--transition-base);
}
/* --scrim-bg is a dark brown at 55% in light theme, so the muted text on it
   was unreadable over the pale map. Light theme gets a paper-toned pill. */
[data-theme="light"] .mm-map-instruction {
  background: rgba(255, 255, 255, 0.92);
  border-color: var(--border-rule);
  color: var(--text-secondary);
  box-shadow: 0 2px 10px rgba(28, 23, 14, 0.12);
}
.mm-map-instruction.hidden { opacity: 0; }

/* ── Right panel ── */
.mm-panel {
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 24px 20px;
  gap: 16px;
}

/* Question card */
.mm-question-card {
  background: #fff;
  border: 0;
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  padding: 20px;
}
.mm-question-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-muted); margin-bottom: 10px;
}
.mm-question-text {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 700;
  line-height: 1.4; color: var(--text-primary);
  margin-bottom: 12px;
}
.mm-question-meta-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
}
.mm-question-meta-row:has(.mm-difficulty:only-child) {
  justify-content: flex-end;
}
.mm-hint-toggle {
  font-size: 12px; color: var(--indigo-light); cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  transition: color var(--transition-fast);
}
.mm-hint-toggle:hover { color: var(--indigo); }
.mm-hint-text {
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.5; margin-top: 8px;
  display: none;
  padding: 10px 14px;
  background: var(--m-map-master-tint);
  border: 0;
  border-radius: 12px;
}
.mm-hint-text.visible { display: block; }

.mm-difficulty {
  display: inline-block; flex-shrink: 0;
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px;
  padding: 3px 8px; border-radius: var(--radius-full); text-transform: uppercase;
}
.mm-difficulty.easy   { background: rgba(var(--emerald-rgb),0.15); color: var(--emerald); border: 1px solid rgba(var(--emerald-rgb),0.3); }
.mm-difficulty.medium { background: rgba(var(--gold-rgb),0.15); color: var(--gold);    border: 1px solid rgba(var(--gold-rgb),0.3); }
.mm-difficulty.hard   { background: rgba(var(--danger-rgb),0.15);  color: var(--danger);  border: 1px solid rgba(var(--danger-rgb),0.3); }

/* Feedback card */
.mm-feedback-card {
  background: #fff;
  border: 0;
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  padding: 20px;
  animation: slideUp 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mm-feedback-result {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 800;
  margin-bottom: 4px;
}
.mm-feedback-result.correct { color: var(--emerald); }
.mm-feedback-result.wrong   { color: var(--danger); }

.mm-feedback-state {
  font-size: 14px; color: var(--text-muted);
  margin-bottom: 14px;
}

.mm-fact-box {
  padding: 12px 16px;
  background: rgba(var(--accent-rgb), 0.06);
  border: 1px solid rgba(var(--accent-rgb), 0.18);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}
.mm-fact-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--indigo-light); margin-bottom: 6px;
}
.mm-fact-text { font-size: 13px; color: var(--text-secondary); line-height: 1.6; }

.mm-xp-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: var(--radius-full);
  background: rgba(var(--gold-rgb), 0.15); border: 1px solid rgba(var(--gold-rgb), 0.3);
  font-size: 16px; font-weight: 800; color: var(--gold);
  margin-bottom: 14px;
  animation: xpPop 0.4s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both;
}
@keyframes xpPop {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.mm-btn-next {
  width: 100%;
  padding: 13px 20px;
  background: linear-gradient(135deg, var(--purple), var(--indigo));
  border: none; border-radius: var(--radius-md);
  color: white; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: all var(--transition-base);
  font-family: var(--font-body);
}
.mm-btn-next:hover {
  filter: brightness(1.15); transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(var(--accent-rgb), 0.35);
}

/* ── River lines ── */
/* Leaflet path styles for rivers are set via JS layer options */

/* ── Point answer markers — Leaflet popup ── */
.leaflet-popup-content-wrapper {
  background: rgba(15, 23, 41, 0.95) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5) !important;
}
[data-theme="light"] .leaflet-popup-content-wrapper {
  background: #FFFFFF !important;
  box-shadow: 0 6px 20px rgba(28,23,14,0.16) !important;
}
.leaflet-popup-content {
  color: var(--text-primary) !important;
  font-family: var(--font-display);
  font-size: 13px !important;
  font-weight: 700 !important;
  margin: 8px 14px !important;
}
.leaflet-popup-tip { background: var(--bg-surface) !important; }
[data-theme="light"] .leaflet-popup-tip { background: #FFFFFF !important; }
.leaflet-popup-close-button { display: none !important; }

/* ── Results page ── */
.mm-results-page { padding: 40px 0 60px; }
.mm-results-card { max-width: 620px; margin: 0 auto; }

.mm-attempt-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.mm-attempt-row:last-child { border-bottom: none; }

.mm-attempt-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(var(--overlay-rgb), 0.06);
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}
.mm-attempt-row.correct .mm-attempt-num { background: rgba(var(--emerald-rgb),0.2); color: var(--emerald); }
.mm-attempt-row.wrong   .mm-attempt-num { background: rgba(var(--danger-rgb),0.2);  color: var(--danger); }

.mm-attempt-question {
  flex: 1; font-size: 13px; color: var(--text-secondary); line-height: 1.4;
}

.mm-attempt-icons { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.mm-attempt-badge {
  font-size: 11px; font-weight: 700; padding: 3px 8px;
  border-radius: var(--radius-full);
}
.mm-attempt-badge.correct {
  background: rgba(var(--emerald-rgb),0.15); color: var(--emerald);
  border: 1px solid rgba(var(--emerald-rgb),0.3);
}
.mm-attempt-badge.wrong {
  background: rgba(var(--danger-rgb),0.12); color: var(--danger);
  border: 1px solid rgba(var(--rose-rgb),0.25);
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .mm-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }
  #mm-map {
    height: 100%;
  }
  .mm-panel {
    border-left: none;
    border-top: 1px solid var(--border-subtle);
    padding: 16px;
    flex: none;
    max-height: 45vh;
  }
}

@media (max-width: 768px) {
  .mm-category-grid { grid-template-columns: 1fr; gap: 14px; }
  .mm-header { padding: 10px 14px; gap: 10px; }
  .mm-logo { font-size: 14px; }
  .mm-category-chip { display: none; }
  .mm-q-counter { font-size: 12px; }
  .mm-header-center { display: none; }
  .mm-question-text { font-size: 16px; }
}

@media (max-width: 480px) {
  .mm-results-card { padding: 0 4px; }
  .mm-attempt-row { flex-direction: column; gap: 6px; }
}
