/* ============================================================================
Base tags
============================================================================ */

a {
    text-decoration: none;
    color: var(--link-color);

    &.Link--external:after {
        content: " "
            url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAVklEQVR4Xn3PgQkAMQhDUXfqTu7kTtkpd5RA8AInfArtQ2iRXFWT2QedAfttj2FsPIOE1eCOlEuoWWjgzYaB/IkeGOrxXhqB+uA9Bfcm0lAZuh+YIeAD+cAqSz4kCMUAAAAASUVORK5CYII=);
    }

    &.Link--broken {
        color: red;
    }
}

p {
    margin: 0 0 1em;
}

hr {
    clear: both;
    margin: 1em 0;
    border: 0;
    border-top: 1px solid var(--hr-color);
}

/* ============================================================================
Components
============================================================================ */

.Button {
    display: inline-block;
    text-align: center;
    vertical-align: middle;
    touch-action: manipulation; // stylelint-disable-line plugin/no-unsupported-browser-features
    cursor: pointer;
    background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
    border: 1px solid transparent;
    white-space: nowrap;
    border-radius: 4px;
    margin-bottom: 0;

    &--small {
        font-size: 12px;
        line-height: 1.5;
        border-radius: 3px;
    }

    &--default {
        color: #333;
        background-color: #fff;
        border-color: #ccc;

        &.Button--active {
            color: #333;
            background-color: #e6e6e6;
            border-color: #adadad;
        }
    }
}

.Permalink {
    text-decoration: none !important;
    color: #333;
    float: left;
    font-size: 0.8em;
    margin-left: -0.7em;
    padding-right: 4px;
    visibility: hidden;

    h1:hover &,
    h2:hover &,
    h3:hover &,
    h4:hover &,
    h5:hover &,
    h6:hover & {
        visibility: visible;
    }
}

.Brand {
    display: block;
    color: var(--brand-color);
    background-color: var(--brand-background);
    padding: 0.75em 0.6em;
    font-size: var(--type-size-4);
    text-shadow: none;
    font-family: var(--font-family-heading);
    font-weight: 700;
}

.Navbar {
    height: 50px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.25);
    background-color: var(--homepage-navbar-background);
    margin-bottom: 0;

    .Brand {
        float: left;
        line-height: 20px;
        height: 50px;
    }
}

.CodeToggler {
    padding: 0 20px;
}

/* stylelint-disable-next-line selector-class-pattern */
.no-js .CodeToggler,
.CodeToggler--hidden {
    display: none;
}

.DarkModeToggler {
    padding: 0 20px;
}

// Hide the HR of the DarkModeToggler if the CodeToggler is present ...
.CodeToggler ~ .DarkModeToggler hr {
    display: none;
}

// ... except if it's hidden
.CodeToggler--hidden ~ .DarkModeToggler hr {
    display: block;
}

// Sidebar navigation
.Nav {
    margin: 0;
    padding: 0;

    &__arrow {
        display: inline-block;
        position: relative;
        width: 16px;
        margin-left: -16px;

        &:before {
            position: absolute;
            display: block;
            content: "";
            margin: -0.25em 0 0 -0.4em;
            left: 50%;
            top: 50%;
            width: 0.5em;
            height: 0.5em;
            border-right: 0.15em solid var(--sidebar-link-arrow-color);
            border-top: 0.15em solid var(--sidebar-link-arrow-color);
            transform: rotate(45deg);
            transition-duration: 0.3s;
        }
    }

    &__item {
        display: block;

        a {
            display: block;
            margin: 0;
            padding: 6px 15px 6px 20px;
            font-family: var(--font-family-heading);
            font-weight: 400;
            color: var(--sidebar-link-color);
            text-shadow: none;
        }

        a:hover {
            color: var(--sidebar-link-color);
            text-shadow: none;
            background-color: var(--sidebar-link-hover-background);
        }
    }
}

