/* Global rules */
@property --highlight-color {
    syntax: "<color>";
    initial-value: #72EBF6;
    inherits: true;
}

:root {
    --note-color: #959494;
    --text-color: #2d2d2d;
    --background-color: #f2f2f2;
    --separator-color: #ddd;
    --highlight-dark: #2996CE;
    --highlight-light: #72EBF6;
    --selector-color: #324ff1;
    --hover-color: #e3e3e3;
}

@media (prefers-color-scheme: dark) {
    :root {
        --text-color: #f2f2f2;
        --separator-color: #444;
        --background-color: #2d2d2d;
        --selector-color: #01ffc8;
        --hover-color: #3c3c3c;
    }
}

body {
    font-family: sans-serif;
    color: var(--text-color);
    cursor: default;
}

:focus {
    border-radius: 1px;
    outline-style: solid;
    outline-width: 4px;
    animation: highlight 1s linear infinite;
    outline-color: var(--highlight-color);
}

.inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

/* Generic elements */
body, dialog {
    margin: auto;
    max-width: 50rem;
    background-color: var(--background-color);
}

a {
    color: inherit;
}

small {
    display: block;
    color: var(--note-color);
}

button {
    border: none;
    font-size: inherit;
    font-family: inherit;
    color: inherit;
    background: none;
}

button:not(:disabled) {
    cursor: pointer;
}

button:disabled * {
    color: gray !important;
}

button:not([disabled]):hover {
    background-color: var(--hover-color);
}

dialog:focus {
    outline: none;
}

.spinner {
    display: inline-block;
    font-size: 0.2em;
    width: 1em;
    height: 1em;
    margin: 2.5em;
    border-radius: 50%;
    animation: spinner 1s infinite ease;
}

progress {
    flex-grow: 1;
    height: 0.5rem;
    overflow: hidden;
    border-radius: 1rem;
}

progress::-webkit-progress-bar {
    background-color: var(--separator-color);
}

progress::-webkit-progress-value {
    background-color: var(--selector-color);
}

/* Page rules */
#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    margin: 0;
    border-bottom: solid 1px var(--text-color);
    padding: 0.8rem 2.5rem;
    font-weight: normal;
    font-size: 1.8rem;
}

main {
    flex-grow: 1;

    ul {
        font-size: 1.3rem;
        margin: 2.5rem 30rem;
        list-style-type: none;
        margin-inline: auto;
        padding-inline: 5rem;
    }

    li {
        border-top: solid;
        border-color: var(--separator-color);
        border-width: 1px;

        & > * {
            padding: 1rem;
            width: 100%;
        }

        & > small {
            padding-top: 0.5rem;
        }
    }

    button .value {
        color: var(--selector-color);
        position: relative;
    }
}

footer {
    display: flex;
    text-align: center;
    border-top: solid 1px var(--text-color);
    justify-content: flex-end;
    padding: 0.8rem 2.5rem;
    gap: 2rem;

    #notify {
        margin-right: auto;
    }
}

dialog {
    --dialog-margin: 0.5rem;
    border: none;
    padding: 2rem 5rem;
    font-size: 1.3rem;
    border-radius: 4px;
    width: 40vw;
    max-width: 35rem;
    text-align: center;
    color: inherit;

    & > *:first-child {
        margin-top: var(--dialog-margin);
    }

    & > *:last-child {
        margin-bottom: var(--dialog-margin);
    }

    &::backdrop {
        background-color: rgba(10, 21, 34, 0.75);
    }
}

[popover] {
    margin: 0;
    padding: 1rem;
    color: white;
    border: none;
    background-color: rgba(20, 20, 20, 0.75);
    box-shadow: 0em 0em 1em 0em rgba(128, 128, 128, 0.1);
}

#progress {
    #progress-label {
        white-space: nowrap;
        position: relative;
        text-align: left;
        width: 5ch;
    }

    #progress-label::after {
        content: attr(data-note);
        position: absolute;
        direction: rtl;
        bottom: -1em;
        left: -1em;
        width: 0;
    }
}

/* Animations */
@keyframes highlight {
    0% {
        --highlight-color: var(--highlight-light);
    }

    50% {
        --highlight-color: var(--highlight-dark);
    }

    100% {
        --highlight-color: var(--highlight-light);
    }
}

