/* --- Hide defaults --- */
.hidden {
  display: none;
}
.glsr-field-rating,
.glsr-default .glsr-review-rating {
  display: none;
}

.glsr-field[data-field="email"] {order:1;}

.glsr-field[data-field="title"] {order:2;} /*zip*/
.glsr-field[data-field="name"] {order:3;}
.glsr-field[data-field="content"] {order:4;}
.glsr-field[data-field="terms"] {order:5; font-size: 80%;} 

div[data-field="submit-button"] {order:6; }

.glsr-field[data-field="terms"] .glsr-toggle-switch {display: none !important;} 

/* Ensure Elementor shortcode containers expand to child maps */
.elementor-widget-shortcode .elementor-widget-container {
  display: block !important;
  overflow: visible;
}

/* Force the inner container to respect the pseudo-element height */
.elementor-widget-shortcode .fm-heart-map {
  display: block;
  position: relative;
  width: 100%;
}

/* Allow Elementor wrappers to inherit map height properly */
.elementor-shortcode {
  display: block;
  width: 100%;
  height: auto;
}

/* --- Map container --- */
.fm-heart-map,
.fm-heart-picker {
  position: relative;
  display: block;
  width: 100%;
  max-width: 900px;
  aspect-ratio: 900 / 695; /* maintain proportion */
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  border-radius: 8px;
  box-shadow: 0 3px 14px rgba(0,0,0,.12);
  margin: 0 auto 2rem;
  overflow: visible;
}

/* Make Elementor respect the heart map's height */
.elementor-widget-container:has(.fm-heart-map) {
  display: block !important;
  height: auto !important;
  overflow: visible !important;
  position: relative;
}

/* Force the heart map to contribute to layout height */
.fm-heart-map {
  position: relative;
  width: 100%;
  display: block;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}


/* Ensure the Elementor outer wrapper expands to the map height */
.elementor-element:has(.fm-heart-map) {
  align-items: flex-start !important; /* prevents flex centering collapse */
  height: auto !important;
  min-height: auto !important;
  overflow: visible !important;
}

/* If the parent container uses flex column layout, force it to grow */
.elementor-element.elementor-widget-shortcode {
  flex: 1 1 auto !important;
  align-self: stretch !important;
}

/* The widget container and map should both establish height */
.elementor-widget-shortcode .elementor-widget-container {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  overflow: visible !important;
  position: relative;
}

/* --- Heart buttons --- */
.fm-heart {
  position: absolute;
  transform: translate(-50%, -50%);
  width: clamp(16px, 2.5vw, 35px);
  height: clamp(16px, 2.5vw, 35px);
  border: 0;
  background: none !important;
  background-color: transparent !important;
  cursor: pointer;
  padding: 0;
  z-index: 5;
  transition: transform 0.15s ease;
}

/* --- Heart icon --- */
.fm-heart-shape {
  display: inline-block;
  width: 100%;
  height: 100%;
  background: url('https://gblibraryfund.org/wp-content/uploads/2025/10/icon-hand-E56B5D-white-thick-full-shadow.png')
    no-repeat center / contain;
  transform-origin: bottom center; /* pivot point for waving */
  animation: wave 2s ease-in-out infinite;
}

/* Optional hover scale */
.fm-heart:hover .fm-heart-shape {
  transform: scale(1.2);
}

/* Fix hover state (prevent ghost background) */
.fm-heart:hover {
  background: none !important;
  background-color: transparent !important;
}

/* --- Animations --- */
@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes wave {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(15deg); }
  40% { transform: rotate(-10deg); }
  60% { transform: rotate(12deg); }
  80% { transform: rotate(-8deg); }
}

/* Randomize wave offset */
.fm-heart:nth-of-type(5n+1) .fm-heart-shape { animation-delay: 0s; }
.fm-heart:nth-of-type(5n+2) .fm-heart-shape { animation-delay: 0.3s; }
.fm-heart:nth-of-type(5n+3) .fm-heart-shape { animation-delay: 0.6s; }
.fm-heart:nth-of-type(5n+4) .fm-heart-shape { animation-delay: 0.9s; }
.fm-heart:nth-of-type(5n+5) .fm-heart-shape { animation-delay: 1.2s; }

/* --- Popover --- */
.fm-heart-popover {
  position: absolute;
  max-width: 280px;
  width: 70vw;
  background: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  transform: translateX(-50%);
  z-index: 30;
  font-size: clamp(0.85rem, 2vw, 1rem);
  line-height: 1.4;
  transition: opacity 0.2s ease, transform 0.2s ease;
  opacity: 1;
}

/* Scroll if long */
.fm-heart-popover-inner {
  position: relative;
  max-height: 70vh;
  overflow-y: visible;
}

/* Close button */
.fm-heart-popover-close {
  position: absolute;
  right: -13px;
  top: -12px;
  border: 0;
  background: transparent;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  color: #666;
  line-height: 1;
  transition: color 0.2s;
}
.fm-heart-popover-close:hover {
  color: #000;
}

/* Typography inside popover */
.fm-heart-popover-title {
  font-weight: 600;
  margin-bottom: 4px;
}
.fm-heart-popover-rating {
  margin-bottom: 6px;
  color: #e31b23;
}
.fm-heart-popover-rating::before {
  content: "★";
  margin-right: 4px;
}
.fm-heart-popover-name {
  margin-top: 5px;
  font-style: italic;
  color: #333;
}
.fm-heart-popover-date {
  display: block;
  margin-top: 2px;
  font-size: 0.85em;
  color: #555;
}
.fm-heart-note {
  font-size: 13px;
  opacity: .8;
  margin: 6px 0;
}

/* --- Mobile adjustments --- */
@media (max-width: 600px) {
  .fm-heart-popover {
    width: 90vw;
    left: 50%;
    bottom: 10px;
    top: auto;
    transform: translateX(-50%);
    border-radius: 12px;
  }
}

/* === Elementor integration fixes (final balanced version) === */

/* Let the shortcode widget expand naturally without overriding width controls */
.elementor-widget-shortcode:has(.fm-heart-map),
.elementor-widget-shortcode:has(.fm-heart-map) .elementor-widget-container {
  display: block !important;
  height: auto !important;
  overflow: visible !important;
  position: relative;
  width: auto !important;       /* allow Elementor’s editor to control width */
  max-width: 100% !important;   /* prevent overflow */
}

/* Ensure parent containers stretch vertically to the map height */
.elementor-element:has(.fm-heart-map) {
  align-items: flex-start !important; /* prevent flex collapse */
  height: auto !important;
  min-height: auto !important;
  overflow: visible !important;
  flex: 0 0 auto !important;
}

/* Do NOT globally affect all Elementor sections */
.elementor-section,
.e-con-inner {
  align-items: stretch !important; /* stretch children normally */
}

/* --- FRONT-END ONLY safeguard --- */
body:not(.elementor-editor-active) .elementor-widget-shortcode:has(.fm-heart-map),
body:not(.elementor-editor-active) .elementor-widget-shortcode:has(.fm-heart-map) .elementor-widget-container {
  width: 100% !important; /* only force full width on live site */
}

