/*
    This file is part of m.css.

    Copyright © 2017, 2018, 2019, 2020 Vladimír Vondruš <mosra@centrum.cz>

    Permission is hereby granted, free of charge, to any person obtaining a
    copy of this software and associated documentation files (the "Software"),
    to deal in the Software without restriction, including without limitation
    the rights to use, copy, modify, merge, publish, distribute, sublicense,
    and/or sell copies of the Software, and to permit persons to whom the
    Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included
    in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
    THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    DEALINGS IN THE SOFTWARE.
*/

a.m-doc, a.m-doc-self, a.m-doc-external,
ul.m-doc li.m-doc-expansible > a:first-child, ul.m-doc li.m-doc-collapsible > a:first-child,
.m-doc-include > a {
  text-decoration: none;
}
ul.m-doc li.m-doc-expansible > a:first-child,
ul.m-doc li.m-doc-collapsible > a:first-child,
ul.m-doc li.m-doc-expansible > a:first-child:hover,
ul.m-doc li.m-doc-expansible > a:first-child:focus,
ul.m-doc li.m-doc-expansible > a:first-child:active,
ul.m-doc li.m-doc-collapsible > a:first-child:hover,
ul.m-doc li.m-doc-collapsible > a:first-child:focus,
ul.m-doc li.m-doc-collapsible > a:first-child:active {
  color: var(--color);
}
a.m-doc-self,
ul.m-doc li.m-doc-expansible > a:first-child:before,
ul.m-doc li.m-doc-collapsible > a:first-child:before {
  color: var(--link-self-color);
}
a.m-doc-self:hover, a.m-doc-self:focus, a.m-doc-self:active,
ul.m-doc li.m-doc-expansible > a:first-child:hover::before,
ul.m-doc li.m-doc-expansible > a:first-child:focus::before,
ul.m-doc li.m-doc-expansible > a:first-child:active::before,
ul.m-doc li.m-doc-collapsible > a:first-child:hover::before,
ul.m-doc li.m-doc-collapsible > a:first-child:focus::before,
ul.m-doc li.m-doc-collapsible > a:first-child:active::before {
  color: var(--link-self-active-color);
}
h3 a.m-doc-external {
  font-weight: normal;
}
span.m-doc-wrap-bumper {
  margin-right: -1rem;
  vertical-align: text-top;
}
span.m-doc-wrap {
  margin-left: 1rem;
  display: inline-block;
  vertical-align: text-top;
  white-space: pre-line;
  max-width: 100%; /* otherwise horizontal scrollbars, wtf */
}
span.m-doc-return {
   display: block;
}
span.m-doc-name {
   display: inline;
   font-size: 125%;
}
span.m-doc-arg {
   margin-left: 4rem;
   display: block;
}

/* Highlight the doc entries the same way as sections */
dl.m-doc dt {
   margin-bottom: 0.25rem;
}
dl.m-doc dd {
  margin-bottom: 1.0rem;
  margin-left: 0;
  padding-left: 2.5rem;
}
dl.m-doc dt:target, dl.m-doc dt:target + dd {
  margin-left: -1.0rem;
  border-left-style: solid;
  border-left-width: 0.25rem;
  border-color: var(--article-heading-color);
}
dl.m-doc dt:target { padding-left: 0.75rem; }
dl.m-doc dt:target + dd { padding-left: 3.25rem; }

ul.m-doc {
  list-style: none;
  margin-left:  1.0375rem;
  padding-left: 0.9rem;
  border-left-color: var(--line-color);
  border-left-width: 0.0625rem;
  border-left-style: solid;
}
ul.m-doc li {
  text-indent: 0;
  padding-left: 0.7rem;
  margin-bottom: 0.5rem;
}
ul.m-doc li.m-doc-expansible > ul {
  display: none;
}
ul.m-doc li.m-doc-expansible, ul.m-doc li.m-doc-collapsible {
  padding-left: 0.7rem;
  text-indent: -1rem;
}
ul.m-doc li.m-doc-expansible > ul.m-doc, ul.m-doc li.m-doc-collapsible > ul.m-doc {
  margin-top: 0.5rem;
  margin-left: 0.5rem;
}
ul.m-doc li.m-doc-expansible > a:first-child:before, ul.m-doc li.m-doc-collapsible > a:first-child:before {
  background-color: var(--background-color);
  display: inline-block;
  width: 1rem;
  font-weight: bold;
}
ul.m-doc li.m-doc-expansible > a:first-child:before { content: '⊕'; }
ul.m-doc li.m-doc-collapsible > a:first-child:before { content: '⊖'; }

