@import "../global";

:root {
  --media-size: 100%;
  --media-bg-color: var(--color-grey-background);
  --embed-toggle-size: 80px;
}

.n-media {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  border-radius: var(--radius-default);
  padding: 0;
  margin: 0 !important;
  width: var(--media-size);
  background: var(--media-bg-color);
  overflow: hidden;

  @each $size, $name in $sizes {
    &.size-#{$name} {
      --media-size: var(--size-#{$size});
    }
  }

  .n-media__content {
    position: relative;
    height: 0;
    width: 100%;

    iframe,
    object,
    img,
    embed,
    .n-img {
      position: absolute;
      display: block;
      width: 100%;
      height: 100%;
    }

    img {
      object-fit: cover;
    }
  }

  &.contained {
    height: 100%;

    .n-media__content {
      height: 100%;
    }
  }

  .n-media__caption {
    position: absolute;
    background: rgba(var(--color-black), 0.5);
    color: var(--color-white);
    bottom: 0;
    right: 0;
    padding: var(--space-xxs) var(--space-xs);
    font-size: var(--text-xs);

    a {
      color: inherit;
    }
  }

  &.avatar {
    border-radius: 50%;
  }
}

.n-embed {
  .n-hero {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-default);
    overflow: hidden;
    padding: 0;
    margin: 0;
  }

  .n-embed__toggle {
    cursor: pointer;
    font-size: calc(var(--embed-toggle-size) - var(--space-l) * 2);
    width: var(--embed-toggle-size);
    height: var(--embed-toggle-size);
    text-align: center;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translateX(-50%) translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-white);
    color: var(--color-black);
    box-shadow: var(--box-shadow-s);
    opacity: 0.6;

    &:hover {
      opacity: 0.8;
    }
  }
}
