/*! Jazzy - https://github.com/realm/jazzy
 *  Copyright Realm Inc.
 *  SPDX-License-Identifier: MIT
 */
// ===========================================================================
//
//  Variables
//
// ===========================================================================

$body_background: #fff;
$body_font: 16px/1.7 'Helvetica Neue', Helvetica, Arial, sans-serif;
$text_color: #333;
$gray_border: 1px solid #ddd;

$heading_weight: 700;
$light_heading_color: #777;

$quote_color: #858585;
$quote_border: 4px solid #e5e5e5;

$link_color: #4183c4;

$table_alt_row_color: #fbfbfb;
$table_border_color: #ddd;

$code_bg_color: #f7f7f7;
$code_font: Consolas, "Liberation Mono", Menlo, Courier, monospace;


// ----- Layout

$gutter: 16px;
$navigation_max_width: 300px;


// ----- Header

$header_bg_color: #444;
$header_link_color: #fff;
$doc_coverage_color: #999;


// ----- Breadcrumbs

$breadcrumbs_bg_color: #fbfbfb;
$breadcrumbs_border_color: #ddd;


// ----- Navigation

$navigation_max_width: 300px;
$navigation_bg_color: #fbfbfb;
$navigation_border_color: #ddd;
$navigation_title_color: #333;
$navigation_task_color: #808080;

// ----- Content

$declaration_title_language_color: #4183c4;
$declaration_language_border: 5px solid #cde9f4;
$declaration_bg_color: #fff;
$declaration_border_color: #ddd;

$aside_color: #aaa;
$aside_border: 5px solid lighten($aside_color, 20%);
$aside_warning_color: #ff0000;
$aside_warning_border: 5px solid lighten($aside_warning_color, 20%);

// ----- Footer

$footer_bg_color: #444;
$footer_text_color: #ddd;
$footer_link_color: #fff;


// ===========================================================================
//
//  Base
//
// ===========================================================================

*, *:before, *:after {
  box-sizing: inherit;
}

body {
  margin: 0;
  background: $body_background;
  color: $text_color;
  font: $body_font;
  letter-spacing: .2px;
  -webkit-font-smoothing: antialiased;
  box-sizing: border-box;
}

// ----- Block elements

@mixin heading($font-size: 1rem, $margin: 1.275em 0 0.85em) {
  font-size: $font-size;
  font-weight: $heading_weight;
  margin: $margin;
}

h1 {
  @include heading(2rem, 1.275em 0 0.6em);
}

h2 {
  @include heading(1.75rem, 1.275em 0 0.3em);
}

h3 {
  @include heading(1.5rem, 1em 0 0.3em);
}

h4 {
  @include heading(1.25rem);
}

h5 {
  @include heading;
}

h6 {
  @include heading;
  color: $light_heading_color;
}

p {
  margin: 0 0 1em;
}

ul, ol {
  padding: 0 0 0 2em;
  margin: 0 0 0.85em;
}

blockquote {
  margin: 0 0 0.85em;
  padding: 0 15px;
  color: $quote_color;
  border-left: $quote_border;
}


// ----- Inline elements

img {
  max-width: 100%;
}

a {
  color: $link_color;
  text-decoration: none;

  &:hover, &:focus {
    outline: 0;
    text-decoration: underline;
  }

  &.discouraged {
    text-decoration: line-through;
    &:hover, &:focus {
      text-decoration: underline line-through;
    }
  }
}

// ----- Tables

table {
  background: $body_background;
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  overflow: auto;
  margin: 0 0 0.85em;
}

tr {
  &:nth-child(2n) {
    background-color: $table_alt_row_color;
  }
}

th, td {
  padding: 6px 13px;
  border: 1px solid $table_border_color;
}

hr {
  height: 1px;
  border: none;
  background-color: $table_border_color;
}

// ----- Code

pre {
  margin: 0 0 1.275em;
  padding: .85em 1em;
  overflow: auto;
  background: $code_bg_color;
  font-size: .85em;
  font-family: $code_font;
}

