/**
 * Styles public Map Studio interactive SVG maps.
 * The shortcode renderer scopes map colors through per-instance CSS variables.
 */

.trybes-map-studio {
  --trybes-map-studio-color-inactive: #d1d5db;
  --trybes-map-studio-color-active: #374151;
  --trybes-map-studio-color-hover: #6b7280;
  --trybes-map-studio-color-stroke: #ffffff;
  --trybes-map-studio-color-bubble-background: #ffffff;
  --trybes-map-studio-color-bubble-text: #111827;
  --trybes-map-studio-space-xs: 4px;
  --trybes-map-studio-space-sm: 8px;
  --trybes-map-studio-space-md: 12px;
  --trybes-map-studio-space-lg: 16px;
  --trybes-map-studio-radius-sm: 4px;
  --trybes-map-studio-shadow: 0 12px 28px rgb(0 0 0 / 18%);
  --trybes-map-studio-bubble-x: 0px;
  --trybes-map-studio-bubble-y: 0px;
  --trybes-map-studio-control-transition: 160ms ease;
  --trybes-map-studio-control-size: 36px;
  --trybes-map-studio-icon-size: 18px;
  --trybes-map-studio-icon-stroke-width: 2;
  --trybes-map-studio-bubble-pointer-size: 14px;
  --trybes-map-studio-bubble-pointer-border: 1px;
  --trybes-map-studio-bubble-pointer-half: calc(var(--trybes-map-studio-bubble-pointer-size) / 2);
  --trybes-map-studio-bubble-pointer-inner-size: calc(var(--trybes-map-studio-bubble-pointer-size) - var(--trybes-map-studio-bubble-pointer-border));
  --trybes-map-studio-bubble-pointer-inner-half: calc(var(--trybes-map-studio-bubble-pointer-half) - var(--trybes-map-studio-bubble-pointer-border));
  --trybes-map-studio-bubble-pointer-x: 50%;
  --trybes-map-studio-bubble-pointer-shadow: 0 8px 14px rgb(0 0 0 / 10%);
  --trybes-map-studio-bubble-close-size: 32px;
  --trybes-map-studio-region-list-min-width: 180px;
  --trybes-map-studio-region-list-width: 240px;
  --trybes-map-studio-region-list-max-height: 460px;
  --trybes-map-studio-region-list-mobile-max-height: 40vh;
  --trybes-map-studio-region-list-selected-bar: 3px;

  position: relative;
  width: 100%;
  max-width: 100%;
  container-name: trybes-map-studio;
  container-type: inline-size;
}

.trybes-map-studio__body {
  display: block;
  width: 100%;
}

.trybes-map-studio.has-region-list .trybes-map-studio__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(var(--trybes-map-studio-region-list-min-width), var(--trybes-map-studio-region-list-width));
  gap: var(--trybes-map-studio-space-lg);
  align-items: start;
}

.trybes-map-studio.has-region-list.is-region-list-left .trybes-map-studio__body {
  grid-template-columns: minmax(var(--trybes-map-studio-region-list-min-width), var(--trybes-map-studio-region-list-width)) minmax(0, 1fr);
}

.trybes-map-studio.is-region-list-left .trybes-map-studio__viewport {
  order: 2;
}

.trybes-map-studio.is-region-list-left .trybes-map-studio__region-list {
  order: 1;
}

.trybes-map-studio.is-region-list-right .trybes-map-studio__viewport {
  order: 1;
}

.trybes-map-studio.is-region-list-right .trybes-map-studio__region-list {
  order: 2;
}

.trybes-map-studio.is-region-list-collapsed .trybes-map-studio__body {
  display: block;
}

.trybes-map-studio.is-region-list-collapsed .trybes-map-studio__region-list {
  display: none;
}

.trybes-map-studio__viewport {
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
}

.trybes-map-studio__svg {
  display: block;
  width: 100%;
  height: auto;
  touch-action: pan-y;
}

.trybes-map-studio.is-zoomed .trybes-map-studio__svg {
  cursor: grab;
}

.trybes-map-studio.is-panning .trybes-map-studio__svg {
  cursor: grabbing;
}

.trybes-map-studio__gesture-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--trybes-map-studio-space-md, 16px);
  background: rgba(17, 24, 39, 0.55);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 200ms ease, visibility 200ms ease;
  z-index: 5;
}

.trybes-map-studio__gesture-hint.is-visible {
  opacity: 1;
  visibility: visible;
}

