/* the map sheet (snippets/map-sheet.liquid): web v3's location sheet in the theme's own colours. A bottom sheet on
   phones, moved by @rekaz/headless as vaul moves web v3's, and a dialog from 48rem. Restyle freely; the behaviour is
   @rekaz/headless's and reads only the data-rk-* attributes. */
.rk-map-sheet {
  --rk-map-primary: var(--brand, #171717);
  --rk-map-surface: #fff;
  --rk-map-text: #171717;
  --rk-map-muted: #6b6b6b;
  --rk-map-danger: #d4163a;
  /* the areas a field or a provider serves, drawn on the map */
  --rk-map-area-fill: var(--rk-map-primary);
  --rk-map-area-stroke: var(--rk-map-primary);

  position: fixed;
  inset: auto 0 0;
  width: 100%;
  max-width: none;
  height: calc(100dvh - 1.5rem);
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 2rem 2rem 0 0;
  background: var(--rk-map-surface);
  color: var(--rk-map-text);
  font: inherit;
  touch-action: none;
  will-change: transform;
  transition: transform 0.5s cubic-bezier(0.32, 0.72, 0, 1);
  animation-duration: 0.5s;
  animation-timing-function: cubic-bezier(0.32, 0.72, 0, 1);
}

.rk-map-sheet[open] {
  display: flex;
}

.rk-map-sheet::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  inset-block-start: 100%;
  height: 200%;
  background: inherit;
}

.rk-map-sheet[data-state="open"] {
  animation-name: rk-map-slide-in;
}

.rk-map-sheet[data-state="closed"] {
  animation-name: rk-map-slide-out;
}

.rk-map-sheet::backdrop {
  background: rgb(0 0 0 / 0.2);
  opacity: var(--rk-sheet-overlay, 1);
  transition: var(--rk-sheet-overlay-transition, none);
}

html:has(.rk-map-sheet[open]) {
  overflow: hidden;
}

@media (min-width: 48rem) {
  .rk-map-sheet {
    inset: 0;
    width: calc(100% - 3rem);
    max-width: 56rem;
    height: min(48rem, calc(100dvh - 3rem));
    margin: auto;
    overflow: hidden;
    border-radius: 2rem;
    touch-action: auto;
    transition: none;
    animation-duration: 150ms;
  }

  .rk-map-sheet::after,
  .rk-map-sheet__handle {
    display: none;
  }

  .rk-map-sheet[data-state="open"] {
    animation-name: rk-map-zoom-in;
  }

  .rk-map-sheet[data-state="closed"] {
    animation-name: rk-map-zoom-out;
  }
}

.rk-map-sheet__frame {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-radius: inherit;
}

.rk-map-sheet__handle {
  width: 3rem;
  height: 0.375rem;
  margin: 0.75rem auto 0;
  border-radius: 999px;
  background: #e5e5e5;
}

.rk-map-sheet__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-block-end: 1px solid #ececec;
}

.rk-map-sheet__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.rk-map-sheet__description {
  margin: 0.25rem 0 0;
  color: var(--rk-map-muted);
  font-size: 0.875rem;
}

.rk-map-sheet__close {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 999px;
  background: #f4f4f4;
  color: inherit;
  cursor: pointer;
}

.rk-map {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #eee;
}

.rk-map__canvas {
  position: absolute;
  inset: 0;
}

.rk-map__top {
  position: absolute;
  inset: 0 0 auto;
  z-index: 2;
  padding: 1rem;
  pointer-events: none;
}

.rk-map__search,
.rk-map__places {
  max-width: 36rem;
  margin-inline: auto;
  pointer-events: auto;
}

.rk-map__search {
  position: relative;
}

