/* ==================================================
   カタログ電子ブック（ページめくり）ビューア
   js/catalog-flipbook.js と対で使用
   ================================================== */

html.flipbook-locked { overflow: hidden; }

/* =========================================================
   共有ビューア（モーダル／インライン共通）
   ルート = .flipbook-viewer
   構成 = .flipbook-canvas（描画エリア） + .flipbook-bar（操作帯）
   ========================================================= */
.flipbook-viewer {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100%;
}

/* 描画エリア（ここに本を 約90% で contain 表示） */
.flipbook-canvas {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	touch-action: none;
}
.flipbook-canvas.is-zoomed { cursor: grab; }
.flipbook-canvas.is-zoomed:active { cursor: grabbing; }

.flipbook-stage {
	margin: 0 auto;
	transform-origin: center center;
	transition: transform 0.2s ease;
	will-change: transform;
}
.flipbook-viewer.is-loading .flipbook-stage { visibility: hidden; }
/* ズーム中はパンを即時反映（カクつき防止） */
.flipbook-canvas.is-zoomed .flipbook-stage { transition: none; }

/* ページ */
.flipbook__page {
	background: #fff;
	overflow: hidden;
	-webkit-box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
	box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
}
/* 未描画ページのプレースホルダ（遅延レンダリング中） */
.flipbook__page.is-rendering {
	background: #eef0f3;
}
.flipbook__page.is-rendering::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 32px;
	height: 32px;
	margin: -16px 0 0 -16px;
	border: 3px solid rgba(0, 0, 0, 0.15);
	border-top-color: rgba(0, 0, 0, 0.4);
	border-radius: 50%;
	-webkit-animation: flipbook-spin 0.8s linear infinite;
	animation: flipbook-spin 0.8s linear infinite;
}
.flipbook__page { position: relative; }
.flipbook__page img {
	position: relative;
	width: 100%;
	height: 100%;
	display: block;
	-o-object-fit: fill;
	object-fit: fill;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
	pointer-events: none;
}

/* 左右クリック領域（一定のめくり） */
.flipbook-zone {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 32%;
	z-index: 3;
	display: flex;
	align-items: center;
	cursor: pointer;
}
.flipbook-zone--prev { left: 0; justify-content: flex-start; }
.flipbook-zone--next { right: 0; justify-content: flex-end; }
.flipbook-canvas.is-zoomed .flipbook-zone { pointer-events: none; }
.flipbook-viewer.is-loading .flipbook-zone { pointer-events: none; }

/* ホバー時のめくりヒント */
.flipbook-zone__hint {
	position: relative;
	width: 54px;
	height: 54px;
	margin: 0 1.4rem;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.35);
	opacity: 0;
	transition: opacity 0.25s ease;
}
.flipbook-zone:hover .flipbook-zone__hint { opacity: 1; }
.flipbook-zone__hint::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 14px;
	height: 14px;
	border-top: 2px solid #fff;
	border-right: 2px solid #fff;
}
.flipbook-zone--next .flipbook-zone__hint::before { transform: translate(-65%, -50%) rotate(45deg); }
.flipbook-zone--prev .flipbook-zone__hint::before { transform: translate(-35%, -50%) rotate(-135deg); }

/* ローダー */
.flipbook-loader {
	position: absolute;
	inset: 0;
	z-index: 4;
	display: none;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	color: #fff;
}
.flipbook-viewer.is-loading .flipbook-loader { display: flex; }
.flipbook-spinner {
	width: 48px;
	height: 48px;
	border: 4px solid rgba(255, 255, 255, 0.25);
	border-top-color: #fff;
	border-radius: 50%;
	-webkit-animation: flipbook-spin 0.8s linear infinite;
	animation: flipbook-spin 0.8s linear infinite;
}
.flipbook-loader-text { font-size: 0.9rem; letter-spacing: 0.08em; }
@-webkit-keyframes flipbook-spin { to { -webkit-transform: rotate(360deg); transform: rotate(360deg); } }
@keyframes flipbook-spin { to { -webkit-transform: rotate(360deg); transform: rotate(360deg); } }

/* =========================================================
   スマホ表示：めくらずに縦スクロールで読む
   （iOS/Androidは iframe でPDFを表示できないため PDF.js の描画を縦に積む）
   ========================================================= */
.flipbook-canvas.flipbook-canvas--scroll {
	display: block;
	overflow-x: hidden;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain; /* 端まで行ってもページ側へスクロールを渡さない */
	touch-action: pan-y;
	padding: 10px;
	background: #d7dadf;
}
.flipbook-canvas--scroll .flipbook-stage {
	width: 100%;
	max-width: none;
	min-width: 0;
	min-height: 0;
	margin: 0;
	transform: none;
	transition: none;
	will-change: auto;
}
.flipbook-scroll__page {
	position: relative;
	width: 100%;
	margin: 0 0 10px;
	overflow: hidden;
	background: #fff;
	-webkit-box-shadow: 0 0 6px rgba(0, 0, 0, 0.18);
	box-shadow: 0 0 6px rgba(0, 0, 0, 0.18);
}
.flipbook-scroll__page:last-child { margin-bottom: 0; }
.flipbook-scroll__page img {
	display: block;
	width: 100%;
	height: auto;
}
.flipbook-scroll__page.is-rendering { background: #eef0f3; }
/* スクロール表示で使わないUIは出さない */
.flipbook-viewer.is-scroll .flipbook-zone,
.flipbook-viewer.is-scroll .flipbook-btn[data-act="zoomin"],
.flipbook-viewer.is-scroll .flipbook-btn[data-act="zoomout"],
.flipbook-viewer.is-scroll .flipbook-btn[data-act="fullscreen"] { display: none; }
.flipbook-viewer.is-scroll .flipbook-bar__divider--zoom { display: none; }

/* =========================================================
   操作帯（参考デザイン準拠の下部バー）
   ========================================================= */
.flipbook-bar {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.6rem;
	height: 60px;
	padding: 0 1rem;
	background: #3b4049;
	color: #fff;
}
.flipbook-bar__divider {
	width: 1px;
	height: 26px;
	margin: 0 0.4rem;
	background: rgba(255, 255, 255, 0.25);
}
.flipbook-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	border: 0;
	border-radius: 6px;
	background: transparent;
	color: #fff;
	font-size: 1.05rem;
	line-height: 1;
	cursor: pointer;
	transition: background 0.2s ease, opacity 0.2s ease;
}
.flipbook-btn:hover { background: rgba(255, 255, 255, 0.14); }
.flipbook-btn:active { background: rgba(255, 255, 255, 0.24); }

