// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only

@use '../mixins';
@use '../variables';

.StoryCreator {
  $tools-height: 44px;

  @mixin svg($icon) {
    @include mixins.color-svg(
      '../images/icons/#{$icon}',
      variables.$color-white
    );
  }

  background: variables.$color-gray-95;
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  inset-inline-start: 0;
  position: absolute;
  top: 0;
  user-select: none;
  z-index: variables.$z-index-popup-overlay;

  &__container {
    display: flex;
    flex: 1;
    justify-content: center;
    overflow: hidden;
    padding-bottom: 0;
    padding-block: 22px;
    padding-inline: 60px;
    position: relative;
  }

  &__input {
    background: transparent;
    border: none;
    color: transparent;
    position: absolute;
    text-align: center;
    top: 50%;
    user-select: none;

    &:focus {
      outline: none;
    }
  }

  &__controls {
    align-items: center;
    display: flex;
    flex-grow: 1;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 596px;
  }

  &__control {
    @include mixins.button-reset;
    & {
      align-items: center;
      border-radius: 32px;
      display: inline-flex;
      height: 32px;
      justify-content: center;
      margin-block: 0;
      margin-inline: 15px;
      opacity: 1;
      width: 32px;
    }

    &::after {
      content: ' ';
      height: 24px;
      width: 24px;
    }

    &--link::after {
      @include mixins.color-svg(
        '../images/icons/v3/link/link.svg',
        variables.$color-white
      );
    }

    &--text::after {
      @include mixins.color-svg(
        '../images/icons/v2/text-24.svg',
        variables.$color-white
      );
    }

    &--bg {
      @include mixins.rounded-corners;
      border: 1.5px solid variables.$color-white;
      display: block;
      height: 24px;
      padding: 2.5px;
      width: 24px;
      &::after {
        display: none;
      }

      &--selected {
        border-width: 4px;
        padding: 0;
      }
    }

    &--selected {
      background-color: variables.$color-white;

      &::after {
        background-color: variables.$color-black;
      }
    }

    &:hover {
      background-color: variables.$color-gray-80;

      &::after {
        background-color: variables.$color-white;
      }
    }
  }

  &__toolbar {
    align-items: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 22px;
    width: 100%;

    &--buttons {
      align-items: center;
      display: flex;
      justify-content: center;
      width: 100%;
    }

    &--space {
      height: $tools-height;
      margin-bottom: 22px;
    }
  }

  &__tools {
    align-items: center;
    background-color: variables.$color-gray-90;
    border-radius: 10px;
    color: variables.$color-white;
    display: flex;
    height: $tools-height;
    justify-content: center;
    margin-bottom: 22px;
    padding-block: 14px;
    padding-inline: 12px;

    &__tool,
    &__tool__button {
      margin-inline-end: 14px;
    }

    &__button {
      @mixin icon($icon) {
        @include svg($icon);
        & {
          height: 20px;
          width: 20px;
          border-radius: 0;
        }
      }

      @include mixins.button-reset;
      & {
        margin-block: 0;
        margin-inline: 8px;
        padding: 8px;
      }

      &--bg {
        @include icon('v2/text-effect-on-24.svg');
      }
      &--bg-inverse {
        @include icon('v2/text-effect-on-24.svg');
      }
      &--bg-none {
        @include icon('v2/text-effect-off-24.svg');
      }
      &--font-regular__button {
        @include icon('v3/font/font-regular-compact.svg');
      }
      &--font-bold__button {
        @include icon('v3/font/font-bold-compact.svg');
      }
      &--font-serif__button {
        @include icon('v3/font/font-serif-compact.svg');
      }
      &--font-script__button {
        @include icon('v3/font/font-script-compact.svg');
      }
      &--font-condensed__button {
        @include icon('v3/font/font-condensed-compact.svg');
      }
    }
  }

  &__icon {
    &--font-regular {
      @include svg('v3/font/font-regular-compact.svg');
    }
    &--font-bold {
      @include svg('v3/font/font-bold-compact.svg');
    }
    &--font-serif {
      @include svg('v3/font/font-serif-compact.svg');
    }
    &--font-script {
      @include svg('v3/font/font-script-compact.svg');
    }
    &--font-condensed {
      @include svg('v3/font/font-condensed-compact.svg');
    }
  }

  &__bg {
    @include mixins.button-reset;
    & {
      @include mixins.rounded-corners;

      border: 2px solid transparent;
      height: 24px;
      margin: 4px;
      width: 24px;
    }

    &--selected {
      border: 2px solid variables.$color-white;
    }
  }

  &__popper {
    background: variables.$color-gray-80;
    border-radius: 10px;
    margin-bottom: 18px;
    padding: 8px;
    width: 144px;

    &__arrow {
      border-inline-start: 14px solid transparent;
      border-inline-end: 14px solid transparent;
      border-top: 14px solid variables.$color-gray-80;
      @include mixins.position-absolute-center-x;
      bottom: -14px;
      height: 0;
      width: 0;
    }
  }

  &__link-preview-input-popper {
    display: flex;
    flex-direction: column;
    min-height: 256px;
    padding: 16px;
    width: 360px;
  }

  &__link-preview-input__container {
    margin-top: 0;
  }

  &__link-preview-container {
    align-items: center;
    display: flex;
    flex-direction: column;
    flex: 1;
    justify-content: center;
  }

  &__link-preview-wrapper {
    transform: scale(0.5);
  }

  &__link-preview-button {
    margin-top: 18px;
    margin-bottom: 8px;
  }

  &__link-preview {
    background: variables.$color-black-alpha-40;
    border-radius: 16px;
    display: flex;
    padding: 14px;
    width: 100%;

    &__image {
      border-radius: 8px;
      height: 76px;
      width: 76px;
    }

    &__meta {
      display: flex;
      flex-direction: column;
      justify-content: center;
      margin-inline-start: 14px;
    }

    &__title {
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      @include mixins.font-body-1-bold;
      color: variables.$color-white;
      display: -webkit-box;
      overflow: hidden;
      user-select: none;
    }

    &__location {
      @include mixins.font-subtitle;
      color: variables.$color-white-alpha-60;
    }
  }

  &__link-preview-empty {
    align-items: center;
    color: variables.$color-gray-45;
    display: flex;
    flex-direction: column;

    &__icon {
      @include mixins.color-svg(
        '../images/icons/v3/link/link.svg',
        variables.$color-gray-45
      );
      & {
        height: 20px;
        width: 20px;
      }
    }
  }

  &__emoji-button,
  &__emoji-button::after {
    height: 20px;
    width: 20px;
  }
}
