/*!
 * Bloom Academy — Locations Map
 * All rules are scoped under .bloom-map so nothing leaks into the theme.
 * Colours are exposed as custom properties: override them on .bloom-map
 * (or :root) from the Elementor custom-CSS box if the brand ever shifts.
 */

.bloom-map {
  /* Palette + type measured from bloomacademstg.wpenginepowered.com:
     headings Roca 600 navy, body Poppins, buttons Komet 700 in 40px pills. */
  --bloom-navy: #2D2C49;
  --bloom-purple: #615EAA;
  --bloom-purple-dark: #4E4B8C;
  --bloom-purple-soft: rgba(97, 94, 170, 0.12);
  --bloom-teal: #7CB0AF;
  --bloom-green: #B8D050;
  --bloom-green-dark: #A6BD42;
  --bloom-lavender: #D0CFE5;
  --bloom-ink: #2D2C49;
  --bloom-muted: #6B6B78;
  --bloom-surface: #FFFFFF;
  --bloom-line: rgba(97, 94, 170, 0.16);
  --bloom-radius: 24px;
  --bloom-radius-sm: 14px;
  --bloom-pill: 40px;
  --bloom-shadow: 0 10px 30px rgba(45, 44, 73, 0.10);
  --bloom-map-height: 520px;
  --bloom-section-bg: transparent;

  /* Fonts ride Elementor's kit variables when present, so the section always
     matches the theme even if the kit is re-fonted. */
  --bloom-font-heading: var(--e-global-typography-primary-font-family, "Roca"), "Poppins", sans-serif;
  --bloom-font-body: var(--e-global-typography-text-font-family, "Poppins"), sans-serif;
  --bloom-font-button: "Komet", var(--e-global-typography-text-font-family, "Poppins"), sans-serif;

  background: var(--bloom-section-bg);
  font-family: var(--bloom-font-body);
  color: var(--bloom-ink);
  box-sizing: border-box;
}
.bloom-map *,
.bloom-map *::before,
.bloom-map *::after { box-sizing: border-box; }

.bloom-map__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 56px 20px 64px;
}

/* ---------- Heading ---------- */

.bloom-map__head { text-align: center; margin: 0 0 28px; }

.bloom-map__eyebrow {
  margin: 0 0 8px;
  color: var(--bloom-purple);
  font-family: var(--bloom-font-body);
  font-size: 1rem;
  font-weight: 600;
  text-wrap: balance; /* if it ever wraps, break into even halves, no orphan word */
}

.bloom-map__title {
  margin: 0;
  text-wrap: balance;
  color: var(--bloom-navy);
  font-family: var(--bloom-font-heading);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 600;
  line-height: 1.15;
}

.bloom-map__intro {
  margin: 12px auto 0;
  max-width: 56ch;
  color: var(--bloom-muted);
  font-family: var(--bloom-font-body);
  font-size: 1.0625rem;
  line-height: 1.55;
}

/* ---------- Layout ---------- */

.bloom-map__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

/* ---------- Map canvas ---------- */

.bloom-map__canvas-wrap { position: relative; }

.bloom-map__canvas {
  height: var(--bloom-map-height);
  border-radius: var(--bloom-radius);
  border: 1px solid var(--bloom-line);
  background: #FBF8F3 url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cpath d='M0 20h40M20 0v40' stroke='%23ffffff' stroke-width='1' opacity='.55'/%3E%3C/svg%3E");
  box-shadow: var(--bloom-shadow);
  overflow: hidden;
  isolation: isolate;
}

/* Skeleton shimmer while Leaflet + tiles are still in flight */
.bloom-map__canvas::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.65) 50%, transparent 80%);
  background-size: 220% 100%;
  animation: bloom-map-shimmer 1.6s linear infinite;
  pointer-events: none;
}
.bloom-map__canvas.leaflet-container::after { content: none; }

@keyframes bloom-map-shimmer {
  from { background-position: 140% 0; }
  to   { background-position: -40% 0; }
}

/* ---------- Gesture hint overlay ---------- */

