/**********************************************************************
* 
*
*
**********************************************************************/


/********************************************************* Config ****/

:root {
	/* dimensions */
	--gallery-image-base-height: 18rem;
	--gallery-image-margin: 0;
	--gallery-current-image-border: 0.7rem;
	--gallery-padding: 3rem;
	--gallery-padding-horizontal: var(--gallery-padding);
	--gallery-padding-vertical: var(--gallery-current-image-border);
	--gallery-padding-top: var(--gallery-padding-vertical);
	--gallery-padding-bottom: var(--gallery-padding-vertical);
	--gallery-padding-left: var(--gallery-padding-horizontal);
	--gallery-padding-right: var(--gallery-padding-horizontal);
	--gallery-image-scroll-margin: calc(2 * var(--gallery-current-image-border));
	--gallery-empty-height: var(--gallery-image-base-height);
	--gallery-scrollbar-width: 0.5rem;

	--lightbox-frame: 5vmin;
	--lightbox-image-margin-top: 0.75;
	--lightbox-button-size: 2em;

	/* theme */
	--gallery-text-color: black;
	--gallery-secondary-color: silver;
	--gallery-background-color: white;

	--lightbox-text-color: black;
	--lightbox-background-color: white;
	/*--lightbox-background-color: rgba(0,0,0,0.8);*/
}

.gallery-dark {
	--gallery-text-color: silver;
	--gallery-secondary-color: gray;
	--gallery-background-color: black;
}

.lightbox-dark {
	--lightbox-text-color: silver;
	--lightbox-background-color: black;
}



/****************************************************** Scrolling ****/

::-webkit-scrollbar {
	width: var(--gallery-scrollbar-width);
}
::-webkit-scrollbar-track {
	background-color: transparent;
	border-radius: 100px;
}
::-webkit-scrollbar-thumb {
	background-color: var(--gallery-secondary-color);
	border-radius: 100px;
}
body {
	overflow-y: scroll;
	/* XXX these for some reason do not work in FF... */
	scrollbar-width: thin;
	scrollbar-color: transparent var(--gallery-secondary-color);

	color: var(--gallery-text-color);
	background: var(--gallery-background-color);
}


/******************************************************** Gallery ****/

/* XXX need to account for scrollbar popping in and out */
.gallery {
	--base-layer: 10;

	padding-top: var(--gallery-padding-top);
	padding-bottom: var(--gallery-padding-bottom);
	padding-left: calc(
		var(--gallery-scrollbar-width) 
		+ var(--gallery-padding-left) );
	padding-right: var(--gallery-padding-right);

	color: var(--gallery-text-color);
	background: var(--gallery-background-color);
}
.gallery .images {
	position: relative;
	display: flex;
	justify-content: flex-start;
	align-content: flex-start;
	flex-flow: row wrap;
}

/* empty... */
.gallery .images:empty {
	height: var(--gallery-empty-height);
	border: dashed 1px black;
}
.gallery .images:empty:after,
.gallery .images:empty:before {
	position: absolute;
	width: 100%;
	left: 0;
	top: 0;
	line-height: var(--gallery-empty-height);
	text-align: center;
	opacity: 0.6;
}
.gallery .images:empty:before {
	content: "Empty";
}
.gallery .images:empty:after {
	content: "(drag new images here)";
	font-size: small;
	margin-top: 1.1em;
	opacity: 0.4;
}

/* image... */
.gallery .images img {
	height: var(--gallery-image-base-height);
	width: auto;

	border: solid var(--gallery-image-margin) transparent;
	box-sizing: border-box;

	scroll-margin: var(--gallery-image-scroll-margin);

	image-rendering: crisp-edges;

	cursor: pointer;
}

/* dragged image... */
.gallery .images img.dragged {
}
.gallery .images:has(.dragged) img:not(.dragged) {
}

/* image dragged over... */
.gallery .images img.dragged-over {
	filter: saturate(0);
}

/* image marked for removal... */
.gallery .images img.to-remove {
	opacity: 0.3;
	filter: saturate(0);
}

/* selection marker... */
.gallery .images img.current {
	z-index: 10;
	box-shadow: 
		0px 0px 0px var(--gallery-current-image-border) rgba(255,255,255,1),
		0.4em 0.4em 3em 0em rgba(0,0,0,0.8);
}

/* hover... */
/* XXX EXPERIMENTAL -- not sure if this is a good idea...
.gallery:not(.lightboxed) .images:has(:hover) img:not(:hover) {
	opacity: 0.8;
	filter: saturate(0);
}
*/
.gallery:not(.lightboxed) .images img:not(.current):hover {
	z-index: calc(var(--base-layer) + 1);
	box-shadow: 
		0px 0px 0px calc(var(--gallery-current-image-border) / 5) rgba(255,255,255,1),
		0.2em 0.2em 1em 0em rgba(0,0,0,0.8);
}
.gallery:not(.lightboxed) .images img.current:hover {
	z-index: calc(var(--base-layer) + 1);
	box-shadow: 
		0px 0px 0px var(--gallery-current-image-border) rgba(255,255,255,1),
		0.6em 0.6em 4em 0em rgba(0,0,0,0.8);
}



