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

@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;
}

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

html {
    --text: #333;
    --bg: #fff;
    --text-faded: #aaa;
    --bg-faded: #eee;
    --bg-faded-faded: #ccc;
    --red: #faa;
    --primary: #67f;

    --rule: 1px;

    font:
        15px / 1.5 Outfit,
        sans-serif;
}

body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    display: grid;
    grid-template-columns: min-content 1fr;
}

form[name="experiment_panel"] {
    background: var(--bg-faded-faded);
}

form[name="control_panel"] {
    background: var(--bg-faded);
}

form.foldable {
    padding: 8px 18px;
    height: 100%;
    overflow: auto;
    border-right: var(--rule) solid var(--text-faded);
    width: 200px;
    position: relative;
    scrollbar-width: none;

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

        &:hover {
            color: var(--primary);
            background: none;
        }

        &:active {
            color: var(--primary);
            background: none;
        }

        &::after {
            content: "↓";
        }
    }

    &.folded {
        width: 1.5rem;

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

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

        /* Depending on the browser the right arrow could look different so to
          enforce consistency, the down arrow is rotated. */
        button.fold::after {
            display: inline-block;
            transform: rotate(-90deg);
        }
    }

    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;

        & + label {
            margin-top: 4px;

            & + input {
                margin-top: 4px;
            }
        }
    }

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

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

    button {
        width: 100%;
    }

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

    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;
        width: 16px;
    }

    summary {
        display: grid;
        grid-template-columns: 1fr repeat(100, min-content);
        align-items: center;

        * {
            margin-left:0.5rem;
        }

        input[type="color"] {
            width:16px;
            height:16px;
        }
    }

    /* summary :is(input[type="color"], input[type="checkbox"]) {
        float: right;
        margin-top: 0.6em;
        margin-left: 0.2rem;

        &[type="color"] {
            margin-top:0.5rem;
            width: 16px;
            height: 16px;
        }
    } */
}

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

    &:hover {
        background: var(--bg-faded);
    }

    &:active {
        background: var(--primary);
        color: var(--bg);
    }
}

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

*.hidden {
    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;
    }
}

loading-animation {
    display: none;
}

*.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;
        }
    }
}

tile-grid {
    display: flex;
    flex-wrap: wrap;
    overflow: auto;

    moving-tile {
        height: 100%;
    }

    &:has(moving-tile:nth-child(3)) moving-tile {
        height: 50%;
    }
}

moving-tile {
    display: grid;
    grid-template:
        "controls controls" min-content
        "panel graph" 1fr
        / min-content 1fr;
    border: var(--rule) solid var(--text-faded);
    flex: 1 1 50%;

    moving-tile-controls {
        grid-area: controls;
    }

    form {
        grid-area: panel;
    }

    [group="d3-container"] {
        grid-area: graph;
    }
}

moving-tile-controls {
    background: var(--bg-faded-faded);
    border-bottom: var(--rule) solid var(--text-faded);
    cursor: pointer;
    display: grid;
    grid-template-columns: 1fr min-content;
    padding: 4px;

    h2 {
        font-weight: normal;
        font-size: 1rem;
    }

    button {
        background: var(--red);
        margin: 0;
        line-height: 1;
    }
}

[group="d3-container"] {
    overflow: auto;
}

.body-style {
    display: flex;
    flex-direction: row;
    justify-content: start;
    height: 100vh;
    max-width: 100vw;
    font-size: 15px;
}

.hr {
    width: 100%;
    height: 0.5px;
    background: gray;
}

.main-container {
    display: flex;
    flex-direction: column;
    width: var(--main-width, calc(100vw - 200px));
}

.lines {
    display: flex;
    flex-direction: column;
    width: var(--lines-width, 200px);
    justify-content: start;
    background-color: rgb(219, 219, 219);
    border-right: 1px solid gray;
    overflow-y: auto;
}

.graph-area {
    border: 1px solid rgba(128, 128, 128, 0.25);
    border-radius: 8px;
    background: rgba(128, 128, 128, 0.04);
    text-align: center;
    margin: 10px;
    padding: 10px;
    max-width: calc(91vh * (16 / 9));
}

.range-container {
    display: flex;
    flex-direction: column;
}

.double-slider {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    min-height: 20px;
}

.slider {
    display: grid;
    place-items: center;
}

.from-slider {
    background-color: transparent;
    z-index: 1;
}

.form-control {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
}

input[type="range"] {
    grid-area: 1 / 1;
    appearance: none;
    height: 2px;
    pointer-events: none;
    width: 120px;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 10px;
    height: 10px;
    pointer-events: all;
    background-color: #4b4b4b;
    border-radius: 50%;
    box-shadow: 0 0 0 1px #c6c6c6;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #f7f7f7;
}

.bpd-data-box {
    display: flex;
    width: 172px;
    flex-direction: column;
    justify-content: start;
    padding: 4px;
    border-radius: 2px;
    background-color: #f9f9f9;
    border: 1px solid black;
    margin-top: 4px;
    font-family: Outfit;
}

.bpd-data-select {
    max-width: 140px;
    height: 1.5em;
    border-radius: 2px;
    background-color: white;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: Outfit;
}

.bpd-data-label {
    max-width: 168px;
    font-weight: bold;
    font-size: 14px;
    color: #333;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-all;
}

.bpd-data-delete {
    background-color: transparent;
    color: #ff4d4d;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
}

.horizontal-box {
    display: flex;
    flex-direction: row;
    justify-content: start;
    align-items: center;
}
