@import '../vars';

.blog-write-link-wrap {
  margin-bottom: $base-padding;
}
.blog-write-table {
  table-layout: fixed;
  border-collapse: collapse;
  border: 0;
  width: 100%;

  > tbody > tr > td {
    text-align: left;
    vertical-align: top;
  }
  > tbody > tr > td:first-child {
    padding-right: 8px;
    width: 45%;
  }
  > tbody > tr > td:last-child {
    padding-left: 8px;
  }
}

.blog-write-form {
  .form-field-input {
    width: 100%;
  }
  textarea.form-field-input {
    height: 400px;
    font-family: $ffMono;
    font-size: 12px;
  }
  textarea.form-field-input.nowrap {
    white-space: pre;
    overflow-wrap: normal;
  }
}
.blog-write-options-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;

  td {
    padding-top: 12px;
  }
  td:nth-child(1) {
    width: 40%;
  }
  td:nth-child(2),
  td:nth-child(3) {
    width: 30%;
    padding-left: 10px;
  }
  tr:first-child td {
    padding-top: 0;
  }
  button[type="submit"] {
    margin-left: 3px;
  }
}

.blog-write-form-toggle-link {
  margin-top: 3px;
  display: inline-block;
}

.blog-upload-form {
  margin-top: $base-padding;
  padding-top: $base-padding;
  padding-bottom: $base-padding;
  background-color: $hover-hl;
  @include radius(4px);

  input[type="text"] {
    background-color: $bg;
  }
}

.blog-upload-list {
  padding-top: $base-padding;
}
.blog-upload-item {
  border-top: 1px $border-color solid;
  padding: 10px 0;
  &:first-child {
    border-top: 0;
  }
}
.blog-upload-item-actions {
  float: right;
}
.blog-upload-item-name {
  font-weight: bold;
  margin-bottom: 2px;
  > a {
    @include no-underline(true);
  }
}
.blog-upload-item-info {
  color: $grey;
  font-size: $fs - 2px;
}
.blog-upload-item-note {
  padding: 8px 0 0;
  > span {
    background-color: $hover-hl;
    padding: 1px 5px;
    color: $dark-grey;
    margin-right: 6px;
  }
}
.blog-upload-item-md {
  margin-top: 3px;
}

.blog-post-wrap2 {
  display: table;
  table-layout: fixed;
  border: none;
  border-collapse: collapse;
	width: 100%;
}
.blog-post-wrap1 {
  display: table-row;
}
.blog-post {
  display: table-cell;
  vertical-align: top;
}
.blog-write-form-preview .blog-post {
  display: block;
}
.blog-post-toc {
  display: table-cell;
  vertical-align: top;
  font-size: $fs - 2px;

  &-wrap {
    position: sticky;
    top: 0;
    padding: 10px 0 0 20px;
    overflow-y: auto;
    max-height: 100vh;
    box-sizing: border-box;
  }

  &-inner-wrap {
    border-left: 1px $border-color solid;
    padding-left: 20px;
    margin-bottom: 10px;

    ul {
      list-style-type: none;
      margin: 5px 0;
      padding-left: 18px;
    }
    > ul {
      padding-left: 0 !important;
    }

    li {
      margin: 2px 0;
      line-height: 140%;
      > a {
        display: inline-block;
      }
    }
  }

  &-title {
    font-weight: bold;
    padding: 6px 0;
  }
}
body.wide .blog-post {
  width: $base_width;
}

@media screen and (max-width: 1150px) {
  .blog-post-toc {
    display: none;
  }
  .blog-post {
    width: auto !important;
  }
  .blog-post-wrap2 {
    width: 100%;
  }
}

.blog-post-title {
  margin: 0 0 16px;
}
.blog-post-title h1 {
  font-size: 22px;
  font-weight: bold;
  padding: 0;
  margin: 5px 0 0 0;
}

.blog-post-date {
  color: $grey;
  margin-top: 5px;
  font-size: $fs - 1px;
  //> a {
  //  margin-left: 5px;
  //}
}

