/*
 * 記事画像の拡大表示。
 *
 * theme の色や font に寄りかからない。overlay は固定色で、閉じれば痕跡が残らない。
 * z-index は既存の最大（100000）より上に 1 段だけ置く。
 */

.pcpe-viewer {
	position: fixed;
	inset: 0;
	z-index: 1000000;
	display: flex;
	flex-direction: column;
	background: rgba(0, 0, 0, .92);
	/* 開いていないときは DOM に居るだけで何も起きない。 */
	visibility: hidden;
	opacity: 0;
	transition: opacity .15s ease;
}

.pcpe-viewer.is-open {
	visibility: visible;
	opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
	.pcpe-viewer { transition: none; }
}

/* --- 画像 --- */

.pcpe-viewer__stage {
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 12px;
}

.pcpe-viewer__img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	/* 縦長でも横長でも比率を保ったまま画面内に収める。 */
	object-fit: contain;
	background: rgba(255, 255, 255, .04);
}

/* --- 操作 --- */

.pcpe-viewer__btn {
	position: absolute;
	z-index: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	min-height: 44px;
	padding: 0;
	border: 1px solid rgba(255, 255, 255, .35);
	border-radius: 4px;
	background: rgba(0, 0, 0, .45);
	color: #fff;
	font: inherit;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
}

.pcpe-viewer__btn:hover,
.pcpe-viewer__btn:focus-visible {
	border-color: #fff;
	background: rgba(0, 0, 0, .7);
}

.pcpe-viewer__btn[hidden] { display: none; }

.pcpe-viewer__close { top: 10px; right: 10px; }
.pcpe-viewer__prev  { top: 50%; left: 10px; transform: translateY(-50%); }
.pcpe-viewer__next  { top: 50%; right: 10px; transform: translateY(-50%); }

.pcpe-viewer__count {
	position: absolute;
	top: 18px;
	left: 14px;
	color: rgba(255, 255, 255, .7);
	font-size: 13px;
	line-height: 1;
}

/* --- 撮影情報 --- */

.pcpe-viewer__meta {
	flex: 0 0 auto;
	max-height: 34vh;
	overflow-y: auto;
	padding: 10px 14px 14px;
	color: rgba(255, 255, 255, .85);
	font-size: 13px;
	line-height: 1.6;
}

.pcpe-viewer__meta[hidden] { display: none; }

.pcpe-viewer__caption {
	margin: 0 0 6px;
	color: rgba(255, 255, 255, .7);
	font-size: 12px;
	word-break: break-word;
}

.pcpe-viewer__exif {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 14px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.pcpe-viewer__exif li {
	margin: 0;
	white-space: nowrap;
}

.pcpe-viewer__exif .pcpe-viewer__label {
	margin-inline-end: .4em;
	opacity: .6;
	font-size: 11px;
	letter-spacing: .04em;
	text-transform: uppercase;
}

/* lens や camera は長いので折り返しを許す。 */
.pcpe-viewer__exif li.is-long { white-space: normal; }

/*
 * リンクされていない viewer 対象画像。
 * class は JS が実行時に付けるので、JS が無効なら見た目も挙動も変わらない。
 * theme の全画像へは当てない。
 */
.pcpe-viewer-target {
	cursor: zoom-in;
}

.pcpe-viewer-target:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/*
 * カジュアルな保存の抑止。
 *
 * mobile の長押しメニューとドラッグ保存を一手間かけさせるだけで、完全な
 * コピー防止ではない。img だけに当てる。本文テキストの選択は止めない。
 * この CSS は single post でしか読み込まれないので、header logo や
 * navigation の画像には掛からない。
 */
.entry-content img,
.pcpe-viewer__img {
	-webkit-touch-callout: none;
	-webkit-user-drag: none;
	user-drag: none;
	-webkit-user-select: none;
	user-select: none;
}

/* 背面のスクロールを止める。 */
body.pcpe-viewer-open { overflow: hidden; }

@media (max-width: 600px) {
	.pcpe-viewer__stage { padding: 8px; }
	.pcpe-viewer__meta { font-size: 12px; padding: 8px 12px 12px; }
	.pcpe-viewer__prev { left: 6px; }
	.pcpe-viewer__next { right: 6px; }
	.pcpe-viewer__exif { gap: 3px 10px; }
}
