@keyframes modal-fade {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}
@keyframes modal-slide-up {
  from {
    bottom: -100%;
  }

  to {
    bottom: 0;
  }
}

.overlay {
  align-items: center;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  height: var(--visual-viewport-height);
  justify-content: center;
  left: 0;
  position: fixed;
  top: 0;
  width: 100vw;
  z-index: 100;

  &[data-entering] {
    animation: modal-fade 200ms;
  }

  &[data-exiting] {
    animation: modal-fade 150ms reverse ease-in;
  }
}

.modal {
  position: absolute;
  left: 0;
  bottom: 0;
  height: calc(100dvh - 20px);
  background-color: var(--Base-Surface-Primary-light-Normal);
  border-radius: var(--Corner-radius-md);
  box-shadow: var(--modal-box-shadow);
  width: 100%;

  &[data-entering] {
    animation: modal-slide-up 200ms;
  }

  &[data-existing] {
    animation: modal-slide-up 200ms reverse;
  }
}

.content {
  flex-direction: column;
  display: flex;
  height: 100%;
}

.sorter {
  padding: var(--Spacing-x-one-and-half) var(--Spacing-x2) var(--Spacing-x-half)
    var(--Spacing-x2);
  flex: 0 0 auto;
}

.badge {
  background-color: var(--Base-Text-Accent);
  border-radius: var(--Corner-radius-xl);
  width: 20px;
  height: 20px;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.filters {
  padding: var(--Spacing-x2);
  padding-top: calc(var(--Spacing-x3) + var(--Spacing-x-half));
  flex: 1 1 auto;
  overflow-y: auto;
}

.filters ul {
  margin-top: var(--Spacing-x3);
}

.filters ul li {
  padding-bottom: var(--Spacing-x1);
}

.header {
  text-align: right;
  padding: var(--Spacing-x-one-and-half);
  flex: 0 0 auto;
}

.title {
  display: none;
}

.close {
  background: none;
  border: none;
  cursor: pointer;
  justify-self: flex-end;
  padding: 0;
}

.divider {
  display: none;
}

.footer {
  display: flex;
  flex-direction: column;
  gap: var(--Spacing-x1);
  padding: var(--Spacing-x3) var(--Spacing-x2);
  flex: 0 0 auto;
  border-top: 1px solid var(--Base-Border-Subtle);
}

@media screen and (min-width: 768px) {
  .modal {
    left: 50%;
    bottom: 50%;
    height: min(80dvh, 680px);
    width: min(80dvw, 960px);
    translate: -50% 50%;
    overflow-y: auto;
  }

  .divider {
    display: block;
    padding: 0 var(--Spacing-x3);
  }

  .header {
    display: grid;
    grid-template-columns: auto 1fr;
    padding: var(--Spacing-x2) var(--Spacing-x3);
    align-items: center;
    border-bottom: 1px solid var(--Base-Border-Subtle);
    position: sticky;
    top: 0;
    background: var(--Base-Surface-Primary-light-Normal);
    z-index: 1;
    border-top-left-radius: var(--Corner-radius-lg);
    border-top-right-radius: var(--Corner-radius-lg);
  }

  .title {
    display: block;
  }

  .content {
    gap: var(--Spacing-x4);
    height: auto;
  }

  .filters {
    overflow-y: unset;
  }

  .sorter {
    padding: var(--Spacing-x2);
  }

  .sorter,
  .filters,
  .footer,
  .divider {
    padding: 0 var(--Spacing-x3);
  }

  .footer {
    flex-direction: row-reverse;
    justify-content: space-between;
    position: sticky;
    bottom: 0;
    background: var(--Base-Surface-Primary-light-Normal);
    z-index: 1;
    border-bottom-left-radius: var(--Corner-radius-lg);
    border-bottom-right-radius: var(--Corner-radius-lg);
    padding: var(--Spacing-x2) var(--Spacing-x3);
  }

  .filters aside > form {
    gap: var(--Spacing-x2);
  }

  .filters aside form > div:last-child {
    margin-top: var(--Spacing-x2);
  }

  .filters aside ul {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-top: var(--Spacing-x1);
  }

  .filters ul li:hover {
    background: var(--UI-Input-Controls-Surface-Hover);
    border-radius: var(--Corner-radius-md);
    outline: none;
  }
  .filters ul li {
    padding: var(--Spacing-x1) var(--Spacing-x-one-and-half);
  }
}
@media screen and (min-width: 1024) {
  .facilities ul {
    grid-template-columns: 1fr 1fr 1fr;
  }
}
