/**
 * PDF Document Manager — Public styles
 * An editorial, archive-room aesthetic: warm paper tones, deliberate typography,
 * confident structure. Designed to coexist with most themes without fighting them.
 */

.pdfdm-wrap {
	--pdfdm-ink: #1a1814;
	--pdfdm-ink-soft: #4a463e;
	--pdfdm-paper: #fbf8f1;
	--pdfdm-paper-soft: #f3eee2;
	--pdfdm-rule: #d8d2c4;
	--pdfdm-accent: #8b1f1f;
	--pdfdm-accent-soft: #f4e6e6;
	--pdfdm-radius: 6px;
	--pdfdm-shadow: 0 1px 2px rgba(26, 24, 20, 0.04), 0 4px 12px rgba(26, 24, 20, 0.06);
	--pdfdm-shadow-hover: 0 2px 4px rgba(26, 24, 20, 0.08), 0 12px 28px rgba(26, 24, 20, 0.12);
	--pdfdm-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--pdfdm-serif: Georgia, "Iowan Old Style", "Apple Garamond", "Palatino Linotype", serif;

	font-family: var(--pdfdm-font);
	color: var(--pdfdm-ink);
	margin: 2rem 0;
}

.pdfdm-wrap *,
.pdfdm-wrap *::before,
.pdfdm-wrap *::after {
	box-sizing: border-box;
}

/* ============ TOOLBAR ============ */

.pdfdm-toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	align-items: center;
	padding: 14px 16px;
	margin-bottom: 24px;
	background: var(--pdfdm-paper);
	border: 1px solid var(--pdfdm-rule);
	border-radius: var(--pdfdm-radius);
}

.pdfdm-search {
	position: relative;
	flex: 1 1 220px;
	min-width: 200px;
}

.pdfdm-search-icon {
	position: absolute;
	left: 12px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--pdfdm-ink-soft);
	pointer-events: none;
}

.pdfdm-search input[type="search"] {
	width: 100%;
	padding: 10px 12px 10px 38px;
	border: 1px solid var(--pdfdm-rule);
	border-radius: var(--pdfdm-radius);
	background: #fff;
	font: inherit;
	color: var(--pdfdm-ink);
	transition: border-color .15s, box-shadow .15s;
}

.pdfdm-search input[type="search"]:focus {
	outline: none;
	border-color: var(--pdfdm-accent);
	box-shadow: 0 0 0 3px rgba(139, 31, 31, 0.12);
}

.pdfdm-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.pdfdm-select {
	padding: 9px 32px 9px 12px;
	border: 1px solid var(--pdfdm-rule);
	border-radius: var(--pdfdm-radius);
	background: #fff
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%234a463e' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E")
		no-repeat right 12px center;
	font: inherit;
	color: var(--pdfdm-ink);
	appearance: none;
	-webkit-appearance: none;
	cursor: pointer;
	min-width: 140px;
}

.pdfdm-select:focus {
	outline: none;
	border-color: var(--pdfdm-accent);
	box-shadow: 0 0 0 3px rgba(139, 31, 31, 0.12);
}

.pdfdm-toolbar-actions {
	display: flex;
	gap: 8px;
	align-items: center;
	margin-left: auto;
}

/* Minimal toolbar when search and filters are both hidden — just the toggle. */
.pdfdm-toolbar-minimal {
	display: flex;
	justify-content: flex-end;
	padding: 0 0 12px;
	border-bottom: none;
	background: none;
	box-shadow: none;
}

/* ── Layout toggle ─────────────────────────────────────── */

.pdfdm-layout-toggle {
	display: inline-flex;
	border: 1px solid var(--pdfdm-border);
	border-radius: var(--pdfdm-radius);
	overflow: hidden;
	flex-shrink: 0;
}

.pdfdm-layout-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	background: transparent;
	border: none;
	cursor: pointer;
	color: var(--pdfdm-ink-soft);
	transition: background-color .15s, color .15s;
	line-height: 1;
}

.pdfdm-layout-btn + .pdfdm-layout-btn {
	border-left: 1px solid var(--pdfdm-border);
}