.trybes-map-studio__gesture-hint-text {
  max-width: 22em;
  padding: 0.6em 1em;
  border-radius: var(--trybes-map-studio-radius-sm, 6px);
  background: rgba(17, 24, 39, 0.85);
  color: #fff;
  font-size: 0.95em;
  line-height: 1.35;
  text-align: center;
}

.trybes-map-studio__region {
  fill: var(--trybes-map-studio-color-inactive);
  stroke: var(--trybes-map-studio-color-stroke);
  stroke-width: 1;
  transition: fill 160ms ease;
}

.trybes-map-studio__region.is-inactive {
  cursor: default;
}

.trybes-map-studio__region.is-active {
  cursor: pointer;
  fill: var(--trybes-map-studio-color-active);
}

.trybes-map-studio__region:focus {
  outline: none;
}

.trybes-map-studio__region.has-custom-color {
  fill: var(--trybes-map-studio-region-custom-color, var(--trybes-map-studio-color-active));
}

.trybes-map-studio__region.is-active:hover,
.trybes-map-studio__region.is-active:focus {
  fill: var(--trybes-map-studio-color-hover);
}

.trybes-map-studio__region.is-active:focus-visible {
  outline: none;
}

.trybes-map-studio__region.is-selected {
  fill: var(--trybes-map-studio-color-active);
}

.trybes-map-studio__region.has-custom-color.is-active:hover,
.trybes-map-studio__region.has-custom-color.is-active:focus,
.trybes-map-studio__region.has-custom-color.is-selected {
  fill: var(--trybes-map-studio-region-custom-color, var(--trybes-map-studio-color-active));
}

.trybes-map-studio__actions {
  position: absolute;
  top: var(--trybes-map-studio-space-md);
  right: var(--trybes-map-studio-space-md);
  z-index: 3;
  display: flex;
  gap: var(--trybes-map-studio-space-sm);
  align-items: center;
}

.trybes-map-studio__reset,
.trybes-map-studio__legend-toggle,
.trybes-map-studio__region-list-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--trybes-map-studio-control-size);
  height: var(--trybes-map-studio-control-size);
  padding: 0;
  border: 1px solid var(--trybes-map-studio-color-stroke);
  border-radius: var(--trybes-map-studio-radius-sm);
  background: var(--trybes-map-studio-color-bubble-background);
  box-shadow: var(--trybes-map-studio-shadow);
  color: var(--trybes-map-studio-color-bubble-text);
  cursor: pointer;
  outline: none;
  transition: border-color var(--trybes-map-studio-control-transition), transform var(--trybes-map-studio-control-transition);
  -webkit-tap-highlight-color: transparent;
}

.trybes-map-studio__reset[hidden],
.trybes-map-studio__legend-toggle[hidden],
.trybes-map-studio__region-list-toggle[hidden] {
  display: none;
}

.trybes-map-studio__reset:hover,
.trybes-map-studio__legend-toggle:hover,
.trybes-map-studio__region-list-toggle:hover {
  border-color: currentColor;
}

.trybes-map-studio__actions button:focus,
.trybes-map-studio__actions button:focus-visible,
.trybes-map-studio__actions button:active {
  border-color: var(--trybes-map-studio-color-stroke);
  box-shadow: var(--trybes-map-studio-shadow);
  outline: none;
}

.trybes-map-studio__reset:active,
.trybes-map-studio__legend-toggle:active,
.trybes-map-studio__region-list-toggle:active {
  transform: scale(0.96);
}

.trybes-map-studio__reset-icon,
.trybes-map-studio__legend-toggle-icon,
.trybes-map-studio__region-list-toggle-icon {
  width: var(--trybes-map-studio-icon-size);
  height: var(--trybes-map-studio-icon-size);
}

.trybes-map-studio__reset-icon path,
.trybes-map-studio__legend-toggle-icon path,
.trybes-map-studio__region-list-toggle-icon path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: var(--trybes-map-studio-icon-stroke-width);
}