code {
  font-family: $code_font;
}

.item-container, .top-matter {
  p, li {
    > code {
      background: $code_bg_color;
      padding: .2em;
      &:before, &:after {
        letter-spacing: -.2em;
        content: "\00a0";
      }
    }
  }
}

pre code {
  padding: 0;
  white-space: pre;
}


// ===========================================================================
//
//  Layout
//
// ===========================================================================

.content-wrapper {
  display: flex;
  flex-direction: column;
  @media (min-width: 768px) {
    flex-direction: row;
  }
}


// ===========================================================================
//
//  Header
//
// ===========================================================================

.header {
  display: flex;
  padding: $gutter/2;
  font-size: 0.875em;
  background: $header_bg_color;
  color: $doc_coverage_color;
}

.header-col {
  margin: 0;
  padding: 0 $gutter/2
}

.header-col--primary {
  flex: 1;
}

.header-link {
  color: $header_link_color;
}

.header-icon {
  padding-right: 2px;
  vertical-align: -3px;
  height: 16px;
}



// ===========================================================================
//
//  Breadcrumbs
//
// ===========================================================================

.breadcrumbs {
  font-size: 0.875em;
  padding: $gutter / 2 $gutter;
  margin: 0;
  background: $breadcrumbs_bg_color;
  border-bottom: 1px solid $breadcrumbs_border_color;
}

.carat {
  height: 10px;
  margin: 0 5px;
}


// ===========================================================================
//
//  Navigation
//
// ===========================================================================

.navigation {
  order: 2;

  @media (min-width: 768px) {
    order: 1;
    width: 25%;
    max-width: $navigation_max_width;
    padding-bottom: $gutter*4;
    overflow: hidden;
    word-wrap: normal;
    background: $navigation_bg_color;
    border-right: 1px solid $navigation_border_color;
  }
}

.nav-groups {
  list-style-type: none;
  padding-left: 0;
}

.nav-group-name {
  border-bottom: 1px solid $navigation_border_color;
  padding: $gutter/2 0 $gutter/2 $gutter;
}

.nav-group-name-link {
  color: $navigation_title_color;
}

.nav-group-tasks {
  margin: $gutter/2 0;
  padding: 0 0 0 $gutter/2;
}

.nav-group-task {
  font-size: 1em;
  list-style-type: none;
  white-space: nowrap;
}

.nav-group-task-link {
  color: $navigation_task_color;
}

// ===========================================================================
//
//  Content
//
// ===========================================================================

.main-content {
  order: 1;
  @media (min-width: 768px) {
    order: 2;
    flex: 1;
    padding-bottom: 60px;
  }
}

.section {
  padding: 0 $gutter * 2;
  border-bottom: 1px solid $navigation_border_color;
}

.section-content {
  max-width: 834px;
  margin: 0 auto;
  padding: $gutter 0;
}

.section-name {
  color: #666;
  display: block;

  p {
    margin-bottom: inherit;
  }
}

.declaration .highlight {
  overflow-x: initial; // This allows the scrollbar to show up inside declarations
  padding: $gutter/2 0;
  margin: 0;
  background-color: transparent;
  border: none;
}

.task-group-section {
  border-top: $gray_border;
}

.task-group {
  padding-top: 0px;
}

.task-name-container {
  a[name] {
    &:before {
      content: "";
      display: block;
    }
  }
}

.section-name-container {
  position: relative;

  .section-name-link {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    margin-bottom: 0;
  }

  .section-name {
    position: relative;
    pointer-events: none;
    z-index: 1;
    a {
      pointer-events: auto;
    }
  }
}

.item-container {
  padding: 0;
}