.pdfdm-layout-btn:hover {
	background: var(--pdfdm-paper);
	color: var(--pdfdm-ink);
}

.pdfdm-layout-btn-active,
.pdfdm-layout-btn[aria-pressed="true"] {
	background: var(--pdfdm-accent);
	color: #fff;
}

.pdfdm-layout-btn-active:hover,
.pdfdm-layout-btn[aria-pressed="true"]:hover {
	background: var(--pdfdm-accent-hover);
	color: #fff;
}

/* ============ BUTTONS ============ */

.pdfdm-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 9px 14px;
	border-radius: var(--pdfdm-radius);
	font: inherit;
	font-weight: 500;
	font-size: .92em;
	text-decoration: none;
	cursor: pointer;
	transition: background-color .15s, color .15s, border-color .15s, transform .05s;
	border: 1px solid transparent;
	line-height: 1.2;
}

.pdfdm-btn:active {
	transform: translateY(1px);
}

/*
 * Use higher-specificity selectors with !important on color where needed.
 * Themes commonly style anchor tags aggressively (e.g. color: inherit, theme-blue),
 * which would otherwise override our button text color and create unreadable
 * white-on-light or dark-on-dark combinations.
 */
.pdfdm-wrap a.pdfdm-btn-primary,
.pdfdm-single a.pdfdm-btn-primary,
.pdfdm-wrap button.pdfdm-btn-primary,
.pdfdm-single button.pdfdm-btn-primary {
	background: var(--pdfdm-accent);
	color: #fff !important;
	border-color: var(--pdfdm-accent);
	text-decoration: none;
}

.pdfdm-wrap a.pdfdm-btn-primary:hover,
.pdfdm-wrap a.pdfdm-btn-primary:focus,
.pdfdm-single a.pdfdm-btn-primary:hover,
.pdfdm-single a.pdfdm-btn-primary:focus,
.pdfdm-wrap button.pdfdm-btn-primary:hover,
.pdfdm-wrap button.pdfdm-btn-primary:focus {
	background: #6f1818;
	border-color: #6f1818;
	color: #fff !important;
}

.pdfdm-wrap a.pdfdm-btn-ghost,
.pdfdm-single a.pdfdm-btn-ghost,
.pdfdm-wrap button.pdfdm-btn-ghost,
.pdfdm-single button.pdfdm-btn-ghost {
	background: transparent;
	color: var(--pdfdm-ink) !important;
	border-color: var(--pdfdm-rule);
	text-decoration: none;
}

.pdfdm-wrap a.pdfdm-btn-ghost:hover,
.pdfdm-wrap a.pdfdm-btn-ghost:focus,
.pdfdm-single a.pdfdm-btn-ghost:hover,
.pdfdm-single a.pdfdm-btn-ghost:focus {
	background: var(--pdfdm-paper-soft);
	color: var(--pdfdm-ink) !important;
	border-color: var(--pdfdm-ink-soft);
}

/* ============ RESULTS GRID ============ */

.pdfdm-results {
	display: grid;
	gap: 24px;
}

.pdfdm-cols-1 { grid-template-columns: 1fr; }
.pdfdm-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pdfdm-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pdfdm-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pdfdm-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.pdfdm-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

@media (max-width: 900px) {
	.pdfdm-cols-3, .pdfdm-cols-4, .pdfdm-cols-5, .pdfdm-cols-6 {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 540px) {
	.pdfdm-cols-2, .pdfdm-cols-3, .pdfdm-cols-4, .pdfdm-cols-5, .pdfdm-cols-6 {
		grid-template-columns: 1fr;
	}
}

/* ============ CARD ============ */

.pdfdm-card {
	display: flex;
	flex-direction: column;
	background: #fff;
	border: 1px solid var(--pdfdm-rule);
	border-radius: var(--pdfdm-radius);
	overflow: hidden;
	box-shadow: var(--pdfdm-shadow);
	transition: transform .2s ease, box-shadow .2s ease, border-color .2s;
}

.pdfdm-card:hover {
	transform: translateY(-2px);
	box-shadow: var(--pdfdm-shadow-hover);
	border-color: var(--pdfdm-ink-soft);
}

.pdfdm-card-thumb {
	position: relative;
	aspect-ratio: 4 / 5;
	background: var(--pdfdm-paper);
	overflow: hidden;
	border-bottom: 1px solid var(--pdfdm-rule);
}

.pdfdm-card-thumb a {
	display: block;
	height: 100%;
}

.pdfdm-card-thumb img,
.pdfdm-card-thumb .pdfdm-thumb-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform .4s ease;
}

