:root {
    --color-bg: #000;
    --color-fg: #222;
    --color-fg-secondary: #111;
    --color-text: #fff;
    --color-highlight: #0f0;
    --color-accent: #0f0;
    --color-accent-neutral: #aaa;
    --color-link: #0ff;
    --color-link-visited: #099;
    --color-link-hover: #0cc;
    --color-link-visited-hover: #066;
    font-family: Inconsolata, monospace;

    &:has(#page403) {
        animation: shadowblink403 1.2s ease-in-out infinite;
        animation-delay: 0.6s;
    }

    &:has(#retromode:checked) {
        --color-text: #0f0;
        --color-accent-neutral: #0a0;
        --color-accent: #f00;
        font-family: "IBM BIOS-2y", monospace;
    }

    /* --- retromode ON, languagemode OFF --- */
    &:has(#retromode:checked):not(:has(#languagemode:checked)) {
        [data-retro="0"] {
            display: none;
        }

        /* The following selector includes the case that data-lang is not set, e.g. elements that only have the data-retro attribute.
           But in the case that it IS set, it must be de */
        [data-retro="1"]:not([data-lang="en"]) {
            display: revert;
        }
    }

    /* --- retromode OFF, languagemode ON --- */
    &:not(:has(#retromode:checked)):has(#languagemode:checked) {
        [data-lang="de"] {
            display: none;
        }

        /* The following selector includes the case that data-retro is not set, e.g. elements that only have the data-lang attribute.
           But in the case that it IS set, it must be 0*/
        [data-lang="en"]:not([data-retro="1"]) {
            display: revert;
        }
    }

    /* --- both ON --- */
    &:has(#retromode:checked):has(#languagemode:checked) {
        [data-lang="de"],
        [data-retro="0"] {
            display: none;
        }

        /* The following selector includes the cases that one of the attributes might not be set.
           But in the case that it IS set, it must be 1 / en */
        [data-lang="en"]:not([data-retro="0"]),
        [data-retro="1"]:not([data-lang="de"]) {
            display: revert;
        }
    }
}

/* Default State: German, non-retro */
[data-lang="en"],
[data-retro="1"] {
    display: none;
}

body {
    margin: 0;
    height: 100dvh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    color: var(--color-text);

    &:has(#sidebar) {
        grid-template-columns: 1fr 5fr;
        grid-template-areas:
            "header header"
            "aside main"
            "footer footer";

        header {
            grid-area: header;
        }

        #sidebar {
            grid-area: aside;
        }

        main {
            grid-area: main;
        }

        footer {
            grid-area: footer;
        }
    }
}

h1 {
    font-size: 40px;
}

.text-glow {
    text-shadow:
        0 0 5px var(--color-highlight),
        0 0 100px var(--color-highlight);
}

.url-suffix {
    font-size: medium;
    vertical-align: sub;
}

a:not(.brand-container):not(.navitem) {
    &:link {
        color: var(--color-link);

        &:hover {
            color: var(--color-link-hover);
        }
    }

    &:visited {
        color: var(--color-link-visited);

        &:hover {
            color: var(--color-link-visited-hover);
        }
    }
}

::selection {
    background: var(--color-highlight);
    color: var(--color-bg);
    text-shadow: none;
}

.navitem {
    color: unset;
    text-decoration: none;
    user-select: none;
    transition: color 0.3s;

    &:hover {
        color: var(--color-accent-neutral);
    }

    img {
        margin-right: 0.25rem;
        width: 1em;
        height: 1em;
    }
}

#contact-list {
    display: none;
}