h1 .m-doc-template, h1 .m-doc-include {
  font-size: 1.2rem;
  font-weight: normal;
}
/* If there's no template, the include is shown after in a slightly more packed
   layout */
h1 .m-doc-include:last-child {
  margin-bottom: -0.5rem;
}
.m-doc-details h3 {
   font-size: 1rem;
   font-weight: normal;
}
h3 .m-doc-template, h3 .m-doc-include {
  font-size: 0.9rem;
}
h3 .m-doc-name {
   font-size: 1.25rem;
}
.m-doc-template, dl.m-doc dd, ul.m-doc li > span.m-doc {
   font-size: 0.9rem;
}
.m-doc-template a, dl.m-doc dd a, ul.m-doc li > span.m-doc a {
  color: var(--dim-link-color);
}
.m-doc-template a:hover, .m-doc-template a:focus, .m-doc-template a:active,
dl.m-doc dd a:hover, dl.m-doc dd a:focus, dl.m-doc dd a:active,
ul.m-doc li > span.m-doc a:hover, ul.m-doc li > span.m-doc a:focus, ul.m-doc li > span.m-doc a:active {
  color: var(--dim-link-active-color);
}
h1 .m-doc-template, h1 .m-doc-include {
   color: var(--color);
}
h1 .m-doc-template a, h1 .m-doc-include a {
  color: var(--link-color);
}
h1 .m-doc-template a:hover, h1 .m-doc-include a:hover {
  color: var(--link-active-color);
}
h3 .m-doc-template, h3 .m-doc-include {
  color: var(--dim-filled-color);
}
h3 .m-doc-template a, h3 .m-doc-include a {
  color: var(--dim-filled-link-color);
}
h3 .m-doc-template a:hover, h3 .m-doc-include a:hover {
  color: var(--dim-filled-link-active-color);
}

article section.m-doc-details > div {
  margin-top: 0;
  margin-left: 0;
  margin-right: 0;
  position: relative;
  padding: 1rem;
}
article section.m-doc-details > div::before {
  position: absolute;
  content: ' ';
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: -1; /* so it doesn't make the contents inactive */
  border-style: solid;
  border-width: 0.125rem;
  border-radius: var(--border-radius);
  border-color: var(--background-color);
}
article section.m-doc-details > div > h3:first-child {
  position: relative; /* so it's above the border */
  margin: -1rem -1rem 1rem -1rem;
  padding: 0.5rem 1rem;
  color: var(--color);
  background-color: var(--code-header-background-color);
  border-radius: var(--border-radius);
}
article section.m-doc-details > div > h3:first-child a {
  color: var(--code-header-link-color);
}
article section.m-doc-details > div > h3:first-child a:hover,
article section.m-doc-details > div > h3:first-child a:focus,
article section.m-doc-details > div > h3:first-child a:active {
  color: var(--code-header-link-active-color);
}
article section.m-doc-details > div > h3:first-child a.m-doc-self {
  color: var(--code-header-self-color);
}
article section.m-doc-details > div > h3:first-child a.m-doc-self:hover,
article section.m-doc-details > div > h3:first-child a.m-doc-self:focus,
article section.m-doc-details > div > h3:first-child a.m-doc-self:active {
  color: var(--code-header-self-active-color);
}
article section.m-doc-details:target {
  border-color: transparent; /* to preserve rounded corners */
}
article section.m-doc-details:target > div {
  z-index: 1; /* so the selection border isn't above figure border */
}

.m-container-inflatable > .m-row > [class*='m-col-'] section.m-doc-details > div {
  margin-left: -1rem;
  margin-right: -1rem;
}