.trybes-map-studio__bubble {
  position: absolute;
  top: var(--trybes-map-studio-bubble-y);
  left: var(--trybes-map-studio-bubble-x);
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: min(340px, calc(100% - var(--trybes-map-studio-space-lg) * 2));
  max-height: min(340px, calc(100% - var(--trybes-map-studio-space-lg) * 2));
  padding: var(--trybes-map-studio-space-md);
  border: 1px solid var(--trybes-map-studio-color-stroke);
  border-radius: var(--trybes-map-studio-radius-sm);
  background: var(--trybes-map-studio-color-bubble-background);
  box-shadow: var(--trybes-map-studio-shadow);
  color: var(--trybes-map-studio-color-bubble-text);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.trybes-map-studio__bubble-pointer {
  position: absolute;
  left: var(--trybes-map-studio-bubble-pointer-x);
  width: 0;
  height: 0;
  pointer-events: none;
  transform: translateX(-50%);
}

.trybes-map-studio__bubble-pointer::before,
.trybes-map-studio__bubble-pointer::after {
  position: absolute;
  left: 0;
  width: 0;
  height: 0;
  border-style: solid;
  content: "";
  transform: translateX(-50%);
}

.trybes-map-studio__bubble-pointer::before {
  filter: drop-shadow(var(--trybes-map-studio-bubble-pointer-shadow));
}

.trybes-map-studio__bubble.is-above-region .trybes-map-studio__bubble-pointer {
  top: 100%;
}

.trybes-map-studio__bubble.is-above-region .trybes-map-studio__bubble-pointer::before {
  top: 0;
  border-width: var(--trybes-map-studio-bubble-pointer-size) var(--trybes-map-studio-bubble-pointer-half) 0 var(--trybes-map-studio-bubble-pointer-half);
  border-color: var(--trybes-map-studio-color-stroke) transparent transparent transparent;
}

.trybes-map-studio__bubble.is-above-region .trybes-map-studio__bubble-pointer::after {
  top: calc(var(--trybes-map-studio-bubble-pointer-border) * -1);
  border-width: var(--trybes-map-studio-bubble-pointer-inner-size) var(--trybes-map-studio-bubble-pointer-inner-half) 0 var(--trybes-map-studio-bubble-pointer-inner-half);
  border-color: var(--trybes-map-studio-color-bubble-background) transparent transparent transparent;
}

.trybes-map-studio__bubble.is-below-region .trybes-map-studio__bubble-pointer {
  bottom: 100%;
}

.trybes-map-studio__bubble.is-below-region .trybes-map-studio__bubble-pointer::before {
  bottom: 0;
  border-width: 0 var(--trybes-map-studio-bubble-pointer-half) var(--trybes-map-studio-bubble-pointer-size) var(--trybes-map-studio-bubble-pointer-half);
  border-color: transparent transparent var(--trybes-map-studio-color-stroke) transparent;
}

.trybes-map-studio__bubble.is-below-region .trybes-map-studio__bubble-pointer::after {
  bottom: calc(var(--trybes-map-studio-bubble-pointer-border) * -1);
  border-width: 0 var(--trybes-map-studio-bubble-pointer-inner-half) var(--trybes-map-studio-bubble-pointer-inner-size) var(--trybes-map-studio-bubble-pointer-inner-half);
  border-color: transparent transparent var(--trybes-map-studio-color-bubble-background) transparent;
}

.trybes-map-studio__bubble.is-legend {
  top: calc(var(--trybes-map-studio-space-md) + var(--trybes-map-studio-control-size) + var(--trybes-map-studio-space-sm));
  right: var(--trybes-map-studio-space-md);
  left: auto;
}

.trybes-map-studio__bubble.is-legend .trybes-map-studio__bubble-pointer {
  display: none;
}

.trybes-map-studio__bubble.is-open {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.trybes-map-studio__bubble-content {
  min-height: 0;
  overflow: auto;
  color: var(--trybes-map-studio-color-bubble-text);
}

.trybes-map-studio__bubble-content > :first-child {
  margin-top: 0;
  padding-right: calc(var(--trybes-map-studio-bubble-close-size) + var(--trybes-map-studio-space-xs));
}

.trybes-map-studio__bubble-content > :last-child {
  margin-bottom: 0;
}

.trybes-map-studio__region-posts {
  margin: var(--trybes-map-studio-space-sm) 0 0;
  padding: 0;
  list-style: none;
}

.trybes-map-studio__region-post + .trybes-map-studio__region-post {
  margin-top: var(--trybes-map-studio-space-xs);
}

.trybes-map-studio__region-post a {
  color: inherit;
}

.trybes-map-studio__close {
  position: absolute;
  top: var(--trybes-map-studio-space-sm);
  right: var(--trybes-map-studio-space-sm);
  width: var(--trybes-map-studio-bubble-close-size);
  height: var(--trybes-map-studio-bubble-close-size);
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--trybes-map-studio-radius-sm);
  background: transparent;
  color: var(--trybes-map-studio-color-bubble-text);
  cursor: pointer;
  font: inherit;
  line-height: 1;
}

.trybes-map-studio__close:hover,
.trybes-map-studio__close:focus-visible {
  border-color: currentColor;
}

.trybes-map-studio__notice {
  margin: var(--trybes-map-studio-space-md) 0;
}

.trybes-map-studio__region-list {
  max-height: var(--trybes-map-studio-region-list-max-height);
  overflow: auto;
  padding: var(--trybes-map-studio-space-sm);
  border: 1px solid var(--trybes-map-studio-color-stroke);
  border-radius: var(--trybes-map-studio-radius-sm);
  background: var(--trybes-map-studio-color-bubble-background);
  color: var(--trybes-map-studio-color-bubble-text);
}

.trybes-map-studio__region-search {
  width: 100%;
  min-height: var(--trybes-map-studio-control-size);
  margin: 0 0 var(--trybes-map-studio-space-sm);
  padding: var(--trybes-map-studio-space-sm) var(--trybes-map-studio-space-md);
  border: 1px solid var(--trybes-map-studio-color-stroke);
  border-radius: var(--trybes-map-studio-radius-sm);
  background: var(--trybes-map-studio-color-bubble-background);
  color: var(--trybes-map-studio-color-bubble-text);
  font: inherit;
}

.trybes-map-studio__region-search:focus-visible {
  border-color: currentColor;
  outline: none;
}

.trybes-map-studio__region-list-items {
  display: grid;
  gap: var(--trybes-map-studio-space-xs);
}

.trybes-map-studio__region-list-item {
  min-width: 0;
}

.trybes-map-studio__region-list-button {
  display: block;
  width: 100%;
  min-height: var(--trybes-map-studio-control-size);
  padding: var(--trybes-map-studio-space-sm) var(--trybes-map-studio-space-md);
  border: 1px solid transparent;
  border-radius: var(--trybes-map-studio-radius-sm);
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.trybes-map-studio__region-list-label {
  display: block;
  overflow-wrap: anywhere;
}

.trybes-map-studio__region-list-button:hover,
.trybes-map-studio__region-list-button:focus-visible {
  border-color: currentColor;
}

.trybes-map-studio__region-list-button.is-selected {
  border-color: var(--trybes-map-studio-color-active);
  box-shadow: inset var(--trybes-map-studio-region-list-selected-bar) 0 0 var(--trybes-map-studio-color-active);
}

@media (max-width: 782px) {
  .trybes-map-studio.has-region-list .trybes-map-studio__body {
    grid-template-columns: 1fr;
  }

  .trybes-map-studio.has-collapsible-region-list.has-region-list .trybes-map-studio__body {
    grid-template-columns: 1fr;
  }

  .trybes-map-studio.is-region-list-left .trybes-map-studio__viewport,
  .trybes-map-studio.is-region-list-right .trybes-map-studio__viewport,
  .trybes-map-studio.has-collapsible-region-list .trybes-map-studio__viewport {
    order: 1;
  }

  .trybes-map-studio.is-region-list-left .trybes-map-studio__region-list,
  .trybes-map-studio.is-region-list-right .trybes-map-studio__region-list,
  .trybes-map-studio.has-collapsible-region-list .trybes-map-studio__region-list {
    order: 2;
  }

  .trybes-map-studio__region-list {
    width: 100%;
    max-height: var(--trybes-map-studio-region-list-mobile-max-height);
  }

  .trybes-map-studio__bubble {
    width: calc(100% - var(--trybes-map-studio-space-md) * 2);
    max-height: min(280px, calc(100% - var(--trybes-map-studio-space-md) * 2));
    padding: var(--trybes-map-studio-space-sm);
  }
}

@container trybes-map-studio (max-width: 782px) {
  .trybes-map-studio.has-region-list .trybes-map-studio__body {
    grid-template-columns: 1fr;
  }

  .trybes-map-studio.has-collapsible-region-list.has-region-list .trybes-map-studio__body {
    grid-template-columns: 1fr;
  }

  .trybes-map-studio.is-region-list-left .trybes-map-studio__viewport,
  .trybes-map-studio.is-region-list-right .trybes-map-studio__viewport,
  .trybes-map-studio.has-collapsible-region-list .trybes-map-studio__viewport {
    order: 1;
  }

  .trybes-map-studio.is-region-list-left .trybes-map-studio__region-list,
  .trybes-map-studio.is-region-list-right .trybes-map-studio__region-list,
  .trybes-map-studio.has-collapsible-region-list .trybes-map-studio__region-list {
    order: 2;
  }

  .trybes-map-studio__region-list {
    width: 100%;
    max-height: var(--trybes-map-studio-region-list-mobile-max-height);
  }
}

@media (prefers-reduced-motion: reduce) {
  .trybes-map-studio__reset,
  .trybes-map-studio__legend-toggle,
  .trybes-map-studio__region-list-toggle {
    transition-duration: 1ms;
  }
}
