/* QPal Community Map compact showcase, custom region picker, and external regional bubbles. */
.qpal-community-map-dialog {
  width: min(92vw, 620px);
  max-height: min(82dvh, 720px);
  padding: 16px;
  border-radius: 24px;
}

.qpal-community-map-header {
  gap: 12px;
}

.qpal-community-map-header h2 {
  margin-top: 4px;
  font-size: clamp(22px, 3.6vw, 30px);
}

.qpal-community-map-header p {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.42;
}

.qpal-community-summary {
  display: block;
  margin-top: 12px;
}

.qpal-community-summary > .qpal-community-registered-card {
  display: grid;
  gap: 9px;
  min-height: 0;
  padding: 11px 13px;
  overflow: hidden;
  background:
    radial-gradient(circle at 8% 15%, color-mix(in srgb, var(--accent) 11%, transparent), transparent 34%),
    var(--surface-muted);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
}

.qpal-community-registered-heading {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 25px;
  text-align: left;
}

.qpal-community-registered-heading strong {
  color: var(--accent);
  font-size: 25px;
  line-height: 1;
}

.qpal-community-registered-label {
  display: grid;
  grid-template-rows: 1fr 1fr;
  align-self: stretch;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 850;
  line-height: 1;
}

.qpal-community-registered-label > span {
  display: flex;
  align-items: center;
}

.qpal-community-showcase {
  min-width: 0;
}

.qpal-community-showcase-viewport {
  position: relative;
  width: min(100% - 24px, 250px);
  min-height: 32px;
  margin-inline: auto;
  overflow: hidden;
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}

.qpal-community-showcase-track {
  position: relative;
  width: 100%;
  min-height: 32px;
}

.qpal-community-showcase-track.is-empty {
  width: 100%;
}

.qpal-community-showcase-group {
  position: absolute;
  top: 2px;
  left: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  animation: qpal-community-showcase-slide var(--showcase-duration, 12s) linear infinite;
  will-change: left, transform;
}

.qpal-community-showcase-avatar.qpal-community-bubble-avatar {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--text-primary);
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  box-shadow: var(--shadow-control);
  margin-left: 0;
  font-size: 10px;
  font-weight: 900;
}

.qpal-community-showcase-avatar.is-current {
  color: var(--accent-contrast);
  background: var(--accent);
  border-color: var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent) 26%, transparent);
}

.qpal-community-showcase-empty {
  width: 100%;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}

@keyframes qpal-community-showcase-slide {
  from {
    left: 0;
    transform: translateX(-100%);
  }
  to {
    left: 100%;
    transform: translateX(0);
  }
}

.qpal-community-map-panel {
  margin-top: 10px;
  padding: 7px;
  border-radius: 20px;
}

.qpal-community-map-stage {
  width: min(100%, 420px);
  aspect-ratio: 1 / 1.033;
}

.qpal-community-map-svg {
  position: absolute;
  left: 14%;
  top: 0;
  width: 72%;
  height: auto;
  transform: none !important;
  transform-origin: 50% 50%;
}

.qpal-community-markers > .qpal-community-marker-cluster {
  display: none !important;
}

.qpal-community-connector-layer,
.qpal-community-bubble-layer {
  position: absolute;
  inset: 0;
}

