/*
 * marnamic map popups and native Google Maps controls.
 *
 * Loaded after the global theme layers so Google Maps' generated markup and
 * late inline styles cannot override the component contrast.
 */

body.wp-child-theme-marnamic .gm-style .gm-style-iw-c:has(.marnamic-map-card) {
  box-sizing: border-box;
  max-width: min(360px, calc(100vw - 32px)) !important;
  padding: 0 !important;
  overflow: visible !important;
  color: var(--marnamic-cream) !important;
  background:
    linear-gradient(180deg, rgba(32, 51, 55, 0.98), rgba(24, 39, 43, 1)) !important;
  border: 1px solid var(--marnamic-border) !important;
  border-radius: calc(var(--marnamic-radius) + 2px) !important;
  box-shadow: 0 22px 52px rgba(0, 0, 0, 0.34) !important;
  /* Google caps the window at the space above the marker (about 170px on a
     phone map), which cut off "Profil ansehen". The card is compact, so it
     gets its full height; the map pans to fit it. */
  max-height: none !important;
}

body.wp-child-theme-marnamic .gm-style .gm-style-iw-d:has(.marnamic-map-card) {
  max-height: none !important;
  overflow: visible !important;
  border-radius: inherit;
}

body.wp-child-theme-marnamic .gm-style .marnamic-map-card {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: min(336px, calc(100vw - 48px));
  min-width: min(280px, calc(100vw - 48px));
  max-width: 100%;
  margin: 0;
  padding: 24px;
  color: var(--marnamic-cream) !important;
  font-family: var(--marnamic-font-body);
}