.rk-map__search-icon {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 1rem;
  z-index: 1;
  color: var(--rk-map-muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.rk-map__search > .rk-map__search-icon {
  inset-block-start: 1.625rem;
}

.rk-map__search-input {
  width: 100%;
  min-height: 3.25rem;
  padding-inline: 2.75rem 1rem;
  border: 0;
  border-radius: 0.75rem;
  background: var(--rk-map-surface);
  color: inherit;
  font: inherit;
  font-size: 1rem;
  box-shadow: 0 8px 20px rgb(0 0 0 / 0.12);
}

.rk-map__search-input:focus-visible {
  outline: 2px solid var(--rk-map-primary);
}

.rk-map__results,
.rk-map__empty {
  max-height: 16rem;
  margin: 0.5rem 0 0;
  overflow-y: auto;
  border-radius: 0.75rem;
  background: var(--rk-map-surface);
  box-shadow: 0 12px 30px rgb(0 0 0 / 0.15);
}

.rk-map__results[hidden],
.rk-map__empty[hidden],
.rk-map__places[hidden] {
  display: none;
}

.rk-map__empty {
  padding: 0.75rem 1rem;
  color: var(--rk-map-muted);
  font-size: 0.875rem;
}

.rk-map__result {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-height: 3.25rem;
  padding: 0.75rem 1rem;
  border: 0;
  border-block-end: 1px solid #f0f0f0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: start;
  cursor: pointer;
}

.rk-map__result:last-child {
  border-block-end: 0;
}

.rk-map__result:hover {
  background: #f7f7f7;
}

.rk-map__result svg,
.rk-map__place svg {
  flex-shrink: 0;
  color: var(--rk-map-muted);
}

.rk-map__places {
  display: flex;
  gap: 0.5rem;
  margin-block-start: 0.75rem;
  padding-block-end: 0.25rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.rk-map__place {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.5rem;
  max-width: 14rem;
  height: 2.5rem;
  padding: 0 0.875rem;
  border: 0;
  border-radius: 999px;
  background: var(--rk-map-surface);
  color: inherit;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.12);
  cursor: pointer;
}

.rk-map__place span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.rk-map__place svg {
  color: var(--rk-map-primary);
}

/* the pin stays at the centre while the map moves under it */
.rk-map__pin {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 50%;
  z-index: 1;
  opacity: 0.35;
  transform: translate(calc(-50% * var(--dir, 1)), -100%);
  transition: opacity 150ms var(--ease-out, ease);
  pointer-events: none;
}

.rk-map__pin[data-active] {
  opacity: 1;
}

.rk-map__pin::after {
  content: "";
  position: absolute;
  inset-block-start: 100%;
  inset-inline-start: 50%;
  width: 1.25rem;
  height: 0.5rem;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.2);
  filter: blur(2px);
  transform: translateX(calc(-50% * var(--dir, 1)));
}

.rk-map__pin-head {
  position: relative;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 999px;
  background: var(--rk-map-primary);
  color: #fff;
  box-shadow: 0 10px 20px rgb(0 0 0 / 0.2);
  transition: transform 200ms var(--ease-out, ease);
}

.rk-map__pin-head::after {
  content: "";
  position: absolute;
  inset-block-end: -0.25rem;
  width: 0.75rem;
  height: 0.75rem;
  background: inherit;
  transform: rotate(45deg);
}

.rk-map__pin-head svg {
  position: relative;
  z-index: 1;
}

.rk-map__pin[data-moving] .rk-map__pin-head {
  transform: translateY(-0.5rem);
}

.rk-map__locate {
  position: absolute;
  inset-block-end: 1rem;
  inset-inline-end: 1rem;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border: 0;
  border-radius: 999px;
  background: var(--rk-map-surface);
  color: var(--rk-map-primary);
  box-shadow: 0 8px 20px rgb(0 0 0 / 0.15);
  cursor: pointer;
}

.rk-map__locate[data-busy] svg {
  animation: rk-map-pulse 1s ease-in-out infinite;
}

.rk-map-sheet__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem max(1.25rem, env(safe-area-inset-bottom));
  border-block-start: 1px solid #ececec;
}

.rk-map-sheet__place {
  display: flex;
  flex: 1 1 16rem;
  align-items: flex-start;
  gap: 0.75rem;
  min-width: 0;
}

.rk-map-sheet__place-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--rk-map-primary) 10%, #fff);
  color: var(--rk-map-primary);
}

.rk-map-sheet__place-title {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
}

.rk-map-sheet__when-resolving,
.rk-map-sheet__frame[data-resolving] .rk-map-sheet__when-idle {
  display: none;
}

.rk-map-sheet__frame[data-resolving] .rk-map-sheet__when-resolving {
  display: block;
}

.rk-map-sheet__address {
  display: -webkit-box;
  margin-block-start: 0.125rem;
  overflow: hidden;
  color: var(--rk-map-muted);
  font-size: 0.875rem;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.rk-map-sheet__confirm {
  flex: 1 1 100%;
  min-height: 3rem;
  padding: 0 1.75rem;
  border: 0;
  border-radius: 999px;
  background: var(--rk-map-primary);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

@media (min-width: 40rem) {
  .rk-map-sheet__confirm {
    flex: 0 0 auto;
    min-width: 11rem;
  }
}

.rk-map-sheet__confirm:disabled {
  opacity: 0.5;
  cursor: default;
}

.rk-map-sheet__outside,
.rk-map-sheet__error {
  flex-basis: 100%;
  margin: 0;
  color: var(--rk-map-danger);
  font-size: 0.875rem;
  font-weight: 500;
}

.rk-map-sheet__outside[hidden],
.rk-map-sheet__error[hidden] {
  display: none;
}

@keyframes rk-map-slide-in {
  from {
    transform: translate3d(0, 100%, 0);
  }
}

@keyframes rk-map-slide-out {
  to {
    transform: translate3d(0, 100%, 0);
  }
}

@keyframes rk-map-zoom-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
}

@keyframes rk-map-zoom-out {
  to {
    opacity: 0;
    transform: scale(0.95);
  }
}

@keyframes rk-map-pulse {
  50% {
    opacity: 0.4;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rk-map-sheet,
  .rk-map-sheet[data-state] {
    animation: none;
    transition: none;
  }

  .rk-map__pin-head,
  .rk-map__locate[data-busy] svg {
    transition: none;
    animation: none;
  }
}
