@import 'variables';

.col75 {
    width: 75%;
    flex: 0.75;
    float: left;
}
.col66 {
    width: 66.666666%;
    flex: 0.66666666;
    float: left;
}
.col60 {
    width: 60%;
    flex: 0.6;
    float: left;
}
.col50 {
    width: calc(50% - 10px);
    flex: 0.5;
    float: left;
}
.col40 {
    width: 40%;
    flex: 0.4;
    float: left;
}
.col33 {
    width: 33.333333%;
    flex: 0.3333333;
    float: left;
}
.col30 {
    width: 30%;
    flex: 0.3;
    float: left;
}
.col25 {
    width: 25%;
    flex: 0.25;
    float: left;
}
.col22 {
    width: 22.222222%;
    flex: 0.22222222;
    float: left;
}
.col16 {
    width: 16.666666%;
    flex: 0.16666666;
    float: left;
}
.col15 {
    width: 15%;
    flex: 0.15;
    float: left;
}
.col10 {
    width: 10%;
    flex: 0.1;
    float: left;
}
.col100-mobile {
    @include mobile {
        width: 100%;
        flex: 0 0 100%;
        float: none;

        hyphens: auto;
    }
}

.bg-black {
    background-color: color('black');
}
.color-black {
    color: color('black');
}
.bg-white {
    background-color: color('white');
}
.color-white {
    color: color('white');
}
@each $hue in map-keys($colors) {
    @each $shade in map-keys(map-get($colors, $hue)) {
        .bg-#{$hue}-#{$shade} {
            background-color: color($hue, $shade) !important;
        }
        .color-#{$hue}-#{$shade} {
            color: color($hue, $shade) !important;
        }
    }
}

.align-left {
    text-align: left !important;
}
.align-right {
    text-align: right !important;
}
.align-center {
    text-align: center !important;
}

.bold {
    font-weight: bold;
}
.italic {
    font-style: italic;
}

.clearfix {
    clear: both;
}
.after-absolute {
    width: 100%;
    position: relative;
    float: left;
}
.hidden,
[hidden] {
    display: none !important;
}
.mobile-only {
    @include desktop {
        display: none !important;
    }
}
.desktop-only {
    @include mobile {
        display: none !important;
    }
}

body {
    margin: 0;
    padding: 0;
    line-height: 1.6;
    font-size: $font-size;
    font-family: $body-font;
    color: $text-color;
    background-color: $bg-color;
}

.container {
    width: 80vw;
    max-width: $max-width;
    margin: auto;

    @include mobile {
        width: 90vw;
    }
}

h1,
h2,
h3,
h4,
h5,
h6 {
    line-height: 1.2;
    margin: 0;
    font-family: $heading-font;
    font-weight: $heading-weight;

    @include mobile {
        hyphens: auto;
    }
}
h1 {
    font-size: 1.7em;
}
h2 {
    font-size: 1.4em;
}

.sub-heading {
    h2 {
        display: inline-block;
        width: fit-content;
    }

    .heading-anchor-link {
        display: none;
        font-size: 1.4em;
    }

    &:hover,
    &:focus {
        .heading-anchor-link {
            display: inline-block;
        }
    }
}

.page {
    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        margin-top: 1em;
    }
}

a,
a:visited {
    color: $accent-color;
    text-decoration: none;
}
a:hover,
a:active,
a:focus {
    color: color('teal', 800);
}

main a {
    overflow-wrap: anywhere;

    &:not(.button):not(.no-link-decoration):not(.icon) {
        position: relative;
        text-decoration: none;
        @media (prefers-reduced-motion: no-preference) {
            transition: all ease 0.3s;
        }

        // Very loosely inspired by: https://codepen.io/aaroniker/pen/pojaBvb
        background-image: linear-gradient(0deg, $accent-color 0%, $accent-color 100%);
        background-position: bottom left;
        background-repeat: no-repeat;
        background-size: 100% 2px;

        #{$external-link-selector} {
            background-size: calc(100% - 16.8px) 2px;
            &:after {
                color: $accent-color;
                font-icon: 80% url('external.svg');
                padding-left: 4px;
                vertical-align: -0.5px;
            }
        }

        &:hover,
        &:focus {
            color: color('white');
            background-size: 100% 100%;
            #{$external-link-selector} {
                background-size: calc(100% - 16.8px) 100%;
            }
        }
    }
}