.qpal-community-connector-layer {
  z-index: 3;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.qpal-community-region-connector {
  fill: none;
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-dasharray: 2.5 2.5;
  vector-effect: non-scaling-stroke;
  opacity: .72;
}

.qpal-community-region-connector.is-luzon { stroke: #ce1126; }
.qpal-community-region-connector.is-visayas { stroke: #fcd116; }
.qpal-community-region-connector.is-mindanao { stroke: #2563eb; }

.qpal-community-region-connector-dot {
  stroke: color-mix(in srgb, var(--surface) 70%, transparent);
  stroke-width: .7;
  vector-effect: non-scaling-stroke;
}

.qpal-community-region-connector-dot.is-luzon { fill: #ce1126; }
.qpal-community-region-connector-dot.is-visayas { fill: #fcd116; }
.qpal-community-region-connector-dot.is-mindanao { fill: #2563eb; }

.qpal-community-bubble-layer {
  z-index: 5;
  pointer-events: none;
}

.qpal-community-region-bubble {
  --bubble-color: var(--accent);
  position: absolute;
  left: var(--bubble-x);
  top: var(--bubble-y);
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 4px;
  transform: translate(-50%, -50%);
  color: var(--text-primary);
  background:
    radial-gradient(circle at 30% 22%, color-mix(in srgb, var(--bubble-color) 18%, transparent), transparent 52%),
    color-mix(in srgb, var(--surface-elevated) 96%, transparent);
  border: 1px solid color-mix(in srgb, var(--bubble-color) 72%, var(--border-subtle));
  border-radius: 50%;
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--surface) 76%, transparent),
    0 8px 20px rgba(0, 0, 0, .28),
    0 0 18px color-mix(in srgb, var(--bubble-color) 18%, transparent);
  cursor: pointer;
  pointer-events: auto;
  transition: width .18s ease, height .18s ease, border-radius .18s ease, transform .18s ease, background .18s ease;
}

.qpal-community-region-bubble.is-luzon { --bubble-color: #ce1126; }
.qpal-community-region-bubble.is-visayas { --bubble-color: #e6b800; }
.qpal-community-region-bubble.is-mindanao { --bubble-color: #2563eb; }

.qpal-community-region-bubble.has-current {
  border-width: 2px;
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent),
    0 9px 22px rgba(0, 0, 0, .3),
    0 0 22px color-mix(in srgb, var(--accent) 30%, transparent);
}

.qpal-community-region-bubble:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.qpal-community-bubble-closed {
  display: grid;
  grid-template-rows: auto auto;
  justify-items: center;
  gap: 1px;
}

.qpal-community-bubble-avatars,
.qpal-community-bubble-detail-members {
  display: flex;
  align-items: center;
  justify-content: center;
}

.qpal-community-bubble-avatars {
  gap: 0;
}

.qpal-community-bubble-avatar {
  display: inline-grid;
  place-items: center;
  width: 21px;
  height: 21px;
  margin-left: -4px;
  color: var(--accent-contrast);
  background: var(--accent);
  border: 2px solid var(--surface-elevated);
  border-radius: 50%;
  font-size: 8px;
  font-weight: 900;
  line-height: 1;
}

.qpal-community-bubble-avatar:first-child {
  margin-left: 0;
}

.qpal-community-bubble-avatar.is-current {
  outline: 2px solid color-mix(in srgb, var(--accent) 34%, transparent);
}

.qpal-community-bubble-count {
  color: var(--text-primary);
  font-size: 8px;
  font-weight: 900;
  line-height: 1;
}

.qpal-community-bubble-details {
  display: none;
  min-width: 0;
  text-align: left;
}

.qpal-community-region-bubble.is-expanded {
  z-index: 12;
  width: 150px;
  min-height: 86px;
  height: auto;
  padding: 10px;
  border-radius: 17px;
}

.qpal-community-region-bubble.is-expanded.is-left {
  transform: translate(0, -50%);
}

.qpal-community-region-bubble.is-expanded.is-right {
  transform: translate(-100%, -50%);
}

.qpal-community-region-bubble.is-expanded .qpal-community-bubble-closed {
  display: none;
}

.qpal-community-region-bubble.is-expanded .qpal-community-bubble-details {
  display: grid;
  gap: 6px;
}

.qpal-community-bubble-details strong {
  overflow: hidden;
  color: var(--text-primary);
  font-size: 10px;
  line-height: 1.25;
  text-overflow: ellipsis;
}

.qpal-community-bubble-detail-members {
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 4px;
}

.qpal-community-bubble-avatar.is-detail {
  width: 23px;
  height: 23px;
  margin: 0;
}

.qpal-community-bubble-more,
.qpal-community-bubble-details small {
  color: var(--text-secondary);
  font-size: 8px;
  font-weight: 750;
}

.qpal-community-location-form {
  position: relative;
  margin-top: 10px;
  padding: 11px;
  border-radius: 16px;
}

.qpal-community-location-controls {
  position: relative;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 8px;
}

.qpal-community-native-select {
  display: none !important;
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.qpal-community-region-picker {
  position: relative;
  min-width: 0;
}

.qpal-community-picker-trigger {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 43px;
  padding: 0 12px;
  color: var(--text-primary) !important;
  background: var(--surface-elevated) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 12px;
  box-shadow: var(--inner-highlight);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.qpal-community-picker-trigger:hover,
.qpal-community-picker-trigger:focus-visible,
.qpal-community-picker-trigger[aria-expanded="true"] {
  border-color: var(--accent-border);
  outline: 3px solid var(--focus-ring);
  outline-offset: 0;
}

.qpal-community-picker-pin {
  color: var(--accent);
  font-size: 18px;
  font-weight: 900;
}

.qpal-community-picker-chevron {
  color: var(--text-secondary);
  font-size: 18px;
  transition: transform .18s ease;
}

.qpal-community-picker-trigger[aria-expanded="true"] .qpal-community-picker-chevron {
  transform: rotate(180deg);
}

.qpal-community-picker-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: auto;
  bottom: calc(100% + 6px);
  z-index: 30;
  max-height: min(34dvh, 230px);
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: color-mix(in srgb, var(--surface-elevated) 98%, transparent);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  box-shadow: var(--shadow-dialog), var(--inner-highlight);
  scrollbar-width: thin;
}

.qpal-community-picker-menu[hidden] {
  display: none;
}

.qpal-community-picker-menu button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-size: 11px;
  font-weight: 750;
  text-align: left;
  cursor: pointer;
}

.qpal-community-picker-menu button:hover,
.qpal-community-picker-menu button:focus-visible {
  color: var(--text-primary);
  background: var(--surface-hover);
  border-color: var(--border-subtle);
  outline: none;
}

.qpal-community-picker-menu button.is-selected {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-muted));
  border-color: var(--accent-border);
}

.qpal-community-picker-check {
  color: var(--accent);
  opacity: 0;
  font-weight: 900;
}

.qpal-community-picker-menu button.is-selected .qpal-community-picker-check {
  opacity: 1;
}

.qpal-community-location-controls > button[data-qpal-community-save] {
  width: 100%;
  min-height: 42px;
}

@media (max-width: 600px) {
  .qpal-community-map-dialog {
    width: min(94vw, 540px);
    max-height: 78dvh;
    padding: 13px;
    border-radius: 21px;
  }

  .qpal-community-map-header h2 {
    font-size: 21px;
  }

  .qpal-community-map-header p {
    font-size: 10.5px;
  }

  .qpal-community-map-close {
    width: 36px;
    height: 36px;
    font-size: 23px;
  }

  .qpal-community-summary {
    margin-top: 10px;
  }

  .qpal-community-summary > .qpal-community-registered-card {
    padding: 9px 11px;
  }

  .qpal-community-map-panel {
    margin-top: 8px;
    padding: 5px;
  }

  .qpal-community-map-stage {
    width: min(100%, 350px);
  }

  .qpal-community-region-bubble {
    width: 44px;
    height: 44px;
  }

  .qpal-community-region-bubble.is-expanded {
    width: 136px;
    min-height: 80px;
  }

  .qpal-community-location-form {
    margin-top: 8px;
    padding: 9px;
  }

  .qpal-community-location-form > p,
  .qpal-community-location-status {
    margin-top: 6px;
    font-size: 9px;
  }
}

@media (max-height: 680px) {
  .qpal-community-map-dialog {
    max-height: 86dvh;
  }

  .qpal-community-map-stage {
    width: min(100%, 300px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .qpal-community-showcase-group {
    position: static;
    justify-content: center;
    animation: none !important;
    transform: none !important;
  }

  .qpal-community-region-bubble,
  .qpal-community-picker-chevron {
    transition: none !important;
  }
}
