/*
 * https://github.com/morethanwords/tweb
 * Copyright (C) 2019-2021 Eduard Kuzmenko
 * https://github.com/morethanwords/tweb/blob/master/LICENSE
 */

.profile {
  &-avatars {
    &-container {
      --secondary-opacity-max: 1;
      width: 100%;
      padding-bottom: 100%;
      //height: 26.25rem;
      //overflow: hidden;
      position: relative;
      cursor: pointer;
      user-select: none;
      background-color: var(--surface-color);
      z-index: 1;
      min-height: 276px;

      @include animation-level(2) {
        transition: padding-bottom var(--transition-standard-in);
      }

      /* &:before, &:after {
        position: absolute;
        content: " ";
        height: 100%;
        width:
      } */
      @include hover() {
        .profile-avatars-arrow {
          opacity: .2;
        }
      }

      &.is-single {
        .profile-avatars-arrow,
        .profile-avatars-tabs {
          display: none;
        }
      }

      &.is-swiping {
        .profile-avatars-arrow {
          opacity: 0 !important;
        }
      }

      &.has-stories {
        .profile-avatars-avatar-fake {
          visibility: visible;
        }
      }
    }

    &-avatars {
      width: 100%;
      height: 100%;
      display: flex;
      align-items: center;
      flex-wrap: nowrap;
      transform: translateZ(-1px) scale(2);
      transform-origin: left top;
      transition: transform .2s ease-in-out;
      position: absolute;

      .scrollable.no-parallax & {
        transform: translate(0, 0);
      }

      // &:before {
      //   content: " ";
      //   top: 0;
      //   right: 0;
      //   bottom: 0;
      //   left: 0;
      // }
    }

    &-avatar {
      width: inherit;
      // height: inherit;
      height: 0;
      padding-bottom: 100%;
      min-width: 100%;
      // min-height: 100%;
      display: flex;
      // background-color: #000;
      position: relative;

      .avatar-star {
        --size: 420px;
        opacity: 0;

        @include animation-level(2) {
          transition: opacity var(--transition-standard-in);
        }
      }

      &.active {
        @include animation-level(2) {
          transform: scale(1);
          border-radius: 0;
          transition: transform var(--transition-standard-in), border-radius var(--transition-standard-in);
        }
      }

      .avatar-full {
        --multiplier: calc(54 / 420);
      }

      .avatar {
        position: absolute !important;
      }

      .avatar-photo {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover;
        pointer-events: none;
      }

      // &-first {
      //   transform: scale(calc(1 / (120 / 420)));
      //   transform-origin: left top;
      // }

      .has-stories &-first {
        opacity: 1;
        transition-delay: 0s, 0s;
        transform: scale(1);

        @include animation-level(2) {
          transition: opacity .05s, transform var(--transition-standard-in);
        }
      }

      &-fake {
        position: absolute !important;
        left: 50%;
        top: 48%;
        transform: translate(-50%, -50%);
        visibility: hidden;
      }
    }

    &-gradient {
      position: absolute;
      left: 0;
      right: 0;
      bottom: 0;
      height: 80px;
      background: linear-gradient(360deg, rgba(0, 0, 0, .3) 8.98%, rgba(0, 0, 0, 0) 100%);
      pointer-events: none;

      @include animation-level(2) {
        opacity: 1;
        transition: opacity var(--transition-standard-easing) calc(var(--transition-standard-in-time) / 2);
        transition-delay: calc(var(--transition-standard-in-time) / 2);
      }

      &-top {
        top: 0;
        bottom: auto;
        transform: scaleY(-1);
      }
    }

    &-info {
      position: absolute;
      bottom: 0;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      inset-inline: 1.5rem;
      bottom: .5625rem;
      pointer-events: none;
      transform: translateY(0);

      @include animation-level(2) {
        transition: transform var(--transition-standard-in), color var(--transition-standard-in);
      }

      .profile-name,
      .profile-subtitle {
        color: currentColor;
        margin: 0;
        text-align: start;
        inset-inline-start: 0;
        transform: translateX(0);
        position: relative;
        white-space: nowrap;

        @include animation-level(2) {
          transition: inset-inline-start var(--transition-standard-in), transform var(--transition-standard-in);
        }
      }

      .profile-subtitle {
        line-height: 16px;
      }

      .profile-subtitle,
      .verified-icon,
      .premium-icon,
      .emoji-status-text-color {
        opacity: var(--secondary-opacity-max);
      }

      .online {
        color: inherit !important;
      }
    }

    &-tabs {
      display: flex;
      position: absolute;
      top: .5rem;
      left: .375rem;
      right: .375rem;
      height: .125rem;
      pointer-events: none;

      @include animation-level(2) {
        opacity: 1;
        transition: opacity var(--transition-standard-in);
      }
    }

    &-tab {
      flex: 1 1 auto;
      border-radius: 4px;
      margin: 0 .125rem;
      background-color: #fff;
      opacity: .2;
      transition: opacity .2s ease-in-out;
      //min-width: 1.6875rem;
      height: inherit;

      &.active {
        opacity: .6;
      }
    }

    &-arrow {
      position: absolute;
      top: 0;
      left: 0;
      bottom: 0;
      width: calc(100% / 3);
      opacity: 0;

      @include animation-level(2) {
        transition: opacity .2s ease-in-out;
      }

      &-icon {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        font-size: 2.1875rem;
        color: #fff;
        left: .625rem;
      }

      .profile-avatars-container:not(.is-swiping) & {
        @include hover() {
          opacity: 1;
        }
      }

      /* &-icon {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
      } */

      &-next {
        left: auto;
        right: 0;

        .profile-avatars-arrow-icon {
          left: auto;
          right: .625rem;
        }
      }
    }

    &-pattern {
      position: absolute;
      top: 49%;
      left: 50%;
      transform: translate(-50%, -50%);
      mix-blend-mode: overlay;
    }
  }

  &-content {
    /* flex: 1 1 auto; */
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    /* height: 100%; */
    position: relative;
    width: 100%;

    /* .checkbox-field {
      margin: 0;
      padding: 0;
      margin-left: -54px;
    }

    .checkbox-caption {
      padding-left: 54px;
    } */

    /* &-wrapper {
      flex: 1 1 auto;
      display: flex;
      flex-direction: column;
      padding-bottom: 13px;

      @include respond-to(not-handhelds) {
        padding-top: 15px;
      }
    } */

    .sidebar-left-section {
      position: relative;
      background-color: var(--surface-color);
      //padding-top: .5625rem;
      padding-bottom: .5rem;
      //margin-bottom: .75rem;
      //box-shadow: 0px 1px 5px -1px rgba(0, 0, 0, .16);

      .profile-subtitle {
        .peer-typing-container {
          justify-content: center;
        }
      }
    }

    /* .search-super {
      &:before {
        content: " ";
        height: 12px;
        width: 100%;
        background-color: var(--background-color-true);
        position: absolute;
        top: -12px;
      }
    } */

    &.search-empty {
      .gradient-delimiter {
        display: none;
      }
    }

    .has-simple-avatar {
      margin-top: 3.5rem;
    }
  }

  &-button {
    @include respond-to(handhelds) {
      border-radius: 0;
    }
  }

  &-change-avatar {
    --size: 3.375rem;
    position: absolute !important;
    top: calc(var(--size) / -2);
    inset-inline-end: 1.25rem;
    transform: none;
    transition: none !important;
  }

  &-container {
    &.is-collapsed {
      .profile-avatars-container {
        padding-bottom: 66%;
      }

      .profile-avatars-avatar.active {
        transform: translateY(-1.5%) scale(calc(120 / 420));
        border-radius: 50%;
      }

      .avatar-star {
        opacity: 1;
      }

      .profile-avatars-tabs,
      .profile-avatars-gradient,
      .profile-avatars-arrow {
        opacity: 0 !important;
      }

      .profile-avatars-gradient {
        transition-delay: 0s;
      }

      .profile-avatars-info {
        transform: translateY(-42%);

        .profile-name,
        .profile-subtitle {
          inset-inline-start: 50%;
          transform: translateX(-50%);
        }
      }

      .has-stories .profile-avatars-avatar-first {
        opacity: 0;
        transform: scale(.8916666667);
        transition-delay: calc(var(--transition-standard-in-time) - .05s), 0s;
      }
    }

    &.is-collapsed:not(.need-white) {
      .profile-avatars-info {
        color: var(--primary-text-color);

        .profile-subtitle {
          color: var(--secondary-text-color);
          opacity: 1;
        }
      }
    }

    // &:not(.is-collapsed) {
      // .profile-avatars-avatar-first {
      //   .avatar-stories-svg {
      //     opacity: 0;
      //   }
      // }
    // }

    &.need-white {
      .profile-avatars-container {
        --secondary-opacity-max: .7;
      }

      .profile-avatars-info,
      .profile-subtitle {
        color: #fff;
      }

      .show-when {
        background-color: rgba(255, 255, 255, .2);
      }

      .topic-name-button {
        --primary-color: #fff;
      }

      .peer-typing-container {
        --color: #fff;
      }

      .profile-avatars-container {
        .premium-icon {
          color: #fff;
        }

        .verified-icon {
          &-background {
            fill: #fff;
          }

          &-check {
            visibility: hidden;
          }
        }
      }
    }

    &:not(.header-filled) {
      .sidebar-header {
        background-color: transparent;

        &:after {
          opacity: 0;
        }
      }

      &.need-white {
        .sidebar-header {
          --light-secondary-text-color: rgba(255, 255, 255, #{$hover-alpha});
          --ripple-color: var(--light-secondary-text-color);

          .sidebar-header__title,
          .btn-icon {
            color: #fff;
          }
        }
      }
    }

    .sidebar-header {
      --transition: .1s ease-in-out;
      position: absolute;
      inset-inline: 0;
      z-index: 2;

      @include animation-level(2) {
        transition: background-color var(--transition);
      }

      &:after {
        @include animation-level(2) {
          transition: opacity var(--transition);
        }
      }

      .animated-close-icon {
        &:before,
        &:after {
          background-color: currentColor;
        }
      }

      .sidebar-header__title,
      .btn-icon {
        @include animation-level(2) {
          transition: color var(--transition);
        }
      }
    }

    // .sidebar-content {
    //   margin-top: -3.5rem;
    // }

    > .scrollable {
      display: flex;
      flex-direction: column;
      //transform: none;
    }

    .search-super-tabs-scrollable {
      top: 3.5rem;
    }
  }

  &-name {
    text-align: center;
    font-size: var(--font-size-20);
    line-height: var(--line-height-20);
    font-weight: var(--font-weight-bold);
	  min-width: 0;
    max-width: 21.25rem;
    margin: 0 auto;
    color: var(--primary-text-color);
    display: flex;
    align-items: flex-end;

    .emoji-native {
      vertical-align: inherit;
      min-width: min-content;
    }

    .peer-title:not(.with-icons) {
      @include text-overflow(false);
    }

    // .verified-icon {
    //   margin-bottom: 3px;
    // }

    .sidebar-left-section-content > & {
      justify-content: center;
    }

    .badge-fake {
      align-self: center;
    }
  }

  &-subtitle {
    text-align: center;
    color: var(--secondary-text-color);
    font-size: .875rem;
    margin-bottom: .875rem;
    margin-top: 1px;
    display: flex;
    align-items: center;
    justify-content: center;

    @include respond-to(handhelds) {
      margin-top: 3px;
    }

    .online {
      color: var(--primary-color);
    }

    .show-when {
      margin-inline-start: .25rem;
      cursor: pointer;
      pointer-events: all;
    }
  }

  &-avatar {
    margin: .5rem auto 10px;
    display: block;
    //flex: 0 0 auto;

    @include respond-to(handhelds) {
      margin: 0 auto 10px;
      --size: 100px;
      --multiplier: .54;
    }
  }

  &-name,
  &-subtitle,
  &-avatar {
    flex: 0 0 auto;
  }

  &-pinned-gifts {
    position: absolute;
    width: 120px;
    height: 120px;
    top: 4.5rem;
    left: 50%;
    transform: translateX(-50%) scale(1);
    opacity: 1;
    transition: opacity 100ms ease-in-out, transform 100ms ease-in-out;
    transform-origin: center;

    @include respond-to(handhelds) {
      // костыль из-за того что аватар в мобилке имеет странные размеры
      top: calc(4.5rem + 5vw);
      width: 28.5%;
      height: auto;
      aspect-ratio: 1/1;
    }

    .profile-container:not(.is-collapsed) & {
      opacity: 0;
      transform: translateX(-50%) scale(1.2);
    }
  }

  &-pinned-gift {
    &::before {
      content: '';
      position: absolute;
      inset: -1px;
      background: var(--halo-color);
      border-radius: 50%;
      filter: blur(15px) saturate(1.5);
    }

    position: absolute;
    width: 30px;
    height: 30px;

    animation: profile-pinned-gift-fade-in 0.5s forwards;

    @keyframes profile-pinned-gift-fade-in {
      0% {opacity: 0;}
      100% {opacity: 1;}
    }

    &[data-idx="0"] { left: -36px; top: -3px; }
    &[data-idx="1"] { left: -96px; top: 57px; }
    &[data-idx="2"] { left: -31px; top: 87px; }
    &[data-idx="3"] { right: -54px; top: 17px; }
    &[data-idx="4"] { right: -114px; top: 37px; }
    &[data-idx="5"] { right: -84px; top: 87px; }
  }

  &-bot-verification {
    --custom-emoji-size: 1rem;
    font-size: 14px;
    line-height: 16px;
    padding-inline: 1rem;
    margin-bottom: 0.75rem;
    color: var(--secondary-text-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
}

.star-gifts-profile-tab {
  background-color: var(--background-color);
  display: flex;
  justify-content: center;
  height: 100%;
}
