/* css reset */

*, *::before, *::after {
  box-sizing: border-box;
}
* {
  margin: 0;
  border: 0;
}
img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

a {color: unset;}

/* global styles */
html {
	/* Reserve scrollbar space even when a dialog locks page scroll. */
	scrollbar-gutter: stable;
}

body {
	color: white;
	background: black;
	font-family: sans-serif;
	overflow-y: scroll;
	min-height: 100vh;
}

/* element styles */

.container {
	margin: 0 auto;
	max-width: 1520px; /* Six 240px grid slots (20px gaps) plus 80px side margins. */
}

#gallery {
  margin: 0 auto 2rem auto;
  width: calc(100% - 80px);
  position: relative;
  text-align: center;
  z-index: 0;
}

#gallery-filters {
	width: calc(100% - 32px);
	max-width: 1000px;
	margin: 0 auto 1rem;
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	text-align: left;
}

#gallery-filters label {
	display: flex;
	flex-direction: column;
	gap: 6px;
	font-size: 14px;
	min-width: 0;
}

#gallery-filters input,
#gallery-filters select {
	background: #252525;
	color: white;
	border: 1px solid #555;
	border-radius: 4px;
	padding: 8px;
	font: inherit;
	width: 100%;
}

#gallery-filters .filter-reactions {
	position: relative;
	width: 170px;
}

.filter-input-prefix {
	position: absolute;
	left: 8px;
	top: 50%;
	transform: translateY(-50%);
	color: #999;
	pointer-events: none;
}

#filter-reactions {
	padding-left: 90px;
	text-align: right;
}
/* Fix the wrapper width before options load; select text must not resize it. */
#gallery-filters .filter-template {
	width: 170px;
	flex: 0 0 170px;
}
#filter-template { max-width: 170px; }
#gallery-filters .filter-search {
	position: relative;
	flex: 1 1 240px;
	min-width: 0;
	font-size: 14px;
}
#gallery-filters #filter-search { padding-right: 38px; }
#filter-search::-webkit-search-cancel-button { display: none; }
#filter-search-icon,
#filter-search-clear {
	position: absolute;
	right: 0;
	top: 0;
	width: 38px;
	height: 38px;
	padding: 9px;
	background: transparent;
	color: white;
}
#filter-search-icon { pointer-events: none; }
#filter-search-clear {
	border-radius: 4px;
	cursor: pointer;
}
#gallery-filters input,
#gallery-filters select { height: 38px; }
#gallery-filters :focus-visible { outline: 2px solid #fae; }
#filter-status { width: 100%; font-size: 14px; color: #bbb; }
#filter-status:empty { display: none; }

.gallery-item {
	position: absolute;
	/* JS sets card dimensions and positions, including 15px vertical gaps. */
	width: var(--thumbnail-display-size, 220px);
	height: var(--gallery-card-height, 290px);
	border-radius: 5px;
	overflow: clip;
	text-align: left;
}

.thumbnail {
	display: block;
	position: relative;
	background-color: #888;
	background-repeat: no-repeat;
	/* Clip zoomed originals at the tile edges; the padding mask below clips
	   the shorter axis at the fitted image bounds without touching the fill. */
	overflow: hidden;
	width: var(--thumbnail-display-size, 220px);
	height: var(--thumbnail-display-size, 220px);
}

/* Only zoomed gallery originals need this fitted-rectangle crop. Transparent
   sprites show the CSS fill directly and never enable the overlay. The legacy
   sprite-padding variable names remain for originals; the lightbox is uncropped. */
.thumbnail[data-sprite-padding="true"]::after {
	content: '';
	position: absolute;
	inset: 0;
	background: var(--sprite-padding-background);
	clip-path: var(--sprite-padding-clip);
	pointer-events: none;
}

.thumbnail:focus-visible {
	outline: 2px solid #fae;
}

.thumbnail-metadata {
	position: relative;
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	column-gap: 8px;
	min-height: 31px;
	padding-top: 1px;
	font-size: 12px;
	line-height: 24px;
	color: #bbb;
}

.thumbnail-metadata time {
	display: block;
}

.thumbnail-metadata > a,
.thumbnail-metadata > .telegram-unavailable {
	margin-left: auto;
	text-align: right;
}