.bloom-map__hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: var(--bloom-radius);
  background: rgba(51, 51, 59, 0.42);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-align: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  pointer-events: none;
  z-index: 500;
}
.bloom-map__hint.is-visible { opacity: 1; visibility: visible; }

/* ---------- Location list ---------- */

.bloom-map__list-wrap { position: relative; }

.bloom-map__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  max-height: var(--bloom-map-height);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--bloom-purple-soft) transparent;
  padding-right: 4px;
}
.bloom-map__list::-webkit-scrollbar { width: 8px; }
.bloom-map__list::-webkit-scrollbar-thumb {
  background: var(--bloom-purple-soft);
  border-radius: 99px;
}

.bloom-loc {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  background: var(--bloom-surface);
  border: 1px solid var(--bloom-line);
  border-radius: var(--bloom-radius-sm);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.bloom-loc:hover,
.bloom-loc:focus-within {
  border-color: var(--bloom-purple);
  box-shadow: 0 6px 18px rgba(97, 94, 170, 0.16);
}
.bloom-loc.is-active {
  border-color: var(--bloom-purple);
  box-shadow: 0 0 0 2px var(--bloom-purple-soft), 0 8px 20px rgba(97, 94, 170, 0.18);
}

.bloom-loc__mark {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  margin-top: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 2px var(--bloom-purple-soft);
  display: grid;
  place-items: center;
}
.bloom-map .bloom-loc__mark img { width: 24px; height: 24px; max-width: none; display: block; }

.bloom-loc__body { min-width: 0; flex: 1 1 auto; }

.bloom-loc__name {
  margin: 0 0 2px;
  font-family: var(--bloom-font-heading);
  font-size: 1.125rem;
  line-height: 1.25;
  font-weight: 600;
  color: var(--bloom-navy);
}

/* Stretched link: the whole card navigates to the school page. */
.bloom-map .bloom-loc__link {
  color: inherit;
  text-decoration: none;
}
.bloom-map .bloom-loc__link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 1;
}
.bloom-map .bloom-loc__link:hover { text-decoration: underline; }
.bloom-map .bloom-loc__link:focus-visible {
  outline: 3px solid var(--bloom-purple);
  outline-offset: 3px;
  border-radius: 4px;
}

.bloom-loc__city {
  display: block;
  margin: 0 0 6px;
  color: var(--bloom-teal);
  font-size: 0.8125rem;
  font-weight: 600;
}

.bloom-loc__addr {
  margin: 0 0 6px;
  color: var(--bloom-muted);
  font-size: 0.875rem;
  line-height: 1.4;
}

.bloom-loc__meta {
  margin: 0;
  font-size: 0.875rem;
  color: var(--bloom-muted);
}
.bloom-loc__hours { margin-top: 2px; }
.bloom-loc__license {
  margin: 4px 0 0;
  font-size: 0.75rem;
  color: var(--bloom-muted);
  opacity: 0.85;
}
.bloom-map .bloom-loc__tel {
  position: relative;
  z-index: 2;
  color: var(--bloom-purple-dark);
  font-weight: 600;
  text-decoration: none;
}
.bloom-map .bloom-loc__tel:hover { text-decoration: underline; }

/*
 * Elementor/theme reset: global kit styles target bare `button` and `a`
 * elements (background, border, radius, padding, text-transform…) with
 * specificity (0,1,1). Everything interactive in this widget is scoped
 * under .bloom-map and re-declared explicitly so the kit never shows
 * through — do not "simplify" these selectors back to single classes.
 */
.bloom-map button.bloom-loc__focus,
.bloom-map button.bloom-map__reset {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  text-transform: none;
  letter-spacing: normal;
  text-decoration: none;
  text-shadow: none;
  text-indent: 0;
  min-width: 0;
  min-height: 0;
  outline: none;
  background-image: none;
}
.bloom-map .bloom-popup__cta,
.bloom-map .bloom-popup__dir,
.bloom-map .bloom-loc__link,
.bloom-map .bloom-loc__tel {
  background: none;
  text-transform: none;
  letter-spacing: normal;
  text-shadow: none;
  border: 0;
}

