/* ── ChicaCharmer · World Map ───────────────────────────────────
   Additive stylesheet, namespaced .wm-* (plus #worldmap-btn on the learning
   screen). Uses the existing tokens from style.css (--bg, --surface, --accent…)
   and the same chunky 3D red CTA language as the onboarding.
   Nothing here changes an existing selector except the temporary hiding of
   #app while the map is on screen.
   ─────────────────────────────────────────────────────────── */

:root {
  --wm-gold:   #ffd166;          /* same gold as the confetti palette */
  --wm-ink:    #2a1745;          /* deep purple of the map's number badges */
  --wm-edge:   #a2301f;          /* 3D edge of the red CTA (same as onboarding) */
}

/* ── Layer ──────────────────────────────────────────── */
.wm {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;                  /* above the screens, below badge / trophy / level-up overlays */
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}
html.cc-map-open .wm { display: block; animation: wm-in .28s ease-out; }
html.cc-ob-active .wm { display: none !important; }          /* onboarding runs exactly as before */
html.cc-map-open #app { visibility: hidden; }                 /* nothing from the learning screen peeks through */
.wm.wm--leaving { opacity: 0; transition: opacity .16s ease-in; }
@keyframes wm-in { from { opacity: 0; } to { opacity: 1; } }

.wm-frame {
  position: relative;
  width: min(100%, 520px);       /* same column width as #app on large screens */
  height: 100%;
  margin: 0 auto;
  overflow: hidden;
  background: #1fb6e8;
}
@media (min-width: 560px) { .wm-frame { box-shadow: 0 0 0 1px var(--surface2), 0 0 60px rgba(0, 0, 0, .6); } }

/* ── Scrolling viewport + stage ─────────────────────── */
.wm-scroll {
  position: absolute;
  inset: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  scrollbar-width: none;
  outline: none;
  cursor: grab;
}
.wm-scroll::-webkit-scrollbar { display: none; }
.wm-scroll.is-dragging { cursor: grabbing; }
.wm-scroll.is-dragging .wm-pin { pointer-events: none; }

.wm-stage {
  position: relative;
  flex: none;
  width: var(--wm-w, 100%);
  height: var(--wm-h, auto);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.wm-stage picture { display: contents; }
.wm-map { display: block; width: 100%; height: 100%; pointer-events: none; }
.wm-pins, .wm-fx { position: absolute; inset: 0; }
.wm-pins { z-index: 2; }
.wm-fx   { z-index: 4; pointer-events: none; }

/* ── Character ──────────────────────────────────────── */
.wm-hero {
  position: absolute;
  left: 0; top: 0;
  z-index: 3;
  pointer-events: none;
  /* feet anchored on (--hx, --hy) = fractions of the map; transform-only → cheap to animate */
  transform: translate3d(calc(var(--hx, 0) * var(--wm-w, 0px) - 50%), calc(var(--hy, 0) * var(--wm-h, 0px) - 100%), 0);
  will-change: transform;
}
.wm-hero-shadow {
  position: absolute;
  left: 50%; bottom: -2.5%;
  width: 118%; height: 9%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(30, 14, 50, .5) 0%, rgba(30, 14, 50, 0) 70%);
}
.wm-hero-bob { display: block; transform-origin: 50% 100%; animation: wm-breathe 2.8s ease-in-out infinite; }
.wm-hero-bob picture { display: block; }
.wm-hero-img { display: block; width: 100%; height: auto; filter: drop-shadow(0 2px 0 rgba(30, 14, 50, .25)); }
.wm-hero[data-facing="left"] .wm-hero-img { transform: scaleX(-1); }

.wm-hero[data-state="walking"] .wm-hero-bob { animation: wm-step .36s ease-in-out infinite; }

@keyframes wm-breathe {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  50%      { transform: translateY(-2.2%) scale(1.012, 1.02); }
}
@keyframes wm-step {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-5.5%) rotate(3deg); }
}

