@charset "UTF-8";
@use 'sass:color';
@use '@craftcms/sass/mixins';

/* No Scroll */
html.noscroll,
html.noscroll body {
  overflow: hidden;
  height: 100%;
}

/* Image Editor */

.modal.imageeditor {
  --focus-ring: var(--focus-ring-light);
  background-color: var(--gray-900);
  color: var(--white);
  @include mixins.light-on-dark-text;
  opacity: 0;
  user-select: none;

  [data-cropper-edit] {
    @include mixins.visually-hidden;
  }
}

.modal.imageeditor.modal {
  border-radius: 0;
}

.modal.imageeditor.modal .body::after {
  display: none;
}

.modal.imageeditor .btn:not(.submit, .noborder) {
  background-color: var(--gray-600);
  color: var(--white);
}

.modal.imageeditor .btn:not(.submit, .noborder):hover {
  background-color: var(--gray-700);
}

.modal.imageeditor .btn:not(.submit, .noborder).active {
  background-color: var(--gray-800);
}

.modal.imageeditor .icon::before {
  width: 24px;
  height: 24px;
  margin-inline-start: -3px;
  display: inline-block;
  content: '';
}

.modal.imageeditor .icon.rotate-left::before {
  background-image: url('../images/image-editor/rotate-left.svg');
}

.modal.imageeditor .icon.rotate-right::before {
  background-image: url('../images/image-editor/rotate-right.svg');
}

.modal.imageeditor .icon.flip-vertical::before {
  background-image: url('../images/image-editor/flip-vertical.svg');
}

.modal.imageeditor .icon.flip-horizontal::before {
  background-image: url('../images/image-editor/flip-horizontal.svg');
}

.modal.imageeditor .icon.constraint::before {
  background-image: url('../images/image-editor/unconstrained.svg');
}

.modal.imageeditor .icon.focal-point::before {
  background-image: url('../images/image-editor/focal-point.svg');
}

.modal.imageeditor .body {
  display: flex;
  padding: 0;
}

.modal.imageeditor input {
  color: var(--text-color);
}

.modal.imageeditor .body .tabs {
  border-inline-end: 1px solid var(--gray-1000);
}

.modal.imageeditor .body .tabs ul {
  width: 100px;
  flex-direction: column;
  align-items: stretch;
}

.modal.imageeditor .body .tabs ul li {
  position: relative;
  padding: 14px;
  text-align: center;
  border-block-end: 1px solid var(--gray-1000);
  cursor: pointer;

  &::before {
    position: absolute;
    inset-block-start: 0;
    inset-inline-start: 0;
    content: '';
    width: 0;
    height: 100%;
    background-color: currentcolor;
  }

  &.selected {
    background-color: color.adjust(mixins.$grey900, $lightness: -5%);

    &::before {
      width: 2px;
    }
  }
}

.modal.imageeditor .body .tabs ul li i {
  background-repeat: no-repeat;
  background-position: top center;
  display: block;
  height: 24px;
}

.modal.imageeditor .body .tabs ul li[data-view='rotate'] i {
  background-image: url('../images/image-editor/rotate-left.svg');
}

.modal.imageeditor .body .tabs ul li[data-view='crop'] i {
  background-image: url('../images/image-editor/crop.svg');
}

.modal.imageeditor .body .tabs ul li[data-view='filters'] i {
  background-image: url('../images/image-editor/filters.svg');
}

.modal.imageeditor .body .tabs ul li:hover {
  background-color: color.adjust(mixins.$grey900, $lightness: -2%);
}

.modal.imageeditor .body .tabs ul li:hover {
  cursor: pointer;
}

.modal.imageeditor .body .views {
  padding: 24px;
  overflow: auto;
}

.modal.imageeditor .body .views .btngroup {
  margin-block-end: 24px;
}

.modal.imageeditor .body .views .filters ul {
  width: 100px;
}

.modal.imageeditor .body .views .filters ul li {
  text-align: center;
  margin-inline-end: 14px;
  margin-block-end: 14px;
}

