/* toolbar container + controls */

#toolbar {
    --toolbar-top: max(25px, env(safe-area-inset-top));
    --toolbar-bottom: max(25px, env(safe-area-inset-bottom));
    --toolbar-tile-inset: 8px;
    --toolbar-tile-width: calc(
        (var(--gallery-width) - 2 * var(--toolbar-tile-inset) -
        (var(--gallery-columns) - 1) * var(--gallery-gap)) / var(--gallery-columns)
    );
    --toolbar-group-padding: 3px;
    --toolbar-editor-step: calc(
        (100vw - var(--editor-left) - var(--editor-right) - 2 * var(--toolbar-tile-inset) + var(--gallery-gap)) / 4
    );
    position: absolute;
    inset: 0;
    width: 100%;
    z-index: 3;
    pointer-events: none;
    transition: opacity 1s;
}

#toolbar .toolbar-left,
#toolbar .toolbar-right { display: contents; }

#toolbar [data-toolbar-row] {
    position: absolute;
    pointer-events: auto;
    z-index: 1;
    margin: 0;
}

/* All panel-column buttons match the width of an actual gallery tile. */
#toolbar [data-toolbar-anchor] {
    width: var(--toolbar-tile-width);
    text-align: center;
}

#toolbar [data-toolbar-row="top"] { top: var(--toolbar-top); }
#toolbar [data-toolbar-row="bottom"] { bottom: var(--toolbar-bottom); }
#toolbar [data-toolbar-anchor="shaders"] { left: calc(var(--gallery-left) + var(--toolbar-tile-inset)); }
#toolbar [data-toolbar-anchor="gl-set"] { left: calc(var(--gl-set-gallery-left) + var(--toolbar-tile-inset)); }
#toolbar [data-toolbar-anchor="textures"] { left: calc(var(--texture-gallery-left) + var(--toolbar-tile-inset)); }
#toolbar [data-toolbar-anchor="videos"] { left: calc(var(--video-gallery-left) + var(--toolbar-tile-inset)); }
#toolbar [data-toolbar-anchor="editor-1"] { left: calc(var(--editor-left) + var(--toolbar-tile-inset)); }
#toolbar [data-toolbar-anchor="editor-2"] {
    left: calc(var(--editor-left) + var(--toolbar-tile-inset) + var(--toolbar-editor-step));
}
#toolbar [data-toolbar-anchor="editor-3"] {
    left: calc(var(--editor-left) + var(--toolbar-tile-inset) + 2 * var(--toolbar-editor-step));
}
#toolbar [data-toolbar-anchor="editor-4"] {
    left: calc(var(--editor-left) + var(--toolbar-tile-inset) + 3 * var(--toolbar-editor-step));
}

#toolbar button,
#toolbar select,
#toolbar a,
#toolbar a:visited {
	padding: 8px 12px;
	border: 0;
	border-radius: 12px;
	margin-right: 0;
	color: #FFFFFF;
	background-color: #000000;
	font-family: monospace;
	font-size: 11px;
	cursor: pointer;
	text-decoration: none;
	text-transform: uppercase;
}

#toolbar .toolbar-gui { background-color: #333; }

#toolbar button:hover,
#toolbar select:hover,
#toolbar a:hover {
	background-color: #FFFFFF;
	color: #000000;
}

#toolbar button.toolbar-toggle-active {
	background-color: rgba(255, 255, 255, 0.35);
	color: #000000;
}

#toolbar button.toolbar-toggle-active:hover {
	background-color: rgba(255, 255, 255, 0.6);
	color: #000000;
}

#toolbar option {
	color: #ffffff;
	background-color: #000000;
}

/* toolbar icon/button styling (fullscreen icon is an <img>) */
#toolbar img {
	display: inline-block;
	padding: 4px;
	border: 0;
	border-radius: 12px;
	margin-right: 0;
	background-color: #000000;
	vertical-align: middle;
	cursor: pointer;
}

#toolbar img:hover { background-color: #FFFFFF; }

#toolbar .toolbar-right > :last-child {
	margin-right: 0;
}
/* One button spans imaginary editor tiles 3 and 4, with a label per tile. */
#toolbar #shaderStatusTimeButton {
    width: calc(2 * var(--toolbar-editor-step) - var(--gallery-gap));
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--gallery-gap);
    align-items: center;
    padding: 8px 0;
}

#shaderStatusTimeButton > span {
    min-width: 0;
    text-align: center;
}

/* Extra translucent surface behind Fullscreen, SCREENSHOT and EXIT only. */
#toolbarUtilityPanel {
    position: absolute;
    left: calc(var(--gallery-left) + var(--toolbar-tile-inset) - var(--toolbar-group-padding));
    bottom: calc(var(--toolbar-bottom) - var(--toolbar-group-padding));
    width: calc(var(--texture-gallery-left) - var(--gallery-left) + var(--toolbar-tile-width) + 2 * var(--toolbar-group-padding));
    height: calc(1lh + 16px + 2 * var(--toolbar-group-padding));
    font: 700 11px var(--interface-font, monospace);
    background: rgba(255, 255, 255, 0.05);
    border-radius: calc(12px + var(--toolbar-group-padding));
    pointer-events: none;
    z-index: 0;
}

/* The icon gets its own full tile-width button surface. */
#toolbar .toolbar-fullscreen {
    height: calc(1lh + 16px);
    display: flex;
    align-items: center;
    justify-content: center;
}

#toolbar .toolbar-fullscreen img {
    width: 20px;
    height: 20px;
    padding: 0;
    margin: 0;
    background: transparent;
}

/* Preserve the tile-centred clock alignment while giving every digit equal space. */
#shaderClock {
    display: flex;
    justify-content: center;
    align-items: center;
    white-space: nowrap;
    font-kerning: none;
}

#shaderClock > span {
    flex: none;
    width: 1ch;
    text-align: center;
}

#shaderClock > .clock-punctuation { width: 0.4ch; }
