/**
 * Module: Utility classes for specific react components.
 */

@utility cc-btn-nav {
  color: var(--color-muted-foreground);
  border-radius: 0.75rem;

  cursor: pointer;
  white-space: nowrap;

  transition-property: background-color, color;
  transition-timing-function: var(--ease-bezier);
  transition-duration: 500ms;

  &:hover {
    color: var(--color-foreground);
  }
}

@utility cc-btn-primary {
  color: var(--color-foreground);
  background-color: var(--color-selected);
  border-color: var(--color-primary-border);

  &:focus-visible,
  &:hover:not(:disabled) {
    color: var(--color-primary-foreground);
    background-color: var(--color-primary);
    border-color: var(--color-primary);
  }
}

@utility cc-search-icon {
  pointer-events: none;
  color: var(--color-muted-foreground);
  background-color: transparent;

  :focus-within > & {
    color: var(--color-primary);
  }
}

@utility cc-tab-tools {
  z-index: var(--z-index-pop);
  position: absolute;
  top: 1.7rem;
  right: 50%;
  padding-top: 0.4rem;
  transform: translate(50%, 0%);
}

@utility cc-label {
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 500;

  cursor: default;
  user-select: text;
  white-space: nowrap;
}

@utility cc-tree-item {
  padding-left: 1.5rem;
  padding-right: 0.75rem;

  cursor: pointer;

  will-change: max-height, opacity, padding, border;
  transition-property: max-height, opacity, padding, border, color, background-color;
  transition-timing-function: var(--ease-bezier);
  transition-duration: var(--duration-dropdown);
}

@utility cc-sample-color {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  margin-right: 0.25rem;
  transform: translateY(0.125rem);

  border-width: 1px;
  border-style: solid;
  border-radius: calc(infinity * 1px);
}

@utility cc-badge-constituenta {
  width: 3rem;
  padding-inline: 0.25rem;

  border-width: 1px;
  border-radius: 0.5rem;

  text-align: center;
  font-weight: 500;
  white-space: nowrap;
}

@utility cc-table-header {
  text-align: start;
  padding: 0.5rem;

  font-size: var(--text-xs);

  /* stylelint-disable-next-line custom-property-pattern */
  line-height: var(--tw-leading, var(--text-xs--line-height));
  font-weight: 500;
  white-space: nowrap;

  user-select: none;
}

@utility cc-modal-wrapper {
  isolation: isolate;
  z-index: var(--z-index-modal);
  position: fixed;
  inset: 0;

  display: flex;
  align-items: center;
  justify-content: center;
}

@utility cc-node-label {
  font-weight: 600;
  -webkit-text-stroke-width: 0.6px;
  -webkit-text-stroke-color: var(--color-background);
}

@utility cc-text-outline {
  -webkit-text-stroke-width: 3px;
  -webkit-text-stroke-color: var(--color-background);
}

@utility cc-ast-label-outline {
  -webkit-text-stroke-width: 2px;
  -webkit-text-stroke-color: var(--color-background);
}

@utility cc-dropdown {
  transition-property: clip-path, transform;
  transition-duration: var(--duration-dropdown);
  transition-timing-function: var(--ease-in-out);

  transform: translateY(-10%);
  clip-path: inset(10% 0% 90% 0%);

  &.open {
    transform: translateY(0);
    clip-path: inset(0% 0% 0% 0%);
  }
}

@utility cc-side-location {
  transition-property: width, min-width, opacity;
  transition-duration: var(--duration-move);
  transition-timing-function: var(--ease-bezier);

  opacity: 0;
  width: 0;
  min-width: 0;

  &.open {
    opacity: 1;
    width: 100%;
  }
}

@utility cc-view-hidden-header {
  transition-property: transform;
  transition-duration: var(--duration-dropdown);
  transition-timing-function: var(--ease-out);

  transform: translateX(0.75rem);

  &.open {
    transform: translateX(calc(6.5rem - 50%));
  }
}

@utility cc-view-hidden-list {
  transition-property: clip-path;
  transition-duration: var(--duration-dropdown);
  transition-timing-function: var(--ease-out);

  clip-path: inset(10% 0% 90% 0%);
  pointer-events: none;

  &.open {
    clip-path: inset(0% 0% 0% 0%);
    pointer-events: auto;
  }
}