header {
    display: flex;
    align-items: center;
    padding: 1rem 3rem;
    background-color: var(--color-fg);
    box-shadow: 0 1px 8px var(--color-highlight);
    z-index: 100;

    .brand-container {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        color: unset;
        text-decoration: none;
        user-select: none;

        img {
            width: 64px;
            height: 64px;
        }

        h1 {
            margin: 0;
        }
    }

    nav {
        margin-left: auto;
        display: flex;
        gap: 1.5rem;
        font-weight: bold;

        a.current {
            pointer-events: none;
            position: relative;

            &::after {
                content: "";
                position: absolute;
                bottom: 0;
                left: 0;
                right: 0;
                height: 1px;
                background: var(--color-accent);
                box-shadow: 0 2px 4px var(--color-accent);
            }
        }
    }
}

#sidebar {
    padding: 1rem;
    text-align: center;
    background-color: var(--color-fg);
    box-shadow: 1px 0 8px var(--color-highlight);
    z-index: 50;
    overflow: auto;

    h2 {
        margin-top: 0;
    }

    nav {
        padding-left: 5%;
        margin-bottom: 0.5rem;

        a {
            display: flex;
            align-items: stretch;
            padding: 0.25rem 0.5rem;
            border-left: solid 2px var(--color-accent-neutral);
            transition: background-color 0.1s, color 0.1s;

            &:active {
                background-color: var(--color-accent);
                color: var(--color-bg);
            }
        }

        ul {
            padding: 0;
            margin: 0;
            text-align: left;
            list-style: none;

            & ul a::before {
                content: "\00a0\00a0\00a0";
            }

            & ul ul a::before {
                content: "\00a0\00a0\00a0\00a0\00a0\00a0";
            }
        }
    }
}

main {
    padding: 1rem 8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    font-size: large;
    background-color: var(--color-bg);
    z-index: 0;
    overflow: auto;
    scroll-behavior: smooth;
}

section {
    padding: 1rem 0;
    width: 100%;

    &:target h1:first-of-type {
        animation: targetflash-text 0.8s ease-in-out;
    }
}

footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    text-align: center;
    line-height: 1.8;
    background-color: var(--color-fg);
    box-shadow: 0 -1px 8px var(--color-highlight);
    z-index: 100;

    p {
        margin: 0;
    }

    strong {
        text-decoration: underline var(--color-accent);
    }

    #footer-buttons {
        display: flex;
        flex-direction: row;
        gap: 4rem;
        justify-content: center;
    }
}

/*****************\
|* Toggle Switch *|
\*****************/

.toggle-switch-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-switch {
    position: relative;
    width: 52px;
    height: 28px;
    margin: 0.5rem;
    background: #333;
    border: 1px solid #fff;
    border-radius: 999px; /* 999px instead of 50% because element is not circular */
    cursor: pointer;
    transition: all 0.3s;
    display: inline-block;

    input {
        visibility: hidden;
    }

    &::before {
        content: "";
        position: absolute;
        top: 3px;
        left: 3px;
        width: 22px;
        height: 22px;
        background: #666;
        border-radius: 50%;
        transition: all 0.3s ease;
    }

    &:has(input:checked) {
        background: #333;
        box-shadow: 0 0 6px #090 inset;

        &::before {
            left: 27px;
            background: #0c0;
            box-shadow: 0 0 4px #0c0;
        }
    }

    & ~ label {
        user-select: none;
        cursor: pointer;
    }
}

/**********\
|* Cards *|
\**********/

.card {
    margin: 2rem auto;
    padding: 1.5rem;
    max-width: 80%;
    box-sizing: border-box;
    background-color: var(--color-fg-secondary);
    border: 1px solid var(--color-accent-neutral);
    transition: border-color 0.3s ease;

    &:target {
        h2 {
            animation: targetflash 0.8s ease-in-out;
        }

        &:not(:has(h2)) {
            animation: targetflash-border 0.8s ease-in-out;
        }
    }

    h2 {
        display: flex;
        align-items: center;
        justify-content: center;
        margin: -1.5rem -1.5rem 1rem; /* negative margin of h2 to counteract padding of card(parent) */
        padding: 0.5rem 0;
        background-color: var(--color-fg);
        border-bottom: 1px solid var(--color-accent-neutral);
        font-size: 1.5rem;

        img {
            margin-right: 0.25rem;
            width: 1em;
            height: 1em;
        }
    }

    p {
        text-align: left;
        line-height: 1.6;
    }

    &:hover {
        border-color: var(--color-accent);
    }

    ol, ul {
        user-select: none;
        line-height: 1.75rem;
        text-align: left;
    }
}

