/**
 * Thipocha Gallery
 *
 * ทุกคลาสขึ้นต้นด้วย tpg- และทุกค่าที่ธีมอาจแทรกแซงถูกกำหนดทับไว้ชัดเจน
 * เพื่อให้หน้าตาไม่เพี้ยนเมื่อ Flatsome อัปเดตหรือเปลี่ยนสไตล์ของปุ่ม/รูป
 */

.tpg {
	--tpg-cols: 4;
	--tpg-cat-cols: 3;
	--tpg-gap: 14px;
	--tpg-radius: 0px;
	/*
	 * 3:2 คืออัตราส่วนของกล้องถ่ายรูป และเป็นอัตราส่วนของภาพในเว็บนี้เกือบทั้งหมด
	 * จึงแสดงได้เต็มภาพโดยแทบไม่ต้องตัดขอบ
	 * บนจอมือถือช่องภาพจะแคบจนเตี้ยเกินไป จึงสลับเป็น 4:3 ในจอเล็ก
	 *
	 * แยกเป็นสองตัวแปรเพราะค่าที่ตั้งจากหน้าแอดมินถูกใส่มาเป็นสไตล์ติดกับแท็ก
	 * ซึ่งมีน้ำหนักเหนือกว่ากฎในไฟล์นี้เสมอ ถ้าเขียนทับตัวเดียวกันโดยตรง
	 * กฎสำหรับจอเล็กจะไม่มีผล จึงให้แอดมินกำหนดเฉพาะค่าของจอใหญ่
	 */
	--tpg-ratio-wide: 3 / 2;
	--tpg-ratio: var(--tpg-ratio-wide);
	--tpg-ink: #3d3227;
	--tpg-muted: #8a7f72;
	--tpg-line: #e6ded3;
	--tpg-accent: #8c6d3f;
	--tpg-bg-card: #faf7f2;
	--tpg-shadow: 0 2px 10px rgba(61, 50, 39, .08);
	--tpg-shadow-hi: 0 10px 28px rgba(61, 50, 39, .16);

	position: relative;
	color: var(--tpg-ink);
}

.tpg *,
.tpg *::before,
.tpg *::after {
	box-sizing: border-box;
}

/* ---------------------------------------------------------- แถบบน */

.tpg-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 22px;
	padding-bottom: 14px;
	border-bottom: 1px solid var(--tpg-line);
}

.tpg-crumbs {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	min-height: 30px;
	font-size: 15px;
	line-height: 1.4;
}

.tpg-crumb {
	display: inline-flex;
	align-items: center;
	padding: 4px 10px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: var(--tpg-accent);
	font: inherit;
	cursor: pointer;
	transition: background .18s ease, color .18s ease;
}

.tpg-crumb:hover,
.tpg-crumb:focus-visible {
	background: var(--tpg-bg-card);
	color: var(--tpg-ink);
}

.tpg-crumb[aria-current="page"] {
	color: var(--tpg-ink);
	font-weight: 600;
	cursor: default;
}

.tpg-crumb-sep {
	color: var(--tpg-muted);
	font-size: 13px;
	user-select: none;
}

/* ปุ่มเปิด-ปิดคำบรรยาย */

.tpg-cap-btn {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	margin: 0;
	padding: 7px 15px;
	border: 1px solid var(--tpg-line);
	border-radius: 999px;
	background: #fff;
	color: var(--tpg-muted);
	font: inherit;
	font-size: 14px;
	line-height: 1;
	cursor: pointer;
	transition: border-color .18s ease, color .18s ease, background .18s ease;
}

.tpg-cap-btn:hover {
	border-color: var(--tpg-accent);
	color: var(--tpg-ink);
}

.tpg-cap-btn[aria-pressed="true"] {
	border-color: var(--tpg-accent);
	background: var(--tpg-accent);
	color: #fff;
}

.tpg-cap-dot {
	position: relative;
	width: 30px;
	height: 16px;
	border-radius: 999px;
	background: var(--tpg-line);
	transition: background .18s ease;
	flex: none;
}

.tpg-cap-dot::after {
	content: "";
	position: absolute;
	top: 2px;
	left: 2px;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
	transition: transform .18s ease;
}

.tpg-cap-btn[aria-pressed="true"] .tpg-cap-dot {
	background: rgba(255, 255, 255, .45);
}

.tpg-cap-btn[aria-pressed="true"] .tpg-cap-dot::after {
	transform: translateX(14px);
}

