/* CWW PDF — responsive list + embedded viewer.
   Priority: maximize the PDF area, especially on small screens.

   Selectors are element-qualified and scoped under .cww-pdf so theme
   button/select/ul styles don't leak in. */

.cww-pdf {
	display: flex;
	gap: 1rem;
	/* Tall by design: give the PDF as much height as possible. */
	height: 82vh;
	min-height: 420px;
	box-sizing: border-box;
	background: transparent;
}

.cww-pdf *,
.cww-pdf *::before,
.cww-pdf *::after {
	box-sizing: border-box;
}

/* ---- Viewer (dominant, left) ---- */
.cww-pdf .cww-pdf__viewer {
	order: 1;
	flex: 1 1 auto;
	min-width: 0;
	/* Anchor for the full-screen overlay button. */
	position: relative;
}

/* Full-screen overlay button (bottom-right, out of the pdf.js toolbar's way). */
.cww-pdf button.cww-pdf__fs {
	-webkit-appearance: none;
	appearance: none;
	position: absolute;
	right: 12px;
	bottom: 12px;
	z-index: 5;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	border: 1px solid rgba( 255, 255, 255, 0.25 );
	border-radius: 8px;
	background: rgba( 0, 0, 0, 0.55 );
	color: #fff;
	cursor: pointer;
	opacity: 0.55;
	box-shadow: none;
	transition: opacity 0.15s ease, background-color 0.15s ease;
}

.cww-pdf button.cww-pdf__fs:hover,
.cww-pdf button.cww-pdf__fs:focus {
	opacity: 1;
	background: rgba( 0, 0, 0, 0.78 );
	color: #fff;
}

.cww-pdf button.cww-pdf__fs svg {
	display: block;
	width: 20px;
	height: 20px;
}

/* While full-screen, let the iframe fill the whole screen. */
.cww-pdf__viewer:-webkit-full-screen {
	width: 100%;
	height: 100%;
	background: #fff;
}

.cww-pdf__viewer:fullscreen {
	width: 100%;
	height: 100%;
	background: #fff;
}

.cww-pdf__viewer:-webkit-full-screen .cww-pdf__frame {
	height: 100%;
	border: 0;
	border-radius: 0;
}

.cww-pdf__viewer:fullscreen .cww-pdf__frame {
	height: 100%;
	border: 0;
	border-radius: 0;
}

/* Single-file embed: no list, viewer fills the width. */
.cww-pdf--single .cww-pdf__viewer {
	flex: 1 1 100%;
}

.cww-pdf .cww-pdf__frame {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	border: 1px solid rgba( 0, 0, 0, 0.12 );
	border-radius: 6px;
	background: #fff;
}

/* ---- List panel (desktop sidebar, right) ---- */
.cww-pdf .cww-pdf__panel {
	order: 2;
	flex: 0 0 260px;
	max-width: 260px;
	display: flex;
	flex-direction: column;
	min-height: 0;
}

.cww-pdf .cww-pdf__select,
.cww-pdf .cww-pdf__select-label {
	/* Hidden on desktop; the button list is used instead. */
	display: none;
}

.cww-pdf ul.cww-pdf__list {
	list-style: none;
	margin: 0;
	padding: 0.25rem;
	/* The long-list fix: cap the height and scroll internally so the
	   viewer never gets pushed out of view. */
	overflow-y: auto;
	flex: 1 1 auto;
	min-height: 0;
	width: 100%;
	max-width: 100%;
	border: 1px solid rgba( 0, 0, 0, 0.12 );
	border-radius: 8px;
	background: #fafafa;
}

.cww-pdf ul.cww-pdf__list > li.cww-pdf__item {
	margin: 0 0 0.25rem;
	padding: 0;
	list-style: none;
	width: 100%;
}

.cww-pdf ul.cww-pdf__list > li.cww-pdf__item:last-child {
	margin-bottom: 0;
}

/* Reset the theme's button chrome, then apply our own. */
.cww-pdf button.cww-pdf__link {
	-webkit-appearance: none;
	appearance: none;
	display: block;
	width: 100%;
	max-width: 100%;
	min-height: 0;
	margin: 0;
	text-align: left;
	text-transform: none;
	letter-spacing: normal;
	padding: 0.5rem 0.65rem;
	border: 1px solid transparent;
	border-radius: 6px;
	background: #fff;
	color: #1a1a1a;
	font: inherit;
	font-weight: 400;
	line-height: 1.35;
	box-shadow: none;
	cursor: pointer;
	/* Wrap long titles cleanly instead of overflowing. */
	white-space: normal;
	overflow-wrap: anywhere;
	transition: background-color 0.12s ease, border-color 0.12s ease;
}

.cww-pdf button.cww-pdf__link:hover,
.cww-pdf button.cww-pdf__link:focus {
	background: #f0f0f0;
	color: #1a1a1a;
}

.cww-pdf button.cww-pdf__link:focus-visible {
	outline: 2px solid rgba( 0, 90, 200, 0.6 );
	outline-offset: 1px;
}

.cww-pdf button.cww-pdf__link.is-active {
	background: #fff;
	border-color: rgba( 0, 0, 0, 0.18 );
	/* Accent stripe marks the open document. */
	box-shadow: inset 3px 0 0 0 rgba( 0, 90, 200, 0.75 );
	font-weight: 600;
}

/* ---- Errors / empty ---- */
.cww-pdf--error,
.cww-pdf--empty {
	display: block;
	height: auto;
	min-height: 0;
}

/* Notice box (errors / empty). Explicit background AND text colour, with
   !important on the readability-critical properties, so a theme can't leave
   the message unreadable. */
.cww-pdf.cww-pdf--error p,
.cww-pdf.cww-pdf--empty p {
	margin: 0 !important;
	padding: 0.75rem 1rem !important;
	background: #fdecea !important;
	color: #611a15 !important;
	border: 1px solid #f5c2bd !important;
	border-radius: 6px;
	font-weight: 400;
	text-shadow: none;
}

.cww-pdf.cww-pdf--error p a,
.cww-pdf.cww-pdf--empty p a {
	color: #611a15 !important;
}

/* Debug table */
.cww-pdf-debug {
	border-collapse: collapse;
	width: 100%;
}

.cww-pdf-debug th,
.cww-pdf-debug td {
	border: 1px solid rgba( 0, 0, 0, 0.15 );
	padding: 0.35rem 0.6rem;
	text-align: left;
}

/* ---- Small screens: swap the list for a dropdown, stack vertically,
   and hand nearly all the height to the PDF. ---- */
@media ( max-width: 782px ) {
	.cww-pdf {
		flex-direction: column;
		height: auto;
		gap: 0.5rem;
	}

	.cww-pdf .cww-pdf__panel {
		order: 0;
		flex: 0 0 auto;
		max-width: 100%;
	}

	.cww-pdf ul.cww-pdf__list {
		/* Hide the long button list on mobile. */
		display: none;
	}

	.cww-pdf .cww-pdf__select-label {
		display: block;
		margin-bottom: 0.25rem;
		font-weight: 600;
	}

	.cww-pdf .cww-pdf__select {
		display: block;
		width: 100%;
		max-width: 100%;
		padding: 0.5rem;
		font: inherit;
	}

	.cww-pdf .cww-pdf__viewer {
		order: 1;
		flex: 1 1 auto;
	}

	.cww-pdf .cww-pdf__frame {
		/* Fill the viewport below the dropdown. */
		height: 80vh;
		min-height: 360px;
	}
}