.thumbnail-stats {
	display: flex;
	flex: 1 0 auto;
	justify-content: space-between;
	gap: 4px;
	white-space: nowrap;
}

.thumbnail-classification {
	flex-basis: 100%;
	min-width: 0;
	height: 39px;
	overflow: hidden;
}

.classification-tags {
	position: relative;
	display: flex;
	flex-wrap: wrap;
	align-content: flex-start;
	align-items: flex-start;
	gap: 3px;
	height: 39px; /* Two 18px lines plus one 3px row gap. */
	line-height: 18px;
	overflow: hidden;
}

.classification-tag:focus-visible {
	outline: 1px solid #fae;
	outline-offset: -1px;
}

.classification-tag:hover {
	background: #444;
}

.classification-tag {
	visibility: hidden;
	border: 0;
	color: inherit;
	font: inherit;
	text-align: left;
	cursor: pointer;
	background: transparent;
	border-radius: 3px;
	padding: 0 4px;
	overflow-wrap: anywhere;
	max-width: 100%;
}

.classification-more {
	flex: 0 0 auto;
	border: 0;
	padding: 0 4px;
	border-radius: 3px;
	background: #252525;
	color: #ddd;
	font: inherit;
	white-space: nowrap;
	cursor: pointer;
}

.classification-more[hidden] {
	display: none;
}

.classification-more:hover,
.tags-overlay-close:hover {
	background: #444;
}

.classification-more:focus-visible,
.tags-overlay-close:focus-visible {
	outline: 1px solid #fae;
}

#all-tags-overlay {
	position: fixed;
	box-sizing: border-box;
	z-index: 10;
	width: min(350px, calc(100vw - 16px));
	max-height: min(250px, calc(100vh - 16px));
	overflow-y: auto;
	padding: 12px;
	border: 1px solid #777;
	border-radius: 6px;
	background: #181818;
	color: #ddd;
	box-shadow: 0 4px 18px rgb(0 0 0 / 60%);
	font-size: 12px;
	line-height: 18px;
	text-align: left;
}

.tags-overlay-close {
	position: absolute;
	top: 8px;
	right: 8px;
	background: none;
	color: inherit;
	font-size: 20px;
	cursor: pointer;
}

.tags-overlay-list {
	padding-right: 24px;
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
}

.tags-overlay-list .classification-tag {
	visibility: visible;
}

.classification-unavailable {
	color: #777;
}

.reaction-count {
	color: #fae;
}

.thumbnail-debug {
	border: 0;
	padding: 0;
	background: none;
	font: inherit;
	cursor: pointer;
}

#image-debug-dialog {
	width: min(800px, 90vw);
	max-height: 85vh;
	box-sizing: border-box;
	padding: 20px;
	border: 1px solid #777;
	border-radius: 6px;
	background: #181818;
	color: #ddd;
}

#image-debug-dialog::backdrop {
	background: rgb(0 0 0 / 70%);
}

#image-debug-dialog form {
	float: right;
}

#image-debug-dialog pre {
	clear: both;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	font-size: 13px;
	text-align: left;
}

.thumbnail-debug,
.telegram-link {
	color: #8ccfff;
	text-decoration: none;
}

.thumbnail-debug:hover,
.thumbnail-debug:focus-visible,
.telegram-link:hover,
.telegram-link:focus-visible {
	text-decoration: underline;
}

.telegram-unavailable {
	color: #777;
}

.footer {
	background: black;
	font-size: 0.8em;
	position: fixed;
	bottom: 0px;
	right: calc(50vw - 12em);
	width: 24em;
	padding: 8px;
	opacity: 0.4;

	color: white;
	text-align: center;
	transition: opacity 500ms;
}

.footer:hover {
    opacity: 1.0;
}

@media screen and (max-width: 1010px) {
	#gallery {
		width: 100%;
		margin: 0 auto;
	}
}

@media screen and (max-width: 600px) {
	#gallery-filters {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 8px;
	}
	#gallery-filters .filter-reactions,
	#gallery-filters .filter-template {
		width: 100%;
	}
	#gallery-filters .filter-search,
	#filter-status {
		grid-column: 1 / -1;
	}
}
