/* texture gallery layout + controls */

:root {
	--texture-gallery-left: calc(var(--gl-set-gallery-left) + var(--gallery-width) + var(--panel-spacing));
	--texture-gallery-right: calc(100% - var(--texture-gallery-left) - var(--gallery-width));
	--texture-gallery-top: var(--gallery-top);
	--texture-gallery-bottom: var(--gallery-bottom);
	--texture-gallery-opacity: 0.95;
	--texture-gallery-radius: 20px;
	--texture-gallery-gap: 12px;

	--texture-label-display: none;
	--texture-label-font-family: monospace;
	--texture-label-font-size: 11px;
	--texture-label-text-transform: uppercase;

	--texture-details-display: block;
	--texture-details-font-size: 10px;
	--texture-details-opacity: 0.8;
}

#textureGallery {
	position: fixed;
	top: var(--texture-gallery-top);
	bottom: var(--texture-gallery-bottom);
	left: var(--texture-gallery-left);
	right: var(--texture-gallery-right);
	width: auto;
	height: auto;
	z-index: 2;
	padding: 32px 8px 8px;
	background-color: transparent;
	opacity: var(--texture-gallery-opacity);
	display: flex;
	flex-direction: column;
	gap: var(--texture-gallery-gap);
	border-radius: var(--texture-gallery-radius);
	overflow: hidden;
	transition: background-color 500ms;	
}

#textureGallery.gallery-hidden {
	display: none;
}

#textureGallery:hover {
	background-color: rgba(0, 0, 0, 0.5);
}

/* texture gallery grid */
.texture-grid {
	flex: 1 1 auto;
	display: grid;
	grid-template-columns: repeat(var(--gallery-columns), minmax(0, 1fr));
	grid-template-rows: repeat(var(--gallery-rows), minmax(0, 1fr));
	grid-auto-rows: minmax(0, 1fr);
	gap: var(--texture-gallery-gap);
	min-height: 0;
}

.texture-tile {
	min-width: 0;
	position: relative;
	border: 0;
	border-radius: var(--texture-gallery-radius);
	padding: 12px;
	min-height: 0;
	color: #ffffff;
	background-color: #111;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	cursor: pointer;
	font-family: monospace;
	font-size: 11px;
	text-transform: uppercase;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	transition: background-color 0.2s ease;
}

.texture-tile:hover {
	background-color: #222;
}

.texture-tile-loaded {
	color: #ffffff;
	text-shadow: 0 0 8px rgba(0, 0, 0, 0.75);
}

.texture-tile-error {
	background-color: #3a0f0f;
}

.texture-label {
	display: var(--texture-label-display);
	font-family: var(--texture-label-font-family);
	font-size: var(--texture-label-font-size);
	text-transform: var(--texture-label-text-transform);
	text-overflow: ellipsis;
	overflow: hidden;
	white-space: nowrap;
}

.texture-details {
	display: var(--texture-details-display);
	font-size: var(--texture-details-font-size);
	opacity: var(--texture-details-opacity);
	text-transform: none;
	text-align: right;
	white-space: pre-line;
}

.texture-input {
	display: none;
}

/* independent texture-gallery pagination. */
#textureGalleryLabel {
    position: absolute;
    top: var(--gallery-page-label-top);
    left: auto;
    right: 10px;
    text-align: right;
    display: var(--gallery-page-label-display);
    transform: var(--gallery-page-label-transform);
    color: var(--gallery-page-label-color);
    font-family: var(--gallery-page-label-font-family);
    font-size: var(--gallery-page-label-font-size);
    opacity: var(--gallery-page-label-opacity);
}

/* match shader-gallery page selector buttons. */
#textureGalleryPrev,
#textureGalleryNext {
    position: absolute;
    top: calc(50% + 12px);
    transform: translateY(-50%);
    z-index: 10;
    pointer-events: auto;
    padding: 8px 12px;
    border: 0;
    border-radius: 5px;
    margin: 0;
    color: #fff;
    background-color: #000;
    font-family: monospace;
    font-size: 11px;
    cursor: pointer;
    text-decoration: none;
    text-transform: uppercase;
    opacity: 0.85;
}

#textureGalleryPrev { left: 5%; }
#textureGalleryNext { right: 5%; }

#textureGalleryPrev:hover,
#textureGalleryNext:hover {
    opacity: 1;
    background-color: #fff;
    color: #000;
}


#textureGallery .texture-tile[hidden] {
    display: none;
}

/* match GL-set drop-target feedback. */
#textureGallery .texture-drop-target {
    outline: 2px solid #fff;
    outline-offset: -2px;
}
