.context-menu {
  position: absolute;
  background-color: white;
  border: 1px solid #ccc;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  list-style: none;
  padding: 0;
  margin: 0;

  li {
    display:flex;
    justify-content: space-between;
    padding: 8px 12px;
    gap: 16px;
    cursor: pointer;
    color: black;
    transition: background-color 0.1s;

    &:hover {
      background-color: #eee;
    }

    &.destructive {
      color: red;

      &:hover {
        background-color: #fdd;
      }
    }

    .command {
      color: black;
      font-style: italic;
      white-space: nowrap;
      font-weight: 300;
    }
  }
}

.card {
  position: relative;
  transition: outline-color 0.1s ease-in-out;
  outline-color: transparent;

  &:not(.empty):not(.loading):hover {
    outline-width: 4px;
    outline-color: var(--interaction-color);
    outline-style: solid;
    z-index: 1000;
  }

  &:before,
  &:after {
    pointer-events: none;
    display: var(--guide-display);
    border-color: black;
    border-style: solid;
    border-width: 0px;
  }

  .placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: white;
  }

  .loading {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top: 4px solid #000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
  }

  .error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: red;
    font-size: 24px;
    user-select: none;
  }

  .empty:after {
    content: "";
    position: absolute;
    top: var(--guide-corner-offset);
    left: var(--guide-corner-offset);
    right: var(--guide-corner-offset);
    bottom: var(--guide-corner-offset);
    border-color: black;
    border-style: solid;
    border-width: var(--guide-border-width);
  }
}

/* top row guides */
.card.first-row:after {
  content: "";
  position: absolute;
  height: 100%;
  bottom: 100%;
  left: var(--guide-corner-offset);
  right: var(--guide-corner-offset);
  border-left-width: var(--guide-border-width);
  border-right-width: var(--guide-border-width);
}

/* bottom row guides */
.card.last-row:after {
  content: "";
  position: absolute;
  height: 100%;
  top: 100%;
  left: var(--guide-corner-offset);
  right: var(--guide-corner-offset);
  border-left-width: var(--guide-border-width);
  border-right-width: var(--guide-border-width);
}

/* right column guides */
.card.last-column:before {
  content: "";
  position: absolute;
  width: 100%;
  left: 100%;
  top: var(--guide-corner-offset);
  bottom: var(--guide-corner-offset);
  border-top-width: var(--guide-border-width);
  border-bottom-width: var(--guide-border-width);
}

/* left column guides */
.card.first-column:before {
  content: "";
  position: absolute;
  width: 100%;
  right: 100%;
  top: var(--guide-corner-offset);
  bottom: var(--guide-corner-offset);
  border-top-width: var(--guide-border-width);
  border-bottom-width: var(--guide-border-width);
}

.image-container {
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  width: calc(var(--card-width, 63mm) + calc(var(--bleed-edge-width) * 2) + var(--image-container-buffer-width));
  height: calc(var(--card-height, 88mm) + calc(var(--bleed-edge-width) * 2) + var(--image-container-buffer-width));
}

.image {
  width: calc(var(--card-width, 63mm) + var(--image-zoom-width));
  object-fit: cover;
}

.image.loading {
  opacity: 0;
}

.guide {
  z-index: 2;
  display: var(--guide-display);
  position: absolute;

  .content {
    position: relative;
    height: 4px;
    width: 4px;
  }

  & .inner, & .outer {
    &:after, &:before {
      display: block;
      position: absolute;
      content: "";
      border-color: var(--guide-border-color);
      border-style: solid;
      border-width: 0px;
    }
  }

  .inner:after, .inner:before {
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
  }

  .outer:after, .outer:before {
    width: calc(var(--bleed-edge-width) - calc(var(--guide-border-width) * 0.5));
    height: calc(var(--bleed-edge-width) - calc(var(--guide-border-width) * 0.5));
  }

  .inner:after, .outer:after {
    border-color: var(--guide-border-color-inverted);
    border-style: dotted;
  }
}

.guide.top-left {
  top: var(--guide-corner-offset);
  left: var(--guide-corner-offset);

  .inner:after, .inner:before {
    border-top-width: var(--guide-border-width);
    border-left-width: var(--guide-border-width);
  }

  .outer:after, .outer:before {
    bottom: calc(100% - 1px);
    right: calc(100% - 1px);
    border-bottom-width: var(--guide-border-width);
    border-right-width: var(--guide-border-width);
  }
}

.guide.top-right {
  top: var(--guide-corner-offset);
  right: var(--guide-corner-offset);
  .inner:after, .inner:before {
    left: -1px;
    border-top-width: var(--guide-border-width);
    border-right-width: var(--guide-border-width);
  }
  .outer:after, .outer:before {
    bottom: calc(100% - 1px);
    left: calc(100% - 1px);
    border-bottom-width: var(--guide-border-width);
    border-left-width: var(--guide-border-width);
  }
}

.guide.bottom-left {
  bottom: var(--guide-corner-offset);
  left: var(--guide-corner-offset);
  .inner:after, .inner:before {
    top: -1px;
    border-bottom-width: var(--guide-border-width);
    border-left-width: var(--guide-border-width);
  }
  .outer:after, .outer:before {
    top: calc(100% - 1px);
    right: calc(100% - 1px);
    border-top-width: var(--guide-border-width);
    border-right-width: var(--guide-border-width);
  }
}

.guide.bottom-right {
  bottom: var(--guide-corner-offset);
  right: var(--guide-corner-offset);
  .inner:after, .inner:before {
    top: -1px;
    left: -1px;
    border-bottom-width: var(--guide-border-width);
    border-right-width: var(--guide-border-width);
  }
  .outer:after, .outer:before {
    top: calc(100% - 1px);
    left: calc(100% - 1px);
    border-top-width: var(--guide-border-width);
    border-left-width: var(--guide-border-width);
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