@utility cc-view-hidden-item {
  outline-width: 0;
  outline-color: transparent;

  &.selected {
    outline: 2px solid var(--color-foreground);
  }

  &.inherited {
    outline-style: dashed;
  }
}

@utility cc-rs-edit-controls {
  transition-property: max-height;
  transition-duration: var(--duration-move);
  transition-timing-function: var(--ease-in-out);

  clip-path: inset(0% 0% 100% 0%);
  max-height: 0;
  margin-top: 0;

  &.open {
    clip-path: inset(0% 0% 0% 0%);
    max-height: 4.5rem;
    margin-top: 0.25rem;
  }
}

@utility cc-prompt-result {
  transition-property: clip-path, height;
  transition-duration: var(--duration-move);
  transition-timing-function: var(--ease-in-out);

  clip-path: inset(0% 0% 100% 0%);
  height: 0;

  &.open {
    clip-path: inset(0% 0% 0% 0%);
    height: 100%;
  }
}

@utility cc-parsing-result {
  transition-property: clip-path, padding, margin, border, height;
  transition-duration: var(--duration-move);
  transition-timing-function: var(--ease-in-out);

  clip-path: inset(0% 0% 100% 0%);
  height: 0;
  margin-top: 0;
  padding: 0;
  border-width: 0;

  &.open {
    clip-path: inset(0% 0% 0% 0%);
    height: 4.5rem;
    margin-top: 0.75rem;
    padding: 0.25rem 0.5rem;
  }
}

@utility cc-topic-dropdown {
  will-change: clip-path;
  transition-property: clip-path;
  transition-duration: var(--duration-move);
  transition-timing-function: var(--ease-in-out);

  clip-path: inset(0% 100% 0% 0%);

  &.open {
    clip-path: inset(0% 0% 0% 0%);
  }
}

@utility cc-animate-popover {
  transform-origin: var(--radix-select-content-transform-origin);

  &[data-state='open'] {
    --tw-enter-opacity: 0;
    --tw-enter-scale: 0.95;
    animation: enter var(--tw-duration, 0.15s) var(--tw-ease, ease);
  }

  &[data-state='closed'] {
    --tw-exit-opacity: 0;
    --tw-exit-scale: 0.95;
    animation: exit var(--tw-duration, 0.15s) var(--tw-ease, ease);
  }

  &[data-side='bottom'] {
    --tw-enter-translate-y: calc(-2 * var(--spacing));
  }

  &[data-side='left'] {
    --tw-enter-translate-x: calc(2 * var(--spacing));
  }

  &[data-side='right'] {
    --tw-enter-translate-x: calc(-2 * var(--spacing));
  }

  &[data-side='top'] {
    --tw-enter-translate-y: calc(2 * var(--spacing));
  }
}

@utility cc-node-operation {
  cursor: pointer;

  border-radius: 5px;
  border-color: var(--color-muted-foreground);
  border-width: 1px;

  color: var(--color-foreground);
  background-color: var(--color-card);

  outline-offset: -2px;
  outline-style: solid;
  outline-color: transparent;

  transition-property: outline-offset;
  transition-timing-function: var(--transition-bezier);
  transition-duration: var(--duration-select);

  .selected & {
    outline-offset: 4px;
    outline-color: var(--color-graph-selected);
    border-color: var(--color-foreground);
  }

  .cursor-relocate .dragging & {
    cursor: move;
  }
}

@utility cc-node-block {
  cursor: default;

  border-radius: 5px;
  border-style: dashed;
  border-width: 2px;

  padding: 4px;

  color: var(--color-muted-foreground);
  background-color: transparent;

  transition-property: color;
  transition-timing-function: var(--transition-bezier);
  transition-duration: var(--duration-select);

  .selected & {
    color: var(--color-foreground);
    border-color: var(--color-graph-selected);
    border-style: solid;
  }

  &:hover {
    color: var(--color-foreground);
    transition-delay: var(--duration-select);
  }

  .cursor-relocate .dragging & {
    cursor: move;
  }
}
