/* ====================================================
   ミニギャラリー＋画像ライトボックス
   base/css/profile.css 抜粋を石黒テーマ向けに移植。色は #003f88 系で固定。
   ==================================================== */

/* ---- グリッド ---------------------------------- */
.photo-container {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	column-gap: 1.2%;
	row-gap: 0.3%;
	list-style: none;
	padding-left: 0;
	margin-top: 60px;
	margin-bottom: 60px;
}

/* 行間確保のための下余白（IMG を block 化した分の補正） */
.photo-card-container {
	padding-bottom: 9px;
}
.photo-card-container img {
	width: 100%;
	object-fit: cover;
	aspect-ratio: 1 / 1;
	cursor: pointer;
	display: block;
	transition: transform 0.4s ease;
}

.image-wrapper {
	position: relative;
	overflow: hidden;
	border: 1px solid #ddd;
}
@media (hover: hover) {
	.photo-card-container:hover img { transform: scale(1.04); }
}

.mushimegane {
	position: absolute;
	bottom: 0; right: 0;
	background: #003f88;
	width: 30px; height: 30px;
	display: flex; justify-content: center; align-items: center;
	cursor: pointer;
}
.fa-solid.fa-magnifying-glass {
	font-size: .9em;
	color: #fff;
	background: #003f88;
	padding: 3px;
}

@media (max-width: 768px) {
	.module-mini-gallery { container-type: inline-size; }
	.photo-container {
		margin-top: 30px;
		column-gap: 3%; row-gap: 3cqw;
		grid-template-columns: repeat(2, 1fr);
	}
	.photo-card-container { padding-bottom: 0; }
}

/* ---- ライトボックス（base 由来：custom.css の旧定義を上書き） ----- */
.lightbox {
	position: fixed; top: 0; left: 0;
	width: 100dvw; height: 100dvh;
	background: rgba(0, 0, 0, 0.8);
	display: flex; justify-content: center; align-items: center;
	z-index: 9999;
	opacity: 0; visibility: hidden; pointer-events: none;
	/* 閉時は visibility:hidden で tab フォーカス順から外す（閉じたライトボックス内の
	   コントロールが phantom なタブ停止になるのを防ぐ）。フェードアウト後に hidden へ遅延切替。 */
	transition: opacity 0.4s ease, visibility 0s linear 0.4s;
}
.lightbox.active { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 0.4s ease, visibility 0s; }

.lightbox-content {
	position: relative;
	display: block;
	max-width: 90%;
	z-index: 10000;
}

.polaroid-frame {
	background: #fff;
	padding: 10px;
	box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
	display: flex; flex-direction: column; align-items: center;
	width: fit-content; margin: 0 auto;
	transform: scale(0.85);
	transition: transform 0.4s ease, opacity 0.3s ease-in-out;
}
.lightbox.active .polaroid-frame { transform: scale(1.0); }

#lightbox-image {
	display: block;
	width: auto;
	max-width: 100%;
	max-height: 75vh;
	height: auto;
	transform: none; /* 画像自体は変形しない（拡大アニメは .polaroid-frame 側が担当） */
	transition: none;
}

.lightbox .polaroid-frame.lb-out-next,
.lightbox .polaroid-frame.lb-out-prev { opacity: 0; transition: opacity 0.3s ease-in-out; }
.lightbox .polaroid-frame.lb-in-next,
.lightbox .polaroid-frame.lb-in-prev  { opacity: 0; transition: none; }

.lightbox-caption {
	margin-top: 10px;
	margin-bottom: 0;
	font-size: .9em;
	line-height: 1.4em;
	width: 100%;
	word-break: break-all;
	overflow-wrap: break-word;
	white-space: normal;
}
.lightbox-caption:empty { display: none; }

/* close ボタン（custom.css 旧定義を上書き）：写真フレーム下中央 */
.lightbox .close-button {
	display: none;
	position: absolute;
	top: calc(100% + 10px);
	left: calc(50% - 20px);
	transform: none;
	font-size: 32px;
	color: #fff;
	background: #003f88;
	width: 40px; height: 40px;
	line-height: 36px;
	text-align: center;
	cursor: pointer;
	user-select: none;
	padding: 0;
	border: 0;
	border-radius: 0;
}
.lightbox.active .close-button { display: block; }
@media (max-width: 768px) {
	.lightbox .close-button { left: calc(50% - 20px); }
}

/* 前後ナビゲーション
   画像のアスペクト比でボタン位置が動かないよう、画像枠（.lightbox-content）基準ではなく
   ビューポート基準（position: fixed）で画面端の一定位置に固定する。
   .lightbox / .lightbox-content に transform は無いため fixed はビューポート基準で効く。 */