/*
 * "Show on map" button — sits above the stretched link.
 * Styled after the site's secondary button: lavender pill, purple content
 * (the green pill stays reserved for the primary "Visit school page" CTA).
 */
.bloom-map .bloom-loc__focus {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  align-self: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: var(--bloom-pill, 40px);
  background: var(--bloom-lavender, #D0CFE5);
  color: var(--bloom-purple);
  cursor: pointer;
  display: none; /* revealed by JS — useless without a map */
  place-items: center;
  box-shadow: 0 1px 2px rgba(45, 44, 73, 0.08);
  transition: background 0.18s ease, color 0.18s ease,
              box-shadow 0.18s ease, transform 0.18s ease;
}
.bloom-map.is-interactive .bloom-loc__focus { display: grid; }

.bloom-map .bloom-loc__focus:hover {
  background: var(--bloom-purple);
  color: #fff;
  box-shadow: 0 4px 10px rgba(97, 94, 170, 0.35);
  transform: translateY(-1px);
}
.bloom-map .bloom-loc__focus:active { transform: none; }

/* Selected school: the button stays "lit" so the pairing with the pin reads. */
.bloom-loc.is-active .bloom-loc__focus {
  background: var(--bloom-purple);
  color: #fff;
  box-shadow: 0 0 0 3px var(--bloom-purple-soft);
}

.bloom-map .bloom-loc__focus:focus-visible {
  outline: 3px solid var(--bloom-purple);
  outline-offset: 2px;
}

.bloom-map .bloom-loc__focus svg {
  fill: none; /* kits sometimes paint `button svg` */
  width: 19px;
  height: 19px;
  display: block;
  transition: transform 0.18s ease;
}
.bloom-map .bloom-loc__focus:hover svg { transform: scale(1.08); }

@media (prefers-reduced-motion: reduce) {
  .bloom-map .bloom-loc__focus:hover { transform: none; }
  .bloom-map .bloom-loc__focus:hover svg { transform: none; }
}

/* Viewport filtering: cards outside the current map view are hidden. */
.bloom-map .bloom-loc[hidden] { display: none; }

.bloom-map__empty {
  display: grid;
  gap: 12px;
  justify-items: center;
  padding: 22px 16px;
  border: 1px dashed var(--bloom-line);
  border-radius: var(--bloom-radius-sm);
  text-align: center;
}
.bloom-map__empty[hidden] { display: none; }
.bloom-map__empty p {
  margin: 0;
  color: var(--bloom-muted);
  font-size: 0.9rem;
}
.bloom-map button.bloom-map__empty-btn {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  padding: 9px 18px;
  border: 0;
  border-radius: var(--bloom-pill, 40px);
  background: var(--bloom-purple);
  color: #fff;
  font-family: var(--bloom-font-button, inherit);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s ease;
}
.bloom-map button.bloom-map__empty-btn:hover { background: var(--bloom-purple-dark); }
.bloom-map button.bloom-map__empty-btn:focus-visible {
  outline: 3px solid var(--bloom-purple);
  outline-offset: 2px;
}

/* ---------- Map pins ---------- */

/*
 * The Bloom mark IS the pin — it is already a solid disc (its white rings are
 * opaque, only the corners are transparent), so it needs no plate behind it,
 * just the soft halo ring from the client mockup.
 *
 * Sizing note: Leaflet's own stylesheet carries
 *   .leaflet-container .leaflet-marker-pane img { width: auto; max-width: none !important; }
 * at specificity (0,2,1), and it is injected lazily so it lands late in the
 * cascade. The pin image rules below are deliberately scoped one level deeper
 * to outrank it — do not "simplify" those selectors.
 */

.bloom-map .leaflet-marker-icon { background: none; border: 0; }

.bloom-pin {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  cursor: pointer;
}

.bloom-pin__dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 32px;
  height: 32px;
  margin: -16px 0 0 -16px;
  display: block;
  transition: transform 0.18s ease;
}

/* Halo ring — sits behind the mark, never on top of it. */
.bloom-pin__dot::before {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: rgba(124, 176, 175, 0.22);
  box-shadow: 0 0 0 1px rgba(97, 94, 170, 0.16);
  transition: background 0.18s ease, box-shadow 0.18s ease;
}