.pdfdm-card:hover .pdfdm-card-thumb img,
.pdfdm-card:hover .pdfdm-card-thumb .pdfdm-thumb-img {
	transform: scale(1.03);
}

.pdfdm-thumb-placeholder {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--pdfdm-paper);
}

.pdfdm-thumb-placeholder img {
	width: 48px;
	height: 48px;
	opacity: .4;
}

.pdfdm-size-badge {
	position: absolute;
	top: 10px;
	right: 10px;
	padding: 3px 8px;
	border-radius: 999px;
	background: rgba(26, 24, 20, 0.85);
	color: #fff;
	font-size: .72em;
	font-weight: 500;
	letter-spacing: .02em;
	backdrop-filter: blur(4px);
}

/* Archive badge — sits bottom-left of the thumbnail, amber/neutral tone. */
.pdfdm-archive-badge {
	position: absolute;
	bottom: 10px;
	left: 10px;
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 3px 8px;
	border-radius: 999px;
	background: rgba(120, 93, 20, 0.88);
	color: #fff;
	font-size: .7em;
	font-weight: 600;
	letter-spacing: .04em;
	text-transform: uppercase;
	backdrop-filter: blur(4px);
	cursor: default;
}

/* Subtle visual distinction for archived cards — slightly muted. */
.pdfdm-card-archived {
	opacity: .88;
}

.pdfdm-card-archived:hover {
	opacity: 1;
}

.pdfdm-card-body {
	padding: 16px 18px 18px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	flex: 1;
}

/* Default sizing — overridden below by .pdfdm-title-* variants. */
.pdfdm-card-title {
	font-family: var(--pdfdm-serif);
	line-height: 1.3;
	margin: 0;
	font-weight: 600;
}

/* High specificity (.pdfdm-wrap parent + !important on font-size) to defeat
   theme rules that target h3 globally with large sizes. */
.pdfdm-wrap.pdfdm-title-small .pdfdm-card-title,
.pdfdm-wrap.pdfdm-title-small .pdfdm-card-title a {
	font-size: 0.875rem !important;
	line-height: 1.35 !important;
}

.pdfdm-wrap.pdfdm-title-medium .pdfdm-card-title,
.pdfdm-wrap.pdfdm-title-medium .pdfdm-card-title a {
	font-size: 1.0625rem !important;
	line-height: 1.3 !important;
}

.pdfdm-wrap.pdfdm-title-large .pdfdm-card-title,
.pdfdm-wrap.pdfdm-title-large .pdfdm-card-title a {
	font-size: 1.375rem !important;
	line-height: 1.25 !important;
}

.pdfdm-card-title a {
	color: var(--pdfdm-ink);
	text-decoration: none;
	border-bottom: 1px solid transparent;
	transition: border-color .15s, color .15s;
}

.pdfdm-card-title a:hover,
.pdfdm-card-title a:focus {
	color: var(--pdfdm-accent);
	border-bottom-color: var(--pdfdm-accent);
}

.pdfdm-card-excerpt {
	font-size: .88em;
	color: var(--pdfdm-ink-soft);
	line-height: 1.5;
	margin: 0;
}

/* "more" / "less" inline toggle button — looks like a text link */
.pdfdm-more-btn {
	display: inline;
	background: none;
	border: none;
	padding: 0;
	margin: 0;
	font: inherit;
	font-size: inherit;
	color: var(--pdfdm-accent);
	cursor: pointer;
	text-decoration: underline;
	text-underline-offset: 2px;
	line-height: inherit;
}

.pdfdm-more-btn:hover {
	color: var(--pdfdm-accent-hover);
}

.pdfdm-excerpt-ellipsis {
	color: var(--pdfdm-ink-soft);
}

.pdfdm-card-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin-top: 2px;
}