img {
    max-width: 100%;
    height: auto;
    &.image {
        display: block;
        margin: auto;
    }
}

table {
    border-collapse: collapse;
    border-spacing: 0;
    &.table {
        width: 100%;
        & thead th,
        & thead td,
        & tfoot th,
        & tfoot td,
        & tbody td {
            padding: 10px;
        }
    }

    tr.border-bottom {
        border-bottom: 2px solid color('blue', 700);
    }

    &#my-requests-table {
        th,
        td {
            &:nth-child(2),
            &:nth-child(4) {
                white-space: nowrap;
            }
        }
    }

    &.fancy-table {
        border: 4px solid $primary-color;
        border-collapse: collapse;

        thead {
            border-bottom: 4px solid $primary-color;
        }

        tr {
            background-color: $bg-accent-color;

            &:nth-child(even) {
                background-color: $bg-color;
            }
        }

        th,
        td {
            padding: 15px;
            text-align: center;
        }
    }
    &.fancy-table-mobile {
        @include mobile {
            thead {
                display: none;
            }

            tr,
            td {
                display: block;
                text-align: right;
            }

            td::before {
                content: attr(data-label);
                float: left;
                font-weight: bold;
            }
        }
    }

    &.narrow-table thead th,
    &.narrow-table tbody td {
        padding: 5px 5px 5px 0;
    }
}

pre {
    white-space: pre-wrap;
    overflow: auto;

    div.highlight > & {
        padding: 20px;
    }
}

.form-group {
    position: relative;
    margin-top: 10px;
    margin-bottom: 10px;

    &.form-row {
        display: flex;
        column-gap: 10px;
        row-gap: 10px;
        flex-wrap: wrap;
    }

    .form-group-label {
        display: flex;
        align-items: baseline;
        column-gap: 5px;
    }
}
.form-group-vertical {
    margin-top: 0;
}
select {
    appearance: menulist;
}

figcaption {
    font-size: 0.9em;
}
figure {
    margin: 0;

    & > * {
        display: block;
        margin: auto;
        text-align: center;
    }
}

blockquote {
    border-left: 7px solid color('blue', 200);
    margin-left: 0;
    padding-left: 20px;
}

.sr-only,
%sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
} /* With thanks to Bootstrap. */

%remove-sr-only {
    position: unset;
    width: unset;
    height: unset;
    padding: unset;
    overflow: unset;
    clip: unset;
    white-space: unset;
    border: unset;
} /* With thanks to Bootstrap. */

.fade-in,
%fade-in {
    animation: fadeIn 300ms ease forwards 1;

    @media screen and (prefers-reduced-motion: reduce) {
        animation: none;
    }
}
@keyframes fadeIn {
    0% {
        opacity: 0;
    }
}

.fade-out {
    animation: fadeOut 300ms ease backwards 1;

    @media screen and (prefers-reduced-motion: reduce) {
        animation: none;
    }
}
@keyframes fadeOut {
    100% {
        opacity: 0;
    }
}

ul {
    padding-left: 2em;

    &.unstyled-list {
        padding-left: 0;

        & > li {
            list-style: none;
        }
    }
}

.flex-spacer-mobile {
    display: none;
    @include mobile {
        display: block;
        width: 100%;
        flex-basis: 0;
        flex-grow: 1;
    }
}

.flex-spacer-desktop {
    display: none;
    @include desktop {
        display: block;
        width: 100%;
        flex-basis: 0;
        flex-grow: 1;
    }
}

.focus-anchor {
    outline: none;
}

// Distinguish consecutive footnotes.
.footnote summary {
    ::before {
        content: '[';
    }
    ::after {
        content: ']';
    }
}

.footnotes ol > li::marker {
    content: '[' counter(list-item) ']\2003';
}