.leaflet-container .leaflet-marker-pane .bloom-pin__dot img {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  border-radius: 50%;
  filter: drop-shadow(0 3px 6px rgba(40, 36, 80, 0.32));
}

.bloom-pin:hover .bloom-pin__dot,
.bloom-pin.is-active .bloom-pin__dot { transform: scale(1.12); }

.bloom-pin:hover .bloom-pin__dot::before,
.bloom-pin.is-active .bloom-pin__dot::before {
  background: rgba(97, 94, 170, 0.26);
  box-shadow: 0 0 0 2px rgba(97, 94, 170, 0.55);
}

.bloom-pin__label {
  position: absolute;
  left: 50%;
  top: 23px;
  transform: translateX(-50%);
  max-width: 160px;
  color: #2D2C49;
  font-family: var(--bloom-font-body, inherit);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  text-align: center;
  pointer-events: none;
  text-shadow:
    -1.5px -1.5px 0 #fff, 1.5px -1.5px 0 #fff,
    -1.5px 1.5px 0 #fff, 1.5px 1.5px 0 #fff,
    0 0 4px #fff, 0 0 8px rgba(255, 255, 255, 0.9);
  transition: opacity 0.15s ease;
}
.bloom-pin.is-label-hidden .bloom-pin__label { opacity: 0; }
.bloom-pin.is-active .bloom-pin__label,
.bloom-pin:hover .bloom-pin__label { opacity: 1; }

/*
 * Cluster pin. Kept close in visual weight to a single pin — a group should
 * read as a peer of a school, not as something louder than it.
 * Single: 32px mark + 5px halo = 42px overall.
 * Cluster: 36px disc + 3px ring = 42px overall.
 */