/*************\
|* Accordion *|
\*************/

.accordion {
    position: relative;
    max-width: 80%;
    margin: 0 auto;
    z-index: 30;

    summary {
        position: relative;
        margin: -0.5em -0.5em 0; /* negative margin of summary counteracts the padding of the details(parent) */
        padding: 0.5em;
        font-weight: bold;
        background-color: var(--color-fg);
        cursor: pointer;
        user-select: none;
        z-index: 32;
        transition: box-shadow 0.2s ease;

        &:target {
            animation: targetflash 0.8s ease-in-out;
        }

        h2 {
            display: inline;
        }
    }

    details {
        position: relative;
        padding: 0.5em 0.5em 0;
        border: 1px solid var(--color-accent-neutral);
        border-bottom: none;
        background-color: var(--color-fg-secondary);
        transition: border-color 0.3s ease, border-top-color 0.3s ease;
        z-index: 31;

        &:last-child {
            border-bottom: 1px solid var(--color-accent-neutral);
        }

        &:hover {
            border-color: var(--color-accent);

            & + details {
                border-top-color: var(--color-accent);
            }
        }

        &[open] {
            padding: 0.5em;

            summary {
                margin-bottom: 0.5em;
                border-bottom: 1px solid var(--color-accent-neutral);

                &:hover {
                    /* https://stackoverflow.com/a/6245879 */
                    box-shadow: 0 4px 4px -4px var(--color-accent); /* spread = negative blur => shadow is only on bottom */
                }
            }

        }

        p {
            padding: 0 3rem;
            text-align: left;
        }

        .img-container {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
            width: 50%;
            height: auto;
            margin: 0.5rem auto;

            img {
                width: 100%;
                height: auto;
            }
        }
    }
}

/************\
|* Tooltips *|
\************/

[data-tooltip] {
    /* https://stackoverflow.com/a/77796790/15924630 */
    position: relative;
    text-decoration: underline dotted var(--color-accent);
    cursor: help;

    &:hover::after,
    &:hover::before {
        position: absolute;
        bottom: 100%;
        left: 50%;
        transform: translateX(-50%);
        pointer-events: none;
        z-index: 101;
    }

    /* Tooltip body */
    &:hover::after {
        content: attr(data-tooltip);
        width: max-content;
        max-width: 10rem;
        margin-bottom: 8px;
        padding: 0.5rem 0.75rem;
        background-color: var(--color-fg-secondary);
        border: 1px solid var(--color-accent);
        box-shadow: 0 2px 8px rgb(from var(--color-accent) r g b / 0.3);
        font-size: 0.9rem;
    }

    /* Small triangle */
    &:hover::before {
        content: "";
        bottom: 66%;
        margin-bottom: 2px;
        border: 6px solid transparent;
        border-top-color: var(--color-accent);
    }
}

/***************\
|* Extra Stuff *|
\***************/

code {
    padding: 2px 8px;
    color: var(--color-accent);
    background: #444;
    border-radius: 5px;
    user-select: text;
    transition: background 0.2s;

    &:hover {
        background: #333;
    }

    &.block {
        display: block;
        padding: 0.8rem;
        margin: 1rem auto;
        width: fit-content;
        overflow: auto;

        &::before {
            content: "> ";
            filter: brightness(50%);
            font-weight: bolder;
        }
    }
}

.construction {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    user-select: none;
    font-family: 'Comic Sans MS';

    .construction-sub {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 1rem;
    }
}