/* ---------------------------------------------------------- กริด */

.tpg-view[hidden] {
	display: none;
}

.tpg-grid {
	display: grid;
	gap: var(--tpg-gap);
	margin: 0 0 var(--tpg-gap);
	padding: 0;
	list-style: none;
}

.tpg-grid--cats {
	grid-template-columns: repeat(var(--tpg-cat-cols), minmax(0, 1fr));
}

.tpg-grid--photos {
	grid-template-columns: repeat(var(--tpg-cols), minmax(0, 1fr));
}

/* การ์ดหมวด */

.tpg-card {
	display: block;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border: 1px solid var(--tpg-line);
	border-radius: var(--tpg-radius);
	background: var(--tpg-bg-card);
	box-shadow: var(--tpg-shadow);
	color: inherit;
	font: inherit;
	text-align: left;
	cursor: pointer;
	transition: transform .25s ease, box-shadow .25s ease;
}

.tpg-card:hover,
.tpg-card:focus-visible {
	transform: translateY(-3px);
	box-shadow: var(--tpg-shadow-hi);
}

.tpg-card-img {
	display: block;
	position: relative;
	overflow: hidden;
	aspect-ratio: var(--tpg-ratio);
	background: #ece5db;
}

.tpg-card:hover .tpg-card-img .tpg-img {
	transform: scale(1.05);
}

.tpg-card-body {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 10px;
	padding: 13px 16px 15px;
}

.tpg-card-name {
	font-size: 17px;
	font-weight: 600;
	line-height: 1.35;
}

.tpg-card-count {
	flex: none;
	color: var(--tpg-muted);
	font-size: 13px;
}

/* รูปในกริด */

.tpg-item {
	margin: 0;
	padding: 0;
}

.tpg-shot {
	display: block;
	position: relative;
	width: 100%;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border: 0;
	border-radius: var(--tpg-radius);
	background: #ece5db;
	aspect-ratio: var(--tpg-ratio);
	cursor: zoom-in;
	box-shadow: var(--tpg-shadow);
	transition: box-shadow .25s ease;
}

.tpg-shot:hover,
.tpg-shot:focus-visible {
	box-shadow: var(--tpg-shadow-hi);
}

.tpg-shot:hover .tpg-img {
	transform: scale(1.06);
}

/* กันธีมมายุ่งกับรูปข้างใน */
.tpg .tpg-img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	object-fit: cover;
	box-shadow: none;
	transition: transform .6s cubic-bezier(.22, .61, .36, 1);
}

.tpg-img--none {
	background: repeating-linear-gradient(45deg, #ece5db, #ece5db 10px, #e3dace 10px, #e3dace 20px);
}

/* คำบรรยายใต้รูป */

/*
 * คำบรรยายมาจากชื่อไฟล์ซึ่งยาวมาก จึงตัดเหลือ 2 บรรทัด
 * เพื่อไม่ให้ความสูงของแต่ละช่องในกริดต่างกันจนดูไม่เป็นระเบียบ
 * ข้อความเต็มยังอ่านได้จาก tooltip และในหน้าต่างดูรูปใหญ่
 */
.tpg-caption {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	margin: 8px 2px 0;
	color: var(--tpg-muted);
	font-size: 12.5px;
	line-height: 1.45;
	word-break: break-word;
}

.tpg[data-captions="off"] .tpg-caption {
	display: none;
}

.tpg-empty {
	margin: 30px 0;
	color: var(--tpg-muted);
	text-align: center;
}

/* ---------------------------------------------------------- lightbox */

.tpg-lb {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 4vh 4vw;
	background: rgba(28, 22, 16, .95);
	animation: tpg-fade .2s ease;
}

.tpg-lb[hidden] {
	display: none;
}

@keyframes tpg-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}

.tpg-lb-figure {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
	max-width: 100%;
	max-height: 100%;
	margin: 0;
}

.tpg-lb-img {
	max-width: 100%;
	max-height: 82vh;
	width: auto;
	height: auto;
	object-fit: contain;
	box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}

.tpg-lb-cap {
	max-width: 760px;
	color: rgba(255, 255, 255, .82);
	font-size: 13.5px;
	line-height: 1.5;
	text-align: center;
	word-break: break-word;
}

.tpg[data-captions="off"] .tpg-lb-cap {
	display: none;
}

