/* Variables */

:root {
    --color-text: #111;
    --color-text-dim: #777;
    --color-error: #db344b;

    --color-brand-blue: #40b1f4;

    --color-panel-border: rgba(0, 0, 0, 20%);
    --color-panel-background: #fff;
    --color-shaded-background: rgba(0, 0, 0, 5%);
    --color-active-background: rgba(0, 0, 0, 10%);

    --dialog-backdrop: rgba(255, 255, 255, 0.5);

    --font-body: "Atkinson Hyperlegible", sans-serif;
    --font-monospace: "Iosevka Hyperlegible", monospace;
    --line-height: 1.5;
    --line-height-em: 1.5em;
}

/* Reset */

body {
    margin: 0;
    color: var(--color-text);
    line-height: var(--line-height);
}

* {
    box-sizing: border-box;
}

/* Fonts */

:root {
    font-family: var(--font-body);
}

button,
textarea,
input {
    font-size: inherit;
    font-family: inherit;
}

pre,
code,
textarea {
    font-family: var(--font-monospace);
    line-height: var(--line-height);
}

/* Buttons */

button {
    color: var(--color-text);

    border: 1px solid var(--color-panel-border);
    border-radius: 9999px;
    padding: 0.5rem 1.5rem;
    background: none;

    &:hover:not(:disabled) {
        background-color: var(--color-shaded-background);
    }

    &:active:not(:disabled) {
        background-color: var(--color-active-background);
    }

    &:disabled {
        opacity: 50%;
    }
}

button.destructive {
    color: var(--color-error);
}

button.icon {
    border: none;
    border-radius: 0;
    padding: 0;
    width: 24px;
    height: 24px;
}

/* Text areas */

input {
    border: none;
    border-bottom: 1px solid var(--color-panel-border);
}

*:focus-visible {
    outline: 1px solid var(--color-brand-blue);
    outline-offset: 4px;
}

/* Modal dialogs */

dialog:not([open]) {
    /* Weird this doesn't seem to work by default. */
    display: none;
}

dialog::backdrop {
    background-color: var(--dialog-backdrop);
    backdrop-filter: blur(8px);
}

/* Details */

details > summary {
    cursor: pointer;
}

/* Throbbers */

@keyframes rkgk-throbber-loading {
    0% {
        clip-path: inset(0% 100% 0% 0%);
        animation-timing-function: cubic-bezier(0.12, 0, 0.39, 0);
    }

    50% {
        clip-path: inset(0% 0% 0% 0%);
        animation-timing-function: cubic-bezier(0.61, 1, 0.88, 1);
    }

    100% {
        clip-path: inset(0% 0% 0% 100%);
    }
}

rkgk-throbber {
    display: inline;

    &.loading {
        display: block;
        width: 16px;
        height: 16px;
        background-color: var(--color-brand-blue);
        animation: infinite alternate rkgk-throbber-loading;
        /* I wonder how many people will get _that_ reference. */
        animation-duration: calc(60s / 141.98);
    }

    &.error {
        /* This could use an icon. */
        color: var(--color-error);
    }
}

/* Panels */

.rkgk-panel {
    --panel-border-radius: 8px;

    display: block;
    background: var(--color-panel-background);
    border: none;
    border-radius: var(--panel-border-radius);
    box-shadow: 0 0 0 1px var(--color-panel-border);
    /* 4px 4px 0 0 var(--color-panel-border); */
    box-sizing: border-box;
}

/* Horizontal separators */

hr {
    border: none;
    border-bottom: 1px solid var(--color-panel-border);
}

/* Lists */

ul,
ol {
    padding-left: 20px;
}

/* Code examples */

pre:has(code) {
    background-color: var(--color-shaded-background);
    border-radius: 8px;
    padding: 1em 1em;
    overflow: auto;
}

/* Abbreviations */

abbr {
    cursor: help;
}

/* Icons */