.blog-post-text {}
.blog-post-text {
  li {
    margin: 13px 0;
  }

  p, center {
    margin-top: 20px;
    margin-bottom: 20px;
  }
  p a {
    word-wrap: break-word;
    //hyphens: auto;
    //word-break: break-all;
  }
  p:first-child, center:first-child {
    margin-top: 0;
  }
  p:last-child, center:last-child {
    margin-bottom: 0;
  }

  pre {
    background-color: $code-block-bg;
    font-family: $ffMono;
    //font-size: $fsMono;
    overflow: auto;
    @include radius(3px);
  }

  code {
    background-color: $inline-code-block-bg;
    font-family: $ffMono;
    font-size: $fsMono;
    padding: 3px 5px;
    @include radius(3px);
  }

  pre code {
    display: block;
    padding: 12px;
    line-height: 145%;
    background-color: $code-block-bg;

    span.term-prompt {
      color: $light-grey;
      @include user-select(none);
    }
  }

  blockquote {
    border-left: 2px $quote_line solid;
    margin-left: 0;
    margin-right: 10px;
    padding: 5px 0 5px 12px;
    color: $quote_color;
    font-style: italic;
    &:first-child {
      padding-top: 0;
      margin-top: 0;
    }
  }

  table {
    border-collapse: collapse;
    border: 1px $border-color solid;
  }
  table thead td {
    font-weight: bold;
  }
  table td, table th {
    padding: 7px;
    border: 1px $border-color solid;
  }
  table th {
    padding-right: 12px;
  }

  table.table-100 {
    border-collapse: collapse;
    border: 0;
    margin: 0;
    width: 100%;
    table-layout: fixed;
  }
  table.table-100 td {
    padding: 0;
    border: 0;
    vertical-align: top;
    text-align: left;
    padding: 0 4px;
  }
  table.table-100 td:first-child {
    padding-left: 0;
  }
  table.table-100 td:last-child {
    padding-right: 0;
  }
  td > pre:first-child {
    margin-top: 0;
  }
  td > pre:last-child {
    margin-bottom: 0;
  }

  h1 {
    margin: 35px 0 16px;
    font-weight: 600;
    font-size: 22px;
    border-bottom: 1px $border-color solid;
    padding-bottom: 6px;
  }

  h2 {
    margin: 35px 0 16px;
    font-weight: 500;
    font-size: 22px;
    border-bottom: 1px $border-color solid;
    padding-bottom: 6px;
  }

  h3 {
    margin: 27px 0 16px;
    font-size: 20px;
    font-weight: 500;
  }

  h4 {
    font-size: 18px;
    margin: 24px 0 16px;
  }

  h5 {
    font-size: 15px;
    margin: 24px 0 16px;
  }

  h6 {
    font-size: 13px;
    margin: 24px 0 16px;
    color: #666;
  }

  h3:first-child,
  h4:first-child,
  h5:first-child,
  h6:first-child {
    margin-top: 0;
  }
  h1:first-child,
  h2:first-child {
    margin-top: 5px;
  }

  hr {
    height: 1px;
    border: 0;
    background: $border-color;
    margin: 17px 0;
  }
}
.blog-post-comments {
  margin-top: $base-padding;
  padding: 12px 15px;
  border: 1px $border-color solid;
  @include radius(3px);
}
.blog-post-comments img {
  vertical-align: middle;
  position: relative;
  top: -1px;
  margin-left: 2px;
}

.index-blog-block {
  margin-top: 23px;
}

.blog-expl {
  line-height: 130%;
  margin-bottom: 15px;
  margin-top: 2px;
  font-size: $fs - 2px;
  p {
    margin: 7px 0;
    line-height: 140%;
    &:first-child {
      margin-top: 0;
    }
    &:last-child {
      margin-top: 0;
    }
  }
}

.blog-list {}
.blog-item-right-links {
  font-size: 16px;
  float: right;
  > a {
    margin-left: 2px;
  }
}
.blog-links-separator {
  color: $grey;
}