body.wp-child-theme-marnamic .gm-style .marnamic-map-card__title {
  order: 1;
  margin: 0 0 14px;
  padding-inline-end: 44px;
  color: var(--marnamic-cream) !important;
  font-family: var(--marnamic-font-display);
  font-size: clamp(1.2rem, 1.05rem + 0.45vw, 1.5rem);
  font-weight: 400;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

body.wp-child-theme-marnamic .gm-style .marnamic-map-card__badge {
  order: 2;
  align-self: flex-start;
  min-height: 30px;
  margin: 0 0 16px;
  padding: 5px 12px;
  color: var(--marnamic-cream) !important;
  background: rgba(15, 25, 27, 0.58) !important;
  border: 1px solid var(--marnamic-border) !important;
  border-radius: 999px !important;
  font-size: 0.78rem;
  line-height: 1;
}

body.wp-child-theme-marnamic .gm-style .marnamic-map-card--listing .marnamic-map-card__badge {
  color: var(--marnamic-dark) !important;
  background: var(--marnamic-lime) !important;
  border-color: var(--marnamic-lime) !important;
}

body.wp-child-theme-marnamic .gm-style .marnamic-map-card__location {
  order: 3;
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin: 0 0 18px;
  color: var(--marnamic-mint) !important;
  font-size: 0.96rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

body.wp-child-theme-marnamic .gm-style .marnamic-map-card__location > .hp-icon {
  flex: 0 0 auto;
  margin-top: 0.2em;
  color: var(--marnamic-lime) !important;
}

body.wp-child-theme-marnamic .gm-style .marnamic-map-card__link,
body.wp-child-theme-marnamic .gm-style .gm-style-iw-c .marnamic-map-card__link,
body.wp-child-theme-marnamic.wp-child-theme-marnamic
  .marnamic-map-hotfix .gm-style .marnamic-map-card__link,
body.wp-child-theme-marnamic.wp-child-theme-marnamic
  .marnamic-map-hotfix .gm-style .gm-style-iw-c .marnamic-map-card__link {
  order: 4;
  display: inline-flex;
  gap: 9px;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 0 18px;
  color: var(--marnamic-dark) !important;
  background: var(--marnamic-lime) !important;
  border: 1px solid var(--marnamic-lime) !important;
  border-radius: var(--marnamic-radius) !important;
  box-shadow: none !important;
  font-family: var(--marnamic-font-display);
  font-size: 0.96rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  text-decoration: none !important;
}

body.wp-child-theme-marnamic .gm-style .marnamic-map-card__link:hover,
body.wp-child-theme-marnamic .gm-style .marnamic-map-card__link:focus-visible,
body.wp-child-theme-marnamic .gm-style .gm-style-iw-c .marnamic-map-card__link:hover,
body.wp-child-theme-marnamic .gm-style .gm-style-iw-c .marnamic-map-card__link:focus-visible,
body.wp-child-theme-marnamic.wp-child-theme-marnamic
  .marnamic-map-hotfix .gm-style .marnamic-map-card__link:hover,
body.wp-child-theme-marnamic.wp-child-theme-marnamic
  .marnamic-map-hotfix .gm-style .marnamic-map-card__link:focus-visible,
body.wp-child-theme-marnamic.wp-child-theme-marnamic
  .marnamic-map-hotfix .gm-style .gm-style-iw-c .marnamic-map-card__link:hover,
body.wp-child-theme-marnamic.wp-child-theme-marnamic
  .marnamic-map-hotfix .gm-style .gm-style-iw-c .marnamic-map-card__link:focus-visible {
  color: var(--marnamic-dark) !important;
  background: var(--marnamic-lime-hover) !important;
  border-color: var(--marnamic-lime-hover) !important;
}

body.wp-child-theme-marnamic .gm-style .marnamic-map-card__link:focus-visible,
body.wp-child-theme-marnamic.wp-child-theme-marnamic
  .marnamic-map-hotfix .gm-style .marnamic-map-card__link:focus-visible {
  outline: 3px solid var(--marnamic-teal);
  outline-offset: 3px;
}

body.wp-child-theme-marnamic .gm-style .gm-style-iw-c:has(.marnamic-map-card)
  .gm-style-iw-chr {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 40px;
  height: 40px;
}

body.wp-child-theme-marnamic .gm-style .gm-style-iw-c:has(.marnamic-map-card)
  .gm-style-iw-ch {
  display: none;
}

body.wp-child-theme-marnamic .gm-style .gm-style-iw-c:has(.marnamic-map-card)
  > button.gm-ui-hover-effect,
body.wp-child-theme-marnamic .gm-style .gm-style-iw-c:has(.marnamic-map-card)
  .gm-style-iw-chr > button.gm-ui-hover-effect {
  position: absolute !important;
  top: 12px !important;
  right: 12px !important;
  display: grid !important;
  width: 40px !important;
  height: 40px !important;
  min-height: 40px !important;
  padding: 0 !important;
  place-items: center;
  opacity: 1 !important;
  color: var(--marnamic-cream) !important;
  background: rgba(15, 25, 27, 0.48) !important;
  border: 1px solid var(--marnamic-border-soft) !important;
  border-radius: var(--marnamic-radius) !important;
  filter: none !important;
}

body.wp-child-theme-marnamic .gm-style .gm-style-iw-c:has(.marnamic-map-card)
  .gm-style-iw-chr > button.gm-ui-hover-effect {
  top: 0 !important;
  right: 0 !important;
}

body.wp-child-theme-marnamic .gm-style .gm-style-iw-c:has(.marnamic-map-card)
  > button.gm-ui-hover-effect:hover,
body.wp-child-theme-marnamic .gm-style .gm-style-iw-c:has(.marnamic-map-card)
  .gm-style-iw-chr > button.gm-ui-hover-effect:hover {
  background: rgba(97, 165, 172, 0.18) !important;
  border-color: var(--marnamic-border) !important;
}

body.wp-child-theme-marnamic .gm-style .gm-style-iw-c:has(.marnamic-map-card)
  > button.gm-ui-hover-effect img,
body.wp-child-theme-marnamic .gm-style .gm-style-iw-c:has(.marnamic-map-card)
  > button.gm-ui-hover-effect span,
body.wp-child-theme-marnamic .gm-style .gm-style-iw-c:has(.marnamic-map-card)
  .gm-style-iw-chr > button.gm-ui-hover-effect img,
body.wp-child-theme-marnamic .gm-style .gm-style-iw-c:has(.marnamic-map-card)
  .gm-style-iw-chr > button.gm-ui-hover-effect span {
  width: 20px !important;
  height: 20px !important;
  margin: 0 !important;
  color: var(--marnamic-cream) !important;
  font-size: 28px;
  line-height: 17px;
  filter: invert(92%) sepia(12%) saturate(512%) hue-rotate(15deg) brightness(106%);
}

body.wp-child-theme-marnamic .gm-style .gm-style-iw-tc::after {
  background: var(--marnamic-panel) !important;
}

body.wp-child-theme-marnamic :is(
  .hp-map,
  #combined-map,
  .combined-map,
  .marnamic-combined-map
) .gm-style :is(
  .gm-fullscreen-control,
  button.gm-control-active,
  .gm-bundled-control button
) {
  width: 44px !important;
  height: 44px !important;
  min-height: 44px !important;
  color: var(--marnamic-cream) !important;
  background: rgba(24, 39, 43, 0.94) !important;
  border: 1px solid var(--marnamic-border) !important;
  border-radius: var(--marnamic-radius) !important;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24) !important;
}

body.wp-child-theme-marnamic :is(
  .hp-map,
  #combined-map,
  .combined-map,
  .marnamic-combined-map
) .gm-style :is(
  .gm-fullscreen-control,
  button.gm-control-active,
  .gm-bundled-control button
):hover {
  background: var(--marnamic-panel-soft) !important;
  border-color: rgba(231, 253, 135, 0.42) !important;
}

body.wp-child-theme-marnamic :is(
  .hp-map,
  #combined-map,
  .combined-map,
  .marnamic-combined-map
) .gm-style :is(
  .gm-fullscreen-control,
  button.gm-control-active,
  .gm-bundled-control button
) img {
  filter: invert(92%) sepia(12%) saturate(512%) hue-rotate(15deg) brightness(106%);
}

body.wp-child-theme-marnamic.marnamic-styleguide .styleguide-map-popup {
  display: grid;
  min-height: 340px;
  padding: 28px;
  place-items: center;
  background:
    radial-gradient(circle at 66% 38%, rgba(231, 253, 135, 0.18), transparent 25%),
    rgba(15, 25, 27, 0.74);
  border: 1px solid var(--marnamic-border-soft);
  border-radius: var(--marnamic-radius);
}

body.wp-child-theme-marnamic.marnamic-styleguide
  .styleguide-map-popup .gm-style-iw-c {
  position: relative !important;
  inset: auto !important;
  transform: none !important;
}

body.wp-child-theme-marnamic.marnamic-styleguide
  .styleguide-map-popup .gm-ui-hover-effect span {
  filter: none !important;
}

@media (max-width: 480px) {
  body.wp-child-theme-marnamic .gm-style .marnamic-map-card {
    width: calc(100vw - 88px);
    min-width: 0;
    padding: 20px;
  }

  body.wp-child-theme-marnamic .gm-style .marnamic-map-card__title {
    font-size: 1.3rem;
  }

  body.wp-child-theme-marnamic .gm-style .marnamic-map-card__location {
    margin-bottom: 18px;
    font-size: 0.9rem;
  }
}