/*************************************************** Image markers ***/

.gallery .images img+.mark {
	z-index: var(--base-layer);
	position: relative;
}
.gallery .images img:hover+.mark {
	z-index: calc(var(--base-layer) + 1);
}
.gallery.lightboxed .images img:not(.current)+.mark {
	display: none;
}
.gallery.lightboxed .images img.current+.mark {
	z-index: calc(var(--base-layer) + 1);
	position: fixed;
	bottom: 0;
	right: 0;
}

/* marker: marked */
.gallery .images img+.mark.marked:after {
	content: "";
	position: absolute;
	display: block;
	width: 1em;
	height: 1em;
	right: 0.5em;
	bottom: 0.5em;
	border-radius: 50%;

	background: blue;

	box-shadow: 0em 0em 0em 0.05em rgba(255,255,255,1);

	cursor: pointer;
}



/******************************************************** Toolbar ****/

/* XXX make the toolbar swirchable and contextual... */
.gallery .toolbar {
	display: inline-block;
	position: sticky;
	top: 1em;
	padding: 0.5rem;

	z-index: calc(var(--base-layer) + 1);

	border: solid 1px var(--gallery-secondary-color);
	background: var(--gallery-background-color);
}
/* XXX need to hide parts of the toolbar and make it transparent... */
.gallery.lightboxed .toolbar,
.gallery.detailed .toolbar {
	display: none;
}

/* buttons... */
.gallery .toolbar button {
	line-height: 1.5rem;
	min-width; 1.5rem;
	text-align: center;

	border: solid 1px transparent;
	background: var(--gallery-background-color);
}
.gallery .toolbar button:hover {
	border-radius: calc(1.5rem / 5);
	border: solid 1px var(--gallery-secondary-color);
}




/******************************************************* Overlays ****/

.gallery.lightboxed,
.gallery.detailed {
	--base-layer: 100;
}
.gallery.lightboxed .lightbox,
.gallery.detailed .details {
	display: block;
}

.gallery .lightbox,
.gallery .details {
	display: none;
	position: fixed;
	width: 100%;
	height: 100%;
	top: 0px;
	left: 0px;
	z-index: var(--base-layer);

	text-align: center;

	color: var(--gallery-text-color);
	background: var(--gallery-background-color);
}


/*------------------------------------------------------ Lightbox ---*/

.gallery .lightbox {
	color: var(--lightbox-text-color);
	background: var(--lightbox-background-color);
}
.gallery .lightbox.show-caption:before {
	content: attr(caption);
	position: absolute;
	bottom: 0.5em;
	left: 0.5em;
}
.gallery .lightbox.clickable {
	cursor: pointer;
}
/* XXX add metadata display... */
.gallery .lightbox img {
	object-fit: contain;
	width: calc(
		100vw 
		- var(--lightbox-frame) * 2);
	height: calc(
		100vh 
		- var(--lightbox-frame) * 2);
	margin-top: calc(
		var(--lightbox-frame) 
		* var(--lightbox-image-margin-top)); 
}


/*------------------------------------------------------- Details ---*/

.gallery .details img {
	width: 20em;
	height: 20em;
	padding: 0.5em;
	object-fit: contain;
	border: solid 1px black;
}


/******************************************************* Controls ****/

.gallery .buttons {
	display: flex;
	position: absolute;
	top: 0;
	right: 0;
}
.gallery .button {
	disbplay: inline-block;
	cursor: pointer;
	width: var(--lightbox-button-size);
	height: var(--lightbox-button-size);
	font-size: var(--lightbox-button-size);
	line-height: var(--lightbox-button-size);
	filter: saturate(0);
	
	opacity: 0.1;
}
.gallery .button:hover {
	opacity: 1;
	filter: saturate(1);
	color: var(--gallery-text-color);

	/* XXX HACK: might be better to use SVG for this... */
	text-shadow: 
		0.02em 0.02em 0em var(--gallery-background-color),
		-0.02em -0.02em 0em var(--gallery-background-color),
		-0.02em 0.02em 0em var(--gallery-background-color),
		0.02em -0.02em 0em var(--gallery-background-color);
}
/* controls: close... */
.gallery .button.close:after {
	content: "✕";
	color: red;
}
.gallery .button.fullscreen:after {
	content: "⛶";
}
.gallery .button.info:after {
	content: "i";
}
.gallery .button.prev:after {
	content: "<";
}
.gallery .button.next:after {
	content: ">";
}


/**********************************************************************
* vim:set ts=4 sw=4 :                                                */
