
/**************** Style ****************/

/* Gallery */

div.gallery {
	display: block;
	width: 100%;
	margin: 0 auto 12px;
}

div.gallery div.tab {
	display: flex;
	justify-content: space-between;
	align-items: center;
	min-height: 32px;
	margin: 0 0 12px;
	padding: 8px 0;
	border-bottom: 2px solid var(--border-primary);
	background: var(--bg-row-even);
	border-radius: 4px;
}

div.gallery div.tab div.tab_left {
	flex: 1;
	margin: 0;
	font-weight: 500;
	color: var(--text-primary);
}

div.gallery div.tab div.tab_right {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 8px;
	margin: 0;
}

div.gallery div.tab div.tab_right a {
	color: var(--text-primary);
	font-size: 14px;
	padding: 6px 12px;
	text-decoration: none;
	white-space: nowrap;
	display: inline-block;
	margin: 4px 2px;
	border-radius: 0.5rem;
	transition: all 0.2s ease;
}

div.gallery div.tab div.tab_right a.active {
	font-weight: bold;
	background-color: var(--main-color);
	color: var(--main-contrast);
	border-bottom: 2px solid var(--border-primary);
}

div.gallery div.tab div.tab_right a:hover {
	color: var(--link-hover);
	background-color: var(--main-color);
	transform: translateY(-1px);
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

div.gallery div.picture {
	display: block;
	margin: 0 0 2px;
	text-align: center;
}

div.gallery ul.overview {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
	gap: 16px;
	width: 100%;
	margin: 0;
	padding: 2px 0;
	list-style-type: none;
}

div.gallery ul.overview li {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	background: var(--bg-row-even);
	border: 1px solid var(--border-primary);
	border-radius: 0.75rem;
	padding: 12px;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
	transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

div.gallery ul.overview li:hover {
	transform: translateY(-2px);
	box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
	border-color: var(--border-primary);
}

div.gallery ul.overview li a {
	text-decoration: none;
	width: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
}

div.gallery ul.overview li img {
	width: 100%;
	height: 140px !important;
	padding: 4px;
	border: 2px solid var(--border-light);
	border-radius: 6px;
	box-sizing: border-box;
	object-fit: cover;
	transition: border-color 0.2s ease, transform 0.2s ease;
	background: var(--bg-row-odd);
}

div.gallery ul.overview li img:hover {
	border-color: var(--link-hover);
	transform: scale(1.02);
}

div.gallery div.title {
	display: block;
	margin: 0 0 2px;
	text-align: center;
	font-weight: bold;
}

div.gallery div.descr {
	display: block;
	margin: 0 0 2px;
	text-align: center;
}

div.gallery div.info {
	display: block;
	margin: 0 0 2px;
	text-align: center;
}

div.gallery div.zoom_link {
	display: block;
	text-align: center;
}

div.gallery div.zoom_link a {
	font-size: 11px;
	text-decoration: none;
}

div.gallery .hide {
	display: none;
}


/* Overlay */

#overlay {
	position: fixed;
	overflow: hidden;
	z-index: 100;
	top: 0;
	left: 0;
	width: 100%;
	height: 100vh;
	display: none;
	background-color: var(--overlay-bg);
	backdrop-filter: blur(4px);
}

#overlay div.screen {
	position: relative;
	width: 90%;
	min-height: 200px;
	z-index: 101;
	margin: 20px auto;
	padding: 24px;
	background-color: var(--overlay-screen-bg);
	border: 1px solid var(--overlay-screen-border);
	border-radius: 12px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

#overlay div.picture {
	text-align: center;
	margin: 0 auto 5px;
	max-width: 100%;
	max-height: 80vh;
	overflow: hidden;
}

#overlay div {
	color: var(--overlay-text);
}

#overlay .hide {
	display: none;
}

#go_pic {
	max-width: 100%;
	max-height: 80vh;
	margin: 0 auto;
	box-sizing: border-box;
}

#go_pic_img {
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: 100%;
	display: block;
	margin: 0 auto;
	object-fit: contain;
}

#go_pic_info {
	width: 20%;
	float: left;
}