.lightbox-nav {
	position: fixed; top: 50%;
	transform: translateY(-50%);
	width: 44px; height: 44px;
	background: #003f88;
	color: #fff;
	border: 0; padding: 0;
	cursor: pointer; user-select: none;
	z-index: 10001;
}
.lightbox-nav::before {
	content: "";
	position: absolute; top: 50%; left: 50%;
	width: 10px; height: 10px;
	border-top: 2px solid #fff;
	border-right: 2px solid #fff;
}
.lightbox-nav--next::before { transform: translate(-65%, -50%) rotate(45deg); }
.lightbox-nav--prev::before { transform: translate(-35%, -50%) rotate(-135deg); }
.lightbox-nav.is-hidden { display: none; }
/* ホバーで黄背景・青矢印にスワップ。ishiguro の汎用 button:hover は紺背景だが、
   こちらは詳細度（.lightbox-nav:hover）で勝つため !important は不要。 */
.lightbox-nav:hover { background: #ffc000; }
.lightbox-nav:hover::before {
	border-top-color: #003f88;
	border-right-color: #003f88;
}

/* close ボタンもホバーで黄背景・青×にスワップ。
   .lightbox .close-button:hover は汎用 button:hover より詳細度が高いため !important 不要。 */
.lightbox .close-button:hover {
	color: #003f88;
	background: #ffc000;
}
.lightbox-nav--prev { left: 20px; }
.lightbox-nav--next { right: 20px; }

/* base 仕様：tap-highlight 抑止 & フォーカスリング（マウスクリック時は出さない） */
.close-button,
.lightbox-nav { -webkit-tap-highlight-color: transparent; }

.close-button:focus,
.lightbox-nav:focus { outline: none; }

.close-button:focus-visible,
.lightbox-nav:focus-visible {
	outline: 2px solid #003f88;
	outline-offset: 2px;
}

/* base のやり方を踏襲：モーダル内はキーボード操作時のみフォーカス位置を明示する。
   :focus ではなく :focus-visible を使うことで、マウスで開いた直後の .focus() では
   枠を出さず（白枠が出る問題を回避）、キーボードで開いた／Tab 移動したときだけ
   白リング＋紺ハロー（紺ボタン＋暗幕上ではっきり視認可）を出す。色は #fff / #003f88 固定（tokens 非対応のため）。 */
.lightbox.active :is(a[href], button, input, [tabindex]):focus-visible {
	outline: 3px solid #fff;
	outline-offset: 2px;
	box-shadow: 0 0 0 2px #003f88;
}

@media (max-width: 768px) {
	.lightbox-content { max-width: calc(100% - 90px); }
	.lightbox-nav { width: 36px; height: 36px; }
	.lightbox-nav::before { width: 8px; height: 8px; }
	.lightbox-nav--prev { left: 8px; }
	.lightbox-nav--next { right: 8px; }
}

/* ====================================================
   マーキーギャラリー（全幅エンドレススクロール）
   base/css/style.css の gallery-loop を石黒テーマ向けに移植。
   下端を SNS 帯（黄色帯）に密着させるため下余白は持たせない。
   ==================================================== */
.section-gallery-loop { margin-top: 60px; margin-bottom: 0; padding: 0; }

/* 自動送り・手動ドラッグ/スワイプ・継ぎ目なしループは js/common.js（または mini-gallery.js）が transform で制御 */
.gallery-loop {
	overflow: hidden; width: 100%; margin: 0 auto;
	touch-action: pan-y;            /* 縦はページスクロール、横はドラッグ操作に回す */
	cursor: grab; user-select: none; -webkit-user-select: none;
}
.gallery-loop.is-dragging, .gallery-loop.is-dragging .gallery-loop__img { cursor: grabbing; }
.gallery-loop__track { display: flex; width: max-content; will-change: transform; }
/* キーボードフォーカス枠（.image-wrapper の overflow で見切れるため内側に描く・色は直書き） */
.gallery-loop .image-thumbnail:focus-visible { outline: 2px solid #003f88; outline-offset: -3px; }
/* JS のライトボックス走査用に .photo-container を流用するが、grid を flex で上書き */
.gallery-loop .photo-container {
	display: flex; flex-wrap: nowrap; gap: 0;
	width: max-content; margin: 0; padding: 0;
}
.gallery-loop__item { list-style: none; flex: 0 0 auto; }
.gallery-loop .image-wrapper { border: 0; }
.gallery-loop__img { height: 260px; width: auto; display: block; -webkit-user-drag: none; }
@media (max-width: 768px) {
	.section-gallery-loop { margin-top: 30px; }
	.gallery-loop__img { height: 220px; }
}
