/* Make sure styles don't apply to the d3 SVG --- outside CSS won't be grabbed
   when saving the graph as a SVG image. */

@font-face {
    font-family: Outfit;
    src: url("./static/Outfit-Regular.ttf");
}

@font-face {
    font-family: Outfit;
    src: url("./static/Outfit-Bold.ttf");
    font-weight: bold;
}

@keyframes loading {
    from {
        opacity: 1;
    }
    to {
        opacity: 0.3;
    }
}

* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

html {
    --text: #333;
    --bg: #fff;
    --text-faded: #aaa;
    --bg-faded: #eee;
    --bg-faded-faded: #ccc;

    --rule: 1px;
}

body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    display: grid;
    grid-template:
        "experiment control d3" 1fr
        / min-content min-content 1fr;
}

div#d3_container {
    grid-area: d3;
    overflow: auto;
    height: 100vh;
    position: relative;
}

form#control_panel {
    grid-area: control;
    background: #eee;
}

form#experiment_panel {
    grid-area: experiment;
    background: #ccc;
}

form.foldable {
    font:
        15px / 1.5 Outfit,
        sans-serif;
    padding: 8px 16px;
    height: 100vh;
    overflow: auto;
    border-right: var(--rule) solid var(--text-faded);
    width: 200px;
    position: relative;
}

form.folded {
    width: 1.5rem;
}

form.folded :not(button.fold, h1) {
    display: none;
}

form.folded h1 {
    transform: translateY(80px) rotate(-90deg);
}

button.fold {
    position: absolute;
    left: 0;
    top: 0;
    width: 1.5rem;
    height: 1.5rem;
    font-size: 1.5rem;
    padding: 0;
    margin: 0;
    border: none;
    background: none;
}

button.fold:hover {
    color: #67f;
    background: none;
}

button.fold:active {
    color: #67f;
    background: none;
}

button.fold::after {
    content: "↓";
}

form.folded button.fold::after {
    content: "→";
}

h1 {
    font-size: 1.5rem;
    font-weight: normal;
    margin-top: 16px;
    margin-bottom: 8px;
}

summary {
    font-size: 1.2rem;
    font-weight: normal;
    cursor: pointer;
}

details {
    border-bottom: var(--rule) solid var(--text-faded);
    margin-inline: -16px;
    padding-inline: 16px;
}

details:is(:open, [open]) {
    padding-bottom: 4px;
}

details + button {
    margin-top: 16px;
}

button {
    padding: 2px 4px;
    display: block;
    border: 1px solid currentColor;
    background: #fff;
    margin-block: 4px;
    width: 100%;
    font:
        15px / 1.5 Outfit,
        sans-serif;
}

button:hover {
    background: #eee;
}

button:active {
    background: #67f;
    color: #fff;
}

fieldset {
    padding: 4px;
    border: var(--rule) solid var(--text-faded);
}

label,
input[type="number"],
input[type="color"],
input[type="text"],
select {
    display: inline-block;
    height: 1.5em;
    font:
        15px / 1.5 Outfit,
        sans-serif;
}

label + input[type="color"] {
    height: 1em;
}

label + select,
label + input:is([type="number"], [type="color"], [type="text"]) {
    width: 64px;
    float: right;
    text-align: right;
}

label + input[type="checkbox"],
label + input[type="color"] {
    float: right;
    margin-top: 0.35em;
}

summary input[type="checkbox"] {
    float: right;
    margin-top: 0.6em;
}

*.two_cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

*.hidden {
    display: none;
}

loading-animation {
    display: none;
}

history-control {
    position: fixed;
    top: 8px;
    right: 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    z-index: 999;

    button {
        line-height: 1;
        padding-inline: 8px;
    }
}

div#d3_container.loading loading-animation {
    position: absolute;

    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);

    width: 100%;
    height: 100%;

    background: rgba(0.2, 0.2, 0.2, 0.2);

    display: grid;

    grid-template-columns: min-content min-content min-content;
    align-items: center;
    padding-inline: calc((100% - 10rem) / 2);

    span {
        font-size: 10rem;
        line-height: 1;
        animation: loading 1s infinite alternate;

        &:nth-child(2) {
            animation-delay: 0.33s;
        }

        &:nth-child(3) {
            animation-delay: 0.66s;
        }
    }
}