/* When section chip is above the title, tighten the gap below it */
.pdfdm-card-meta-top {
	margin-top: 0;
	margin-bottom: 6px;
}

.pdfdm-chip {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 3px;
	font-size: .7em;
	font-weight: 500;
	text-transform: uppercase;
	letter-spacing: .05em;
	line-height: 1.5;
}

.pdfdm-chip-section {
	background: var(--pdfdm-ink);
	color: var(--pdfdm-paper);
}

.pdfdm-chip-category {
	background: var(--pdfdm-paper-soft);
	color: var(--pdfdm-ink-soft);
	border: 1px solid var(--pdfdm-rule);
}

.pdfdm-card-actions {
	display: flex;
	gap: 8px;
	margin-top: auto;
	padding-top: 12px;
}

.pdfdm-card-actions .pdfdm-btn {
	flex: 1;
	justify-content: center;
	padding: 7px 10px;
	font-size: .85em;
}

/* ============ LIST LAYOUT ============ */

.pdfdm-layout-list .pdfdm-results {
	grid-template-columns: 1fr !important;
	gap: 12px;
}

.pdfdm-layout-list .pdfdm-card {
	flex-direction: row;
	align-items: stretch;
}

.pdfdm-layout-list .pdfdm-card-thumb {
	flex: 0 0 120px;
	aspect-ratio: 4 / 5;
	border-bottom: none;
	border-right: 1px solid var(--pdfdm-rule);
}

.pdfdm-layout-list .pdfdm-card-body {
	flex: 1;
}

@media (max-width: 540px) {
	.pdfdm-layout-list .pdfdm-card {
		flex-direction: column;
	}
	.pdfdm-layout-list .pdfdm-card-thumb {
		flex: 0 0 auto;
		border-right: none;
		border-bottom: 1px solid var(--pdfdm-rule);
	}
}

/* ============ EMPTY STATE ============ */

.pdfdm-empty-state {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 60px 20px;
	background: var(--pdfdm-paper);
	border: 1px dashed var(--pdfdm-rule);
	border-radius: var(--pdfdm-radius);
	color: var(--pdfdm-ink-soft);
	text-align: center;
}

.pdfdm-empty-state svg {
	color: var(--pdfdm-rule);
	margin-bottom: 12px;
}

.pdfdm-empty-state p {
	margin: 0;
	font-family: var(--pdfdm-serif);
	font-style: italic;
	font-size: 1.05rem;
}

/* ============ PAGINATION ============ */

.pdfdm-pagination {
	display: flex;
	flex-wrap: wrap;
	gap: 3px;
	justify-content: center;
	margin-top: 16px;
}

.pdfdm-page-item .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 28px;
	height: 28px;
	padding: 0 7px;
	border: 1px solid var(--pdfdm-rule);
	border-radius: var(--pdfdm-radius);
	background: #fff;
	color: var(--pdfdm-ink);
	text-decoration: none;
	font-size: .78em;
	transition: background-color .15s, border-color .15s, color .15s;
}

.pdfdm-page-item .page-numbers:hover {
	background: var(--pdfdm-paper-soft);
	border-color: var(--pdfdm-ink-soft);
}

.pdfdm-page-item .page-numbers.current {
	background: var(--pdfdm-ink);
	color: var(--pdfdm-paper);
	border-color: var(--pdfdm-ink);
}

.pdfdm-page-item .page-numbers.dots {
	border-color: transparent;
	background: transparent;
	cursor: default;
}

/* ============ SINGLE DOCUMENT VIEW ============ */

.pdfdm-single {
	--pdfdm-ink: #1a1814;
	--pdfdm-ink-soft: #4a463e;
	--pdfdm-paper: #fbf8f1;
	--pdfdm-paper-soft: #f3eee2;
	--pdfdm-rule: #d8d2c4;
	--pdfdm-accent: #8b1f1f;
	--pdfdm-radius: 6px;
	--pdfdm-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

	font-family: var(--pdfdm-font);
	color: var(--pdfdm-ink);
	margin: 1.5rem 0 3rem;
}

.pdfdm-single *,
.pdfdm-single *::before,
.pdfdm-single *::after {
	box-sizing: border-box;
}

