@import '../../_variables.scss';
@import '../../_logical.scss';

.user-card {
  position: relative;
  z-index: 1;

  &:hover {
    --_still-image-img-visibility: visible;
    --_still-image-canvas-visibility: hidden;
    --_still-image-label-visibility: hidden;
  }

  .panel-heading {
    padding-block: .5em;
    padding-inline: 0;
    text-align: center;
    box-shadow: none;
    background: transparent;
    flex-direction: column;
    align-items: stretch;
    // create new stacking context
    position: relative;
  }

  .panel-body {
    word-wrap: break-word;
    border-end-end-radius: inherit;
    border-end-start-radius: inherit;
    // create new stacking context
    position: relative;
  }

  .background-image {
    position: absolute;
    inset-block-start: 0;
    inset-inline-start: 0;
    inset-inline-end: 0;
    inset-block-end: 0;
    mask: linear-gradient(to top, white, transparent) bottom no-repeat,
          linear-gradient(to top, white, white);
    // Autoprefixer seem to ignore this one, and also syntax is different
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    background-size: cover;
    mask-size: 100% 60%;
    border-start-start-radius: calc(var(--panelRadius) - 1px);
    border-start-end-radius: calc(var(--panelRadius) - 1px);
    background-color: var(--profileBg);
    z-index: -2;

    .#{$writing-mode-vertical}lr & {
      mask: linear-gradient(to left, white, transparent) right no-repeat,
            linear-gradient(to left, white, white);
      mask-composite: exclude;
      mask-size: 60% 100%;
    }
    .#{$writing-mode-vertical}rl & {
      mask: linear-gradient(to right, white, transparent) left no-repeat,
            linear-gradient(to right, white, white);
      mask-composite: exclude;
      mask-size: 60% 100%;
    }

    &.hide-bio {
      mask-size: 100% 40px;
      [class^=#{$writing-mode-vertical}] & { mask-size: 40px 100%; }
    }
  }

  &-bio {
    text-align: center;
    display: block;
    line-height: 1.3;
    padding: 1em;
    margin: 0;

    a {
      color: $fallback--link;
      color: var(--postLink, $fallback--link);
    }

    img {
      object-fit: contain;
      vertical-align: middle;
      max-inline-size: 100%;
      max-block-size: 400px;
    }
  }

  // Modifiers

  &-rounded-t {
    border-start-start-radius: $fallback--panelRadius;
    border-start-start-radius: var(--panelRadius, $fallback--panelRadius);
    border-start-end-radius: $fallback--panelRadius;
    border-start-end-radius: var(--panelRadius, $fallback--panelRadius);
  }

  &-rounded {
    border-radius: $fallback--panelRadius;
    border-radius: var(--panelRadius, $fallback--panelRadius);
  }

  &-bordered {
    border-width: 1px;
    border-style: solid;
    border-color: $fallback--border;
    border-color: var(--border, $fallback--border);
  }
}

