/* bit murals by Eugene Yakshin, 2021
   License: CC Attribution-NonCommercial */

:root {
    --bg: rgb(40, 40, 40);
    --track: rgb(56, 56, 56);
    --bar: rgb(130, 130, 130);
    --button: rgb(76, 76, 76);
    --button-hover: rgb(92, 92, 92);
    --button-on: rgb(200, 200, 200);
    --text: rgb(220, 220, 220);
    --text-dim: rgb(140, 140, 140);
    --text-on: rgb(40, 40, 40);
    --bad: rgb(230, 120, 90);
    --control-height: 19px;
}

[hidden] { display: none !important; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font: 11px/1.35 ui-monospace, Menlo, Consolas, monospace;
}

#overlay {
    position: fixed;
    left: 0;
    top: 0;
    pointer-events: none;
    z-index: 10;
}

.app {
    display: flex;
    height: 100%;
}

#pattern-area {
    flex: 1;
    min-width: 0;
    cursor: grab;
    touch-action: none;
}

#panel {
    width: clamp(330px, 36vw, 520px);
    box-sizing: border-box;
    height: 100%;
    overflow-y: auto;
    padding: 12px 14px 12px 4px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#panel > * { flex: none; }

.header { display: flex; justify-content: space-between; align-items: baseline; }
.header .title { color: var(--text); letter-spacing: 0.2em; text-transform: uppercase; }
.header a { color: var(--text-dim); }
.title-row { display: flex; align-items: baseline; gap: 10px; }
.title-row .btn { padding: 0 8px; }

.user-functions { display: flex; flex-direction: column; gap: 2px; }
.user-function { display: flex; align-items: baseline; gap: 6px; }
.user-function .weight-glyph { color: var(--text-dim); }
.user-functions input {
    flex: 1;
    min-width: 0;
    font: inherit;
    color: var(--text);
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--track);
    padding: 3px 0;
    outline: none;
}
.user-functions input::placeholder { color: rgb(95, 95, 95); }
.user-functions input:focus { border-bottom-color: var(--bar); }
.user-functions input.bad { color: var(--bad); }

.info { display: flex; flex-direction: column; gap: 3px; }
.info .formula {
    color: var(--text-dim);
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.info .framing, .info .value { color: var(--text-dim); }

.buttons { display: grid; gap: 3px; }
.transport { grid-template-columns: repeat(8, 1fr); }
.sweep-row { display: flex; gap: 3px; }
.sweep-row .btn { padding: 0 12px; }
.sweep-row .bar-slider { flex: 1; }
.modes { grid-template-columns: repeat(5, 1fr); }
.btn {
    font: inherit;
    color: var(--text);
    background: var(--button);
    border: 0;
    height: var(--control-height);
    padding: 0;
    cursor: pointer;
    min-width: 0;
}
.btn:hover { background: var(--button-hover); }
.btn.on { background: var(--button-on); color: var(--text-on); }
.btn.idle { opacity: 0.45; }

.tone { display: flex; flex-direction: column; gap: 3px; }
.histogram { width: 100%; height: 54px; display: block; cursor: crosshair; }
.window-row { display: flex; gap: 3px; }
.window-row .bar-slider { flex: 1; }
.window-row .btn { width: 40px; }
.window-row.idle { opacity: 0.45; }
.tone-caption { color: var(--text-dim); }

.bar-slider {
    position: relative;
    height: var(--control-height);
    background: var(--track);
    cursor: ew-resize;
    user-select: none;
    touch-action: none;
}
.bar-slider .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--bar); }
.bar-slider.from-right .fill { left: auto; right: 0; }
.bar-slider .label {
    position: absolute;
    left: 6px;
    top: 3px;
    color: var(--text);
    mix-blend-mode: difference;
    pointer-events: none;
}
.bar-slider.from-right .label { left: auto; right: 6px; }
.bar-slider .readout {
    position: absolute;
    right: 6px;
    top: 3px;
    cursor: text;
    mix-blend-mode: difference;
}
.bar-slider .readout-edit {
    position: absolute;
    right: 2px;
    top: 1px;
    width: 45%;
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--bar);
    outline: none;
}

/* the list scrolls on its own and takes what height is left */
#panel > .generator {
    flex: 1 1 0;
    min-height: 160px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 4px;
}
.generator > * { flex: none; }
.generator-head { position: sticky; top: 0; background: var(--bg); z-index: 1; padding-bottom: 2px; }
.generator .bar-slider { height: 15px; background: transparent; }
.generator .bar-slider .label { top: 1px; }
.generator-head { display: flex; justify-content: space-between; align-items: center; }
.generator-head .caption { color: var(--text-dim); }
.generator-head .btn { padding: 0 10px; }

.hint { color: rgb(110, 110, 110); }

.tooltip {
    position: fixed;
    z-index: 20;
    max-width: 300px;
    padding: 5px 7px;
    background: rgb(230, 230, 230);
    color: var(--text-on);
    white-space: pre-line;
    pointer-events: none;
}

@media (max-width: 760px) {
    .app { flex-direction: column; height: auto; }
    #pattern-area { flex: none; height: 100vw; }
    #panel { width: 100%; height: auto; overflow: visible; padding: 12px 16px 32px; }
    .transport { grid-template-columns: repeat(4, 1fr); }
    #panel > .generator { flex: none; overflow: visible; }
}
