/**
 * TBB PDF Inserter – frontend viewer styles.
 *
 * The viewer renders as a centered, outlined card (max-width 1200px)
 * with the toolbar and PDF pages inside it.
 *
 * Pages are left-aligned (flex-start) inside the card.
 * The canvas area uses overflow-x:auto for horizontal scroll when zoomed in.
 */

/* -------------------------------------------------------------------------
 * Viewer shell
 * ---------------------------------------------------------------------- */

.tbb-pdf-viewer {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 14px;
	margin: 0 auto 1em;
	box-sizing: border-box;
	/* positioning context for the toolbar dropdown menus, which must live
	   inside the container so they stay visible in fullscreen mode */
	position: relative;
	width: 100%;
	max-width: 1200px;
	border: 1px solid #d0d0d0;
	border-radius: 8px;
	/* clip — not hidden — so the rounded corners clip child content
	   without creating a new scroll container that would break position:sticky
	   on the toolbar. */
	overflow: clip;
}

/* -------------------------------------------------------------------------
 * Toolbar – slim, flat bar; no rounded corners, no heavy background
 * ---------------------------------------------------------------------- */

.tbb-pdf-toolbar {
	position: sticky;
	top: 0;
	z-index: 100;
	display: flex;
	justify-content: center;
	align-items: center;
	padding: 8px 0;
	background: #ffffff;
	border-bottom: 1px solid #d0d0d0;
	box-sizing: border-box;
}

/* -------------------------------------------------------------------------
 * Controls group
 * ---------------------------------------------------------------------- */

.tbb-pdf-controls {
	display: flex;
	align-items: center;
	background: #ffffff;
	border: 1px solid #d0d0d0;
	border-radius: 999px;
	box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.10 );
	overflow: hidden;
}

.tbb-pdf-controls button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	padding: 0;
	background: transparent;
	border: none;
	border-right: 1px solid #e8e8e8;
	color: #444444;
	cursor: pointer;
	transition: background 0.12s ease;
	touch-action: manipulation;
	flex-shrink: 0;
}

.tbb-pdf-controls button:last-child {
	border-right: none;
}

.tbb-pdf-controls button:hover {
	background: #f0f0f0;
}

.tbb-pdf-controls button:active {
	background: #e4e4e4;
}

.tbb-pdf-controls button:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: -2px;
}

/* Current page readout, e.g. "2 / 14" */
.tbb-pdf-page-indicator {
	display: inline-flex;
	align-items: center;
	height: 38px;
	padding: 0 12px;
	border-right: 1px solid #e8e8e8;
	color: #444444;
	font-size: 13px;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	flex-shrink: 0;
}

/* -------------------------------------------------------------------------
 * Canvas area – no border, no card chrome
 * ---------------------------------------------------------------------- */

.tbb-pdf-canvas-area {
	background: transparent;
	overflow-x: auto;
	overflow-y: visible;
	padding: 12px 12px 8px;
	box-sizing: border-box;
	/* Allow one/two-finger panning but keep browser pinch-zoom off the PDF,
	   so the viewer's own pinch-to-zoom handler receives the gesture. */
	touch-action: pan-x pan-y;
}

.tbb-pdf-loading {
	color: #888;
	text-align: left;
	padding: 1.5em 0;
	margin: 0;
}

/* Pages stacked vertically, left-aligned */
.tbb-pdf-pages {
	display: flex;
	flex-direction: column;
	align-items: flex-start;   /* left-align – no centering inside parent card */
	gap: 12px;
	min-width: min-content;    /* lets wide canvases push the scroll area */
}

/* Individual page wrappers – position:relative anchors the link layer */
.tbb-pdf-page-wrapper {
	position: relative;
	line-height: 0;
	background: #fff;
}

.tbb-pdf-page-wrapper canvas {
	display: block;
}

/* Clickable link overlays for link annotations inside the PDF */
.tbb-pdf-link-layer a {
	position: absolute;
	display: block;
	border-radius: 2px;
}

.tbb-pdf-link-layer a:hover {
	background: rgba( 34, 113, 177, 0.12 );
}

/* -------------------------------------------------------------------------
 * Mobile (≤ 480 px)
 * ---------------------------------------------------------------------- */

@media ( max-width: 480px ) {
	/* Keep a small gutter so the card doesn't touch the screen edges when
	   the theme's content area is full-width. */
	.tbb-pdf-viewer {
		width: auto;
		margin-left: 8px;
		margin-right: 8px;
	}

	.tbb-pdf-toolbar {
		padding: 5px 0 5px 0;
		min-height: 38px;
	}

	.tbb-pdf-controls button {
		width: 38px;
		height: 42px;
	}

	.tbb-pdf-page-indicator {
		height: 42px;
		padding: 0 8px;
		font-size: 12px;
	}

	.tbb-pdf-canvas-area {
		padding: 8px 8px 6px;
	}

	.tbb-pdf-pages {
		gap: 8px;
	}
}

/* Share dropdown menu */
.tbb-pdf-share-menu {
	display: none;
	position: absolute;
	z-index: 9999;
	background: #ffffff;
	border: 1px solid #e0e0e0;
	border-radius: 10px;
	box-shadow: 0 4px 16px rgba( 0, 0, 0, 0.13 );
	padding: 6px;
	min-width: 180px;
}

.tbb-pdf-share-item {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 9px 12px;
	background: transparent;
	border: none;
	border-radius: 6px;
	color: #222222;
	font-size: 14px;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
	box-sizing: border-box;
	transition: background 0.1s ease;
}

.tbb-pdf-share-item:hover,
.tbb-pdf-share-item:focus,
.tbb-pdf-share-item:active {
	background: #f4f4f4;
	color: #222222;
}

.tbb-share-icon {
	display: flex;
	align-items: center;
	flex-shrink: 0;
	color: #555555;
}

.tbb-share-label {
	white-space: nowrap;
}

/* -------------------------------------------------------------------------
 * Fullscreen mode
 * ---------------------------------------------------------------------- */

/* Applied in both native fullscreen and the iOS fake-fullscreen fallback.
   The container becomes a full-height column; the canvas area takes over
   vertical scrolling since the page itself can no longer scroll. */
.tbb-pdf-viewer.tbb-pdf-fullscreen {
	display: flex;
	flex-direction: column;
	max-width: none;
	height: 100%;
	margin: 0;
	border: none;
	border-radius: 0;
	background: #ffffff;
}

.tbb-pdf-viewer.tbb-pdf-fullscreen .tbb-pdf-canvas-area {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
}

/* iOS Safari has no element Fullscreen API: emulate with a fixed overlay. */
.tbb-pdf-viewer.tbb-pdf-fake-fullscreen {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 99999;
	width: auto;
}

body.tbb-pdf-noscroll {
	overflow: hidden;
}

