@use 'pix-design-tokens/breakpoints';
@use 'pix-design-tokens/typography';
@use 'pix-design-tokens/fonts';
@use 'challenge-embed-simulator';
@use '../globals/a11y' as *;

.challenge-statement {
  /* XXX required to let "help tooltip" displaying well even if instruction section is short (1 line) */
  overflow: visible;
}

.challenge-statement__instruction-section {
  @extend %pix-body-m;

  display: flex;
  justify-content: space-between;
  margin: 20px 20px 16px;

  hr {
    border-top: 1px solid var(--pix-neutral-20);
    border-bottom: none;
  }

  @include breakpoints.device-is('desktop') {
    font-size: 1.25rem;
  }
}

.challenge-statement__instructions-and-text-to-speech-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.challenge-statement__text-to-speech-trigger {
  width: 1.5rem;
  height: 1.5rem;
  margin-bottom: 4px;
  font-size: 1rem;
}

.challenge-statement-instruction__text blockquote {
  position: relative;
  margin-left: 20px;
  font-size: inherit;

  &::before {
    position: absolute;
    left: -18px;
    display: block;
    width: 4px;
    height: 100%;
    background-color: var(--pix-neutral-20);
    border-radius: 2px;
    content: '';
  }
}

.challenge-statement-instruction {
  &__text {
    @extend %pix-body-l;

    width: 100%;
    color: var(--pix-neutral-800);

    p {
      overflow-wrap: break-word; // keep break-word as fallback for older browsers
      overflow-wrap: anywhere;
    }

    strong {
      font-weight: var(--pix-font-bold);
    }

    a {
      color: var(--pix-primary-500);
      text-decoration: underline;

      @include breakpoints.device-is('tablet') {
        display: inline-block;
      }

      &:active,
      &:focus,
      &:hover {
        color: var(--pix-primary-700);
      }
    }

    a::after {
      @include external-link;
    }
  }
}

.challenge-statement__illustration-section {
  display: block;
  box-sizing: content-box;
  padding: 10px 0;
  text-align: center;
  border-top: 1px solid var(--pix-neutral-20);
}

.challenge-statement__attachments-section {
  padding: 20px;
  text-align: center;
  background-color: var(--pix-neutral-20);
}

.challenge-statement__text {
  font-size: 1rem;
}

.challenge-statement__help-icon {
  position: relative;
  display: inline-block;
  margin: 0 5px;
  color: var(--pix-primary-500);
  cursor: pointer;
}

.challenge-statement__help-tooltip {
  position: absolute;
  bottom: 30px;
  left: 50%;
  z-index: 999;
  width: 430px;
  height: auto;
  margin-left: -400px;
  padding: 15px;
  color: var(--pix-neutral-100);
  text-align: justify;
  background-color: var(--pix-neutral-0);
  border: solid 1px var(--pix-neutral-20);
  border-radius: 6px;
  box-shadow: 1px 1px 1px 0 rgb(0 0 0 / 10%);
  visibility: hidden;
}

/* XXX tooltip bottom arrow */
.challenge-statement__help-tooltip::before {
  position: absolute;
  top: 100%;
  left: 400px;
  width: 0;
  height: 0;
  margin-left: -10px;
  border-top: 10px solid var(--pix-neutral-20);
  border-right: 10px solid transparent;
  border-left: 10px solid transparent;
  content: '';
}

.challenge-statement__help-tooltip::after {
  position: absolute;
  top: 100%;
  left: 400px;
  width: 0;
  height: 0;
  margin-left: -8px;
  border-top: 8px solid var(--pix-neutral-0);
  border-right: 8px solid transparent;
  border-left: 8px solid transparent;
  content: '';
}

/* XXX the magic trick to manage tooltip appearing at icon mouse hover */
.challenge-statement__help-icon:hover .challenge-statement__help-tooltip {
  visibility: visible;
}

.challenge-statement__help-text {
  color: var(--pix-neutral-800);
  font-size: 0.875rem;
}

.challenge-statement__file-options {
  margin-left: 0;
  padding: 10px 0;
}

.challenge-statement__file-option {
  display: inline-block;
  margin: 5px;
  padding: 0 15px;
  list-style-type: none;
}

.label-checkbox-downloadable {
  position: relative;
  display: inline-block;
  padding-left: 6px;
  cursor: pointer;
}

.challenge-statement__file-option-label {
  font-weight: var(--pix-font-normal);
  font-size: 1rem;
  line-height: 10px;
}

.challenge-statement__action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.challenge-statement__action-link {
  width: 156px;
  height: 46px;
  margin-bottom: var(--pix-spacing-6x);
  color: var(--pix-neutral-0);
  text-align: center;
  background-color: var(--pix-primary-500);
  border-radius: 23px;
  cursor: pointer;
}

.challenge-statement__action-link:hover,
.challenge-statement__action-link:focus {
  color: var(--pix-neutral-0);
}

.challenge-statement__action-help {
  font-size: 0.825rem;

  &--link {
    color: var(--pix-primary-700);
    text-decoration: underline;

    &:active,
    &:focus,
    &:hover {
      color: var(--pix-primary-700);
    }

    &:visited {
      color: var(--pix-primary-500);
    }

    &::after {
      @include external-link;

      position: relative;
      top: 4px;
      left: 2px;
    }
  }
}

.challenge-statement__action-label {
  width: 76px;
  font-weight: var(--pix-font-bold);
  font-size: 1rem;
  line-height: 46px;
  text-transform: uppercase;
}

.challenge-statement__alternative-instruction {
  margin: 20px;

  button {
    padding: 0;
    color: var(--pix-primary-500);
    font-weight: 500;
    font-size: 1rem;
    background-color: transparent;
    border: none;
    cursor: pointer;

    &:hover,
    &:focus,
    &:active {
      color: var(--pix-neutral-0);
    }
  }

  &-text {
    margin-top: 10px;
  }
}