#go_pic_title {
	width: 80%;
	float: right;
	font-weight: bold;
}

#go_pic_descr {
	width: 80%;
	float: right;
}

#go_pic_close {
	position: absolute;
	top: 10px;
	right: 10px;
	height: 32px;
	width: 32px;
	cursor: pointer;
	background: url(buttons.png) no-repeat -32px -128px;
	z-index: 120;
}

#go_pic_close:hover {
	background-position: 0 -128px;
}

#go_pic_prev {
	position: absolute;
	overflow: hidden;
	top: 50%;
	left: 0;
	height: 64px;
	width: 64px;
	cursor: pointer;
	background: url(buttons.png) no-repeat -64px 0;
	transform: translateY(-50%);
	z-index: 110;
}

#go_pic_prev_a {
	position: absolute;
	top: 0;
	left: 0;
	height: 64px;
	width: 64px;
}

#go_pic_prev:hover {
	background-position: 0 0;
}

#go_pic_next {
	position: absolute;
	overflow: hidden;
	top: 50%;
	right: 0;
	height: 64px;
	width: 64px;
	cursor: pointer;
	background: url(buttons.png) no-repeat -64px -64px;
	transform: translateY(-50%);
	z-index: 110;
}

#go_pic_next_a {
	position: absolute;
	top: 0;
	left: 0;
	height: 64px;
	width: 64px;
}

#go_pic_next:hover {
	background-position: 0 -64px;
}


/* Teaser */

div.gallery_teaser {
	display: block;
	width: 100%;
	height: 100%;
}

div.gallery_teaser td {
	height: 130px;
	vertical-align: middle;
}

div.gallery_teaser td.caption {
	width: 192px;
}

div.gallery_teaser td.caption td {
	height: 65px;
}

div.gallery_teaser td.image {
	width: 140px;
	text-align: center;
}

/* Responsive styles */

@media (max-width: 768px) {
	div.gallery div.tab {
		height: auto;
		padding: 12px;
		flex-direction: column;
		align-items: stretch;
		gap: 8px;
	}
	
	div.gallery ul.overview {
		grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
		gap: 12px;
	}
	
	div.gallery ul.overview li {
		padding: 8px;
	}
	
	div.gallery div.tab div.tab_left {
		width: 100%;
		position: static;
		margin-bottom: 4px;
	}
	
	div.gallery div.tab div.tab_right {
		width: 100%;
		position: static;
		text-align: center;
		margin-bottom: 10px;
		justify-content: center;
	}
	
	div.gallery div.tab div.tab_right a.page_link {
		display: inline-block;
		margin: 2px 4px;
		padding: 4px 8px;
		font-size: 14px;
		white-space: normal;
	}
	
	#overlay div.screen {
		width: 95%;
		padding: 16px;
		margin: 10px auto;
		height: auto;
		max-height: 95vh;
		box-sizing: border-box;
	}
	
	#go_pic_info {
		width: 100%;
		float: none;
		margin-bottom: 10px;
	}
	
	#go_pic_title {
		width: 100%;
		float: none;
	}
	
	#go_pic_descr {
		width: 100%;
		float: none;
	}
}

@media (max-width: 480px) {
	div.gallery ul.overview {
		grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
		gap: 8px;
	}
	
	div.gallery ul.overview li {
		padding: 6px;
	}
	
	#overlay div.screen {
		position: fixed;
		top: 0;
		left: 0;
		width: 100vw;
		height: 100vh;
		margin: 0;
		padding: 0;
		border: none;
		border-radius: 0;
		box-sizing: border-box;
		overflow: hidden;
	}
	
	#go_pic_prev, #go_pic_next {
		top: 80%;
	}
	
	#overlay div.picture {
		margin-top: 50px; /* space for close button */
		max-height: calc(80vh - 50px); /* leave space for prev/next and below content */
	}
	
	#go_pic {
		max-height: calc(80vh - 50px);
	}
	
	div.gallery div.tab div.tab_right a.page_link {
		padding: 4px 6px;
		font-size: 12px;
		margin: 2px 2px;
	}
}