/*
 * ธีมมักตั้ง min-height, line-height และ padding ให้ปุ่มทุกตัวในเว็บ
 * ซึ่งจะยืดปุ่มกลมให้กลายเป็นวงรี จึงต้องกำหนดค่าเหล่านี้ทับให้ชัดเจนทุกตัว
 * และเขียนตัวเลือกให้เจาะจงกว่าของธีมเพื่อให้ชนะโดยไม่ต้องพึ่ง !important
 */
.tpg .tpg-lb-close,
.tpg .tpg-lb-nav {
	position: absolute;
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: rgba(255, 255, 255, .1);
	color: #fff;
	font-family: inherit;
	font-weight: 400;
	line-height: 1;
	letter-spacing: normal;
	text-transform: none;
	text-shadow: none;
	box-shadow: none;
	cursor: pointer;
	transition: background .18s ease, transform .18s ease;
	-webkit-tap-highlight-color: transparent;
	-webkit-appearance: none;
	appearance: none;
}

.tpg .tpg-lb-close:hover,
.tpg .tpg-lb-nav:hover {
	background: rgba(255, 255, 255, .22);
}

/*
 * ธีมบางตัวตั้งความสูงขั้นต่ำของปุ่มไว้แบบบังคับ (!important)
 * ซึ่งจะดันปุ่มปิดที่ต้องเป็นวงกลมให้ยืดเป็นวงรี
 * กรณีนี้เป็นที่เดียวในไฟล์ที่ต้องใช้การบังคับกลับ เพราะไม่มีวิธีอื่นที่ชนะได้
 */
.tpg .tpg-lb-close {
	top: 18px;
	right: 18px;
	width: 44px !important;
	height: 44px !important;
	min-width: 44px !important;
	min-height: 44px !important;
	max-width: 44px !important;
	max-height: 44px !important;
	border-radius: 50%;
	font-size: 26px;
}

.tpg .tpg-lb-nav {
	top: 50%;
	width: 50px !important;
	height: 76px !important;
	min-width: 50px !important;
	min-height: 76px !important;
	max-width: 50px !important;
	max-height: 76px !important;
	border-radius: 8px;
	font-size: 22px;
	transform: translateY(-50%);
}

.tpg-lb-prev { left: 14px; }
.tpg-lb-next { right: 14px; }

.tpg-lb-counter {
	position: absolute;
	bottom: 20px;
	left: 50%;
	transform: translateX(-50%);
	color: rgba(255, 255, 255, .6);
	font-size: 13px;
	letter-spacing: .06em;
}

/* กันหน้าเว็บเลื่อนตอนเปิด lightbox */
body.tpg-lock {
	overflow: hidden;
}

/* ---------------------------------------------------------- จอเล็ก */

@media (max-width: 1024px) {
	.tpg-grid--photos {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.tpg-grid--cats {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 640px) {
	.tpg {
		--tpg-gap: 10px;
		/* ช่องภาพแคบลงมากในจอเล็ก จึงเพิ่มความสูงให้ภาพไม่ดูเป็นแถบเตี้ย */
		--tpg-ratio: 4 / 3;
	}

	.tpg-grid--photos {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.tpg-grid--cats {
		grid-template-columns: 1fr;
	}

	.tpg-bar {
		align-items: flex-start;
	}

	.tpg-card-name {
		font-size: 16px;
	}

	.tpg-lb {
		padding: 0;
	}

	.tpg-lb-img {
		max-height: 74vh;
		border-radius: 0;
	}

	/* ต้องเจาะจงและบังคับเท่ากับกฎของจอใหญ่ ไม่งั้นขนาดใหม่จะไม่มีผล */
	.tpg .tpg-lb-nav {
		width: 42px !important;
		height: 62px !important;
		min-width: 42px !important;
		min-height: 62px !important;
		max-width: 42px !important;
		max-height: 62px !important;
	}

	.tpg-lb-prev { left: 6px; }
	.tpg-lb-next { right: 6px; }

	.tpg .tpg-lb-close {
		top: 10px;
		right: 10px;
		width: 40px !important;
		height: 40px !important;
		min-width: 40px !important;
		min-height: 40px !important;
		max-width: 40px !important;
		max-height: 40px !important;
	}
}

/* เคารพการตั้งค่าลดการเคลื่อนไหวของผู้ใช้ */
@media (prefers-reduced-motion: reduce) {
	.tpg *,
	.tpg *::before,
	.tpg *::after {
		transition-duration: .01ms !important;
		animation-duration: .01ms !important;
	}
}
