@import (reference) '../../styles/variables.less';

.@{prefix}-previewer {
  margin: 24px 0 32px;
  // border: 1px solid @c-border-light;
  border-radius: 16px;
  background-color: inherit;

  @{dark-selector} & {
    border-color: @c-border-dark;
  }

  [data-dumi-demo-grid] & {
    margin: 0 0 16px;

    &:first-child {
      margin-top: 24px;
    }

    &:last-child {
      margin-bottom: 32px;
    }
  }

  &-actions {
    position: absolute;
    right: 0;
    bottom: 0;
    display: flex;
    height: 32px;
    align-items: center;
    justify-content: flex-end;

    button:last-child {
      margin-right: 18px;
    }

    .qr-icon {
      display: flex;
      position: relative;
      cursor: pointer;

      > canvas {
        position: absolute;
        bottom: 30px;
        right: 12px;
        border: 4px solid #fff;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        box-sizing: content-box;
        transition: all 0.2s ease-in-out;
        transform: scale(0);
        transform-origin: center bottom;
        z-index: 9999;
      }

      &:hover > canvas,
      &:focus > canvas {
        transform: scale(1);
      }
    }
  }

  &-demo {
    position: relative;
    border-radius: 8px;
    padding: 40px 24px 82px;
    border: 1px solid @c-border;
    @{dark-selector} & {
      border-color: @c-border-dark;
    }

    @media @mobile {
      padding: 40px 8px 82px;
    }

    > iframe {
      display: block;
      width: 100%;
      height: 300px;
      border: 0;
    }

    // demo render controls
    &[data-iframe] {
      position: relative;
      padding: 0;
      overflow: hidden;

      &::before {
        content: '';
        display: block;
        height: 24px;
        background-color: @c-border-light;

        @{dark-selector} & {
          // background-color: @c-border-less-dark;
        }
      }

      &::after {
        @btn-gap: 8px;
        @btn-width: 12px;
        content: '';
        position: absolute;
        top: 5px;
        left: @btn-gap;
        display: inline-block;
        width: @btn-width;
        height: @btn-width;
        border-radius: 50%;
        background-color: #fd6458;
        box-shadow:
          (@btn-width + @btn-gap) 0 0 #ffbf2b,
          (@btn-width + @btn-gap) * 2 0 0 #24cc3d;
      }
    }

    &[data-transform] {
      transform: translate(0, 0);
    }

    &[data-compact] {
      padding: 0;
    }
  }

  &-meta {
    // margin-top: 24px;

    // border-top: 1px solid @c-border-light;

    // @{dark-selector} & {
    //   border-top-color: @c-border-less-dark;
    // }
  }

  &-desc {
    position: relative;

    > .markdown {
      padding: 14px 24px;
      border-bottom: 1px dashed @c-border;

      @{dark-selector} & {
        border-bottom-color: @c-border-dark;
      }
    }

    > h5 {
      position: absolute;
      top: -7px;
      left: 20px;
      margin: 0;
      padding: 0 4px;
      display: inline-block;
      font-size: 14px;
      line-height: 1;
      font-weight: bold;
      background: linear-gradient(
          to top,
          rgba(255, 255, 255, 1),
          rgba(255, 255, 255, 1) 50%,
          rgba(255, 255, 255, 0)
        )
        100%;

      @{dark-selector} & {
        background: linear-gradient(
            to top,
            rgba(0, 0, 0, 0.95),
            rgba(0, 0, 0, 0.95) 50%,
            rgba(0, 0, 0, 0)
          )
          100%;
      }

      > a {
        color: @c-text;

        @{dark-selector} & {
          color: @c-text-dark;
        }

        &:not(:hover) {
          text-decoration: none;
        }

        > strong {
          float: inline-start;
          padding-inline-end: 8px;
          color: @c-warning;
          font-size: 12px;
          line-height: 15px;

          @{dark-selector} & {
            color: @c-warning-dark;
          }
        }
      }
    }
  }
  // active
  &[data-active] {
    box-shadow: 0 0 0 4px fade(@c-primary, 10%);
    border-color: lighten(@c-primary, 20%);

    @{dark-selector} & {
      box-shadow: 0 0 0 4px fade(@c-primary-dark, 10%);
      border-color: darken(@c-primary-dark, 20%);
    }
  }

  // debug mode
  &[data-debug] {
    border-color: lighten(@c-warning, 20%);

    @{dark-selector} & {
      border-color: darken(@c-warning-dark, 20%);
    }

    &[data-active] {
      box-shadow: 0 0 0 4px fade(@c-warning, 10%);

      @{dark-selector} & {
        box-shadow: 0 0 0 4px fade(@c-warning-dark, 10%);
      }
    }
  }
}