:root {
    --icon-brackets: url("data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjE2IiB2aWV3Qm94PSIwIDAgMTYgMTYiIHdpZHRoPSIxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJtNyA0aC0zdjhoM20yLThoM3Y4aC0zIiBzdHJva2U9IiMwMDAiIHN0cm9rZS13aWR0aD0iMiIvPjwvc3ZnPg==");
    --icon-droplet: url("data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjE2IiB2aWV3Qm94PSIwIDAgMTYgMTYiIHdpZHRoPSIxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJtNSAxMGMwLTEuNjM0NzIgMS4wMDIxMi00LjI3MTU2IDIuMTg3MjYtNi41NDUzNy4zNDg5My0uNjY5NDQgMS4yNzY1NS0uNjY5NDQgMS42MjU0OCAwIDEuMTg1MTQgMi4yNzM4MSAyLjE4NzI2IDQuOTEwNjUgMi4xODcyNiA2LjU0NTM3IDAgMi0xLjUgMy0zIDNzLTMtMS0zLTN6IiBmaWxsPSIjMDAwIi8+PC9zdmc+");
    --icon-external-link: url("data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjE2IiB2aWV3Qm94PSIwIDAgMTYgMTYiIHdpZHRoPSIxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBzdHJva2U9IiMwMDAiPjxwYXRoIGQ9Im0xMC41IDl2Mi41aC02di02aDIuNSIvPjxwYXRoIGQ9Im03IDkgNC41LTQuNW0wIDBoLTMuNW0zLjUgMHYzLjUiLz48L2c+PC9zdmc+");
    --icon-memory: url("data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjE2IiB2aWV3Qm94PSIwIDAgMTYgMTYiIHdpZHRoPSIxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMDAwIiBzdHJva2U9IiMwMDAiIHN0cm9rZS13aWR0aD0iLjEiPjxwYXRoIGQ9Im01LjA1IDMuMDVoNS45djkuOWgtNS45eiIvPjxwYXRoIGQ9Im0zLjA1IDQuMDVoMS45djEuOWgtMS45eiIvPjxwYXRoIGQ9Im0xMS4wNSA0LjA1aDEuOXYxLjloLTEuOXoiLz48cGF0aCBkPSJtMy4wNSA3LjA1aDEuOXYxLjloLTEuOXoiLz48cGF0aCBkPSJtMTEuMDUgNy4wNWgxLjl2MS45aC0xLjl6Ii8+PHBhdGggZD0ibTMuMDUgMTAuMDVoMS45djEuOWgtMS45eiIvPjxwYXRoIGQ9Im0xMS4wNSAxMC4wNWgxLjl2MS45aC0xLjl6Ii8+PC9nPjwvc3ZnPg==");
    --icon-object: url("data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWln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luPSJyb3VuZCIgc3Ryb2tlLW9wYWNpdHk9Ii41Ii8+PHBhdGggZD0ibTMgNWgxIi8+PC9nPjwvZz48L3N2Zz4=");
    --icon-plus: url("data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjE2IiB2aWV3Qm94PSIwIDAgMTYgMTYiIHdpZHRoPSIxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMDAwIj48cGF0aCBkPSJtNyA0aDJ2OGgtMnoiLz48cGF0aCBkPSJtNCA3aDh2MmgtOHoiLz48L2c+PC9zdmc+");
    --icon-minus: url("data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjE2IiB2aWV3Qm94PSIwIDAgMTYgMTYiIHdpZHRoPSIxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJtNCA3aDh2MmgtOHoiIGZpbGw9IiMwMDAiLz48L3N2Zz4=");

    --icon-brackets-white: url("data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjE2IiB2aWV3Qm94PSIwIDAgMTYgMTYiIHdpZHRoPSIxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJtNyA0aC0zdjhoM20yLThoM3Y4aC0zIiBzdHJva2U9IiNmZmYiIHN0cm9rZS13aWR0aD0iMiIvPjwvc3ZnPg==");
    --icon-droplet-white: url("data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjE2IiB2aWV3Qm94PSIwIDAgMTYgMTYiIHdpZHRoPSIxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJtNSAxMGMwLTEuNjM0NzIgMS4wMDIxMi00LjI3MTU2IDIuMTg3MjYtNi41NDUzNy4zNDg5My0uNjY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tMy4wNSA3LjA1aDEuOXYxLjloLTEuOXoiLz48cGF0aCBkPSJtMTEuMDUgNy4wNWgxLjl2MS45aC0xLjl6Ii8+PHBhdGggZD0ibTMuMDUgMTAuMDVoMS45djEuOWgtMS45eiIvPjxwYXRoIGQ9Im0xMS4wNSAxMC4wNWgxLjl2MS45aC0xLjl6Ii8+PC9nPjwvc3ZnPg==");
}

.icon {
    vertical-align: middle;
    width: 16px;
    height: 16px;

    background-repeat: no-repeat;
    background-position: 50% 50%;

    &.icon-brackets {
        background-image: var(--icon-brackets);
    }
    &.icon-droplet {
        background-image: var(--icon-droplet);
    }
    &.icon-external-link {
        background-image: var(--icon-external-link);
    }
    &.icon-memory {
        background-image: var(--icon-memory);
    }
    &.icon-object {
        background-image: var(--icon-object);
    }
    &.icon-rkgk-grayscale {
        background-image: var(--icon-rkgk-grayscale);
    }
    &.icon-plus {
        background-image: var(--icon-plus);
    }
    &.icon-minus {
        background-image: var(--icon-minus);
    }

    &.icon-brackets-white {
        background-image: var(--icon-brackets-white);
    }
    &.icon-droplet-white {
        background-image: var(--icon-droplet-white);
    }
    &.icon-memory-white {
        background-image: var(--icon-memory-white);
    }
    &.icon-object-white {
        background-image: var(--icon-object-white);
    }
}