#page404 {
    display: flex;
    gap: 0;
    align-items: flex-start;
    padding: 0.5rem;
    text-align: left;
    color: #fff;

    ::selection {
        background: #fff;
        color: #000;
    }

    pre {
        margin: 0;
    }

    ul {
        display: flex;
        flex-direction: row;
        gap: 0 1rem;
        flex-wrap: wrap;
        padding: 0;
        margin: 0;
        list-style: none;

        li {
            width: fit-content;
            text-decoration: none;

            a, a:hover, a:visited {
                color: #fff;
                text-decoration: none;
            }
        }
    }

    .cli-input {
            display: none;
            flex: 1;
            width: 100%;
        }

    form {
        display: inline;
        flex: 1;

        input {
            width: 100%;
            padding: 0;
            background: transparent;
            border: none;
            color: #fff;
            font-family: inherit;
            font-size: inherit;
            outline: none;
        }

        label {
            display: inline-block;
            width: 100%;
            height: 100%;
            cursor: text;
        }
    }

    #full404, #small404, #cmd-full, #cmd-small {
        display: none;
    }

    #full404 {
        font-size: medium;
    }

    #small404 {
        font-size: x-small;
    }
}

#page403 {
    display: flex;
    align-items: flex-start;
    padding: 0.5rem;
    text-align: left;

    ::selection {
        background: #fff;
        color: #000;
    }

    a, a:hover, a:visited {
        color: #fff;
        text-decoration: none;
    }

    #popup403 {
        display: flex;
        flex-direction: column;
        align-items: center;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 20%;
        height: 30%;
        border: 3px solid #fff;
        background: #f00;
        box-shadow: 8px 8px #600;
        user-select: none;

        & > span {
            color: #000;
            font-weight: bold;
            font-size: 1.5rem;

            &:first-of-type {
                margin-top: 0.5rem;
            }

            &:last-of-type {
                margin-bottom: 0.5rem;
            }
        }

        #blink403 {
            margin: auto;
            padding: 2px 8px;
            font-size: 2rem;
            border: 2px solid #000;
            box-shadow: 4px 4px #600;
            animation: textblink403 1.2s ease-in-out infinite;
        }

        .marquee {
            display: flex;
            overflow: hidden;
            white-space: nowrap;
            width: 75%;
            background: #000;
            color: #f00;
            font-weight: bolder;
            font-size: 1.3rem;

            &:first-child {
                margin-top: 1.5rem;
            }

            &:last-child {
                margin-bottom: 1.5rem;
            }

            span {
                margin: 0;
                padding: 0.25rem 1rem;
                animation: marquee 2s linear infinite;
            }

            &[data-reverse] span {
                animation-direction: reverse;
            }
        }
    }
}

.sr-only {
    position:absolute;
    left:-10000px;
    top:auto;
    width:1px;
    height:1px;
    overflow:hidden;
}

@keyframes targetflash {
    50% {
        background-color: var(--color-accent);
        color: var(--color-bg);
    }
}

@keyframes targetflash-text {
    50% {
        color: var(--color-accent);
    }
}

@keyframes targetflash-border {
    50% {
        border-color: var(--color-accent);
    }
}

@keyframes shadowblink403 {
    50% {
        --color-highlight: #f00;
    }
}

@keyframes textblink403 {
    50% {
        opacity: 0;
    }
}

@keyframes marquee {
    0% {
        transform: translateX(0%);
    }
    100% {
        transform: translateX(-100%);
    }
}

@font-face {
    font-family: 'Inconsolata';
    src:
        local('Inconsolata'),
        url('/assets/fonts/Inconsolata-Regular.woff2') format('woff2'),
        url('/assets/fonts/Inconsolata-Regular.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IBM BIOS-2y';
    src: url('/assets/fonts/WebPlus_IBM_BIOS-2y.woff2') format('woff2'),
        url('/assets/fonts/WebPlus_IBM_BIOS-2y.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}