dialog {
  margin: auto;
  border-radius: 10px;
  transform-origin: center;
  scale: 0.9;
  opacity: 0;
  animation:
  /* Scale animation only for dialogs without SplideJS */
    scaleUp var(--duration-200) cubic-bezier(0.1, 0.7, 0.3, 1) forwards,
    fadeIn var(--duration-200) ease-out forwards;
}

dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn var(--duration-200) ease-out forwards;
}

.modal-box {
  width: 1000px;
  max-width: 100%;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: thin;
  background-color: var(--color-secondary);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  transition:
    width var(--duration-200) ease-out,
    height var(--duration-200) ease-out;
}

.modal-box.vertical {
  width: 700px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-right: 20px;
}

.modal-header .modal-label {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-header .modal-label .floor-select {
  position: relative;

  & select {
    appearance: none;
    height: 50px;
    padding-inline: 15px 40px;
    font-size: 28px;
    font-weight: 600;
    color: var(--color-primary);
    background-color: transparent;
    border-radius: 0.25rem;
    cursor: pointer;

    @media (hover: hover) and (pointer: fine) {
      &:hover {
        background-color: var(--color-secondary-hover);
      }
    }
  }

  &::before,
  &::after {
    --size: 0.3rem;
    content: "";
    position: absolute;
    right: 1rem;
    pointer-events: none;
  }

  &::before {
    border-left: var(--size) solid transparent;
    border-right: var(--size) solid transparent;
    border-bottom: var(--size) solid black;
    top: 40%;
  }

  &::after {
    border-left: var(--size) solid transparent;
    border-right: var(--size) solid transparent;
    border-top: var(--size) solid black;
    top: 55%;
  }
}

.modal-header button {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  padding: 0;
  width: 50px;
  height: 50px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background-color: transparent;

  @media (hover: hover) and (pointer: fine) {
    &:hover {
      background-color: var(--color-secondary-hover);
    }
  }

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;

    &:hover {
      background-color: transparent;
    }
  }
}

.modal-header button:first-of-type {
  margin-left: auto;
}

.modal-header button img,
.modal-header button svg {
  width: 30px;
  height: 30px;
}

.modal-header button svg {
  fill: none;
  stroke: var(--color-primary);
  stroke-linejoin: round;
  stroke-linecap: round;
}

.modal-content {
  position: relative;
  min-height: 100px;
  padding: 0 30px 30px;
  overflow: auto;
}

.modal-content::after {
  content: "";
  position: absolute;
  z-index: -1;
  left: 50%;
  top: 50%;
  translate: -50% -100%;
  display: block;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-top: 2px solid var(--color-primary);
  border-radius: 50%;
  animation: rotate 1s linear infinite;
}

.modal-content::-webkit-scrollbar {
  width: 16px;
}

.modal-content::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
  border-radius: 10px;
  border: 4px solid transparent;
  background-clip: content-box;
}

.modal-content p {
  padding-block: 20px;
  font-size: var(--font-size-label);
  text-align: center;
  background-color: var(--color-secondary);
}

.modal-content svg {
  max-height: 80vh;
  background-color: var(--color-secondary);
}

.modal-content svg text {
  fill: var(--color-primary);
  font-size: 20px;
  font-weight: 600;
  text-anchor: middle;
  /* user-select: none;
  pointer-events: none; */

  &.unit-code {
    font-weight: 300;
  }
}

.modal-content svg.vertical .unit-text {
  rotate: -90deg;
  transform-origin: center;
  transform-box: fill-box;
}

.modal-content svg .unit path {
  fill: hsl(206, 16%, 20%);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--duration-100);
}

/* .modal-content svg .unit.taken text {
  display: none;
} */

.modal-content svg .unit.taken path {
  cursor: not-allowed;
  opacity: 0.4;
}

@media (hover: hover) and (pointer: fine) {
  .modal-content svg .unit:not(.taken) path:hover {
    opacity: 0.2;
  }
}

/* Gallery Modal */
#gallery-modal {
  width: 100%;
  max-width: min(var(--max-site-width), 100vw);
  max-width: min(var(--max-site-width), 100dvw);
  max-height: 100vh;
  max-height: 100dvh;
  border-radius: 0px;
  transform-origin: center;
  /* SplideJS can't handle the scaleUp animation */
  scale: 1;
  animation: fadeIn var(--duration-200) ease-out forwards;

  &::backdrop {
    background-color: black;
  }

  & .close-btn {
    position: fixed;
    z-index: 1;
    top: calc(var(--inline-padding) / 2);
    right: calc(var(--inline-padding) / 2);
    width: 50px;
    height: 50px;
    display: grid;
    place-items: center;
    padding: 0;
    background-color: rgba(0, 0, 0, 0.5);
    border: none;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity var(--duration-200);

    @media (hover: hover) and (pointer: fine) {
      &:hover,
      &:focus-visible {
        opacity: 1;
      }
    }

    & svg {
      width: 30px;
      height: 30px;
      pointer-events: none;
      fill: none;
      stroke: white;
      stroke-width: 2;
      stroke-linejoin: round;
      stroke-linecap: round;
    }
  }

  & .splide,
  & .splide__track,
  & .splide__list,
  & .splide__slide {
    max-height: 100vh;
    max-height: 100dvh;
  }

  & .splide__slide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: black;
  }

  & .splide__pagination {
    inset: 0;
    top: auto;
    height: 150px;
    padding-bottom: 30px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.5));
    transform: none;
    border-radius: 0;

    & .splide__pagination__page {
      width: 18px;
      height: 18px;
      margin-inline: 10px;
      border: 2px solid var(--color-secondary);
      background-color: transparent;

      &:focus-visible {
        outline: 2px solid var(--color-secondary);
        outline-offset: 2px;
      }

      &.is-active {
        background-color: var(--color-secondary);
      }
    }

    @media (max-width: 600px) {
      height: 80px;
      padding-bottom: 20px;
      & .splide__pagination__page {
        width: 14px;
        height: 14px;
        margin-inline: 6px;
      }
    }

    @media (max-width: 420px) {
      height: 50px;
      padding-bottom: 15px;

      & .splide__pagination__page {
        width: 10px;
        height: 10px;
        margin-inline: 4px;
      }
    }
  }
}