.pdfdm-single-description {
	margin-bottom: 1.5rem;
	font-size: 1rem;
	line-height: 1.6;
	color: var(--pdfdm-ink-soft);
}

.pdfdm-single-meta {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 14px 18px;
	margin-bottom: 1.5rem;
	background: var(--pdfdm-paper);
	border: 1px solid var(--pdfdm-rule);
	border-radius: var(--pdfdm-radius);
}

.pdfdm-single-meta-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.pdfdm-single-meta-label {
	font-size: .78em;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .06em;
	color: var(--pdfdm-ink-soft);
	margin-right: 4px;
}

.pdfdm-single-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 1.25rem;
}

.pdfdm-single-actions .pdfdm-btn {
	padding: 11px 18px;
	font-size: .95em;
}

.pdfdm-single-size {
	font-weight: 400;
	color: var(--pdfdm-ink-soft);
	margin-left: 4px;
}

.pdfdm-single-viewer {
	width: 100%;
	background: var(--pdfdm-paper-soft);
	border: 1px solid var(--pdfdm-rule);
	border-radius: var(--pdfdm-radius);
	overflow: hidden;
	box-shadow: 0 4px 16px rgba(26, 24, 20, 0.08);
}

/*
 * On the single document view, break the PDF viewer out of the theme's
 * content-column width and let it use the full viewport. This gives readers
 * meaningfully more reading area for the PDF itself, while keeping the
 * surrounding metadata (description, section tags, action buttons) at the
 * theme's normal content width for readability.
 *
 * The 100vw + negative margin trick is the standard "full bleed" pattern;
 * calc accounts for scrollbar width to avoid horizontal scroll.
 */
/* Single viewer — heights and layout are now controlled by inline styles
   in render_single() so they bypass theme overrides. Class-based rules here
   are minimal so they don't conflict. */

.pdfdm-viewer-fallback {
	padding: 40px 20px;
	text-align: center;
	color: var(--pdfdm-ink-soft);
}

/* ============ ADA ARCHIVE BANNER ============ */

.pdfdm-archive-banner {
	font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	background: #f3eee2;
	border-left: 4px solid #8b7236;
	border-radius: 4px;
	padding: 14px 18px;
	margin: 0 0 1.5rem;
	font-size: .92em;
	line-height: 1.5;
	color: #4a463e;
}

.pdfdm-archive-banner strong {
	display: inline-block;
	margin-right: 6px;
	color: #1a1814;
	font-size: 1em;
	letter-spacing: .01em;
}

.pdfdm-archive-banner .pdfdm-archive-banner-cta {
	display: block;
	margin-top: 8px;
	padding-top: 8px;
	border-top: 1px solid rgba(139, 114, 54, 0.25);
	font-size: .92em;
}

.pdfdm-archive-banner a {
	color: #8b1f1f;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.pdfdm-archive-banner a:hover {
	color: #6f1818;
}

/* ── Visitor sort dropdown ─────────────────────────────── */
.pdfdm-sort {
	display: inline-flex;
	align-items: center;
}

/* Suppress browser :invalid styling on selects inside our toolbar —
   only target the invalid pseudo-class so normal .pdfdm-select border is untouched. */
.pdfdm-toolbar select:invalid {
	box-shadow: none !important;
	border-color: var(--pdfdm-rule) !important;
	outline: none;
}


/* ============ COMPACT LIST LAYOUT ============
   Note: compact rows have all base styles inline on each element so themes can't
   override them. The rules below only add hover/transition behavior that requires
   pseudo-selectors. */

.pdfdm-compact-row {
	transition: background-color .12s !important;
}

.pdfdm-compact-row:hover {
	background: #dde6f5 !important;
	cursor: pointer;
}

/* Invert the View badge on hover so it pops against the hover background */
.pdfdm-compact-row:hover .pdfdm-compact-view-btn {
	background: var(--pdfdm-accent, #1e3a8a) !important;
	color: #fff !important;
}

.pdfdm-compact-view-btn:hover {
	background: var(--pdfdm-accent, #1e3a8a) !important;
	color: #fff !important;
}