/* ダウンロード（操作ボタンの右端／a要素） */
a.flipbook-btn {
	text-decoration: none;
	color: #fff;
}
.flipbook-btn--download {
	width: auto;
	gap: 0.45rem;
	padding: 0 0.9rem;
	border: 1px solid rgba(255, 255, 255, 0.35);
	font-size: 0.95rem;
	white-space: nowrap;
}
.flipbook-btn--download:hover { background: rgba(255, 255, 255, 0.18); }
.flipbook-btn__label { letter-spacing: 0.04em; }

.flipbook-pager {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	font-size: 0.95rem;
	letter-spacing: 0.03em;
	font-variant-numeric: tabular-nums;
}
.flipbook-pageinput {
	width: 3.2em;
	height: 34px;
	padding: 0 0.4rem;
	border: 1px solid rgba(255, 255, 255, 0.4);
	border-radius: 5px;
	background: rgba(255, 255, 255, 0.06);
	color: #fff;
	text-align: center;
	font-size: 0.95rem;
	-moz-appearance: textfield;
	appearance: textfield;
}
.flipbook-pageinput::-webkit-outer-spin-button,
.flipbook-pageinput::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}
.flipbook-sep { opacity: 0.6; }

/* =========================================================
   モーダル（カード画像クリックで開く）
   ========================================================= */
.flipbook-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: none;
	opacity: 0;
	transition: opacity 0.3s ease;
}
.flipbook-modal.is-open { display: block; opacity: 1; }
.flipbook-modal__overlay {
	position: absolute;
	inset: 0;
	background: rgba(10, 14, 30, 0.88);
	-webkit-backdrop-filter: blur(2px);
	backdrop-filter: blur(2px);
	cursor: pointer;
}
.flipbook-modal__inner {
	position: relative;
	z-index: 1;
	width: 100vw;
	height: 100vh;
	display: flex;
	flex-direction: column;
	color: #fff;
}
.flipbook-modal__header {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	height: 56px;
	padding: 0 1.2rem;
}
.flipbook-modal__title {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.flipbook-modal__close {
	position: relative;
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	border: 1px solid rgba(255, 255, 255, 0.4);
	border-radius: 50%;
	background: transparent;
	cursor: pointer;
	transition: background 0.25s ease;
}
.flipbook-modal__close:hover { background: rgba(255, 255, 255, 0.12); }
.flipbook-modal__close span {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 18px;
	height: 2px;
	background: #fff;
}
.flipbook-modal__close span:nth-child(1) { transform: translate(-50%, -50%) rotate(45deg); }
.flipbook-modal__close span:nth-child(2) { transform: translate(-50%, -50%) rotate(-45deg); }

.flipbook-modal__host {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
}
.flipbook-viewer--modal { height: 100%; }

/* =========================================================
   インライン（フルページ / 別タブ表示用）
   ========================================================= */
.flipbook-viewer--inline {
	height: calc(100vh - 80px);
	min-height: 480px;
	background: #d7dadf;
}
.flipbook-viewer--inline .flipbook-loader { color: #333; }
.flipbook-viewer--inline .flipbook-spinner {
	border-color: rgba(0, 0, 0, 0.2);
	border-top-color: #333;
}

/* 全画面表示中はビューアを画面いっぱいに */
.flipbook-viewer--modal:fullscreen,
.flipbook-modal__inner:fullscreen { background: rgba(10, 14, 30, 0.96); }
.flipbook-viewer--inline:fullscreen { height: 100vh; }

/* =========================================================
   レスポンシブ
   ========================================================= */
@media screen and (max-width: 767px) {
	.flipbook-modal__header { height: 48px; padding: 0 0.8rem; }
	.flipbook-modal__title { font-size: 0.85rem; }
	.flipbook-bar { height: 54px; gap: 0.3rem; padding: 0 0.5rem; }
	.flipbook-btn { width: 38px; height: 38px; font-size: 1rem; }
	.flipbook-bar__divider { margin: 0 0.2rem; }
	/* SPは幅が足りないのでラベルを省いてアイコンのみ */
	.flipbook-btn--download { width: 38px; padding: 0; }
	.flipbook-btn__label { display: none; }
	.flipbook-viewer--inline { height: calc(100vh - 60px); }
}

/* トリガーのカーソル */
[data-flipbook] { cursor: pointer; }
