/* mama map — every sale as a dot on a globe.
   Brand: peach #fff5ea, ink #0b0b0b, 30px pills, Space Mono labels, serif
   headings. Uses Fable theme CSS vars where available, on-brand fallbacks.
   Self-contained for the store (theme widgets never link brand.css). */

/* media shell — same treatment as the shipping map page: the map leads,
   chrome recedes, near edge-to-edge on mobile. */
.mama-map-page { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }
@media (max-width: 767px) {
  .mama-map-page { padding: 8px 6px 24px; }
  .mama-map { border-radius: 14px; }
}

/* Intro line above the globe card */
.mama-map__intro {
  font-family: var(--FONT-STACK-HEADING, "Petrona", Georgia, serif);
  color: var(--COLOR-HEADING, #0b0b0b);
  text-align: center;
  font-size: 1.15rem;
  line-height: 1.45;
  max-width: 40rem;
  margin: 28px auto 0;
}
.mama-map__subtext {
  font-family: var(--FONT-STACK-LABEL, "Space Mono", ui-monospace, monospace);
  color: var(--COLOR-HEADING, #0b0b0b);
  opacity: .55;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .075em;
  font-size: .62rem;
  margin: 8px auto 0;
}
@media (max-width: 540px) {
  .mama-map__intro { font-size: 1rem; padding: 0 8px; }
}

.mama-map {
  --mms-peach: var(--COLOR-INPUT-BG, #fff5ea);
  --mms-ink: var(--COLOR-HEADING, #0b0b0b);
  --mms-border: var(--COLOR-BORDER, #0b0b0b);
  --mms-radius: var(--RADIUS, 30px);
  --mms-label: var(--FONT-STACK-LABEL, "Space Mono", ui-monospace, monospace);
  --mms-heading: var(--FONT-STACK-HEADING, "Petrona", Georgia, serif);
  --mms-ocean: #cfeaf2;

  position: relative;
  width: 100%;
  /* Near full-viewport, pure CSS. svh is frozen while the mobile URL bar
     moves, so no jitter; the vh line is the fallback for older browsers.
     170px ≈ announcement bar + header + shell padding. */
  height: clamp(420px, 78vh, 760px);
  height: clamp(420px, calc(100svh - 170px), 960px);
  border-radius: var(--mms-radius);
  overflow: hidden;
  border: 1px solid var(--mms-border);
  background: var(--mms-ocean);
  font-family: var(--FONT-STACK-BODY, system-ui, sans-serif);
  color: var(--mms-ink);
  -webkit-tap-highlight-color: transparent;
}

/* Two classes on purpose: Mapbox's own stylesheet loads after this one and
   sets .mapboxgl-map { position: relative } on the same element, which
   would collapse the wrapper to zero height and hide the canvas. */
.mama-map > .mama-map__canvas { position: absolute; inset: 0; width: auto; height: auto; }
.mama-map .mapboxgl-ctrl-logo,
.mama-map .mapboxgl-ctrl-bottom-right { opacity: .55; }

/* Title chip (top-left) */
.mama-map__title {
  position: absolute; top: 14px; left: 14px; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: var(--mms-peach);
  border: 1px solid var(--mms-border);
  border-radius: var(--mms-radius);
  font-family: var(--mms-heading);
  font-weight: 600;
  font-size: 1.05rem;
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
}
.mama-map__title small {
  font-family: var(--mms-label);
  text-transform: uppercase;
  letter-spacing: .075em;
  font-size: .58rem;
  opacity: .7;
}
.mms-live-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: #e0483e;
  animation: mms-live-pulse 1.6s ease-in-out infinite;
}
@keyframes mms-live-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(224,72,62,.45); }
  50% { opacity: .6; box-shadow: 0 0 0 5px rgba(224,72,62,0); }
}

/* Country pills (top-right) — same treatment as the shipping map's chips */
.mama-map__legend {
  position: absolute; top: 14px; right: 14px; z-index: 5;
  display: flex; flex-direction: column; gap: 8px;
  align-items: stretch; /* pills all match the widest one */
}
.mama-map__chip {
  padding: 8px 12px;
  text-align: center;
  background: var(--mms-peach);
  color: var(--mms-ink);
  border: 1px solid var(--mms-border);
  border-radius: var(--mms-radius);
  font-family: var(--mms-label);
  text-transform: uppercase; letter-spacing: .075em;
  font-size: .68rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
  transition: transform .15s ease, background .15s ease;
}
.mama-map__chip:hover { transform: translateY(-1px); }
.mama-map__chip[aria-pressed="true"] { background: var(--mms-ink); color: #fff5ea; }

/* Zoom buttons sit above the attribution, rounded to match the brand */
.mama-map .mapboxgl-ctrl-group {
  border-radius: 12px;
  border: 1px solid var(--mms-border);
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
}

/* Timelapse readout (top-left, replaces the live chip while a sweep runs):
   the sweep date, serif, big enough to read in a story */
.mama-map__readout {
  position: absolute; top: 14px; left: 14px; z-index: 5;
  padding: 10px 22px 12px;
  background: var(--mms-peach);
  border: 1px solid var(--mms-border);
  border-radius: var(--mms-radius);
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
  text-align: center;
}
.mama-map__readout[hidden] { display: none; }
.mama-map__readout-d {
  font-family: var(--mms-heading);
  font-weight: 600;
  font-size: 1.6rem;
  line-height: 1.1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.mama-map.is-timelapse .mama-map__title { display: none; }

/* Timelapse pills (bottom-left): ranges, then Play/Pause/Replay + Save video */
.mama-map__tl {
  position: absolute; bottom: 14px; left: 14px; z-index: 5;
  display: flex; flex-wrap: wrap; gap: 8px;
  max-width: calc(100% - 80px); /* leave the zoom buttons their corner */
}
.mama-map__chip--action { background: var(--mms-ink); color: #fff5ea; }
.mama-map__chip:disabled { opacity: .6; cursor: default; }
.mama-map__chip:disabled:hover { transform: none; }

/* Story frame (data-story="on"): a 9:16 stage filling the viewport, chrome
   hidden while a sweep plays so a screen recording is just globe + readout */
.mama-map--story {
  height: min(100svh, calc(100vw * 16 / 9));
  aspect-ratio: 9 / 16;
  width: auto;
  margin: 0 auto;
  border-radius: 0;
  border: none;
}
.mama-map--story .mama-map__readout {
  top: auto; bottom: 18%; left: 50%; transform: translateX(-50%);
  padding: 14px 32px 16px;
}
.mama-map--story .mama-map__tl { top: 14px; bottom: auto; max-width: calc(100% - 170px); } /* clear of the readout */
.mama-map--story .mama-map__readout-d { font-size: 2.2rem; }
.mama-map--story .mapboxgl-ctrl-bottom-right .mapboxgl-ctrl-group { display: none; }
.mama-map--story .mama-map__title { display: none; }
.mama-map__legend, .mama-map__tl, .mama-map .mapboxgl-ctrl-bottom-right {
  transition: opacity .3s ease;
}
.mama-map--story.is-playing .mama-map__legend,
.mama-map--story.is-playing .mama-map__tl,
.mama-map.is-recording .mama-map__legend,
.mama-map.is-recording .mama-map__tl,
.mama-map--story.is-playing .mapboxgl-ctrl-bottom-right { opacity: 0; pointer-events: none; }

/* Problem chip (top-centre): tiles blocked, context lost */
.mama-map__note {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 6;
  max-width: min(78%, 420px);
  padding: 10px 16px;
  background: var(--mms-peach);
  border: 1px solid var(--mms-border);
  border-radius: 18px;
  font-family: var(--mms-label);
  font-size: .7rem; line-height: 1.5;
  text-align: center;
  white-space: pre-wrap; word-break: break-word;
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
}
.mama-map__note[hidden] { display: none; }

/* Loading / error states */
.mama-map__msg {
  position: absolute; inset: 0; z-index: 7; display: grid; place-items: center;
  text-align: center; padding: 24px;
  font-family: var(--mms-label); text-transform: uppercase; letter-spacing: .075em; font-size: .68rem;
  background: var(--mms-ocean);
}
.mama-map__msg.is-hidden { display: none; }

@media (max-width: 540px) {
  .mama-map__title { font-size: .92rem; }
  .mama-map__readout { padding: 8px 16px 10px; }
  .mama-map__readout-d { font-size: 1.3rem; }
  .mama-map--story .mama-map__readout-d { font-size: 1.9rem; }
  .mama-map__tl { gap: 6px; }
  .mama-map__tl .mama-map__chip { padding: 7px 10px; font-size: .62rem; }
}
