@use 'sass:map';
@use '@ecl/theme-ec/theme' as *;

.nameWrapper {
  position: relative;

  .nameHoverHidden {
    display: inline;
  }

  .nameHoverOnly {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    white-space: nowrap;
  }
}

.item {
  align-items: center;
  box-sizing: border-box;
  box-shadow: 0 0 2px rgba(#000, 0.3) inset;
  display: flex;
  flex-direction: row;
  flex-grow: 1;
  height: 4.5rem;
  justify-content: space-between;
  position: relative;
  margin: 0;
  padding: var(--ws-s-m);

  &:hover .nameHoverHidden {
    display: none;
  }

  &:hover .nameHoverOnly {
    display: inline;
  }
}

.item--main {
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.3);
  margin: 0 -0.5rem;
  position: relative;

  &::before,
  &::after {
    content: '';
    position: absolute;
    display: block;
    border-style: solid;
    border-color: currentcolor transparent transparent;
    bottom: -0.5rem;
    filter: brightness(85%);
  }

  &::before {
    left: 0;
    border-width: 0.5rem 0 0 0.5rem;
  }

  &::after {
    right: 0;
    border-width: 0.5rem 0.5rem 0 0;
  }
}

.title {
  background-color: transparent;
  border: none;
  font: var(--ws-f-s);
  font-weight: map.get($theme, 'font-weight', 'bold');
  margin: 0;

  .item--light & {
    color: #fff;
  }

  .item--dark & {
    color: #000;
  }

  &:hover {
    cursor: pointer;
  }
}

.button {
  background: none;
  border-style: solid;
  border-width: 2px;
  font: var(--ws-f-s);
  height: 2.5rem;
  margin-left: var(--ws-s-s);
  width: 5rem;

  .item--light & {
    border-color: #fff;
    color: #fff;

    &:focus {
      background-color: rgba(#fff, 0.1);
    }

    &:hover {
      background-color: #fff;
      color: #000;
    }
  }

  // stylelint-disable-next-line no-descending-specificity
  .item--dark & {
    border-color: var(--ws-c-d);
    color: #000;

    &:focus {
      background-color: color-mix(in srgb, var(--ws-c-d) 10%, transparent);
    }

    &:hover {
      background-color: var(--ws-c-d);
      color: #fff;
    }
  }

  .buttonHoverHidden {
    display: inline;
  }

  .buttonHoverOnly {
    display: none;
  }

  &:hover .buttonHoverHidden {
    display: none;
  }

  &:hover .buttonHoverOnly {
    display: inline;
  }
}

.tooltip {
  position: absolute;
  top: -30px;
  left: 6rem;
  transform: translateX(-50%);
  background-color: #333;
  font: var(--ws-f-s);
  color: white;
  padding: 5px 10px;
  border-radius: 3px;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
  pointer-events: none;
}

.item .tooltip {
  opacity: 1;
  visibility: visible;
}