/* ── Level pins (interactive layer over the numbered badges painted in the map) ── */
.wm-pin {
  position: absolute;
  width: max(44px, 11%);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.wm-pin:focus-visible { outline: 3px solid var(--wm-gold); outline-offset: -2px; }
.wm-pin-dim  { position: absolute; inset: 17%; border-radius: 50%; pointer-events: none; transition: background .5s; }
.wm-pin-ring { position: absolute; inset: 11%; border-radius: 50%; pointer-events: none; }
.wm-pin-chip {
  position: absolute;
  right: 4%; top: 4%;
  width: 31%; height: 31%;
  display: none;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  box-shadow: 0 2px 0 rgba(30, 14, 50, .45);
  pointer-events: none;
}
.wm-pin-chip svg { width: 58%; height: 58%; }

.wm-pin-label {
  position: absolute;
  left: 50%; top: 87%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 5px 9px 4px;
  border-radius: 999px;
  background: #fff;
  color: var(--wm-ink);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
  box-shadow: 0 2px 0 rgba(42, 23, 69, .5);
  pointer-events: none;
}

/* current: gold ring + ripple — "you are here" */
.wm-pin--current .wm-pin-ring {
  border: 3px solid var(--wm-gold);
  box-shadow: none;
}
.wm-pin--current .wm-pin-ring::after {
  content: '';
  position: absolute; inset: -3px;
  border-radius: 50%;
  border: 3px solid var(--wm-gold);
  opacity: 0;
  animation: wm-ripple 2.2s ease-out infinite;
}
.wm-pin--current .wm-pin-label { background: var(--wm-gold); }

/* next: dashed ring, lock still on — something worth reaching */
.wm-pin--next .wm-pin-ring { border: 3px dashed rgba(255, 255, 255, .95); animation: wm-spin 16s linear infinite; }
.wm-pin--next .wm-pin-dim  { background: rgba(42, 23, 69, .2); }
.wm-pin--next .wm-pin-chip, .wm-pin--locked .wm-pin-chip { display: grid; background: var(--wm-ink); }
.wm-pin--next .wm-pin-label { background: var(--wm-ink); color: #fff; box-shadow: 0 2px 0 rgba(0, 0, 0, .35); }

/* locked: still visible, just dimmed */
.wm-pin--locked .wm-pin-dim { background: rgba(42, 23, 69, .42); }

/* done */
.wm-pin--done .wm-pin-chip { display: grid; background: #06d6a0; }

.wm-pin.is-unlocking { animation: wm-pop .9s cubic-bezier(.2, .9, .3, 1.3); z-index: 3; }

@keyframes wm-ripple { 0% { transform: scale(1); opacity: .85; } 100% { transform: scale(1.7); opacity: 0; } }
@keyframes wm-spin   { to { transform: rotate(360deg); } }
@keyframes wm-pop {
  0%   { transform: translate(-50%, -50%) scale(1); }
  35%  { transform: translate(-50%, -50%) scale(1.28); }
  65%  { transform: translate(-50%, -50%) scale(.94); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

/* ── Tap-a-pin bubble + unlock notice ───────────────── */
.wm-peek {
  position: absolute;
  z-index: 5;
  width: max-content;
  max-width: 220px;
  padding: 8px 13px 7px;
  border-radius: 14px;
  background: #fff;
  color: var(--wm-ink);
  text-align: center;
  box-shadow: 0 3px 0 rgba(42, 23, 69, .5);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -100%) translateY(8px) scale(.96);
  transition: opacity .18s, transform .22s cubic-bezier(.2, .9, .3, 1.2);
}
.wm-peek.is-on { opacity: 1; transform: translate(-50%, -100%); }
.wm-peek::after {
  content: '';
  position: absolute;
  left: 50%; bottom: -5px;
  width: 11px; height: 11px;
  background: inherit;
  transform: translateX(-50%) rotate(45deg);
  border-radius: 0 0 3px 0;
}
.wm-peek b    { display: block; font-size: 13px; font-weight: 800; }
.wm-peek span { display: block; margin-top: 2px; font-size: 11.5px; font-weight: 600; opacity: .75; }
.wm-peek--unlock { background: var(--wm-gold); }
.wm-peek--unlock span { opacity: .85; }

/* ── Unlock FX ──────────────────────────────────────── */
.wm-burst {
  position: absolute;
  width: 11%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 4px solid var(--wm-gold);
  opacity: 0;
  transform: translate(-50%, -50%) scale(.5);
  animation: wm-burst 1.1s ease-out forwards;
}
@keyframes wm-burst { 0% { opacity: .95; transform: translate(-50%, -50%) scale(.5); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(2.6); } }
.wm-spark {
  position: absolute;
  font-size: 17px;
  line-height: 1;
  opacity: 0;
  transform: translate(-50%, -50%) scale(.4);
  animation: wm-spark 1.2s ease-out forwards;
}
@keyframes wm-spark {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(.4); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.1); }
}

/* ── HUD ────────────────────────────────────────────── */
.wm-hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 12px 0;
  pointer-events: none;
}
.wm-hud > * { pointer-events: auto; }
.wm-hud-gap { flex: 1; pointer-events: none; }
.wm-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 2px solid rgba(255, 255, 255, .22);
  color: var(--text);
  font: 700 12.5px/1 var(--font-body);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .35);
}
.wm-profile { max-width: 38%; padding-left: 10px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.wm-profile svg { width: 15px; height: 15px; flex: none; color: var(--wm-gold); }
.wm-profile span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wm-profile:active { transform: scale(.96); }
.wm-profile:focus-visible, .wm-tool:focus-visible, .wm-cta:focus-visible { outline: 3px solid var(--wm-gold); outline-offset: 2px; }
.wm-xp { gap: 8px; }
.wm-xp-lvl { color: var(--wm-gold); font-weight: 800; letter-spacing: .06em; }
.wm-xp-bar { width: 44px; height: 7px; border-radius: 99px; background: var(--surface2); overflow: hidden; }
.wm-xp-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--wm-gold); transition: width .6s ease; }
.wm-xp-txt { color: var(--text-muted); font-weight: 700; }
@media (max-width: 385px) { .wm-xp-txt { display: none; } .wm-pill { padding: 0 10px; } }

