/* shader gallery layout + controls */

:root {
	/* gallery overlay margins (adjust like index.css asymmetric margins) */
    --panel-outer-margin: 4vw;
    --panel-spacing: 12px;
    --panel-section-width: calc(
        (100vw - 2 * var(--panel-outer-margin) - 4 * var(--panel-spacing)) / 6
    );
    --gallery-left: var(--panel-outer-margin);
    --gallery-width: var(--panel-section-width);
	--gallery-right: calc(100% - var(--gallery-left) - var(--gallery-width));
    --gallery-top: max(4vh, var(--panel-toolbar-clearance, 4vh));
    --gallery-bottom: var(--gallery-top);
	--gallery-opacity: 0.95;
	--gallery-radius: 20px;
	--gallery-gap: 12px;
	--gallery-columns: 2;
	--gallery-rows: 8;

	/* page label controls */
	--gallery-page-label-display: block;
	--gallery-page-label-top: 10px;
	--gallery-page-label-left: 10px;
	--gallery-page-label-transform: none;
	--gallery-page-label-color: #fff;
	--gallery-page-label-font-family: monospace;
	--gallery-page-label-font-size: 11px;
	--gallery-page-label-opacity: 1;
}

#gallery {
	position: fixed;
	top: var(--gallery-top);
	bottom: var(--gallery-bottom);
	left: var(--gallery-left);
	right: var(--gallery-right);
	width: auto;
	height: auto;
	z-index: 2;
	padding: 32px 8px 8px;
	background-color: transparent;
	opacity: var(--gallery-opacity);
	display: flex;
	flex-direction: column;


	gap: var(--gallery-gap);
	border-radius: var(--gallery-radius);
	overflow: hidden;
	transition: background-color 500ms;	
}

#gallery.gallery-hidden {
	display: none;
}

#gallery:hover {
	background-color: rgba(0, 0, 0, 0.5);
}

#gallery button {
	padding: 8px 12px;
	border: 0;
	border-radius: 5px;
	margin-right: 5px;
	color: #ffffff;
	background-color: #000000;
	font-family: monospace;
	font-size: 11px;
	cursor: pointer;
	text-decoration: none;
	text-transform: uppercase;
}

#gallery button:hover {
	background-color: #ffffff;
	color: #000000;
}

/* controls block becomes overlay container */
.gallery-controls {
	position: absolute;
	inset: 0;
	pointer-events: none; /* allow clicks through except buttons */
	margin: 0;
	padding: 0;
}

/* Compact unlabeled checkboxes occupy the existing page-label line. */
#galleryHeader {
    position: absolute;
    top: var(--gallery-page-label-top);
    left: var(--gallery-page-label-left);
    right: 10px;
    height: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
    pointer-events: auto;
    white-space: nowrap;
}

#galleryFilters {
    display: grid;
    grid-template-columns: repeat(9, minmax(0, 1fr));
    gap: clamp(1px, 0.2vw, 4px);
    flex: 1 1 140px;
    max-width: 140px;
    min-width: 0;
}

#galleryFilters input {
    appearance: auto;
    width: 100%;
    max-width: 10px;
    min-width: 0;
    height: auto;
    aspect-ratio: 1;
    margin: 0;
    accent-color: #fff;
    cursor: pointer;
}

#galleryPageLabel {
    position: static;
    margin-left: auto;
    flex: 0 0 auto;
    display: var(--gallery-page-label-display);
    color: var(--gallery-page-label-color);
    font-family: var(--gallery-page-label-font-family);
    font-size: var(--gallery-page-label-font-size);
    line-height: 13px;
    opacity: var(--gallery-page-label-opacity);
    user-select: none;
    pointer-events: none;
}

/* Center arrows on the tile grid: 32px top padding, 8px bottom. */
#galleryPrev,
#galleryNext {
	position: absolute;
	top: calc(50% + 12px);
	transform: translateY(-50%);
	z-index: 10;
	pointer-events: auto; /* clickable */
	margin-right: 0;
	padding: 10px 14px;
	font-size: 14px;
	opacity: 0.85;
}

#galleryPrev:hover,
#galleryNext:hover {
	opacity: 1;
}

/* left: ~5% from left edge */
#galleryPrev { left: 5%; }

/* right: ~5% from right edge */
#galleryNext { right: 5%; }

/* 2 x 5 gallery grid */
.gallery-grid {
	flex: 1 1 auto;
	display: grid;
	grid-template-columns: repeat(var(--gallery-columns), 1fr);
	grid-template-rows: repeat(var(--gallery-rows), 1fr);
	gap: var(--gallery-gap);
	min-height: 0; /* important in flex column */
}

/* gallery tiles */
.thumb {
	background-color: #111;
	cursor: pointer;
	overflow: hidden;
	border-radius: var(--gallery-radius);
}

.thumb:hover { background-color: #222; }

/* gallery images: neutral */
#gallery img {
	display: block;
	width: 100%;
	height: 100%;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	outline: none;
	object-fit: cover;
}

/* tile sizing and empty padding slots. */
.thumb {
    min-width: 0;
    min-height: 0;
}

.thumb-empty,
.thumb-empty:hover {
    background-color: #111;
    cursor: default;
}

/* missing previews and the last-clicked download target. */
.asset-preview-fallback {
    display: block;
    padding: 8px;
    color: #fff;
    font: 11px monospace;
    pointer-events: none;
}
.asset-preview-fallback[hidden],
#gallery img[hidden],
#glSetGallery img[hidden] { display: none; }
#gallery .thumb.asset-download-selected,
#glSetGallery .thumb.asset-download-selected,
#textureGallery .texture-tile.asset-download-selected,
#videoGallery .texture-tile.asset-download-selected {
    outline: 2px solid #fff;
    outline-offset: -2px;
}
