$cover-z-index: 0;
$metadata-z-index: 1;

.channel-cover {
  position: relative;
  background-image: linear-gradient(to right, #637ad2, #318794 80%);
  display: flex;
  align-items: flex-end;
  box-sizing: content-box;
  color: #fff;
}

.channel-cover__custom {
  z-index: $cover-z-index;
  align-self: flex-start;
  position: absolute;
  object-fit: cover;
  filter: brightness(60%);
}

.channel-cover,
.channel-cover__custom {
  min-height: var(--cover-photo-height);
  width: 100%;
  border-top-left-radius: var(--card-radius);
  border-top-right-radius: var(--card-radius);

  @media (max-width: $breakpoint-small) {
    // Yikes
    // I, Sean Yesmunt, take full responsibility for this monster
    min-height: calc(var(--cover-photo-height) + 2 * var(--spacing-xlarge) + var(--spacing-medium));
  }
}

.channel-thumbnail {
  display: flex;
  height: 5rem;
  width: 5rem;
  background-size: cover;
  margin-right: var(--spacing-medium);
}

.channel-thumbnail--small {
  height: 3rem;
  width: 3rem;
}

.channel__thumbnail--channel-page {
  position: absolute;
  height: var(--channel-thumbnail-width);
  width: var(--channel-thumbnail-width);
  left: var(--spacing-medium);
  top: 4rem;
  margin-top: var(--spacing-large);
  box-shadow: var(--card-box-shadow);

  @media (max-width: $breakpoint-small) {
    display: none;
  }
}

.channel-thumbnail__custom {
  width: 100%;
  object-fit: cover;
}

.channel-thumbnail__default {
  width: 80%;
  height: 80%;
  margin-left: auto;
  margin-right: auto;
  align-self: flex-end;
}

.channel-thumbnail,
.channel-thumbnail__custom {
  border-radius: var(--card-radius);
}

.channel-thumbnail__default--0 {
  background-color: #748ffc;
}

.channel-thumbnail__default--1 {
  background-color: #ffa855;
}

.channel-thumbnail__default--2 {
  background-color: #339af0;
}

.channel-thumbnail__default--3 {
  background-color: #ec8383;
}

.channel-thumbnail__default--4 {
  background-color: #ccc;
}

.channel__primary-info {
  // Ensure the profile pic/title sit ontop of the default cover background
  z-index: $metadata-z-index;
  // Jump over the thumbnail photo because it is absolutely positioned
  // Then add normal page spacing, _then_ add the actual padding
  padding-left: calc(var(--channel-thumbnail-width) + var(--spacing-large));
  padding-right: var(--spacing-medium);
  padding-bottom: var(--spacing-medium);
  margin-top: var(--spacing-xlarge);
  min-width: 0;
  width: 100%;

  @media (max-width: $breakpoint-small) {
    padding-left: var(--spacing-medium);
    margin-top: 0;
  }
}

.channel__title {
  display: inline;
  margin-right: var(--spacing-small);
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: xx-large;
  font-weight: var(--font-weight-bold);

  // Quick hack to get this to work
  // We should have a generic style for "header with button next to it"
  .button {
    margin-left: var(--spacing-medium);
  }

  @media (max-width: $breakpoint-small) {
    padding-top: var(--spacing-xlarge);
  }
}

.channel__meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;

  .button {
    height: auto;
  }
}

.channel__image--blurred {
  filter: blur(16px);
}

.channel__quick-actions {
  display: flex;
  flex-direction: row;
  margin-top: var(--spacing-small);
  margin-left: var(--spacing-medium);
  position: absolute;
  top: 0;
  right: var(--spacing-medium);
  margin-top: var(--spacing-medium);
  z-index: $metadata-z-index;
  flex-wrap: wrap;
  font-size: var(--font-base);

  > * {
    padding: 0 var(--spacing-xsmall);

    &:not(:last-child) {
      margin-right: var(--spacing-medium);
    }
  }

  @media (max-width: $breakpoint-small) {
    > * {
      margin-bottom: var(--spacing-xsmall);
    }
  }
}

.channel-name--inline {
  margin-left: var(--spacing-xsmall);
}

.menu__list.channel__list {
  margin-top: var(--spacing-small);
  margin-left: 0;
  border-radius: var(--border-radius);
  background: transparent;

  [role='menuitem'] {
    &[data-selected] {
      background: transparent;
      .channel__list-item {
        background-color: var(--color-card-background-highlighted);
      }
    }

    &:first-child {
      .channel__list-item {
        border-top: 1px solid var(--color-border);
        border-top-left-radius: var(--border-radius);
        border-top-right-radius: var(--border-radius);
      }
    }

    &:last-child {
      .channel__list-item {
        border-bottom-left-radius: var(--border-radius);
        border-bottom-right-radius: var(--border-radius);
      }
    }

    .channel__list-item {
      padding-right: calc(var(--spacing-xlarge) + var(--spacing-small) * 2);
      border-left: 1px solid var(--color-border);
      border-right: 1px solid var(--color-border);
    }
  }
}

.channel__list-item {
  display: flex;
  align-items: center;
  background-color: var(--color-card-background);
  padding: var(--spacing-small);
  border-bottom: 1px solid var(--color-border);

  .channel-thumbnail {
    height: 2rem;
    width: 2rem;
  }

  .icon {
    color: var(--color-menu-icon);
    margin-left: var(--spacing-large);
    margin-right: var(--spacing-small);
  }

  &:hover {
    background-color: var(--color-card-background-highlighted);
  }
}

.channel__list-item--selected {
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  background-color: var(--color-card-background-highlighted);
}