/* ── Zoom / locate tools ────────────────────────────── */
.wm-tools {
  position: absolute;
  right: 12px;
  top: calc(max(10px, env(safe-area-inset-top)) + 46px);
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wm-tool {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  padding: 0;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid rgba(255, 255, 255, .22);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .35);
  -webkit-tap-highlight-color: transparent;
}
.wm-tool svg { width: 20px; height: 20px; }
.wm-tool:active { transform: scale(.94); }
.wm-locate { display: none; color: var(--wm-gold); }
.wm-locate.is-visible { display: grid; animation: wm-in .2s ease-out; }
.wm-zoom .wm-zoom-in { display: none; }
.wm-zoom.is-overview .wm-zoom-in  { display: block; }
.wm-zoom.is-overview .wm-zoom-out { display: none; }

/* ── Primary call to action ─────────────────────────── */
.wm-cta-wrap {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 8;
  display: flex;
  justify-content: center;
  padding: 0 16px max(18px, env(safe-area-inset-bottom));
  pointer-events: none;
}
.wm-cta {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: min(100%, 360px);
  padding: .8rem 1.2rem .75rem;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-family: inherit;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--wm-edge);
  transition: transform .12s ease, box-shadow .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.wm-cta-main { font-size: 1.02rem; font-weight: 800; letter-spacing: .09em; }
.wm-cta-sub  { font-size: .72rem; font-weight: 600; letter-spacing: .02em; opacity: .93; }
.wm-cta-arrow { display: inline-block; animation: wm-nudge 1.6s ease-in-out infinite; }
@keyframes wm-nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(4px); } }
@media (hover: hover) { .wm-cta:hover { transform: translateY(-2px); box-shadow: 0 4px 0 var(--wm-edge); } }
.wm-cta:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--wm-edge); }

/* ── "World Map" button on the existing learning screen ──
   Mirrors the quiet pill of the profile button (top-left). */
.worldmap-btn {
  position: absolute;
  top: 0; left: 0;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .32rem .7rem .32rem .55rem;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: .75rem;
  letter-spacing: .02em;
  border: 1px solid var(--surface2);
  border-radius: 999px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.worldmap-btn svg { width: 15px; height: 15px; flex: none; color: var(--accent2); }
.worldmap-btn:hover, .worldmap-btn:focus-visible { color: var(--text); border-color: var(--accent); background: var(--surface); }
.worldmap-btn:active { transform: scale(.96); }
.worldmap-btn .wmb-short { display: none; }
@media (max-width: 440px) { .worldmap-btn .wmb-long { display: none; } .worldmap-btn .wmb-short { display: inline; } }
@media (max-width: 380px) { .worldmap-btn .wmb-short { display: none; } .worldmap-btn { padding: .38rem .5rem; } }

/* ── Reduced motion: a calm, static map (no bounce, no pulses) ── */
@media (prefers-reduced-motion: reduce) {
  .wm, .wm *, .wm *::before, .wm *::after { animation: none !important; transition: none !important; }
}
