/* ======================================================================
   HQ world map — styling for map.js.

   Palette and house rules come from styles.css (turquoise, blue, green,
   navy card, 4px arcade corners, chunky 0 6px 0 press shadows). Every
   custom property has a literal fallback so this file also works on its
   own. Pixel font is for shouting — numbers, counts, headings — never for
   the set titles he has to read.
   ====================================================================== */

.hq-map {
  display: block;
  --map-reserve: 160px;                 /* room kept below the map (trophy case) */
  --tile: 88px;
  --pix: var(--pixel, "Press Start 2P", "Courier New", ui-monospace, monospace);
}

.map-empty {
  color: var(--muted, #8fb0c2);
  padding: 24px 2px;
}

/* ---------------------------------------------------------- subject band */

.map-region + .map-region { margin-top: 18px; }

.map-subject {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 10px;
  font-family: var(--pix);
  font-size: 13px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--turq, #2ec4b6);
  text-shadow: 0 3px 0 #071018;
}
.map-subject-rule {
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, var(--line, #21405a), transparent);
}
.map-subject-count {
  font-family: var(--pix);
  font-size: 9px;
  letter-spacing: .05em;
  color: var(--muted, #8fb0c2);
  white-space: nowrap;
}

/* ----------------------------------------------------------------- world */

.map-world {
  box-sizing: border-box;
  position: relative;
  height: 420px;                        /* map.js overwrites this on layout */
  border: 2px solid var(--line, #21405a);
  border-radius: var(--radius, 4px);
  overflow: hidden;
  background-color: #0b1c2b;
  background-image:
    linear-gradient(rgba(46, 196, 182, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(46, 196, 182, .05) 1px, transparent 1px),
    radial-gradient(120% 95% at 50% -10%, #1a4054 0%, #0e2233 55%, #081420 100%);
  background-size: 38px 38px, 38px 38px, auto;
  box-shadow: inset 0 0 44px rgba(0, 0, 0, .55), 0 5px 0 #0a1a26;
}

/* ----------------------------------------------------------------- trail */

.map-trail {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.map-trail .star { fill: rgba(143, 176, 194, .30); }
.map-trail .star.warm { fill: rgba(46, 196, 182, .32); }

.trail-road {
  fill: none;
  stroke: rgba(7, 21, 35, .88);
  stroke-width: 16;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.trail-dots {
  fill: none;
  stroke: rgba(46, 196, 182, .55);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 0.1 15;
}
.trail-done {
  fill: none;
  stroke: var(--green, #4ade80);
  stroke-width: 7;
  stroke-linecap: round;
  filter: drop-shadow(0 0 7px rgba(74, 222, 128, .65));
  transition: stroke-dasharray .5s steps(14, end);
}

/* ----------------------------------------------------------------- nodes */

.map-node {
  box-sizing: border-box;
  position: absolute;
  width: 154px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.map-node:focus-visible { outline: 3px solid var(--blue, #38bdf8); outline-offset: 6px; border-radius: 6px; }

/* the tile itself — the tappable target, never under 76px */
.node-tile {
  position: relative;
  width: var(--tile);
  height: var(--tile);
  min-width: 76px;
  min-height: 76px;
  display: grid;
  place-items: center;
  border-radius: var(--radius, 4px);
  border: 3px solid var(--line, #21405a);
  background: linear-gradient(180deg, #1b3348, var(--card, #16293c));
  box-shadow: 0 6px 0 #071018, 0 10px 22px rgba(0, 0, 0, .45);
  transition: transform .08s ease, box-shadow .08s ease;
}
.node-face {
  display: grid;
  place-items: center;
  width: calc(100% - 8px);
  height: calc(100% - 8px);
  border-radius: 2px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .05);
}
.node-glyph {
  font-family: var(--pix);
  font-size: 22px;
  line-height: 1;
  color: var(--muted, #8fb0c2);
  text-shadow: 0 3px 0 #06121b;
}

.map-node:active .node-tile { transform: translateY(4px); box-shadow: 0 2px 0 #071018; }

/* --- unvisited: looks unexplored, is fully tappable ------------------- */
.map-node.fresh .node-tile {
  border-style: dashed;
  border-color: rgba(46, 196, 182, .45);
  background: linear-gradient(180deg, #15293a, #101f2d);
}
.map-node.fresh .node-glyph { color: #6d93a8; }
.map-node.fresh .node-title { color: #cfe3ea; }

/* --- in progress ------------------------------------------------------ */
.map-node.going .node-tile {
  border-color: var(--turq, #2ec4b6);
  background: linear-gradient(180deg, #1e5163, #14384a);
  box-shadow: 0 6px 0 #071018, 0 0 18px rgba(46, 196, 182, .45);
}
.map-node.going .node-glyph { color: var(--turq, #2ec4b6); }

/* --- cleared ---------------------------------------------------------- */
.map-node.cleared .node-tile {
  border-color: var(--green, #4ade80);
  background: linear-gradient(180deg, #1d5238, #12301f);
  box-shadow: 0 6px 0 #071018, 0 0 18px rgba(74, 222, 128, .4);
}
.map-node.cleared .node-glyph { color: var(--green, #4ade80); font-size: 26px; }

/* a flag planted on a cleared stage */
.node-flag { display: none; }
.map-node.cleared .node-flag {
  display: block;
  position: absolute;
  top: -19px;
  right: -7px;
  width: 3px;
  height: 25px;
  background: var(--green, #4ade80);
  box-shadow: 0 0 8px rgba(74, 222, 128, .8);
}
.map-node.cleared .node-flag::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 0;
  border-style: solid;
  border-width: 6px 0 6px 14px;
  border-color: transparent transparent transparent var(--green, #4ade80);
}

/* --- you are here ----------------------------------------------------- */
.map-node.here .node-tile {
  border-color: var(--blue, #38bdf8);
  box-shadow: 0 6px 0 #071018, 0 0 0 4px rgba(56, 189, 248, .18), 0 0 26px rgba(56, 189, 248, .55);
  animation: map-here 1.4s ease-in-out infinite alternate;
}
.map-node.here .node-glyph { color: var(--blue, #38bdf8); }
.map-node.here .node-tile::before {
  content: "▼";
  position: absolute;
  top: -27px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 15px;
  color: var(--blue, #38bdf8);
  text-shadow: 0 0 10px rgba(56, 189, 248, .9);
  animation: map-bob 1s ease-in-out infinite alternate;
}
@keyframes map-here {
  to { box-shadow: 0 6px 0 #071018, 0 0 0 7px rgba(56, 189, 248, .10), 0 0 30px rgba(56, 189, 248, .75); }
}
@keyframes map-bob { to { transform: translate(-50%, 5px); } }

/* --- label ------------------------------------------------------------ */
.node-label {
  display: block;
  width: 100%;
  pointer-events: none;
}
.node-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: 12.5px;
  line-height: 1.25;
  font-weight: 700;
  color: var(--ink, #eaf6f8);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .65);
}
.node-prog {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 5px;
}
.node-prog b {
  font-family: var(--pix);
  font-size: 9px;
  font-weight: 400;
  color: var(--muted, #8fb0c2);
}
.map-node.going .node-prog b { color: var(--turq, #2ec4b6); }
.map-node.cleared .node-prog b { color: var(--green, #4ade80); }

.node-pips { display: inline-flex; gap: 3px; }
.node-pips i {
  width: 7px;
  height: 7px;
  background: #1d374b;
  box-shadow: inset 0 0 0 1px #2b506b;
}
.node-pips i.on {
  background: var(--green, #4ade80);
  box-shadow: 0 0 6px rgba(74, 222, 128, .8);
}

/* a small pop when he taps, matching the rest of the cabinet */
.map-node.tapped .node-tile { animation: map-pop .26s ease; }
@keyframes map-pop { 40% { transform: scale(1.12) translateY(-2px); } }

/* ------------------------------------------------------------ narrow/wide */

@media (max-width: 700px) {
  .map-node { width: 128px; }
  .node-title { font-size: 11.5px; }
}
@media (orientation: landscape) and (min-width: 900px) {
  .map-node { width: 168px; }
  .node-title { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .map-node.here .node-tile,
  .map-node.here .node-tile::before,
  .map-node.tapped .node-tile { animation: none; }
  .trail-done { transition: none; }
}
