/**
 * Campaign mode styling for Map Studio: a dark map with twinkling donation lights.
 * Scoped to .trybes-map-studio.is-campaign so regular maps are unaffected.
 */

.trybes-map-studio.is-campaign {
  /* Het Vergeten Kind uses a flat design: no shadows/depth on elements. */
  --trybes-map-studio-shadow: none;

  background: radial-gradient(125% 95% at 50% 0%,
    color-mix(in srgb, var(--ms-campaign-map-bg, #112337) 78%, #ffffff) 0%,
    var(--ms-campaign-map-bg, #112337) 65%);
  border-radius: 18px;
  padding: 6px;
}

.trybes-map-studio.is-campaign .trybes-map-studio__region {
  fill: var(--ms-campaign-land, #1d3052);
  stroke: color-mix(in srgb, var(--ms-campaign-land, #1d3052) 68%, #ffffff);
  stroke-width: 0.4;
  transition: fill 0.25s ease, stroke 0.25s ease;
}

.trybes-map-studio.is-campaign .trybes-map-studio__region.is-active,
.trybes-map-studio.is-campaign .trybes-map-studio__region.is-inactive,
.trybes-map-studio.is-campaign .trybes-map-studio__region.is-selected {
  fill: var(--ms-campaign-land, #1d3052);
}

.trybes-map-studio.is-campaign .trybes-map-studio__region.has-donations {
  fill: color-mix(in srgb, var(--ms-campaign-land, #1d3052) 80%, #ffffff);
}

.trybes-map-studio.is-campaign .trybes-map-studio__region.is-hovered {
  fill: color-mix(in srgb, var(--ms-campaign-land, #1d3052) 62%, #ffffff);
  stroke: var(--ms-campaign-light, #ff6a78);
  stroke-width: 0.8;
}

/* Hover label: which municipality you are looking at */
.trybes-map-studio__region-label {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  align-items: baseline;
  max-width: calc(100% - 28px);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(8, 12, 24, 0.82);
  border: 1px solid rgba(255, 206, 107, 0.3);
  color: #fff;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.trybes-map-studio__region-label.is-visible {
  opacity: 1;
}

.trybes-map-studio__region-label-count {
  color: var(--ms-campaign-light, #ff8a6b);
  font-weight: 600;
  font-size: 0.9em;
}

/* Rich label: a small card with the contributor names/messages listed below. */
.trybes-map-studio__region-label--rich {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  border-radius: 14px;
  white-space: normal;
  text-align: left;
  width: min(380px, calc(100% - 28px));
  max-width: min(380px, calc(100% - 28px));
  max-height: 260px;
  overflow-y: auto;
}

/* "View all" button on the pinned touch card — opens the full contributor
   pop-up. The label itself is pointer-events:none, so the button re-enables
   pointer events and gets a comfortable tap target. */
.trybes-map-studio__region-label-open {
  pointer-events: auto;
  align-self: stretch;
  margin-top: 2px;
  padding: 9px 14px;
  min-height: 40px;
  border: 1px solid rgba(255, 206, 107, 0.55);
  border-radius: 999px;
  background: rgba(255, 206, 107, 0.14);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.trybes-map-studio__region-label-open:hover,
.trybes-map-studio__region-label-open:focus-visible {
  background: rgba(255, 206, 107, 0.26);
  outline: none;
}

.trybes-map-studio__region-label-contributors {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  font-weight: 400;
}

.trybes-map-studio__region-label-contributor {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.86em;
  line-height: 1.3;
}

.trybes-map-studio__region-label-contributor-name {
  font-weight: 600;
}

.trybes-map-studio__region-label-contributor-message {
  opacity: 0.85;
}

.trybes-map-studio__region-label-contributor-more {
  font-size: 0.8em;
  opacity: 0.7;
}

/* Full contributor list panel (click a region) */
.trybes-map-studio__contrib-panel {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(6, 9, 18, 0.55);
}

.trybes-map-studio__contrib-panel[hidden] {
  display: none;
}

.trybes-map-studio__contrib-panel-inner {
  position: relative;
  width: min(420px, 100%);
  max-height: min(80%, 520px);
  overflow-y: auto;
  /* Keep scrolling inside the panel — don't chain to the map/page behind it. */
  overscroll-behavior: contain;
  padding: 20px 22px 22px;
  border-radius: 16px;
  background: rgba(12, 16, 28, 0.98);
  border: 1px solid rgba(255, 206, 107, 0.28);
  color: #fff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.trybes-map-studio__contrib-panel-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.trybes-map-studio__contrib-panel-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.trybes-map-studio__contrib-panel-title {
  margin: 0 30px 12px 0;
  font-size: 1.1em;
}

.trybes-map-studio__contrib-panel-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.trybes-map-studio__contrib-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  line-height: 1.3;
}

.trybes-map-studio__contrib-row:focus-visible {
  outline: 2px solid var(--ms-campaign-light, #ff6a78);
  outline-offset: 2px;
  border-radius: 10px;
}

.trybes-map-studio__contrib-row-name {
  font-weight: 600;
}

.trybes-map-studio__contrib-row-message {
  opacity: 0.85;
  font-size: 0.95em;
}

.trybes-map-studio__contrib-panel-more {
  margin-top: 14px;
  width: 100%;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.trybes-map-studio__contrib-panel-more:hover {
  background: rgba(255, 255, 255, 0.14);
}

.trybes-map-studio__contrib-panel-empty {
  margin: 6px 0 0;
  opacity: 0.7;
}

/* "Donate" CTA link shown under the empty-state message in the pop-up. */
.trybes-map-studio__contrib-panel-cta {
  display: inline-block;
  margin: 10px 0 2px;
  font-weight: 700;
  color: var(--ms-campaign-light, #ff8a6b);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.trybes-map-studio__contrib-panel-cta:hover,
.trybes-map-studio__contrib-panel-cta:focus-visible {
  text-decoration-thickness: 2px;
}

/* Campaign goal progress bar (top of the campaign, below the hero) */
.trybes-map-studio__progress {
  margin: 4px 8px 12px;
  color: #eaf1ff;
}

.trybes-map-studio__progress[hidden] {
  display: none;
}

.trybes-map-studio__progress-row + .trybes-map-studio__progress-row {
  margin-top: 10px;
}

.trybes-map-studio__progress-row[hidden] {
  display: none;
}

.trybes-map-studio__progress-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Hidden when there is no goal — the class selector would otherwise beat the
   UA [hidden] rule and keep the empty bar visible. */
.trybes-map-studio__progress-bar-row[hidden] {
  display: none;
}

.trybes-map-studio__progress-track {
  position: relative;
  flex: 1;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.trybes-map-studio__progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--ms-campaign-light, #ff6a78) 70%, #ffffff),
    var(--ms-campaign-light, #ff6a78));
  transition: width 0.6s ease;
}

.trybes-map-studio__progress-percent {
  min-width: 3.2em;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.trybes-map-studio__progress-label {
  margin: 6px 0 0;
  font-size: 0.95em;
  font-weight: 700;
  opacity: 0.9;
  text-align: center;
}

/* Donated amount alongside a region / contributor */
.trybes-map-studio__region-label-amount {
  color: var(--ms-campaign-light, #ff8a6b);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.trybes-map-studio__contrib-row-header,
.trybes-map-studio__region-label-contributor-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.trybes-map-studio__region-label-contributor-amount,
.trybes-map-studio__contrib-row-amount {
  color: var(--ms-campaign-light, #ff8a6b);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* "Welcome back" thank-you card after a donation */
.trybes-map-studio__thanks {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translate(-50%, -12px);
  z-index: 6;
  width: min(360px, calc(100% - 28px));
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
}

.trybes-map-studio__thanks.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.trybes-map-studio__thanks-inner {
  position: relative;
  padding: 16px 20px 18px;
  border-radius: 14px;
  background: rgba(12, 16, 28, 0.96);
  border: 1px solid var(--ms-campaign-light, #ffce6b);
  box-shadow: 0 16px 46px rgba(0, 0, 0, 0.5);
  color: #fff;
  text-align: center;
}

.trybes-map-studio__thanks-close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.trybes-map-studio__thanks-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.trybes-map-studio__thanks-title {
  margin: 0 0 4px;
  font-size: 1.15em;
  font-weight: 700;
  color: var(--ms-campaign-light, #ffce6b);
}

.trybes-map-studio__thanks-body {
  margin: 0;
  opacity: 0.92;
  line-height: 1.35;
}

/* Brief pulse on the count bar when a donation ticks it up */
.trybes-map-studio__progress-row.is-bumped .trybes-map-studio__progress-label,
.trybes-map-studio__progress-row.is-bumped .trybes-map-studio__progress-percent {
  animation: trybes-map-studio-bump 0.9s ease;
}

@keyframes trybes-map-studio-bump {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.14); }
}

@media (prefers-reduced-motion: reduce) {
  .trybes-map-studio__thanks {
    transition: opacity 0.2s ease;
    transform: translate(-50%, 0);
  }
  .trybes-map-studio__progress-row.is-bumped .trybes-map-studio__progress-label,
  .trybes-map-studio__progress-row.is-bumped .trybes-map-studio__progress-percent {
    animation: none;
  }
}

/* Twinkling lights */
.trybes-map-studio__lights {
  pointer-events: none;
}

.trybes-map-studio__light {
  transform-box: fill-box;
  transform-origin: center;
  animation: trybes-map-studio-twinkle var(--trybes-map-studio-twinkle-duration, 2s) ease-in-out var(--trybes-map-studio-twinkle-delay, 0s) infinite;
  will-change: opacity, transform;
}

.trybes-map-studio__light-core {
  fill: #fffdf5;
}

.trybes-map-studio__light.is-new {
  animation: trybes-map-studio-light-burst 1s ease-out;
}

@keyframes trybes-map-studio-twinkle {
  0%, 100% { opacity: 0.18; transform: scale(0.55); }
  50%      { opacity: 1; transform: scale(1.15); }
}

@keyframes trybes-map-studio-light-burst {
  0%   { opacity: 0; transform: scale(0.1); }
  35%  { opacity: 1; transform: scale(2.2); }
  100% { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .trybes-map-studio__light,
  .trybes-map-studio__light.is-new {
    animation: none;
    opacity: 0.9;
  }
}

/* Donation total badge */
.trybes-map-studio__donation-total {
  position: absolute;
  left: 14px;
  bottom: 14px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(17, 35, 55, 0.78);
  border: 1px solid rgba(255, 106, 120, 0.4);
  color: #ffe1d2;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
  pointer-events: none;
}

/* A pulsing light dot instead of a heart, so the badge reads as "lights on the
   map" rather than "likes". Uses the campaign light colour. */
.trybes-map-studio__donation-total::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--ms-campaign-light, #ffce6b);
  box-shadow: 0 0 6px var(--ms-campaign-light, #ffce6b);
  vertical-align: middle;
  animation: trybes-map-studio-total-pulse 1.6s ease-in-out infinite;
}

@keyframes trybes-map-studio-total-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.6); }
}

@media (prefers-reduced-motion: reduce) {
  .trybes-map-studio__donation-total::before {
    animation: none;
  }
}

/* Anonymous donations: a quiet own row inside the data table. */
.trybes-map-studio__data-unknown[hidden] {
  display: none;
}

/* Visually hidden, still read by screen readers */
.trybes-map-studio__sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Accessible data table (alternative to the visual map) */
.trybes-map-studio.is-campaign .trybes-map-studio__data-table {
  margin: 14px 6px 6px;
  color: #dce6fb;
  font-size: 14px;
}

.trybes-map-studio.is-campaign .trybes-map-studio__data-table summary {
  cursor: pointer;
  padding: 8px 4px;
  color: #ffffff;
  font-weight: 600;
}

.trybes-map-studio.is-campaign .trybes-map-studio__data-table summary:focus-visible {
  outline: 2px solid var(--ms-campaign-light, #ff6a78);
  outline-offset: 2px;
  border-radius: 4px;
}

.trybes-map-studio__data-search {
  width: 100%;
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  font: inherit;
}

.trybes-map-studio__data-search::placeholder {
  color: #9fb0d4;
}

.trybes-map-studio__data-search:focus-visible {
  outline: 2px solid var(--ms-campaign-light, #ff6a78);
  outline-offset: 1px;
}

.trybes-map-studio__data-table-scroll {
  max-height: 320px;
  overflow: auto;
  margin-top: 8px;
}

.trybes-map-studio__data-name {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.25);
}

.trybes-map-studio__data-name:hover {
  text-decoration-color: var(--ms-campaign-light, #ff6a78);
}

.trybes-map-studio__data-name:focus-visible {
  outline: 2px solid var(--ms-campaign-light, #ff6a78);
  outline-offset: 2px;
  border-radius: 3px;
}

.trybes-map-studio.is-campaign .trybes-map-studio__data-empty td {
  padding: 16px 8px;
  text-align: center;
  color: #aab8da;
  font-style: italic;
}

.trybes-map-studio.is-campaign .trybes-map-studio__data-table table {
  width: 100%;
  border-collapse: collapse;
}

.trybes-map-studio.is-campaign .trybes-map-studio__data-table caption {
  text-align: left;
  padding: 4px 0 8px;
  color: #aab8da;
}

.trybes-map-studio.is-campaign .trybes-map-studio__data-table th,
.trybes-map-studio.is-campaign .trybes-map-studio__data-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.trybes-map-studio.is-campaign .trybes-map-studio__data-table thead th {
  color: #ffffff;
}

.trybes-map-studio__sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  cursor: pointer;
}

.trybes-map-studio__sort-btn:focus-visible {
  outline: 2px solid var(--ms-campaign-light, #ff6a78);
  outline-offset: 2px;
  border-radius: 4px;
}

.trybes-map-studio__data-th[aria-sort="ascending"] .trybes-map-studio__sort-btn::after {
  content: "▲";
  font-size: 0.7em;
}

.trybes-map-studio__data-th[aria-sort="descending"] .trybes-map-studio__sort-btn::after {
  content: "▼";
  font-size: 0.7em;
}

.trybes-map-studio.is-campaign .trybes-map-studio__data-table td {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Right-align the numeric column headers to match the values below them
   (the region-name header stays left). */
.trybes-map-studio.is-campaign .trybes-map-studio__data-table thead th[data-trybes-map-studio-sort="count"],
.trybes-map-studio.is-campaign .trybes-map-studio__data-table thead th.trybes-map-studio__data-amount-th {
  text-align: right;
}

.trybes-map-studio.is-campaign .trybes-map-studio__data-table tfoot th,
.trybes-map-studio.is-campaign .trybes-map-studio__data-table tfoot td {
  color: #ffffff;
  font-weight: 700;
}

/* Live-update toast: a brief notice pinned bottom-left of the viewport when a
   poll adds lights, so visitors discover the map updates itself. */
.trybes-map-studio__poll-toast {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 1000;
  max-width: min(320px, calc(100vw - 40px));
  padding: 12px 18px;
  border-radius: 12px;
  background: rgba(8, 12, 24, 0.9);
  border: 1px solid rgba(255, 206, 107, 0.35);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.trybes-map-studio__poll-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .trybes-map-studio__poll-toast,
  .trybes-map-studio__poll-toast.is-visible {
    transition: opacity 0.2s ease;
    transform: none;
  }
}
