@charset "utf-8";

// Define defaults for each variable.

$black: black;
$accent: #999;
$accent-dark: #222;

$string: #b93b5a;
$keyword: purple;

$sidebar-width: 12rem;
$docs-options-inset: 6rem;

$wide-enough-for-side-nav: 1200px;
$narrow: 800px;

$serif: T, Times, Times New Roman, serif;
$mono: 'Input Mono', 'Source Code Pro', Menlo, Consolas, Monaco, monospace;
$system: system-ui, sans-serif;

* {
  margin: 0;
  padding: 0;
  font: inherit;
  box-sizing: border-box;
  text-indent: 0;
}

html {
  font-family: $serif;
  font-size: max(19px, min(calc(13px + 0.4 * 4vw), 26px));
  font-size: clamp(19px, calc(13px + 0.4 * 4vw), 26px);
  line-height: 1.5;
  letter-spacing: 0.007em;
  font-weight: 300;
}

html.times {
  font-family: serif;
  font-size: clamp(22px, calc(15px + 0.4 * 4vw), 28px);
  line-height: 1.33;
  letter-spacing: -0.02em;
}

body {
  -webkit-text-size-adjust: 100%;
  -webkit-font-feature-settings: 'kern' 1;
  -moz-font-feature-settings: 'kern' 1;
  -o-font-feature-settings: 'kern' 1;
  font-feature-settings: 'kern' 1;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

strong {
  font-weight: 600;
}
em {
  font-style: italic;
}

.sc {
  text-transform: uppercase;
  font-size: 0.95em;
}

.home-btns {
  margin: 1.5rem 0;
}

.btn,
.post-content .btn {
  font: 0.6rem/1.4 $system;
  display: inline-block;
  padding: 0.3rem 0.6rem;
  border-radius: 0.2rem;
  border: 1px solid currentColor;
  font-weight: 400;
  margin-right: 0.5rem;
  transition: all 0.2s;
  transform: translate3d(0, 0, 0);
  box-shadow: 0 0 0 currentColor;

  &:hover {
    color: black;
    opacity: 1;
    background: white;
    box-shadow: -3px 3px 0 currentColor;
    transform: translate3d(3px, -3px, 0);
  }
  &:active {
    background: #eee;
    box-shadow: 0 0 0 currentColor;
    transform: translate3d(0, 0, 0);
  }
}
.btn-link {
  font: 0.6rem/1.4 $system;
}
.make-book {
  position: absolute;
  top: -0.7rem;
  right: 0;
}

p + p {
  text-indent: 1.5em;
}

a {
  color: inherit;
  // color: blue;
  text-decoration: none;
  &:active {
    opacity: 0.4;
  }
}

li {
  margin-left: 1.2rem;
  padding-left: 0.3rem;
}

.post-content a:not(.btn-img):not(.btn) {
  // color: $accent;
  text-shadow: 2px 0 0 white, -2px 0 0 white, 0 2px 0 white;
  background-image: linear-gradient(
    to bottom,
    currentColor 50%,
    rgba(0, 0, 0, 0) 50%
  );
  background-repeat: repeat-x;
  background-size: 2px 1px;
  background-position: 0 1.22em;
  &:hover {
    color: $accent;
    background-image: linear-gradient(
      to bottom,
      $accent 50%,
      rgba(0, 0, 0, 0) 50%
    );
  }
}
.times .post-content a {
  background-position: 0 1.05em;
}

.page-content,
.site-footer {
  margin: 0 5%;
}

.short-title {
  display: none;
}

.page-content {
  margin: 0 5%;
}

.post-content {
  max-width: 35rem;
  margin: 1.5rem auto 0;
}

.site-header {
  position: relative;
  margin: 0 5%;
  margin-top: 1.5rem;
  margin-top: max(1rem, min(4vw, 2rem));
  margin-top: clamp(1rem, 4vw, 2rem);
}

.site-footer {
  padding-top: 1rem;
  padding-bottom: 4rem;
}

.nav-item {
  display: inline-block;
  position: relative;
  margin-right: 1rem;

  &:last-child {
    margin-right: 0;
  }

  &.nav-active a {
    // color: $accent;

    &::before {
      content: '';
      background: currentColor;
      position: absolute;
      width: 4px;
      height: 4px;
      left: 0;
      right: 0;
      margin: auto;
      top: 100%;
      border-radius: 50%;
    }
  }
}

.scroll-back {
  display: none;
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  transform: scale(0.7);
  .docs-scrolled & {
    transform: translate3d(0, 0, 0);
    opacity: 1;
    pointer-events: all;
  }
  a {
    font-family: $system;
    font-size: 1rem;
    text-align: center;
    display: inline-block;
    line-height: 1.5rem;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    // box-shadow: inset 0 0 0 0.8px black;
    &:hover {
      opacity: 0.5;
      color: $accent;
    }
  }
}

.credit {
  font: 0.6rem / 1.5 $system;
  margin-top: 0.2rem;
}

.docs-nav {
  display: flex;
  flex-flow: wrap;
  font-weight: 400;
  background: white;
  z-index: 99;
  margin-bottom: 1.5rem;
  a {
    position: relative;
    background: transparent !important;
    &:hover {
      opacity: 1;
    }
  }
  .selected {
    opacity: 1;
    &::before {
      content: '';
      background: currentColor;
      position: absolute;
      width: 4px;
      height: 4px;
      left: -0.7rem;
      top: 0.4rem;
      margin: auto;
      border-radius: 50%;
    }
  }
}

.docs-content p + ul {
  margin-top: 1.5rem;
}

.docs-content ul {
  list-style: none;
  padding: 0;
  margin-bottom: 1.5rem;
}

.grid {
  display: flex;
  flex-wrap: wrap;
  position: relative;
}
.grid figure {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #f4f4f4;
  width: 100%;
  padding-bottom: 80%;
  flex-shrink: 0;
  margin-right: 1.5rem;
  margin-bottom: 0.5rem;
}

.grid li {
  display: block;
  width: 100%;
  margin: 0;
  margin-bottom: 1rem;
  text-indent: 0;
}

.grid li {
  display: flex;
  flex-direction: row;
}

.grid figure {
  width: 5.2rem;
  height: 4rem;
  padding-bottom: 0;
}

.docs-content ul li {
  margin: 0 0 1rem 1.5rem;
  position: relative;
}

.docs-content li li {
  margin: 0;
  text-indent: 0;
  code:first-child {
    color: $string;
    display: inline-block;
    margin-right: 0.5em;
  }
}

.docs-content > ul > li:not(.📖-continuation) > code:first-child {
  // color: #008080;
  font-weight: 500;
  position: relative;
  left: -1.5rem;
  display: block;
  line-height: 1.5rem;
}

.docs-content > ul > li {
  margin: 0 0 1rem $docs-options-inset;
  text-indent: 0;
}
.docs-content > ul > li:not(.📖-continuation) > code:first-child {
  position: absolute;
  left: -$docs-options-inset;
}

.docs-nav-group {
  margin-bottom: 0.5rem;
  width: 9rem;
  max-width: 50%;
  padding-top: 0.5rem;
  padding-right: 1rem;
  font-size: 0.7rem;
  background: white;
  z-index: 99;
}

.docs-nav-subitem {
  font-style: italic;
}

.logo {
  height: 1.6667rem;
  width: 1.6667rem;
  background-image: url(logo40.svg);
  background-position: center;
  background-size: cover;
  vertical-align: middle;
  margin-right: 1.8rem;
  display: inline-block;
}

.btn-logo {
  display: block;
}

.site-title {
  font-weight: 400;
  max-width: 35rem;
  margin: auto;
  display: flex;
  position: relative;
}

.site-nav {
  display: flex;
  width: 100%;
}

.site-nav-right {
  position: absolute;
  top: 0;
  right: 0;
  .btn {
    white-space: nowrap;
    display: block;
    margin-bottom: 4px;
  }
}

.nav-item a {
  &:hover {
    color: $accent;
    opacity: 1;
  }
}
.btn-logo {
  &:hover {
    opacity: 0.5;
  }
  &:active {
    opacity: 0.3;
  }
}

img {
  max-width: 100%;
  vertical-align: middle;
}

figure > img {
  display: block;
}

h1 {
  font-size: 3rem;
  line-height: 1.15em;
  margin: 1rem -0.1rem;
  max-width: 32rem;
}

h2 {
  margin: 4rem 0 1.5rem;
  font-size: 1.5rem;
}

body {
  counter-reset: docs 0;
}

.docs-content h2 {
  position: relative;
}
.docs-nav + h2 {
  margin-top: 0;
}

.docs-content h3 {
  font-style: italic;
  position: relative;
}

h3 {
  font-style: italic;
  margin: 3rem 0 1.5rem;

  &:first-child {
    margin-top: 1.5rem;
  }
}

h1 + h3 {
  margin-top: 1.5rem;
}

h4 {
  font-style: italic;
}

h5 {
  padding-top: 1.5rem;
  font-weight: 600;
}

blockquote {
  font-style: italic;
}

/**
 * Code formatting
 */
pre,
code {
  line-height: 1.2rem;
  font-family: $mono;
  letter-spacing: -0.015em;
  font-size: 0.7rem;
}

p code,
li code {
  font-size: 0.8rem;
}

@media (max-width: $narrow) {
  .site-title {
    align-items: start;
    flex-direction: column;
  }
  .site-nav {
    margin-top: 0.75rem;
  }
  .post-content {
    margin-top: 0;
  }
  .grid figure {
    width: 4.2rem;
    height: 3.5rem;
    margin-right: 1.2em;
    margin-top: 0.3rem;
  }
  div pre.highlight {
    border-radius: 0;
    padding: 1em 5%;
    box-shadow: none;
    margin: 0.5rem -5%;
  }
}

@mixin sideBySide {
  width: calc(50% - 6px);
  display: inline-block;
  vertical-align: top;
  pre {
    width: 100%;
  }
  &:last-child pre {
    box-shadow: none;
  }
}

@media (min-width: $narrow) {
  .code-compare {
    display: flex;
    flex-flow: wrap;
    > .highlighter-rouge {
      flex-grow: 1;
    }
    > .highlighter-rouge:first-child {
      margin-right: 0.2rem;
    }
  }
}

@media (max-width: $wide-enough-for-side-nav) {
  .page-content {
    margin-top: 1rem;
  }
  .short-title {
    display: block;
  }
  .long-title {
    display: none;
  }
  .docs-nav-subitem {
    padding-top: 0;
    a {
      display: inline;
    }
  }
}

@media (min-width: $wide-enough-for-side-nav) {
  .docs-content {
    position: relative;
    padding-left: 240px;
    max-width: 40rem;
  }
  .docs-nav {
    position: sticky;
    padding-left: 40px;
    margin-left: -300px;
    top: 0;
    bottom: 0;
    width: 280px;
    overflow: scroll;
    height: 100vh;
    margin-bottom: -100vh;
    flex-flow: column;
    h1 {
      margin-top: 1.2rem;
    }
    a {
      opacity: 0.4;
    }
  }
  .docs-nav-group {
    width: auto;
    max-width: unset;
  }

  .logo {
    position: absolute;
    left: -3.6rem;
  }
  .docs-toc-btn {
    display: none;
  }
  .docs-toc-scrim {
    display: none;
  }
  .scroll-back {
    display: block;
  }

  .docs-nav h2 {
    padding-bottom: 3rem;
  }

  .docs-content h2::before {
    position: absolute;
    left: -3rem;
    top: 0.55rem;
  }
}

.highlight {
  height: 100%;
}

.highlight pre,
pre.highlight {
  padding: 1rem 1.5rem;
  background: #f8f8f8;
  border-radius: 8px;
  margin: 1.5rem 0;
}

.code-compare {
  margin: 1.5rem 0;
  .highlight {
    margin-top: 0;
    margin-bottom: 0;
  }
  div.highlighter-rouge {
    margin-top: 0;
    margin-bottom: 0;
  }
}

div.highlighter-rouge {
  margin: 1.5rem 0;
}

.highlight pre code {
  font-size: 0.7rem;
  line-height: 1.3;
}

pre {
  overflow-x: auto;

  > code {
    border: 0;
    padding-right: 0;
    padding-left: 0;
  }
}

html.book {
  font-size: 12pt;
  word-wrap: break-word;
}

.book {
  h1 {
    margin-top: 0;
    margin-bottom: 2.4rem;
  }
  h2 {
    margin: 2.4rem 0;
  }
  h2:first-child {
    margin-top: 0;
  }
  .cover-subtitle {
    font: 0.7rem/1.3 $mono;
    letter-spacing: -0.015em;
    display: block;
    margin-top: 3rem;
  }
  #cover {
    text-align: center;
    line-height: 0.98;
    font-size: 4.5rem;
    top: 0;
    left: calc(-1 * var(--bindery-bleed));
    right: 0;
    bottom: 0;
    position: absolute;
    height: 30rem;
    margin: auto;
  }
  .logo {
    display: block;
    margin: auto;
    margin-bottom: 1rem;
    position: relative;
    left: unset;
    width: 40px;
    height: 40px;
  }
  h1 {
    display: none;
  }
  .h1-page {
    display: block;
    text-align: center;
    font-size: 4.5rem;
    line-height: 6in;
  }
  h3 {
    &:first-child {
      margin-top: 0;
    }
  }

  .code-compare {
    display: flex;
  }

  .📖-running-header,
  .📖-footer {
    font: 0.6rem / 1.5 $mono;
  }
  .site-header {
    position: relative;
  }
  .toc {
    margin-top: 8rem;
    font-size: 2rem;
    line-height: 1.2;
    .toc-num {
      width: 4rem;
      text-align: right;
      margin-right: 1rem;
      display: inline-block;
    }
  }
  pre.highlight {
    box-shadow: none;
    white-space: pre-wrap;
    width: 100%;
    padding: 0;
    margin: 1.5rem 0;
    margin-top: 0;
    background: none;
  }
  .highlighter-rouge:first-child {
    margin-top: 0;
  }
  .highlighter-rouge {
    margin-top: 1.5rem;
  }
  .highlighter-rouge:first-child .highlight {
    // margin-top: 0;
  }
  .post-content .btn {
    border: 0;
    padding: 0;
    font-size: 0.8rem;
    /*display: none;*/
  }
  .docs-content,
  .post-content {
    margin: 0;
    padding: 0;
  }
  .docs-content li li {
    code:first-child {
      display: block;
    }
  }
  .grid figure {
    width: 8rem;
    height: 6rem;
    padding: 0;
  }
  .grid a {
    flex-direction: row;
  }
}

sup {
  font: 0.6rem/1.3 $mono;
}

.footnote {
  font: 0.7rem/1.3 $mono;
  letter-spacing: -0.015em;
}

// Import partials.
@import 'syntax-highlighting';