.user-info {
  color: $fallback--lightText;
  color: var(--lightText, $fallback--lightText);
  padding-block: 0;
  padding-inline: 26px;

  .container {
    min-inline-size: 0;
    padding-block: 16px 6px;
    padding-inline: 0;
    display: flex;
    align-items: flex-start;
    max-block-size: 56px;

    > * {
      min-inline-size: 0;
    }

    .Avatar {
      --_avatarShadowBox: var(--avatarShadow);
      --_avatarShadowFilter: var(--avatarShadowFilter);
      --_avatarShadowInset: var(--avatarShadowInset);

      flex: 1 0 100%;
      inline-size: 56px;
      block-size: 56px;
      object-fit: cover;
    }
  }

  &-avatar-link {
    position: relative;
    cursor: pointer;

    &-overlay {
      position: absolute;
      inset-inline-start: 0;
      inset-block-start: 0;
      inset-inline-end: 0;
      inset-block-end: 0;
      background-color: rgba(0, 0, 0, 0.3);
      display: flex;
      justify-content: center;
      align-items: center;
      border-radius: $fallback--avatarRadius;
      border-radius: var(--avatarRadius, $fallback--avatarRadius);
      opacity: 0;
      transition: opacity .2s ease;

      svg {
        color: #FFF;
      }
    }

    &:hover &-overlay {
      opacity: 1;
    }
  }

  .external-link-button, .edit-profile-button {
    cursor: pointer;
    inline-size: 2.5em;
    text-align: center;
    margin-block: -0.5em;
    margin-inline: 0;
    padding-block: 0.5em;
    padding-inline: 0;

    &:not(:hover) .icon {
      color: $fallback--lightText;
      color: var(--lightText, $fallback--lightText);
    }
  }

  .user-summary {
    display: block;
    margin-inline-start: 0.6em;
    text-align: start;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 0;
    // This is so that text doesn't get overlapped by avatar's shadow if it has
    // big one
    z-index: 1;
    line-height: 2em;

    --emoji-size: 1.7em;

    .top-line,
    .bottom-line {
      display: flex;
    }
  }

  .user-name {
    text-overflow: ellipsis;
    overflow: hidden;
    flex: 1 1 auto;
    margin-inline-end: 1em;
    font-size: 1.1em;
  }

  .bottom-line {
    font-weight: light;
    font-size: 1.1em;
    align-items: baseline;

    .lock-icon {
      margin-inline-start: 0.5em;
    }

    .user-screen-name {
      min-inline-size: 1px;
      flex: 0 1 auto;
      text-overflow: ellipsis;
      overflow: hidden;
      color: $fallback--lightText;
      color: var(--lightText, $fallback--lightText);
    }

    .dailyAvg {
      min-inline-size: 1px;
      flex: 0 0 auto;
      margin-inline-start: 1em;
      font-size: 0.7em;
      color: $fallback--text;
      color: var(--text, $fallback--text);
    }

    .user-role {
      flex: none;
      color: $fallback--text;
      color: var(--alertNeutralText, $fallback--text);
      background-color: $fallback--fg;
      background-color: var(--alertNeutral, $fallback--fg);
    }
  }

  .user-meta {
    margin-block-end: .15em;
    display: flex;
    align-items: baseline;
    line-height: 22px;
    flex-wrap: wrap;

    .following, .requested_by {
      flex: 1 0 auto;
      margin: 0;
      margin-block-end: .25em;
      text-align: start;
    }

    .highlighter {
      flex: 0 1 auto;
      display: flex;
      flex-wrap: wrap;
      margin-inline-end: -.5em;
      align-self: start;

      .userHighlightCl {
        padding-block: 2px;
        padding-inline: 10px;
        flex: 1 0 auto;
      }

      .userHighlightSel {
        padding-block-start: 0;
        padding-block-end: 0;
        flex: 1 0 auto;
      }

      .userHighlightText {
        inline-size: 70px;
        flex: 1 0 auto;
      }

      .userHighlightCl,
      .userHighlightText,
      .userHighlightSel {
        vertical-align: top;
        margin-inline-end: .5em;
        margin-block-end: .25em;
      }
    }
  }
  .user-interactions {
    position: relative;
    display: flex;
    flex-flow: row wrap;
    margin-inline-end: -.75em;

    > * {
      margin-block: 0 .6em;
      margin-inline: 0 .75em;
      white-space: nowrap;
      min-inline-size: 95px;
    }

    button {
      margin: 0;
    }
  }
}

.sidebar .edit-profile-button {
  display: none;
}

.user-counts {
  display: flex;
  line-height:16px;
  padding-block: .5em 0em;
  padding-inline: 1.5em 1.5em;
  text-align: center;
  justify-content: space-between;
  color: $fallback--lightText;
  color: var(--lightText, $fallback--lightText);
  flex-wrap: wrap;
}

.user-count {
  flex: 1 0 auto;
  padding-block: .5em .5em;
  padding-inline: 0 0;
  margin-block: 0;
  margin-inline: .5em;

  h5 {
    font-size:1em;
    font-weight: bolder;
    margin-block: 0 0.25em;
    margin-inline: 0;
  }
  a {
    text-decoration: none;
  }
}