.item {
  padding-top: 8px;
  width: 100%;
  list-style-type: none;

  a[name] {
    &:before {
      content: "";
      display: block;
    }
  }

  .token, .direct-link {
    display: inline-block;
    text-indent: -20px;
    padding-left: 3px;
    margin-left: 20px;
    font-size: 1rem;
  }

  .declaration-note {
    font-size: .85em;
    color: #808080;
    font-style: italic;
  }
}

.pointer-container {
  border-bottom: $gray_border;
  left: -23px;
  padding-bottom: 13px;
  position: relative;
  width: 110%;
}

.pointer {
  left: 21px;
  top: 7px;
  display: block;
  position: absolute;
  width: 12px;
  height: 12px;
  border-left: 1px solid $declaration_border_color;
  border-top: 1px solid $declaration_border_color;
  background: $declaration_bg_color;
  transform: rotate(45deg);
}

.height-container {
  display: none;
  position: relative;
  width: 100%;
  overflow: hidden;
  .section {
    background: $declaration_bg_color;
    border: $gray_border;
    border-top-width: 0;
    padding-top: 10px;
    padding-bottom: 5px;
    padding: $gutter / 2 $gutter;
  }
}

.aside, .language {
  padding: 6px 12px;
  margin: 12px 0;
  border-left: $aside_border;
  overflow-y: hidden;
  .aside-title {
    font-size: 9px;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding-bottom: 0;
    margin: 0;
    color: $aside_color;
    -webkit-user-select: none;
  }
  p:last-child {
    margin-bottom: 0;
  }
}

.language {
  border-left: $declaration_language_border;
  .aside-title {
    color: $declaration_title_language_color;
  }
}

.aside-warning, .aside-deprecated, .aside-unavailable {
  border-left: $aside_warning_border;
  .aside-title {
    color: $aside_warning_color;
  }
}

.graybox {
  border-collapse: collapse;
  width: 100%;
  p {
    margin: 0;
    word-break: break-word;
    min-width: 50px;
  }
  td {
    border: $gray_border;
    padding: 5px 25px 5px 10px;
    vertical-align: middle;
  }
  tr td:first-of-type {
    text-align: right;
    padding: 7px;
    vertical-align: top;
    word-break: normal;
    width: 40px;
  }
}

.slightly-smaller {
  font-size: 0.9em;
}


// ===========================================================================
//
//  Footer
//
// ===========================================================================

.footer {
  padding: $gutter/2 $gutter;
  background: $footer_bg_color;
  color: $footer_text_color;
  font-size: 0.8em;

  p {
    margin: $gutter/2 0;
  }

  a {
    color: $footer_link_color;
  }
}


// ===========================================================================
//
//  Dash
//
// ===========================================================================

html.dash {

  .header, .breadcrumbs, .navigation {
    display: none;
  }

  .height-container {
    display: block;
  }
}

// ===========================================================================
//
//  Search
//
// ===========================================================================
form[role=search] {
  input {
    font: $body_font;
    font-size: 14px;
    line-height: 24px;
    padding: 0 10px;
    margin: 0;
    border: none;
    border-radius: 1em;
    .loading & {
      background: white url(../img/spinner.gif) center right 4px no-repeat;
    }
  }

  // Typeahead elements

  .tt-menu {
    margin: 0;
    min-width: 300px;
    background: $navigation_bg_color;
    color: $text_color;
    border: 1px solid $navigation_border_color;
  }

  .tt-highlight {
    font-weight: bold;
  }

  .tt-suggestion {
    font: $body_font;
    padding: 0 $gutter/2;
    span {
      display: table-cell;
      white-space: nowrap;
    }
    .doc-parent-name {
      width: 100%;
      text-align: right;
      font-weight: normal;
      font-size: 0.9em;
      padding-left: $gutter;
    }
  }

  .tt-suggestion:hover,
  .tt-suggestion.tt-cursor {
    cursor: pointer;
    background-color: $link_color;
    color: #fff;
  }

  .tt-suggestion:hover .doc-parent-name,
  .tt-suggestion.tt-cursor .doc-parent-name {
    color: #fff;
  }
}
