/*
 * DT Flipbook Viewer v2 — CSS 3D page-turn engine.
 * Loaded only inside the embed iframe.
 */

html, body {
	margin: 0;
	padding: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
	background: #efece6;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	-webkit-user-select: none;
	user-select: none;
}

/* ---- Stage ---- */
#dtfb-stage {
	position: relative;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: radial-gradient(ellipse at center, #f7f5f0 0%, #e5e0d6 100%);
}
#dtfb-stage:fullscreen { background: radial-gradient(ellipse at center, #f7f5f0 0%, #e5e0d6 100%); }

#dtfb-loading {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 15px;
	font-size: 1.05rem;
	color: #6b6455;
	background: inherit;
	z-index: 50;
	padding: 0 2em;
	text-align: center;
}
#dtfb-loading p {
	margin: 0;
	color: #6c5286;
	font-size: 1.1rem;
	font-weight: 600;
}
#dtfb-loading.is-error { color: #a04444; }
#dtfb-loading[hidden] { display: none; }

/* Spinner ported from Ask a Trainer (dt-kb-support-bridge kb-style.css) —
   same track/disk colours and spin so loading feels the same across DT tools. */
.dtfb-spinner {
	width: 50px;
	height: 50px;
	border: 5px solid #f3e8ff; /* Light purple track */
	border-top: 5px solid #a987c2; /* Brand purple disk */
	border-radius: 50%;
	animation: dtfb-spin 1s linear infinite;
}
@keyframes dtfb-spin {
	0% { transform: rotate(0deg); }
	100% { transform: rotate(3600deg); }
}
@media (prefers-reduced-motion: reduce) {
	.dtfb-spinner { animation: none; }
}

/* ---- Book ---- */
#dtfb-book {
	position: relative;
	perspective: 2400px;
	transform-style: preserve-3d;
	filter: drop-shadow(0 18px 30px rgba(60, 50, 30, 0.28));
	cursor: pointer;
}

.dtfb-sheet {
	position: absolute;
	top: 0;
	left: 50%;
	width: 50%;
	height: 100%;
	transform-origin: left center;
	transform-style: preserve-3d;
	transition: transform 0.8s cubic-bezier(0.25, 0.1, 0.25, 1);
	transform: rotateY(0deg);
}
.dtfb-sheet.is-turned { transform: rotateY(-180deg); }

/* Single-page mode: the page fills the book and pivots on the book's left edge. */
#dtfb-book.is-single .dtfb-sheet {
	left: 0;
	width: 100%;
}

.dtfb-face {
	position: absolute;
	inset: 0;
	background: #fff;
	overflow: hidden;
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
}
.dtfb-back { transform: rotateY(180deg); }

.dtfb-face canvas {
	width: 100%;
	height: 100%;
	display: block;
	pointer-events: none;
}

/* Spine shading gives the spread a gentle curve. */
.dtfb-front::after,
.dtfb-back::after {
	content: "";
	position: absolute;
	inset: 0;
	pointer-events: none;
}
.dtfb-front::after {
	background: linear-gradient(to right, rgba(0,0,0,0.12) 0%, rgba(0,0,0,0) 7%);
}
.dtfb-back::after {
	background: linear-gradient(to left, rgba(0,0,0,0.12) 0%, rgba(0,0,0,0) 7%);
}
#dtfb-book.is-single .dtfb-front::after { background: none; }

/* ---- Controls ---- */
.dtfb-navbtn {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 40;
	width: 44px;
	height: 44px;
	border: none;
	border-radius: 50%;
	background: rgba(40, 34, 22, 0.55);
	color: #fff;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	transition: background 0.2s, opacity 0.2s;
	display: flex;
	align-items: center;
	justify-content: center;
}
.dtfb-navbtn:hover { background: rgba(40, 34, 22, 0.85); }
.dtfb-navbtn:disabled { opacity: 0.25; cursor: default; }
#dtfb-prev { left: 12px; }
#dtfb-next { right: 12px; }

.dtfb-toolbar {
	position: absolute;
	bottom: 10px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 40;
	display: flex;
	align-items: center;
	gap: 12px;
	background: rgba(40, 34, 22, 0.55);
	color: #fff;
	border-radius: 20px;
	padding: 6px 14px;
	font-size: 0.85rem;
	opacity: 0;
	transition: opacity 0.25s;
}
#dtfb-stage.is-ready .dtfb-toolbar,
#dtfb-stage.is-ready .dtfb-navbtn { opacity: 1; }
#dtfb-stage:not(.is-ready) .dtfb-navbtn { opacity: 0; }

/* Top-right cluster: days-left countdown + full-screen button (v2.5.3 —
   the countdown moved here from the buy bar so the deadline sits by the
   control everyone looks for). */
.dtfb-topright {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 45;
	display: flex;
	align-items: center;
	gap: 10px;
}
.dtfb-days-note {
	background: rgba(40, 34, 22, 0.55);
	color: #fff;
	border-radius: 20px;
	padding: 6px 12px;
	font-size: 12px;
	line-height: 1.3;
	white-space: nowrap;
}

/* Prominent, always-visible full-screen button (now positioned by .dtfb-topright). */
.dtfb-fs-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	background: #7d3c98;
	color: #fff;
	border: none;
	border-radius: 24px;
	padding: 10px 18px;
	font-size: 0.95rem;
	font-weight: 700;
	font-family: inherit;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
	transition: background 0.2s, transform 0.15s;
}
.dtfb-fs-btn:hover { background: #6a2f84; transform: translateY(-1px); }
.dtfb-fs-btn svg { flex-shrink: 0; }

/* ---- Optional audio bar ---- */
#dtfb-audio {
	position: absolute;
	top: 10px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 40;
	width: min(420px, 86%);
}
#dtfb-audio audio { width: 100%; height: 34px; }
#dtfb-audio[hidden] { display: none; }

/* ---- Buy bar (v2.4) — shown when the book is also sold. Top-left (v2.5.1):
   mirrors the Full Screen button top-right, where the eye actually lands —
   bottom-left was dead space nobody scanned. */
.dtfb-buybar {
	position: absolute;
	top: 12px;
	left: 12px;
	z-index: 45;
	display: flex;
	align-items: center;
	gap: 10px;
	opacity: 0;
	transition: opacity 0.25s;
}
#dtfb-stage.is-ready .dtfb-buybar { opacity: 1; }
.dtfb-buybar-btn {
	display: inline-flex;
	align-items: center;
	background: #7d3c98;
	color: #fff;
	border-radius: 24px;
	padding: 9px 18px;
	font-size: 14px;
	font-weight: 700;
	text-decoration: none;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
	transition: background 0.2s, transform 0.15s;
}
.dtfb-buybar-btn:hover { background: #6a2f84; color: #fff; transform: translateY(-1px); }

/* Narrow screens: both top clusters stack vertically toward their own corner,
   smaller, so nothing runs into the audio bar (top-centre) or the book. */
@media (max-width: 600px) {
	.dtfb-buybar { top: 8px; left: 8px; flex-direction: column; align-items: flex-start; gap: 6px; }
	.dtfb-buybar-btn { font-size: 12px; padding: 7px 14px; }
	.dtfb-topright { top: 8px; right: 8px; flex-direction: column; align-items: flex-end; gap: 6px; }
	.dtfb-days-note { font-size: 11px; }
}

/* Print-edition button (v2.5) — outline variant so the e-book button stays primary. */
.dtfb-buybar-btn--alt {
	background: rgba(255, 255, 255, 0.92);
	color: #7d3c98;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.dtfb-buybar-btn--alt:hover { background: #fff; color: #6a2f84; }
