/* 114 學年度工學院專題競賽 — 活動相簿
 *
 * 刻意不依賴任何外部套件或 CDN：本站的 skel/jQuery 都是離線檔，
 * 相簿也維持同樣可離線、可整包搬移的特性。
 *
 * 這份 CSS 同時被兩個頁面使用：
 *   photo-gallery/index.html  獨立版（body 帶 .gallery-standalone）
 *   photo2025.html            嵌入本站 Ion 模板的版本
 * 所以所有樣式都收斂在 #gallery-root 底下，避免和本站的 style.css 打架。
 */

#gallery-root,
#gallery-root * { box-sizing: border-box; }

#gallery-root {
	color: #4c4c4c;
	font-family: "Helvetica Neue", Helvetica, Arial, "微軟正黑體",
		"Microsoft JhengHei", sans-serif;
}

/* 獨立開啟 index.html 時才套用的頁面外框 */
body.gallery-standalone {
	margin: 0;
	padding: 0 14px 40px;
	background: #fff;
	-webkit-text-size-adjust: 100%;
}

/* ---------------------------------------------------------- 頂端計數列 */

#gallery-root #bar {
	padding: 14px 2px 12px;
	font-size: 0.85em;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: #9a9a9a;
}

/* ---------------------------------------------------------- 縮圖牆 */

#gallery-root #grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
	gap: 10px;
}

#gallery-root .cell {
	position: relative;
	display: block;
	width: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	background: #f0f0f0;
	cursor: pointer;
	border-radius: 3px;
}

#gallery-root .cell img {
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	display: block;
	margin: 0;
	border: 0;
	border-radius: 0;
	opacity: 0;
	transition: opacity 0.35s ease, transform 0.35s ease;
}

#gallery-root .cell img.ready { opacity: 1; }

#gallery-root .cell:hover img,
#gallery-root .cell:focus img { transform: scale(1.06); }

#gallery-root .cell:focus-visible {
	outline: 3px solid #21b2a6;
	outline-offset: 2px;
}

/* aspect-ratio 在較舊的瀏覽器沒有支援，退回用 padding-top 撐出正方形 */
@supports not (aspect-ratio: 1 / 1) {
	#gallery-root .cell { height: 0; padding-top: 100%; }
	#gallery-root .cell img { position: absolute; top: 0; left: 0; }
}

#gallery-root #empty {
	padding: 40px 0;
	color: #999;
	text-align: center;
}

#gallery-root #sentinel { height: 1px; }

/* ---------------------------------------------------------- 燈箱
 *
 * 燈箱的樣式刻意「不」收在 #gallery-root 底下：gallery.js 會在啟動時
 * 把 #lightbox 搬到 <body> 最後面。
 *
 * 原因是 skel-layers.min.js 會把頁首搬進另一個 #skel-layers-visibleWrapper，
 * 讓它變成相簿所在容器的「後方兄弟節點」。留在原地的話，就算 z-index 一樣大
 * 頁首還是會蓋在燈箱上面，關閉鈕和計數都會被擋住。
 */

#lightbox {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 100000;
	background: rgba(0, 0, 0, 0.93);
	display: flex;
	align-items: center;
	justify-content: center;
	font-family: "Helvetica Neue", Helvetica, Arial, "微軟正黑體",
		"Microsoft JhengHei", sans-serif;
}

#lightbox, #lightbox * { box-sizing: border-box; }

#lightbox[hidden] { display: none; }

#lb-stage {
	position: relative;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 62px 64px 28px;
}

#lb-img {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	border: 0;
	border-radius: 0;
	opacity: 0;
	transition: opacity 0.25s ease;
	touch-action: pan-y;
}

#lb-img.ready { opacity: 1; }

#lb-spinner {
	position: absolute;
	width: 42px;
	height: 42px;
	border: 3px solid rgba(255, 255, 255, 0.25);
	border-top-color: #fff;
	border-radius: 50%;
	animation: gallery-spin 0.8s linear infinite;
}

#lb-spinner[hidden] { display: none; }

@keyframes gallery-spin { to { transform: rotate(360deg); } }

#lb-top {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	display: flex;
	align-items: center;
	gap: 18px;
	padding: 14px 18px;
	color: #fff;
	font-size: 0.9em;
	background: linear-gradient(rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
}

#lb-count { letter-spacing: 0.08em; }

#lb-hint { color: rgba(255, 255, 255, 0.5); }

#lb-download {
	color: #fff;
	text-decoration: none;
	border: 0;
	border-bottom: 1px solid rgba(255, 255, 255, 0.45);
	padding-bottom: 1px;
}

#lb-download:hover { border-bottom-color: #fff; }

#lb-close {
	margin-left: auto;
	font-size: 30px;
	line-height: 1;
}

#lb-close,
#lb-prev,
#lb-next {
	background: none;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	color: #fff;
	cursor: pointer;
	padding: 8px 14px;
	height: auto;
	line-height: 1;
	opacity: 0.72;
	transition: opacity 0.2s ease;
	font-family: inherit;
	text-transform: none;
}

#lb-close:hover,
#lb-prev:hover,
#lb-next:hover { opacity: 1; }

#lb-prev,
#lb-next {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	font-size: 34px;
	text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

#lb-prev { left: 4px; }
#lb-next { right: 4px; }

#lb-prev[disabled],
#lb-next[disabled] { opacity: 0.18; cursor: default; }

/* 燈箱開啟時鎖住背景捲動 */
body.gallery-lightbox-open { overflow: hidden; }

/* ---------------------------------------------------------- 手機 */

@media screen and (max-width: 736px) {
	body.gallery-standalone { padding: 0 8px 24px; }

	#gallery-root #grid {
		grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
		gap: 6px;
	}

	#lb-stage { padding: 56px 10px 20px; }

	#lb-prev,
	#lb-next { font-size: 26px; padding: 8px 6px; }

	#lb-top { gap: 12px; font-size: 0.82em; }

	#lb-hint { display: none; }
}