.Nav .Nav {
    margin-left: 15px;

    /* stylelint-disable-next-line selector-class-pattern */
    html:not(.no-js) & {
        height: 0;
        transition: height 400ms ease-in-out;
        overflow: hidden;
    }

    .Nav__item a {
        margin: 0;
        margin-left: -15px;
        padding: 3px 30px;
        font-family: var(--font-family-text);
        color: var(--sidebar-link-secondary-color);
        opacity: 0.7;

        &:hover {
            opacity: 1;
        }
    }

    .Nav__item--active a {
        color: var(--sidebar-link-color);
    }
}

.Nav__item {
    &--open,
    &--active {
        > a {
            background-color: var(--sidebar-link-active-background);
        }
    }

    &--open {
        > a > .Nav__arrow:before {
            margin-left: -0.25em;
            transform: rotate(135deg);
        }
    }
}

.Page__header {
    margin: 0 0 10px;
    padding: 0;
    border-bottom: 1px solid var(--page-header-separator-color);

    @include clearfix();

    h1 {
        margin: 0;
        padding: 0;
        line-height: 57px;
    }

    &--separator {
        height: 0.6em;
        fill: currentColor;
    }

    a {
        text-decoration: none;
    }

    .ModifiedDate {
        float: left;
        font-size: 10px;
        color: var(--page-header-details-color);
    }

    .EditOn {
        float: right;
        font-size: 10px;
        color: var(--page-header-details-color);
    }
}

.Links {
    padding: 0 20px;

    a {
        font-family: var(--font-family-heading);
        font-weight: 400;
        color: var(--sidebar-link-color);
        line-height: 2em;
    }
}

.Twitter {
    padding: 0 20px;
    font: normal normal normal 11px/18px "Helvetica Neue", Arial, sans-serif;

    &__button {
        text-decoration: none;

        display: inline-block;
        vertical-align: top;

        position: relative;
        height: 20px;
        box-sizing: border-box;
        padding: 1px 8px 1px 6px;
        background-color: #1b95e0;
        color: #fff;
        border-radius: 3px;
        font-weight: 500;
        cursor: pointer;

        .Twitter__button__label {
            display: inline-block;
            vertical-align: top;

            margin-left: 3px;
            white-space: nowrap;
        }

        svg {
            position: relative;
            top: 2px;
            display: inline-block;
            width: 14px;
            height: 14px;
        }
    }
}

.PoweredBy {
    padding: 0 20px 1rem 20px;
    font-size: var(--type-size-6);
}

.Search {
    position: relative;

    &__field {
        display: block;
        width: 100%;
        height: 34px;
        padding: 6px 30px 6px 20px;
        color: var(--search-field-color);
        border-width: 0 0 1px;
        border-bottom: 1px solid var(--search-field-border-color);
        background: var(--search-field-background);
        transition: border-color ease-in-out 0.15s;

        &:focus {
            border-color: var(--search-field-hover-border-color);
            outline: 0; // stylelint-disable-line plugin/no-unsupported-browser-features
        }
    }

    &__icon {
        position: absolute;
        right: 9px;
        top: 9px;
        width: 16px;
        height: 16px;
        cursor: pointer;
        fill: currentcolor;
    }
}

.Navbar .Search {
    float: right;
    margin: 8px 20px;

    &__field {
        box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
        border-width: 0;
        border-radius: 4px;
        padding-left: 10px;
    }
}

.TableOfContentsContainer {
    float: right;
    min-width: 300px;
    max-width: 25%;
    padding-left: 1em;

    &__title {
        margin-bottom: 0 !important;
    }

    &__content {
        border: 1px solid var(--toc--border-color);
        border-width: 4px 2px 2px 6px;
    }

    &__content > .TableOfContents > li + li {
        border-top: 1px solid var(--toc--inner-border-color);
    }
}