.m-container-inflatable section.m-doc-details:target > div > h3:first-child,
.m-container-inflatable section.m-doc-details:target section > div > h3:first-child {
  margin-left: -1.0rem;
  border-left-style: solid;
  border-left-color: var(--article-heading-active-color);
  border-left-width: 0.25rem;
  padding-left: 0.75rem;
}
.m-container-inflatable section.m-doc-details:target > div::before,
.m-container-inflatable section.m-doc-details:target section > div.m::before {
  border-left-width: 0.25rem;
  border-left-color: var(--article-heading-color);
}

a.m-doc-search-icon {
  padding-left: 1rem;
  padding-right: 1rem;
}
a.m-doc-search-icon svg {
  fill: var(--header-link-color);
}
body > header > nav #m-navbar-collapse a.m-doc-search-icon svg {
  vertical-align: -5%;
}
a.m-doc-search-icon:focus svg, a.m-doc-search-icon:hover svg, a.m-doc-search-icon:active svg {
  fill: var(--header-link-active-color);
}
.m-doc-search {
  display: none;
  z-index: 10;
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background-color: var(--search-overlay-color);
}
.m-doc-search:target {
  display: block;
}
.m-doc-search > a {
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}
.m-doc-search-header {
  background-color: var(--search-border-color);
  border-color: var(--search-border-color);
  border-width: 1px 1px 0;
  border-style: solid;
  border-top-left-radius: var(--border-radius);
  border-top-right-radius: var(--border-radius);
  margin-top: 2.5rem;
  padding: 0.5rem 1rem;
  height: 2rem;
}
.m-doc-search-header > div:first-child {
  float: right;
}
.m-doc-search-content {
  background-color: var(--search-background-color);
  border-color: var(--search-border-color);
  border-width: 0 1px 1px;
  border-style: solid;
  border-bottom-left-radius: var(--border-radius);
  border-bottom-right-radius: var(--border-radius);
  padding: 1rem;
}
.m-doc-search input {
  width: 100%;
  height: 3rem;
  font-size: 1.2rem;
  border-width: 0;
  color: var(--color);
  background-color: var(--default-filled-background-color);
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
  padding: 0 1rem; /* putting it on all sides cuts text off in FF */
}
.m-doc-search #search-notfound {
  display: none;
}
.m-doc-search ul#search-results {
  list-style-type: none;
  padding-left: 0;
  /* Size breakdown:
      2.5   margin of .m-doc-search-header from top
      2     height of .m-doc-search-header
      1     padding around .m-doc-search-header (twice 0.5rem)
      1     padding of .m-doc-search-content from top
      3     height of the input field
      1     margin under input
      1     padding of .m-doc-search-content from bottom
      1     margin under .m-doc-search-content
     ------
     12.5   total */
  max-height: calc(100vh - 12.5rem);
  overflow-y: auto;
  display: none;
}
.m-doc-search ul#search-results li a {
  display: block;
  padding-left: 1rem;
  padding-right: 1rem;
  text-decoration: none;
  width: 100%;
  line-height: 1.5rem;
  color: var(--color);
}
.m-doc-search ul#search-results li a > div {
  white-space: nowrap;
  overflow: hidden;
}
.m-doc-search ul#search-results li a > div:not(.m-doc-search-alias) {
  /* This is here in order to cut the text off at the left side. Besides this
     there's special patching needed for punctuation characters, see search.js
     for details. */
  direction: rtl;
}
.m-doc-search ul#search-results li a .m-label {
  float: right;
  line-height: 1rem;
  margin-top: 0.1rem;
  margin-left: 0.25rem;
}
.m-doc-search ul#search-results li a .m-label.m-flat {
  margin-right: -0.75rem;
}
.m-doc-search ul#search-results li#search-current a {
  background-color: var(--default-filled-background-color);
}
.m-doc-search ul#search-results li#search-current.m-doc-search-copied a {
  background-color: var(--success-filled-background-color);
}
.m-doc-search-typed {
  color: var(--link-color);
}

/* WELL THANK YOU WEBKIT! FOR SURE I WANTED ALL THAT SHIT HERE! */
.m-doc-search input[type="search"] { -webkit-appearance: textfield; }
.m-doc-search input[type="search"]::-webkit-search-decoration,
.m-doc-search input[type="search"]::-webkit-search-cancel-button,
.m-doc-search input[type="search"]::-webkit-search-results-button,
.m-doc-search input[type="search"]::-webkit-search-results-decoration {
  display: none;
}
