/* Mapa de fases, níveis difíceis e portão de estrelas */

/* ===== Mapa de fases ===== */
.app[hidden], .map-screen[hidden] { display: none; }
.map-screen { padding: 16px 12px 40px; }

/* Fundo: o mesmo campo à noite da tela inicial, parado atrás da trilha e um pouco escurecido */
.map-screen::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(rgba(24, 12, 16, 0.3), rgba(24, 12, 16, 0.45)),
    #2b1a20 url("../img/fundo.webp") center bottom / cover no-repeat;
}
@media (orientation: landscape) {
  .map-screen::before { background-position: center, center 22%; }
}
/* Cenário do mapa: duas camadas trocam de imagem com um fade conforme a dezena no meio da tela (worlds.js) */
.map-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.9s ease;
  background: #2b1a20 center bottom / cover no-repeat;
}
.map-bg.on { opacity: 1; }
.map-bg::after { content: ""; position: absolute; inset: 0; background: rgba(24, 12, 16, 0.3); }
.map-fx { position: fixed; inset: 0; z-index: -1; width: 100%; height: 100%; pointer-events: none; }
.map-sky { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }

.map-header { text-align: center; margin-top: 8px; }
.map-header h1 {
  margin: 0;
  font-family: var(--font-title);
  font-size: 2.4rem;
  font-weight: 700;
  color: #e8707f;
  -webkit-text-stroke: 0.06em #5c2a35;
  paint-order: stroke fill;
  text-shadow: 0 0 14px rgba(255, 196, 120, 0.5), 0 3px 0 #5c2a35;
}
.map-header p { margin: 6px 0 0; color: rgba(255, 244, 230, 0.85); font-weight: 700; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6); }

/* Volta para a tela inicial, no canto direito de cima (o canto esquerdo é do perfil) */
/* Casinha e loja: uma coluna só no canto direito, com os dois botões centralizados um sobre o outro */
.map-corner { position: fixed; z-index: 50; top: 12px; right: 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
body:not([data-screen="map"]) .map-corner { display: none; }
.map-home {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  color: var(--accent-dark);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.2s;
}
.map-home:hover { transform: translateY(-1px); }
.map-home:active { transform: scale(0.92); }
.map-home:focus-visible { outline: 3px solid #ffe28a; outline-offset: 3px; }
.map-home .house {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* A porta acesa: amarelo de vagalume, com um halo que pulsa de leve */
.map-home .lit {
  fill: #ffcf5c;
  filter: drop-shadow(0 0 2.5px rgba(255, 207, 92, 0.95));
  animation: house-glow 2.2s ease-in-out infinite alternate;
}
@keyframes house-glow {
  from { opacity: 0.75; }
  to { opacity: 1; }
}

.map { position: relative; width: 280px; margin: 8px auto 0; }
.map-svg { position: absolute; inset: 0; overflow: visible; }
.map-svg path {
  fill: none;
  stroke: var(--card-soft);
  stroke-width: 14;
  stroke-linecap: round;
}
.map-svg path.done { stroke: var(--accent); opacity: 0.55; }

.node {
  position: absolute;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  font: inherit;
  font-size: 1.2rem;
  font-weight: 800;
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.12s;
}
.node:hover:not(:disabled) { transform: scale(1.08); }
.node:active:not(:disabled) { transform: scale(0.95); }
.node.done { background: var(--accent); color: #fff; }
.node.locked { background: var(--card-soft); color: var(--muted); cursor: default; box-shadow: none; }
.node.locked .node-num { font-size: 1rem; opacity: 0.7; }
.node.current {
  width: 70px;
  height: 70px;
  margin: -35px 0 0 -35px;
  font-size: 1.5rem;
  background: var(--accent-dark);
  color: #fff;
  animation: node-pulse 1.6s ease-in-out infinite;
}
/* Nível recém-liberado esperando o vagalume chegar */
.node.current.awaiting { animation: none; filter: saturate(0.6) brightness(0.9); }

/* Vagalume que mora no nível atual; ao liberar um nível, voa até o novo */
.map-firefly {
  position: absolute;
  left: 0;
  top: 0;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  z-index: 3;
  pointer-events: none;
  filter: drop-shadow(0 0 8px rgba(255, 210, 90, 0.9));
}
.map-firefly-bob { width: 100%; height: 100%; animation: bob 1.4s ease-in-out infinite alternate; }
.map-firefly .mark-cat { width: 100%; height: 100%; animation: none; }

/* Trecho do caminho sendo pintado enquanto o vagalume passa */
.map-svg path.drawing {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: path-draw 1.4s 0.4s ease-in-out forwards;
}
@keyframes path-draw { to { stroke-dashoffset: 0; } }
@keyframes bob { from { transform: translateY(2px); } to { transform: translateY(-5px); } }
.node-stars {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 2px;
  font-size: 0.8rem;
  letter-spacing: 1px;
  color: #f2b705;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.node-tag {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.node.current .node-tag { display: none; }
@keyframes node-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224, 112, 127, 0.55); }
  50% { box-shadow: 0 0 0 14px rgba(224, 112, 127, 0); }
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn:disabled:active { transform: none; }

/* Níveis difíceis (10, 20, 30…) */
.node.hard { box-shadow: 0 0 0 4px #7b4bd1, var(--shadow); }
.node.hard.done { background: #7b4bd1; }
.node.hard.current { background: #7b4bd1; animation: node-pulse-hard 1.6s ease-in-out infinite; }
.node.hard.locked { box-shadow: 0 0 0 4px rgba(123, 75, 209, 0.45); }
.node.current .node-tag.hard-tag { display: block; }
.node-tag.hard-tag { background: #7b4bd1; color: #fff; }
@keyframes node-pulse-hard {
  0%, 100% { box-shadow: 0 0 0 4px #7b4bd1, 0 0 0 4px rgba(123, 75, 209, 0.55); }
  50% { box-shadow: 0 0 0 4px #7b4bd1, 0 0 0 18px rgba(123, 75, 209, 0); }
}


/* ===== Portão de estrelas (níveis 10, 20, 30…) ===== */
.btn[hidden] { display: none; }
.map-gate {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 190px;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  text-align: center;
  font-size: 0.78rem;
  line-height: 1.35;
  box-shadow: var(--shadow), 0 0 0 3px #7b4bd1;
  z-index: 2;
}
.map-gate strong { display: block; font-size: 1rem; color: #7b4bd1; }
.map-gate span { color: var(--muted); }

/* Tema escuro sobre o fundo noturno: caminho e níveis bloqueados um pouco mais claros, para não sumirem */