ul.TableOfContents {
    font-size: 1rem;
    padding-left: 0;
    margin: 0;
    list-style-type: none;

    p {
        margin-bottom: 0;
    }

    a {
        text-decoration: none;
        display: block;
        padding: 0.2em 0 0.2em 0.75em;
    }

    .TableOfContents {
        padding-left: 0.75em;
    }
}

.Pager {
    padding-left: 0;
    margin: 1em 0;
    list-style: none;
    text-align: center;
    clear: both;

    @include clearfix();

    li {
        display: inline;

        > a {
            display: inline-block;
            padding: 5px 14px;
            background-color: var(--pager-background-color);
            border: 1px solid var(--pager-border-color);
            border-radius: 15px;
            cursor: pointer;
        }

        > a:hover,
        > a:focus {
            text-decoration: none;
            background-color: var(--pager-hover-background-color);
        }
    }

    &--next > a {
        float: right;
    }

    &--prev > a {
        float: left;
    }
}

.Checkbox {
    position: relative;
    display: block;
    padding-left: 30px;
    cursor: pointer;

    input {
        position: absolute;
        z-index: -1;
        opacity: 0;
    }
}

.Checkbox__indicator {
    position: absolute;
    top: 50%;
    left: 0;
    width: 20px;
    height: 20px;
    margin-top: -10px;
    background: var(--checkbox-background);

    /* Check mark */
    &:after {
        position: absolute;
        display: none;
        content: "";
    }

    /* Hover and focus states */
    .Checkbox:hover input ~ &,
    .Checkbox input:focus ~ & {
        background: var(--checkbox-hover-background);
    }

    /* Checked state */
    .Checkbox input:checked ~ & {
        background: var(--checkbox-checked-background);

        /* Show check mark */
        &:after {
            display: block;
        }
    }

    /* Hover state whilst checked */
    .Checkbox:hover input:not([disabled]):checked ~ &,
    .Checkbox input:checked:focus ~ & {
        background: var(--checkbox-checked-hover-background);
    }

    /* Disabled state */
    .Checkbox input:disabled ~ & {
        pointer-events: none;
        opacity: 0.6;
        background: var(--checkbox-disabled-background);
    }

    /* Checkbox tick */
    .Checkbox &:after {
        top: 4px;
        left: 8px;
        width: 5px;
        height: 10px;
        transform: rotate(45deg);
        border: solid var(--checkbox-tick-color);
        border-width: 0 2px 2px 0;
    }

    /* Disabled tick colour */
    .Checkbox input:disabled ~ &:after {
        border-color: var(--checkbox-disabled-tick-color);
    }
}

.Admonition {
    border: 1px solid var(--admonition-border-color);
    background: var(--admonition-bg-color);
    box-shadow: var(--admonition-box-shadow);
    border-radius: var(--admonition-border-radius);
    display: flow-root;
    margin-bottom: 1.3em;
    padding: 0.6rem;
    page-break-inside: avoid;

    *:last-child {
        margin-bottom: 0;
    }
}

.Admonition__title {
    background-color: var(--admonition-title-bg-color);
    border-top-left-radius: var(--admonition-border-radius);
    border-top-right-radius: var(--admonition-border-radius);
    font-weight: bold;
    margin: -0.6rem -0.6rem 0.4rem -0.6rem !important;
    padding: 0.4rem 0.6rem;
    position: relative;
}

.Admonition--info {
    border-color: var(--admonition-info-border-color);
    background: var(--admonition-info-background);

    .Admonition__title {
        background: var(--admonition-info-title-background);
    }
}

.Admonition--warning {
    border-color: var(--admonition-warning-border-color);
    background: var(--admonition-warning-background);

    .Admonition__title {
        background: var(--admonition-warning-title-background);
    }
}

.Admonition--danger {
    border-color: var(--admonition-danger-border-color);
    background: var(--admonition-danger-background);

    .Admonition__title {
        background: var(--admonition-danger-title-background);
    }
}
