.gallery-filter-block {
  position: sticky;
  top: -1px;
  z-index: 1;
  display: flex;
  justify-content: flex-end;
}

.gallery-filter-controls {
  padding: 0.25rem 0.75rem 0.75rem;
  background-color: rgba(255, 255, 255, 0.75);
  border-radius: 1rem;
  margin-bottom: var(--wp--style--block-gap);
  backdrop-filter: blur(0.5rem);
  transition: all 0.2s ease-in-out;
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  box-shadow: 0 2px 0.5rem -0.25rem rgba(0, 0, 0, 0.5);
}

[data-stuck] .gallery-filter-controls {
  box-shadow: 0 2px 2rem -1rem rgba(0, 0, 0, 0.75);
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.gallery-filter-open-button {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--wp--preset--color--secondary);
  color: #fff;
  border-radius: 0.5rem;
  border: 0;
  font-family: inherit;
  font-size: 1rem;
  padding: 0.5rem 1.5rem;
  box-shadow: 0 0 2rem -1rem rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  margin-top: 0.5rem;
}
.gallery-filter-open-button:hover {
  background-color: color-mix(
    in srgb,
    var(--wp--preset--color--secondary) 80%,
    #222
  );
}

.gallery-filter-selected-count {
  font-size: 0.875rem;
  font-weight: 500;
  color: #34333e;
  margin-right: 0.75rem;
  align-self: center;
  margin-top: 0.25rem;
}

.gallery-filter-suggestions {
  display: flex;
  flex-direction: column;
}

.gallery-filter-suggestion-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #4a4954;
  margin-bottom: 0.25rem;
}

.gallery-filter-suggestion-list {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0;
  gap: 0.5rem;
  max-width: 32rem;
  margin-right: -0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to left, transparent 0%, black 16px);
  mask-image: linear-gradient(to left, transparent 0%, black 16px);
}

.gallery-filter-suggestion-list::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.gallery-filter-suggestion-list-item {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--wp--preset--color--primary);
  color: #fff;
  border-radius: 5rem;
  border: 0;
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.125rem 0.75rem 0.15rem;
  box-shadow: 0 0 2rem -1rem rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}

.gallery-filter-suggestion-list-item:last-child {
  margin-right: 0.75rem;
}

.gallery-filter-suggestion-list-item a::first-letter {
  text-transform: uppercase;
}

.gallery-filter-suggestion-list-item a {
  color: #fff !important;
  text-decoration: none;
}

.gallery-filter-suggestion-list-item:hover {
  background-color: color-mix(
    in srgb,
    var(--wp--preset--color--primary) 80%,
    #222
  );
}

.gallery-filter-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 10vh;
  z-index: 1;
}

.gallery-filter-backdrop.is-active {
  background-color: rgba(0, 0, 0, 0);
  animation: gallery-filter-backdrop-fade-in 0.175s ease-in-out forwards;
}

.gallery-filter-backdrop.is-active .gallery-filter-modal {
  opacity: 0;
  animation: gallery-filter-modal-fade-in 0.2s ease-in-out forwards 125ms;
}

.gallery-filter-backdrop:not(.is-active) {
  display: none;
}

.gallery-filter-modal {
  position: relative;
  background-color: #fff;
  padding: 2rem;
  border-radius: 1rem;
  width: calc(100% - 4rem);
  max-width: 30rem;
  box-shadow: 0 0 2rem -1rem rgba(0, 0, 0, 0.5);
}

.gallery-filter-title {
  margin: 0 0 1.5rem;
  font-size: 1.5rem;
}

.gallery-filter-close-button {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.5rem;
  margin: -0.5rem;
  background-color: transparent;
  border: 0;
  color: var(--wp--preset--color--contrast);
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}

.gallery-filter-close-button svg {
  width: 1em;
  height: 1em;
}

/* Form Groups */

.gallery-filter-groups {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  max-height: 60vh;
  overflow-y: auto;
}

.gallery-filter-group {
  border: 0;
  padding: 0;
}

.gallery-filter-group legend {
  font-size: 1.25rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

/* Checkboxes */

.gallery-filter-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.gallery-filter-checkbox-input {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-content: center;
  justify-content: center;
  font-size: 0.75rem;
  border: 2px solid var(--wp--preset--color--secondary);
  border-radius: 0.25rem;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}

.gallery-filter-checkbox-input::before {
  content: "";
  width: 1.4em;
  height: 1.4em;
  transform: scale(0.85);
  background-color: var(--wp--preset--color--secondary);
  opacity: 0;
  transition: all 75ms ease-in-out;
}

.gallery-filter-checkbox-input::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: auto;
  width: 1.3em;
  height: 1.3em;
  clip-path: polygon(
    17% 54%,
    28% 43%,
    38% 54%,
    70% 22%,
    81% 33%,
    38% 75%,
    17% 54%
  );
  transform: scale(0.85);
  background-color: #fff;
  opacity: 0;
  transition: all 125ms ease-in-out;
}

.gallery-filter-checkbox-input:checked::before,
.gallery-filter-checkbox-input:checked::after {
  transform: scale(1);
  opacity: 1;
}

.gallery-filter-checkbox-input:focus {
  outline: none;
  color: var(--wp--preset--color--secondary);
  box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 20%, transparent);
}

.gallery-filter-checkbox-input + label {
  user-select: none;
  cursor: pointer;
  font-size: 0.875rem;
  color: #44434b;
  padding: 0.25rem 0;
}

.gallery-filter-checkbox-input + label::first-letter {
  text-transform: uppercase;
}

.gallery-filter-checkbox-input:checked + label {
  color: var(--wp--preset--color--contrast);
}

/* Footer */

.gallery-filter-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 2rem;
  gap: 1rem;
}

.gallery-filter-footer button {
  background-color: var(--wp--preset--color--secondary);
  color: #fff;
  border-radius: 0.5rem;
  border: 0;
  font-family: inherit;
  font-size: 1rem;
  padding: 0.5rem 1.5rem;
  box-shadow: 0 0 2rem -1rem rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}

.gallery-filter-footer .gallery-filter-reset-button {
  background-color: transparent;
  color: var(--wp--preset--color--secondary);
  box-shadow: none;
}

.gallery-filter-footer .gallery-filter-submit-button {
  position: relative;
}
.gallery-filter-footer .gallery-filter-submit-button:hover {
  background-color: color-mix(
    in srgb,
    var(--wp--preset--color--secondary) 80%,
    #222
  );
}

.gallery-filter-footer .gallery-filter-submit-button svg {
  display: none;
}

.gallery-filter-footer .gallery-filter-submit-button.is-loading {
  color: var(--wp--preset--color--secondary);
}
.gallery-filter-footer .gallery-filter-submit-button.is-loading:hover {
  color: color-mix(in srgb, var(--wp--preset--color--secondary) 80%, #222);
}

.gallery-filter-footer .gallery-filter-submit-button.is-loading svg {
  display: inline-block;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  fill: #fff;
  width: 1em;
  height: 1em;
}

/* Responsive */

@media screen and (max-width: 781px) {
  .gallery-filter-suggestion-list {
    max-width: 12rem;
  }

  .gallery-filter-modal {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* Animations */

@keyframes gallery-filter-backdrop-fade-in {
  from {
    background-color: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0);
  }
  to {
    background-color: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(5px);
  }
}

@keyframes gallery-filter-modal-fade-in {
  from {
    opacity: 0;
    transform: translateY(1rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
