@import "components/reading-mode/helpers";

html, body {
  height: 100%;
  width: 100%;
  padding: 0;
  margin: 0;

  * {
    box-sizing: border-box;
  }

}

.hidden {
  display: none;
}

.reading-mode {
  display: flex;
  background-color: #e9e9e9;
  padding: 60px 20px;
  min-height: 100vh;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;

  a {
    color: #f06040;
    text-decoration: none;
  }

  @media (max-width: 767px) {
    padding: 0;
  }

  /***--- reading-mode-header ---***/
  &-header {
    width: 100%;
  }

  /***--- Sidebar ---***/
  &-sidebar {
    position: sticky;
    top: 60px;
    flex: 1;
    display: flex;
    flex-direction: column;

    &.sidebar-left {
      overflow-y: auto;
      max-height: calc(100vh - 30px);
      padding-right: 15px;
      align-items: flex-end;

      //scroll
      &::-webkit-scrollbar {
        width: 3px;
      }

      &::-webkit-scrollbar-track {
        background: #EFEFEF;
      }

      &::-webkit-scrollbar-thumb {
        background: #ddd;
      }
    }

    &.sidebar-right {
      padding-left: 20px;
      align-items: flex-start;
      font-family: Georgia, 'Times New Roman', Times, serif;
    }

    .reading-mode-toc,
    .reading-mode-links {
      width: 350px;
      max-width: 100%;
      font-size: 15px;
    }


    @media print {
      display: none;
    }

    @media (max-width: 767px) {
      &.sidebar-left {
        position: relative;
        top: 0;
        padding: 0;
        align-items: flex-start;
        width: 100%;
        flex: auto;

        .reading-mode-toc,
        .reading-mode-links {
          width: 100%;
          padding: 15px;
          margin-bottom: 0;

          &:empty {
            display: none;
          }
        }

      }

      &.sidebar-right {
        position: sticky;
        flex-flow: row;
        width: 100%;
        bottom: 0;
        padding: 5px !important;
        background: #FFF;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);

        .reading-mode-tools {
          flex-direction: row;

          &-wrap {
            width: 100%;
          }

          .reading-mode-tool {
            &:first-child {
              margin-top: 5px;
            }
          }

        }
      }
    }

  }

  &-body {
    color: #dbdbdb;
    border: 1px solid;
    background-color: #f8f8f8;
    padding: 60px;
    word-break: break-all;
    width: 860px;
    max-width: 100%;

    @media print {
      border: none !important;
      padding: 0 !important;
      max-width: 100%;
    }

    @media (max-width: 767px) {
      padding: 20px;
    }

  }

  &-site {
    display: flex;
    align-items: center;

    img {
      margin: 0;
    }

    .site-url {
      margin-left: 7px;
      color: #696969;
      text-decoration: none;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;

      &:hover {
        color: #f06040;
      }

    }
  }

  &-title {
    letter-spacing: -0.5px;
    margin: 22px 0 15px 0;
    color: #333333;
  }

  /*-------------- reading-mode-byline ---------------*/
  &-byline {
    color: #696969;
    display: flex;
    align-items: center;
    flex-wrap: wrap;

    .reading-mode-time {
      margin-right: 15px;
    }

    & > div {
      display: flex;
      align-items: center;
      white-space: nowrap;

      i {
        margin-right: 5px;
      }

      &.reading-mode-author {
        margin-left: auto;
      }

    }

    @media print {
      .reading-mode-time {
        display: none;
      }
    }

    @media (max-width: 767px) {
      .reading-mode-time {
        width: 100%;
        margin-bottom: 10px;
      }
    }

  }

  /*--------------- reading-mode-content ----------------*/
  &-content {
    border-top: 2px solid #dbdbdb;
    margin-top: 20px;
    color: #333333;
    font-size: 21px;
    line-height: 32px;

    a {
      border-bottom: 1px solid #f06040;
      transition: border-bottom-color .15s ease-out, color .2s ease-out;
    }


    .media {
      display: block
    }

    figure {
      margin: 0
    }

    blockquote {
      border-left: 3px solid #e1e1e1;
      padding-left: 37px;
      font-style: normal;
      color: inherit;
      font-size: inherit
    }

    figcaption {
      font-size: 13px;
      color: #666;
      line-height: 16px
    }

    @media print {
      figcaption {
        color: #000
      }
    }

    a {
      border-bottom: 1px solid #f06040;
      transition: border-bottom-color .15s ease-out, color .2s ease-out
    }

    @media print {
      a {
        border-bottom: none
      }
    }

    a:hover {
      border-bottom-color: #a4422f;
      color: #a4422f
    }

    h2 {
      font-size: 35px;
      line-height: 38px
    }

    h3 {
      font-size: 28px;
      line-height: 31px
    }

    h4 {
      font-size: 24px;
      line-height: 29px
    }

    h5 {
      font-size: 20px;
      line-height: 25px
    }

    h6 {
      font-size: 16px;
      line-height: 21px
    }


    h2, h3, h4, h5, h6 {
      margin-top: 30px
    }

    @media print, screen {
      h2,
      h3,
      h4,
      h5,
      h6 {
        font-family: FreightText W01 Bold
      }
    }

    @media print, screen {
      em, i {
        font-family: FreightText W01 Book Italic
      }
    }

    aside :first-child,
    aside :last-child {
      margin-top: 23px
    }

    aside {
      padding: 0 27px 0 26px
    }

    iframe {
      border: none
    }

    iframe[src^="https://player.vimeo.com/video"],
    iframe[src^="https://www.youtube.com/embed"],
    video {
      width: 100%;
      height: 394px
    }

    img, video {
      max-width: 100%;
      display: block;
      margin: 10px auto;
    }

    img {
      height: auto;
    }

    @media (max-width: 767px) {
      font-size: 16px;

      h2 {
        font-size: 28px;
        line-height: 31px
      }

      h3 {
        font-size: 24px;
        line-height: 29px
      }

      h4 {
        font-size: 20px;
        line-height: 25px
      }

      h5 {
        font-size: 16px;
        line-height: 21px
      }

      h6 {
        font-size: 14px;
        line-height: 19px
      }


      h2, h3, h4, h5, h6 {
        margin-top: 20px
      }

      iframe[src^="https://player.vimeo.com/video"],
      iframe[src^="https://www.youtube.com/embed"],
      video {
        height: 250px
      }

    }

  }


  &-footer {
    width: 100%;
  }

  &-tools {
    display: flex;
    flex-direction: column;

    .reading-mode-tool {
      margin: 5px;
      padding: 5px;
      cursor: pointer;

      i {
        height: auto;
        width: auto;
        font-size: 24px;
        color: #9D9E9F;
      }

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

      &:hover, &.active {
        i {
          color: #000;
        }
      }

    }

    @media (max-width: 767px) {
      justify-content: space-between;
      .reading-mode-tool {
        padding: 2.5px;
        margin: 2.5px;
      }
    }
  }

  .toc-box {
    padding: 0;
    list-style: none;

    li {
      margin-bottom: 15px;
      display: flex;
      align-items: center;

      a {
        color: #9D9E9F;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        font-size: .875rem;
        font-weight: normal;
        font-family: "Helvetica Neue", "Helvetica", "Arial", "sans-serif";
      }

      &:before {
        content: "\f139";
        font-family: Dashicons;
        color: #9D9E9F;
      }

      &:hover {

        &:before {
          color: #f06040;
        }

        a {
          color: #f06040;
        }
      }

    }
  }

  .reading-mode-toc {
    .toc-box {
      li {
        &.active {
          &:before {
            color: #f06040;
          }

          a {
            color: #f06040;
          }
        }
      }
    }

    &:empty {
      display: none;
    }

    margin-bottom: 30px;
  }

  .scroll-tooltip {
    padding: 10px !important;
    border-radius: 7px !important;

    @media (max-width: 767px) {
      bottom: 50px;
      width: 190px;
      right: 20px;
      left: auto !important;
      top: auto !important;

      &:before,
      &:after {
        left: auto !important;
        right: 60px;
      }
    }
  }

  .appearance-tooltip {
    padding: 15px !important;
    border-radius: 7px !important;

    .settings-field {
      display: flex;
      flex-direction: column;
      margin-bottom: 20px;

      .label {
        margin-bottom: 10px;
        font-size: 16px;
      }

      .theme-option-icon {
        width: 20px;
        height: 20px;
        background-color: #00a0d2;
        margin-right: 10px;

        &.icon-light {
          mask: url('../images/light.svg') no-repeat center/contain;
        }

        &.icon-dark {
          mask: url('../images/dark.svg') no-repeat center/contain;
        }

        &.icon-system {
          mask: url('../images/system.svg') no-repeat center/contain;
        }

      }

      .is-primary {

        .theme-option-icon {
          background-color: #fff;
        }
      }

      .components-button-group {
        button {

          &:first-child {
            border-top-left-radius: 5px;
            border-bottom-left-radius: 5px;
          }

          &:last-child {
            border-top-right-radius: 5px;
            border-bottom-right-radius: 5px;
          }

          &.is-primary {
            z-index: auto;
          }

        }
      }

      .reading-mode-select {
        &__option {
          font-size: 18px;
        }
      }

    }

    @media (max-width: 767px) {
      left: 20px !important;

      &:before,
      &:after {
        left: 50px !important;
      }

      .settings-field {
        &.field-content-width {
          display: none;
        }
      }

    }

  }

  .translate-tooltip {
    left: 50px !important;
  }

  /*---------- Width ----------*/
  &.width-large {
    .reading-mode-body {
      width: 1050px;
    }
  }

  &.width-medium {
    .reading-mode-body {
      width: 880px;
    }
  }

  &.width-small {
    .reading-mode-body {
      width: 750px;
    }
  }

}

.reading-mode-progress {
  --reading-mode-progress-color: #7C7EE5;
  --reading-mode-progress-height: 5px;

  position: fixed;
  height: var(--reading-mode-progress-height);
  z-index: 999999;
  top: 0;
  left: 0;
  width: 0;

  &.position-bottom {
    top: auto;
    bottom: 0;
  }

  .reading-mode-progress-fill {
    height: 100%;
    width: 100%;
    transition: width 100ms ease;
    background: var(--reading-mode-progress-color);
  }
}

/*---------- Theme Dark ----------*/
html[data-dracula-scheme="dark"] {
  .reading-mode {
    &-body {
      border: none !important;
    }
  }
}