.bloom-pin--cluster .bloom-pin__dot {
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border-radius: 50%;
  background: var(--bloom-purple, #615EAA);
  display: grid;
  place-items: center;
  box-shadow:
    0 0 0 3px #fff,
    0 3px 8px rgba(40, 36, 80, 0.30);
}
.bloom-pin--cluster .bloom-pin__dot::before {
  inset: -3px;
  background: transparent;
  box-shadow: none;
}
.bloom-pin--cluster:hover .bloom-pin__dot::before,
.bloom-pin--cluster.is-active .bloom-pin__dot::before {
  background: transparent;
  box-shadow: 0 0 0 5px rgba(97, 94, 170, 0.22);
}
.bloom-pin__count {
  position: relative;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}
.bloom-pin--cluster .bloom-pin__label { top: 25px; }

/* ---------- Popup ---------- */

.bloom-map .leaflet-popup-content-wrapper {
  border-radius: 16px;
  box-shadow: 0 12px 34px rgba(40, 36, 80, 0.24);
  padding: 4px;
}
.bloom-map .leaflet-popup-content { margin: 12px 14px; line-height: 1.45; }
.bloom-map .leaflet-popup-close-button { color: var(--bloom-muted); padding: 8px 8px 0 0; }

.bloom-popup { font-size: 14px; max-width: 240px; }
.bloom-popup__name {
  margin: 0 0 2px;
  color: var(--bloom-navy, #2D2C49);
  font-family: var(--bloom-font-heading, inherit);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
}
.bloom-popup__city {
  display: block;
  margin: 0 0 8px;
  color: #7CB0AF;
  font-size: 12px;
  font-weight: 600;
}
.bloom-popup__addr { margin: 0 0 6px; color: #2D2C49; }
.bloom-popup__license { margin: 0 0 4px; color: #6B6B78; font-size: 11.5px; opacity: 0.85; }
.bloom-popup__meta { margin: 0; color: #6B6B78; font-size: 13px; }
.bloom-popup__hours { margin-top: 2px; }
.bloom-popup a { color: #4E4B8C; }
.bloom-popup__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}
.bloom-map .bloom-popup__cta {
  display: inline-block;
  padding: 10px 20px;
  background: var(--bloom-green, #B8D050);
  color: #fff !important;
  border-radius: var(--bloom-pill, 40px);
  font-family: var(--bloom-font-button, inherit);
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
  transition: background 0.18s ease;
}
.bloom-map .bloom-popup__cta:hover { background: var(--bloom-green-dark, #A6BD42); }
.bloom-map .bloom-popup__dir { font-size: 13px; font-weight: 600; text-decoration: none; }
.bloom-map .bloom-popup__dir:hover { text-decoration: underline; }

/* ---------- Leaflet chrome ---------- */

.bloom-map .leaflet-container { font: inherit; background: #FBF8F3; }
.bloom-map .leaflet-control-zoom a {
  color: var(--bloom-purple);
  border-radius: 10px !important;
  border: 1px solid var(--bloom-line);
}
.bloom-map .leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.82);
  border-radius: 8px 0 0 0;
  font-size: 10px;
}

/*
 * "View all locations" — floats top-centre over the map, appearing only once
 * the visitor has zoomed or picked a school. White pill so it reads as map
 * chrome (the coloured pills are reserved for actions on the cards/popups).
 */
.bloom-map .bloom-map__reset {
  position: absolute;
  top: 16px;
  left: 50%;
  z-index: 800; /* above tiles + pins, below Leaflet popups (~z 700 pane, popups sit in map stack) */
  padding: 10px 20px;
  border: 0;
  border-radius: var(--bloom-pill);
  background: #fff;
  color: var(--bloom-purple);
  font-family: var(--bloom-font-button);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(45, 44, 73, 0.22);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -8px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease,
              background 0.18s ease, color 0.18s ease;
}
.bloom-map .bloom-map__reset.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}
.bloom-map .bloom-map__reset:hover {
  background: var(--bloom-purple);
  color: #fff;
  box-shadow: 0 4px 14px rgba(97, 94, 170, 0.4);
}
.bloom-map .bloom-map__reset:focus-visible {
  outline: 3px solid var(--bloom-purple);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .bloom-map .bloom-map__reset { top: 12px; padding: 9px 16px; font-size: 12px; }
}

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
  .bloom-map__layout { grid-template-columns: minmax(0, 1fr) 300px; }
}

@media (max-width: 900px) {
  .bloom-map { --bloom-map-height: 420px; }
  .bloom-map__inner { padding: 40px 16px 48px; }
  .bloom-map__layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }

  /* Cards become a horizontal, snap-scrolling rail under the map. */
  .bloom-map__list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(255px, 78%);
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-padding-left: 16px; /* snapped cards rest at the map's edge, not the screen's */
    scroll-padding-right: 16px;
    padding: 4px 4px 12px;
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
  }
  .bloom-loc { scroll-snap-align: start; }

  /* While a popup is open there is no room for the reset pill on small maps. */
  .bloom-map.has-popup .bloom-map__reset {
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -8px);
  }
}

@media (max-width: 480px) {
  .bloom-map { --bloom-radius: 18px; }

  /* At heading-adjacent size the eyebrow muddies the hierarchy on small
     screens; smaller + tighter reads as one eyebrow-and-headline unit. */
  .bloom-map__head { margin-bottom: 24px; }
  .bloom-map__eyebrow { font-size: 0.875rem; margin-bottom: 6px; }
  /* Square map: fitBounds still shows all seven schools (the region is
     taller than wide, so height — not width — sets the zoom). */
  .bloom-map__canvas {
    height: auto;
    aspect-ratio: 1 / 1;
  }
  .bloom-map__list { grid-auto-columns: minmax(240px, 86%); }
}

/* ---------- Motion / print ---------- */

@media (prefers-reduced-motion: reduce) {
  .bloom-map *,
  .bloom-map *::before,
  .bloom-map *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .bloom-pin:hover .bloom-pin__dot,
  .bloom-pin.is-active .bloom-pin__dot { transform: none; }
}

@media print {
  .bloom-map__canvas-wrap { display: none; }
  .bloom-map__list {
    grid-auto-flow: row;
    grid-template-columns: 1fr 1fr;
    max-height: none;
    overflow: visible;
  }
  .bloom-map .bloom-loc__focus { display: none !important; }
}
