$text: #ddd;
$bg: #540362;
$link: #f778e3;
$lowerbg1: darken($bg, 5);
$lowerbg2: darken($bg, 10);
$higherbg1: lighten($bg, 10);
$lower1: darken($text, 18);
$lower2: darken($text, 30);

@import 'fonts';

@mixin reset-list {
    li {
        display: inline-block;
    }
    margin: 0;
    padding: 0;
}

@mixin flex-center {
    display: flex;
    align-content: center;
    justify-content: center;
}

@mixin chonky-link-underline($elType: "a", $thickness: 2px) {
    #{$elType} {
        border-bottom: solid $thickness;
        padding-bottom: 0px;
        border-radius: 1px;
    }
}

@mixin a-normal($class: "") {
    a#{$class} {
        color: $text;
        text-decoration: none;
    }
}

@mixin box {
    padding: 1em;
    margin: .5em 0;
    border-radius: .3em;
    background-color: $lowerbg1;
}

pre {
    @include box;
    overflow: auto;

    code {
        font-family: Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;
    }
}

html {
    font-size: 18px;
}

body {
    font-family: 'Source Sans 3', 'sans-serif';
    background-color: $bg;
    color: $text;
    line-height: 1.35;

    margin: {
        left: 0.75rem;
        right: 0.75rem;
    }
}

a {
    color: $link;
    text-decoration: none;
}

// navigation between pages at the end of articles
nav.article-nav {
    margin-top: 5rem;
    margin-bottom: 2rem;

    .disabled-link {
        color: $lower2;
        cursor: default;
    }

    .nav-label {
        color: $lower1;
        font-size: 1rem;
        user-select: none;
    }

    .older {
        text-align: right;
    }

    // force there to be some space between the nav directions
    ul li {
        max-width: 40vw;
    }

    ul {
        @include reset-list();
        @include chonky-link-underline($thickness: 1px);
        @include chonky-link-underline($elType: ".disabled-link", $thickness: 1px);
        @include a-normal();
        display: flex;
        justify-content: space-between;
        font-size: 1.4rem;
        font-weight: 400;
    }
}

// navigation at the top of the page
nav.main-nav {
    @include flex-center;

    ul {
        @include reset-list();
        @include chonky-link-underline();
        @include a-normal();
        font-size: 1.4rem;
        font-weight: 700;

        li {
            margin: {
                left: -2px;
                right: 2rem;
                bottom: .25rem;
            }
        }
    }

    margin: {
        bottom: 2rem;
        top: 2rem;
    }
}

header.page-header {
    margin: {
        bottom: 1em;
    }
}

main {
    // the details below individual page titles on the home page
    .detail span {
        font-weight: 600;
        font-size: 0.8rem;
        color: $lower1;
    }

    .detail {
        margin-top: 0.3rem;
    }

    display: block;
    margin: 0 auto;
    max-width: 860px;

    .detail.page-detail span {
        font-size: 1rem;
    }

    .detail span:first-child::after {
        content: " - ";
    }
}

article.homepage-article {
    @include a-normal($class: ".homepage-link");
}

footer {
    @include flex-center;
    p {
        margin: 0 1em;
    }
}

// stuff on pages

:not(pre) > code {
    // add background with rounded corners
    background: $lowerbg1;
    padding: 0.05rem;
    border-radius: 0.3rem;

    // wrap words instead of causing scrolling
    word-wrap: break-word;
}

code {
    font-size: 0.9em;
}

summary {
    margin-left: 2em;
    font-weight: 800;
    font-size: 1.1em;
}

details {
    margin-top: 2em;
    margin-bottom: 2em;
}

img, video {
    // make the alt text extremely obnoxious and harder to miss if the image
    // is missing
    font-size: 3rem;
    color: #0f0;

    // stop images from overflowing
    width: 100%;
}

div.image {
    display: flex;
    align-content: center;
    justify-content: center;

    img {
        border-radius: .3rem;
    }
}

blockquote {
    border-left: solid $higherbg1;
    border-left-width: 0.5rem;
    padding-left: 1rem;
    margin-left: 1.5rem;
}

hr {
    margin: {
        top: 3rem;
        bottom: 3rem;
    }
}

// h1 at the top of blog post pages
:not(header) > h1 {
    margin: {
        top: 2.5rem;
    }
}

h1 {
    margin: {
        bottom: -0.3rem;
    }
}

h2, h3 {
    margin: {
        top: 1.5rem;
        bottom: -0.5rem;
    }
}

h2 {
    font-size: 1.7em;
}

h3 {
    font-size: 1.3em;
}

h4 {
    font-size: 1.1em;
    margin: {
        top: 2rem;
        bottom: -0.5rem;
    }
}

:not(nav) > ul > li {
    margin-bottom: 0.5rem;
}

kbd {
    display:inline-block;
    border: 1px solid $lowerbg2;
    background-color: $lowerbg1;
    border-radius: 5px;
    margin-right: 0.2rem;
    padding: 2px;
    box-shadow: 0px 2px 3px $lowerbg2;
}

/* asides. god help me */
aside {
    @include box;
}

/* headings */

h1 {
    line-height: 1.10;
}