/* Based on https://cssloaders.github.io/ */
@keyframes spinner {

    0%,
    100% {
        box-shadow: 0em -2.5em 0em 0em rgb(from var(--text-color) r g b / 1.0), 1.8em -1.8em 0 0em rgb(from var(--text-color) r g b / 0.2), 2.5em 0em 0 0em rgb(from var(--text-color) r g b / 0.2), 1.8em 1.8em 0 0em rgb(from var(--text-color) r g b / 0.2), 0em 2.5em 0 0em rgb(from var(--text-color) r g b / 0.2), -1.8em 1.8em 0 0em rgb(from var(--text-color) r g b / 0.2), -2.5em 0em 0 0em rgb(from var(--text-color) r g b / 0.5), -1.8em -1.8em 0 0em rgb(from var(--text-color) r g b / 0.7);
    }

    12.5% {
        box-shadow: 0em -2.5em 0em 0em rgb(from var(--text-color) r g b / 0.7), 1.8em -1.8em 0 0em rgb(from var(--text-color) r g b / 1.0), 2.5em 0em 0 0em rgb(from var(--text-color) r g b / 0.2), 1.8em 1.8em 0 0em rgb(from var(--text-color) r g b / 0.2), 0em 2.5em 0 0em rgb(from var(--text-color) r g b / 0.2), -1.8em 1.8em 0 0em rgb(from var(--text-color) r g b / 0.2), -2.5em 0em 0 0em rgb(from var(--text-color) r g b / 0.2), -1.8em -1.8em 0 0em rgb(from var(--text-color) r g b / 0.5);
    }

    25% {
        box-shadow: 0em -2.5em 0em 0em rgb(from var(--text-color) r g b / 0.5), 1.8em -1.8em 0 0em rgb(from var(--text-color) r g b / 0.7), 2.5em 0em 0 0em rgb(from var(--text-color) r g b / 1.0), 1.8em 1.8em 0 0em rgb(from var(--text-color) r g b / 0.2), 0em 2.5em 0 0em rgb(from var(--text-color) r g b / 0.2), -1.8em 1.8em 0 0em rgb(from var(--text-color) r g b / 0.2), -2.5em 0em 0 0em rgb(from var(--text-color) r g b / 0.2), -1.8em -1.8em 0 0em rgb(from var(--text-color) r g b / 0.2);
    }

    37.5% {
        box-shadow: 0em -2.5em 0em 0em rgb(from var(--text-color) r g b / 0.2), 1.8em -1.8em 0 0em rgb(from var(--text-color) r g b / 0.5), 2.5em 0em 0 0em rgb(from var(--text-color) r g b / 0.7), 1.8em 1.8em 0 0em rgb(from var(--text-color) r g b / 1.0), 0em 2.5em 0 0em rgb(from var(--text-color) r g b / 0.2), -1.8em 1.8em 0 0em rgb(from var(--text-color) r g b / 0.2), -2.5em 0em 0 0em rgb(from var(--text-color) r g b / 0.2), -1.8em -1.8em 0 0em rgb(from var(--text-color) r g b / 0.2);
    }

    50% {
        box-shadow: 0em -2.5em 0em 0em rgb(from var(--text-color) r g b / 0.2), 1.8em -1.8em 0 0em rgb(from var(--text-color) r g b / 0.2), 2.5em 0em 0 0em rgb(from var(--text-color) r g b / 0.5), 1.8em 1.8em 0 0em rgb(from var(--text-color) r g b / 0.7), 0em 2.5em 0 0em rgb(from var(--text-color) r g b / 1.0), -1.8em 1.8em 0 0em rgb(from var(--text-color) r g b / 0.2), -2.5em 0em 0 0em rgb(from var(--text-color) r g b / 0.2), -1.8em -1.8em 0 0em rgb(from var(--text-color) r g b / 0.2);
    }

    62.5% {
        box-shadow: 0em -2.5em 0em 0em rgb(from var(--text-color) r g b / 0.2), 1.8em -1.8em 0 0em rgb(from var(--text-color) r g b / 0.2), 2.5em 0em 0 0em rgb(from var(--text-color) r g b / 0.2), 1.8em 1.8em 0 0em rgb(from var(--text-color) r g b / 0.5), 0em 2.5em 0 0em rgb(from var(--text-color) r g b / 0.7), -1.8em 1.8em 0 0em rgb(from var(--text-color) r g b / 1.0), -2.5em 0em 0 0em rgb(from var(--text-color) r g b / 0.2), -1.8em -1.8em 0 0em rgb(from var(--text-color) r g b / 0.2);
    }

    75% {
        box-shadow: 0em -2.5em 0em 0em rgb(from var(--text-color) r g b / 0.2), 1.8em -1.8em 0 0em rgb(from var(--text-color) r g b / 0.2), 2.5em 0em 0 0em rgb(from var(--text-color) r g b / 0.2), 1.8em 1.8em 0 0em rgb(from var(--text-color) r g b / 0.2), 0em 2.5em 0 0em rgb(from var(--text-color) r g b / 0.5), -1.8em 1.8em 0 0em rgb(from var(--text-color) r g b / 0.7), -2.5em 0em 0 0em rgb(from var(--text-color) r g b / 1.0), -1.8em -1.8em 0 0em rgb(from var(--text-color) r g b / 0.2);
    }

    87.5% {
        box-shadow: 0em -2.5em 0em 0em rgb(from var(--text-color) r g b / 0.2), 1.8em -1.8em 0 0em rgb(from var(--text-color) r g b / 0.2), 2.5em 0em 0 0em rgb(from var(--text-color) r g b / 0.2), 1.8em 1.8em 0 0em rgb(from var(--text-color) r g b / 0.2), 0em 2.5em 0 0em rgb(from var(--text-color) r g b / 0.2), -1.8em 1.8em 0 0em rgb(from var(--text-color) r g b / 0.5), -2.5em 0em 0 0em rgb(from var(--text-color) r g b / 0.7), -1.8em -1.8em 0 0em rgb(from var(--text-color) r g b / 1.0);
    }
}