.modal.imageeditor .body .views .filters ul li:last-child {
  margin-inline-end: 0;
}

.modal.imageeditor .body .views .filters ul li img {
  border: 3px solid transparent;
  border-radius: 4px;
}

.modal.imageeditor .body .views .filters ul li span {
  display: block;
}

.modal.imageeditor .body .views .filters ul li:hover {
  cursor: pointer;
}

.modal.imageeditor .body .views .filters ul li.selected img {
  border-color: var(--white);
}

.modal.imageeditor .body .image-container {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.modal.imageeditor .body .image-container .image {
  text-align: center;
  flex-grow: 1;
  position: relative;
  margin: 14px;
}

.modal.imageeditor .body .image-container .image canvas {
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
}

.modal.imageeditor .body .image-container .image-tools {
  text-align: center;
}

.modal.imageeditor .body .image-container .image-tools .straightening {
  max-width: 400px;
  min-height: calc(60 / 16 * 1rem);
  display: block;
  margin-block: 0;
  margin-inline: auto;
  overflow: hidden;
}

.modal.imageeditor .footer {
  position: absolute;
  background-color: transparent;
  inset-block-end: 0;
  inset-inline-start: 0;
  width: 100%;
  border-block-start: 1px solid #000;

  body.has-debug-toolbar & {
    padding-block-end: calc(8px + 42px);
  }
}

.modal.imageeditor .body .views .crop {
  fieldset .heading {
    display: none;
  }

  .custom-constraint-spacer {
    padding-block: 0;
    padding-inline: var(--xs);
  }

  .constraint-group {
    display: grid;
    grid-gap: var(--xs);
  }

  .custom {
    padding-inline-start: calc(1rem + 5px);
  }

  .orientation {
    display: flex;
    align-items: center;
    justify-content: center;

    input {
      appearance: none;
      background-position: center center;
      background-repeat: no-repeat;
      margin-block: 0;
      margin-inline: 4px;
      cursor: pointer;

      &[value='landscape'] {
        width: 30px;
        height: 20px;
        background-image: url('../images/image-editor/orientation-landscape-unchecked.svg');

        &:checked {
          background-image: url('../images/image-editor/orientation-landscape-checked.svg');
        }
      }

      &[value='portrait'] {
        width: 20px;
        height: 30px;
        background-image: url('../images/image-editor/orientation-portrait-unchecked.svg');

        &:checked {
          background-image: url('../images/image-editor/orientation-portrait-checked.svg');
        }
      }
    }
  }
}

.modal.imageeditor.vertical .body .views .crop {
  & > .btngroup:first-child {
    justify-content: center;
  }
}

.modal.imageeditor:not(.vertical) .body .views .crop {
  .constraint.custom {
    margin-block-start: var(--xs);
  }
}

/* Vertical */

.vertical.imageeditor .body {
  flex-direction: column;

  .image-container {
    flex-basis: 30vh;
    flex-shrink: 0;
  }

  .constraint-group {
    grid-template-columns: 1fr 1fr;
  }
}

.vertical.imageeditor .body .tabs ul {
  display: flex;
  flex-direction: row;
  width: 100%;
  border-block-start: 1px solid #000;
  border-block-end: 1px solid #000;
}

.vertical.imageeditor .body .tabs ul li {
  flex-grow: 1;
  border: 0;
  border-inline-end: 1px solid #000;
  padding-block: 10px;
  padding-inline: 7px;

  &::before {
    inset-block-start: unset;
    inset-block-start: 0;
    width: 100%;
    height: 0;
  }

  &.selected::before {
    width: 100%;
    height: 2px;
  }
}

.vertical.imageeditor .body .views {
  width: auto;
}

.vertical.imageeditor .body .views .rotate {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  margin-block-end: -14px;
}

.vertical.imageeditor .body .views .rotate .btngroup {
  margin-block: 0 14px;
  margin-inline: 7px;
}

.vertical.imageeditor .body .views .filters ul {
  width: auto;
  height: 109px;
  overflow: auto;
  white-space: nowrap;
  margin-block: 0;
  margin-inline: -24px;
  margin-block-end: -24px;
  padding: 24px;
  text-align: center;
}

.vertical.imageeditor .body .views .filters ul li {
  display: inline-block;
  margin-block-end: 0;
}

/* Slide Rule */

.slide-rule {
  position: relative;
  padding-block: 10px;
  padding-inline: 0;

  &:focus-visible {
    .cursor::after {
      box-shadow: var(--focus-ring);
    }
  }

  .cursor {
    &::after {
      content: '';
      width: calc(20 / 16 * 1rem);
      height: calc(50 / 16 * 1rem);
      position: absolute;
      inset-block-start: -15px;
      inset-inline-start: 50%;
      transform: translateX(-50%);
    }
  }
}

.slide-rule .cursor {
  position: absolute;
  margin-inline-start: calc(-4 / 16 * 1rem);
  margin-block-start: 4px;
  inset-inline-start: 50%;
  z-index: 1;
  width: 0;
  height: 0;
  border-inline-start: calc(5 / 16 * 1rem) solid transparent;
  border-inline-end: calc(5 / 16 * 1rem) solid transparent;
  border-block-start: calc(5 / 16 * 1rem) solid #63a6e1;
}

.slide-rule .graduations {
  white-space: nowrap;
  height: 40px;
  position: relative;
}

.slide-rule .graduations ul {
  position: relative;
  float: inline-start;
  height: 40px;

  /* We need to use "left" vs. a logical property here because that's wha the JS sets */
  transition: 200ms left linear; /* stylelint-disable-line */
}

.slide-rule.dragging .graduations ul {
  transition: none;
}

.slide-rule .graduations ul li {
  display: inline-block;
  font-size: 8px;
  position: relative;
  width: 10px;

  &:hover {
    cursor: pointer;

    &::before {
      border-inline-start-color: #63a6e1;
    }
  }
}

.slide-rule .graduations ul li:not(.main-graduation) {
  inset-inline-start: 1px;
}

.slide-rule .graduations ul li.main-graduation::before {
  border-inline-start-width: 4px;
  height: 10px;
}

.slide-rule .graduations ul li.main-graduation .label {
  display: block;
  cursor: default;
}

.slide-rule .graduations ul li.selected::before {
  border-inline-start-color: #63a6e1;
}

.slide-rule .graduations ul li::before {
  content: '';
  position: absolute;
  border-inline-start: 2px solid var(--white);
  height: 6px;
  inset-block-start: 0;
  inset-inline-start: 0;
}

.slide-rule .graduations ul li .label {
  width: 20px;
  position: absolute;
  inset-block-start: 10px;
  inset-inline-start: -9px;
  display: none;
  text-align: center;
}

.slide-rule .value {
  display: none;
  position: absolute;
  inset-block-end: 0;
  inset-inline-start: 50%;
  z-index: 1;
  box-sizing: border-box;
  padding: 5px;
  width: 50px;
  margin-inline-start: -25px;
  background: var(--gray-600);
}

.slide-rule .overlay {
  z-index: 2;
  position: absolute;
  inset-block: 0 1px;
  inset-inline: 0;
  pointer-events: none;
  background-image: linear-gradient(
    to right,
    var(--gray-900) 0%,
    color.adjust(mixins.$grey900, $alpha: -1) 15%,
    color.adjust(mixins.$grey900, $alpha: -1) 85%,
    var(--gray-900) 100%
  );
}

/* Misc */

.menu.dark {
  background-color: var(--gray-600);
  @include mixins.light-on-dark-text;

  ul {
    li {
      a {
        color: var(--white) !important;

        &:not(.sel, .disabled):hover {
          background-color: var(--gray-700);
        }
      }
    }
  }
}

#cropping-canvas {
  --focus-ring: none;
}