.blog-list {
  &-wrap {
    padding: 5px 0;
  }

  &-item {
    @include no-underline();
    display: block;
    padding: 6px 8px;
    margin-left: -8px;
    margin-right: -8px;
    font-size: $fs;
    //line-height: 140%;

    &:not(.no-block):hover {
      text-decoration: none;
      background-color: $hover-hl;
      @include radius(3px);
    }

    &-date {
      color: $grey;
      float: left;
    }
    &-title {
      margin-left: 70px;
      text-align: left;
    }
    &.is-hidden &-title {
      color: $fg;
    }
    &.is-hidden &-title > a {
      color: $fg;
      border-bottom-color: desaturate($link-color-underline, 100%);
      &:hover {
        border-bottom-color: desaturate($link-color-underline-hover, 100%);
      }
    }
  }
}
.blog-list-expand {
  display: block;
  @include no-underline();
  padding: 10px 8px;
  font-size: $fs;
  background-color: $hover-hl;
  text-align: center;
  @include radius(3px);
  margin-top: 10px;

  > svg {
    position: relative;
    top: 4px;
    margin-left: -6px;
    margin-right: -4px;
    margin-top: -5px;
    color: $light-grey;
    opacity: 0.7;
  }

  &:hover {
    text-decoration: none;
    background-color: $hover-hl-darker;
    @include radius(3px);
  }
}

.blog-list-title {
  font-size: $fs + 2px;
  padding-top: 14px;
  margin-bottom: 8px;
  &:first-child { padding-top: 0; }
}

.blog-quote {
  position: relative;
  //padding: $base-padding;
  background: $hover-hl;
  border-left: 2px $hover-hl-darker2 solid;
  border-radius: 2px;
  margin: $base-padding 0;
  font-size: $fs - 2px;

  &-begin, &-end {
    position: relative;
    background-color: $hover-hl-darker2;
    font-weight: 600;
    padding: 7px $base-padding;
  }
  &-begin-simple {
    height: 14px;
    position: relative;
  }

  &-begin:before,
  &-begin-simple:before,
  &-end:after,
  &-end-simple:after {
    display: block;
    width: 15px;
    height: 12px;
    position: absolute;
    content: '';
  }
  &-begin {
    text-align: left;
    padding-left: 37px;
  }
  &-begin:before, &-begin-simple:before {
    background: url(/img/ic_q_open.svg) center center no-repeat;
    background-size: 15px 12px;
    left: 13px;
    top: 8px;
  }
  &-end {
    padding-right: 37px;
    text-align: right;
  }

  &-end:after, &-end-simple:after {
    background: url(/img/ic_q_close.svg) center center no-repeat;
    background-size: 15px 12px;
    right: 13px;
    bottom: 9px;
  }

  &-content {
    padding: $base-padding;

    > blockquote:last-child {
      margin-bottom: 0;
    }
  }
}

span.blog-footnote-ref, a.blog-ref {
  display: inline-block;
  color: $blog-ref-color;
  font-family: "Liberation Mono", monospace;
  font-size: $fs - 2px;
  letter-spacing: -0.5px;
  font-style: normal !important;
}

a.blog-ref {
  @include no-underline();
  padding: 0 1px;
  margin-left: -2px;
}
.blog-quote-begin a.blog-ref, .blog-quote-end a.blog-ref {
  color: $blog-ref-color-over-quote;
}

@media (hover: hover) {
  a.blog-ref:hover {
    color: $blog-ref-color-hover;
    background-color: $blog-ref-bg-hover;
    border-radius: 3px;
  }
  .blog-quote-begin a.blog-ref:hover, .blog-quote-end a.blog-ref:hover {
    color: $blog-ref-color-hover-over-quote;
    background-color: $blog-ref-bg-hover-over-quote;
  }
}

p.blog-footnote-line:target {
  background-color: $blog-ref-bg-hover;
  border-radius: 3px;
  a {
    @include no-underline(true);
  }
}
