@use '_variables' as *;
@use '_mixins' as *;
@use '_miniature' as *;

$more-button-width: 40px;

.video-miniature {
  --co-fs-small: #{$miniature-fs-small};
  --co-fs-medium: #{$miniature-fs-medium};
  --co-fs-big: #{$miniature-fs-big};
}

.video-name-container {
  display: flex;
  align-items: center;
  min-width: 1px;
}

.video-name {
  font-size: var(--co-fs-big);

  @include miniature-name;
}

.video-info {
  display: grid;
}

.owner {
  display: flex;
  position: relative;
  font-size: var(--co-fs-medium);
}

.date-and-views {
  font-size: var(--co-fs-small);
  color: pvar(--fg-200);
}

.nsfw-warning {
  my-global-icon {
    @include global-icon-size(18px);
  }
}

.owner-container {
  display: flex;
  min-width: 1px;
  width: 100%;
}

my-actor-host {
  flex-shrink: 1;
  min-width: 1px;

  @include margin-left(0.25rem);
}

.owner-label {
  flex-shrink: 1;
  color: pvar(--fg-300);

  @include disable-default-a-behaviour;

  &:hover {
    color: pvar(--fg);
    opacity: 1;
  }
}

.video-actions {
  width: $more-button-width;

  ::ng-deep .dropdown-root:not(.show) {
    opacity: 0;
  }

  ::ng-deep .playlist-dropdown.show + my-action-dropdown .dropdown-root {
    opacity: 1;
  }

  ::ng-deep .dropdown-root > .dropdown-toggle {
    --input-y-padding: 0;
  }
}

.video-miniature:hover,
.video-miniature:focus-within {
  my-video-thumbnail ::ng-deep .actions-overlay,
  .video-actions ::ng-deep .dropdown-root {
    opacity: 1 !important;
  }
}

// Grid mode
// Takes all the width on mobile
.video-miniature:not(.display-as-row) {
  display: flex;
  flex-direction: column;
  padding-bottom: 1rem;
  width: 100%;

  .video-name {
    width: calc(100% - #{$more-button-width});
  }

  my-video-thumbnail {
    margin-bottom: 0.35rem;

    @include block-ratio($selector: '::ng-deep .video-thumbnail');
  }

  &.has-avatar .video-info {
    @include padding-left(0.75rem);
  }

  my-actor-avatar {
    border: 2px solid pvar(--bg);
    position: absolute;
    top: -20px;
    background: pvar(--bg);
    z-index: z(miniature);

    @include left(-2px);

    &[actorType=account] {
      border-radius: $account-avatar-radius;
    }

    &[actorType=channel] {
      border-radius: $channel-avatar-radius;
    }

    & + .owner-container {
      // Keep 34px in sync with the component
      @include margin-left(calc(0.5rem + 34px));
    }
  }

  .date-and-views {
    margin-top: 3px;
  }

  @media screen and (max-width: $small-view) {
    width: 100%;
    margin-bottom: 25px;

    .video-info {
      width: 100%;
      text-align: left;
    }

    .video-actions {
      top: -3px;
      width: auto;

      ::ng-deep .dropdown-root {
        opacity: 1 !important;
      }
    }

    ::ng-deep .video-thumbnail {
      border-radius: 0;
    }
  }
}

.video-miniature.display-as-row {
  --co-fs-small: #{$miniature-fs-row-small};
  --co-fs-medium: #{$miniature-fs-row-medium};
  --co-fs-big: #{$miniature-fs-row-big};

  --co-row-thumbnail-width: #{$video-thumbnail-width};
  --co-row-thumbnail-height: #{$video-thumbnail-height};

  display: flex;
  flex-direction: row;

  my-video-thumbnail {
    min-width: var(--co-row-thumbnail-width);
    max-width: var(--co-row-thumbnail-width);
    height: var(--co-row-thumbnail-height);

    @include margin-right(1rem);
  }

  .video-info {
    grid-template-rows: auto;
    height: min-content;
  }

  .video-name {
    grid-row: 1;
  }

  .date-and-views {
    grid-row: 2;
  }

  .owner {
    grid-row: 3;
    align-items: center;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
  }

  my-actor-avatar {
    @include margin-right(0.5rem);
  }
}

@include on-small-main-col {
  .video-miniature.display-as-row {
    --co-row-thumbnail-width: #{$video-thumbnail-medium-width};
    --co-row-thumbnail-height: #{$video-thumbnail-medium-height};
  }
}

@include on-mobile-main-col {
  .video-miniature.display-as-row {
    --co-row-thumbnail-width: #{$video-thumbnail-small-width};
    --co-row-thumbnail-height: #{$video-thumbnail-small-height};

    --co-fs-small: #{$miniature-fs-mobile-small};
    --co-fs-medium: #{$miniature-fs-mobile-medium};
    --co-fs-big: #{$miniature-fs-mobile-big};

    my-actor-avatar {
      display: none;
    }
  }
}
