/* PDF Flipbook Catalog – visualizzatore */
.pfc-viewer {
	--pfc-bg: #2b2d31;
	--pfc-bar: #1e1f22;
	--pfc-fg: #f2f3f5;
	--pfc-accent: #e30613;
	position: relative;
	width: 100%;
	max-width: 100%;
	margin: 0 auto 1.5em;
	background: var(--pfc-bg);
	border-radius: 8px;
	overflow: hidden;
	box-sizing: border-box;
	outline: none;
	-webkit-user-select: none;
	user-select: none;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.pfc-viewer *, .pfc-viewer *::before, .pfc-viewer *::after { box-sizing: border-box; }

.pfc-stage {
	position: relative;
	width: 100%;
	height: 60vh;              /* sovrascritto via JS */
	min-height: 260px;
	padding: 16px;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
}
.pfc-book { width: 100%; margin: 0 auto; opacity: 0; transition: opacity .3s; }
.pfc-viewer.pfc-ready .pfc-book { opacity: 1; }

.pfc-page {
	background: #fff;
	overflow: hidden;
}
.pfc-page canvas {
	display: block;
	width: 100% !important;
	height: 100% !important;
	object-fit: contain;
}

/* Loading */
.pfc-loading {
	position: absolute; inset: 0;
	display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
	color: var(--pfc-fg); font-size: 14px;
}
.pfc-viewer.pfc-ready .pfc-loading { display: none; }
.pfc-spinner {
	width: 36px; height: 36px; border-radius: 50%;
	border: 3px solid rgba(255,255,255,.2); border-top-color: var(--pfc-accent);
	animation: pfc-spin .8s linear infinite;
}
@keyframes pfc-spin { to { transform: rotate(360deg); } }

/* Toolbar */
.pfc-toolbar {
	display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px;
	padding: 8px 10px;
	background: var(--pfc-bar);
	color: var(--pfc-fg);
}
.pfc-btn {
	display: inline-flex; align-items: center; justify-content: center;
	width: 40px; height: 40px; padding: 0; margin: 0;
	background: transparent; border: 0; border-radius: 6px;
	color: var(--pfc-fg); cursor: pointer; text-decoration: none;
	-webkit-tap-highlight-color: transparent;
}
.pfc-btn:hover, .pfc-btn:focus-visible { background: rgba(255,255,255,.12); color: #fff; outline: none; }
.pfc-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.pfc-btn svg {
	width: 22px; height: 22px; fill: none; stroke: currentColor;
	stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.pfc-counter { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; padding: 0 6px; white-space: nowrap; }
.pfc-page-input {
	width: 56px; height: 30px; padding: 0 4px; margin: 0;
	text-align: center; font-size: 14px;
	color: var(--pfc-fg); background: rgba(255,255,255,.08);
	border: 1px solid rgba(255,255,255,.2); border-radius: 4px;
}
.pfc-sep { width: 1px; height: 24px; background: rgba(255,255,255,.2); margin: 0 6px; }

/* Lente / ingrandimento */
.pfc-zoom-layer {
	position: absolute; inset: 0; z-index: 20;
	background: rgba(20,20,22,.96);
}
.pfc-zoom-layer[hidden] { display: none; }
.pfc-zoom-scroll {
	position: absolute; inset: 0;
	overflow: auto; -webkit-overflow-scrolling: touch;
	touch-action: pan-x pan-y pinch-zoom;
}
.pfc-zoom-scroll canvas { display: block; margin: 0 auto; max-width: none; }
.pfc-zoom-close {
	position: absolute; top: 10px; right: 10px; z-index: 2;
	background: rgba(0,0,0,.55);
}

/* Schermo intero (nativo e fallback iOS) */
.pfc-viewer:fullscreen { border-radius: 0; margin: 0; display: flex; flex-direction: column; }
.pfc-viewer:-webkit-full-screen { border-radius: 0; margin: 0; display: flex; flex-direction: column; }
.pfc-viewer.pfc-pseudo-fs {
	position: fixed; inset: 0; z-index: 999999;
	margin: 0; border-radius: 0;
	display: flex; flex-direction: column;
}
html.pfc-noscroll, html.pfc-noscroll body { overflow: hidden !important; }

/* Modalità embed (iframe / link diretto) */
.pfc-viewer.pfc-mode-embed {
	height: 100vh; height: 100dvh;
	margin: 0; border-radius: 0;
	display: flex; flex-direction: column;
}
.pfc-viewer.pfc-mode-embed .pfc-stage,
.pfc-viewer:fullscreen .pfc-stage,
.pfc-viewer.pfc-pseudo-fs .pfc-stage { flex: 1 1 auto; height: auto !important; }

/* Mobile */
@media (max-width: 640px) {
	.pfc-stage { padding: 8px; }
	.pfc-first, .pfc-last, .pfc-sep { display: none; }
	.pfc-btn { width: 42px; height: 42px; }
	.pfc-toolbar { flex-wrap: nowrap; gap: 0; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
	.pfc-counter { font-size: 13px; padding: 0 2px; gap: 4px; }
	.pfc-page-input { width: 44px; }
}

/* Link cliccabili del PDF */
.pfc-links { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.pfc-link {
	position: absolute; display: block;
	pointer-events: auto; cursor: pointer;
	border-radius: 2px;
	transition: background-color .15s;
}
.pfc-link:hover, .pfc-link:focus-visible { background: rgba(255, 213, 0, .25); outline: 1px solid rgba(227, 6, 19, .6); }
@media (hover: none) { .pfc-link { background: rgba(255, 213, 0, .12); } }

/* Ricerca */
.pfc-btn-label { margin-left: 6px; font-size: 14px; }
.pfc-search-btn { width: auto; padding: 0 12px; }
.pfc-hl-layer { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.pfc-hl {
	position: absolute;
	background: rgba(255, 213, 0, .45);
	box-shadow: 0 0 0 2px rgba(227, 6, 19, .75);
	border-radius: 2px;
	mix-blend-mode: multiply;
	animation: pfc-pulse 1.2s ease-out 2;
}
@keyframes pfc-pulse { 50% { box-shadow: 0 0 0 6px rgba(227, 6, 19, .35); } }

.pfc-search-panel {
	position: absolute; top: 0; right: 0; bottom: 56px; z-index: 15;
	width: 360px; max-width: 100%;
	display: flex; flex-direction: column;
	background: #fff; color: #222;
	box-shadow: -4px 0 20px rgba(0,0,0,.25);
}
.pfc-search-panel[hidden] { display: none; }
.pfc-search-head {
	display: flex; align-items: center; gap: 6px;
	padding: 10px 8px 10px 14px; border-bottom: 1px solid #e5e5e5;
}
.pfc-search-ico { width: 20px; height: 20px; flex: none; fill: none; stroke: #888; stroke-width: 2; stroke-linecap: round; }
.pfc-search-input {
	flex: 1 1 auto; min-width: 0; height: 40px; margin: 0; padding: 0 8px;
	font-size: 16px; /* 16px evita lo zoom automatico su iPhone */
	color: #222; background: #fff; border: 0; outline: none; box-shadow: none;
}
.pfc-search-panel .pfc-search-close { color: #555; }
.pfc-search-panel .pfc-search-close:hover { background: #f0f0f0; color: #000; }
.pfc-search-status { padding: 8px 14px; font-size: 13px; color: #666; }
.pfc-search-status:empty { display: none; }
.pfc-search-results { list-style: none; margin: 0; padding: 0 0 8px; overflow-y: auto; flex: 1 1 auto; -webkit-overflow-scrolling: touch; }
.pfc-search-results li {
	display: flex; gap: 10px; padding: 10px 14px; margin: 0;
	border-bottom: 1px solid #f0f0f0; cursor: pointer; font-size: 14px; line-height: 1.4;
}
.pfc-search-results li:hover, .pfc-search-results li:focus, .pfc-search-results li.is-active { background: #fff7d6; outline: none; }
.pfc-res-page { flex: none; width: 58px; font-weight: 600; color: var(--pfc-accent); }
.pfc-res-page small { font-weight: 400; color: #888; }
.pfc-res-text { color: #444; word-break: break-word; }
.pfc-res-text mark { background: #ffd500; color: #000; padding: 0 1px; border-radius: 2px; }

@media (max-width: 640px) {
	.pfc-btn-label { display: none; }
	.pfc-search-btn { width: 42px; padding: 0; }
	.pfc-search-panel { width: 100%; bottom: 50px; }
}

.pfc-viewer.pfc-search-side .pfc-stage { padding-right: 376px; }

/* Anteprima veloce e caricamento progressivo */
.pfc-page { background: #fff; }
.pfc-page canvas { position: relative; z-index: 1; }
.pfc-page::before {
	content: ""; position: absolute; left: 50%; top: 50%;
	width: 28px; height: 28px; margin: -14px 0 0 -14px; border-radius: 50%;
	border: 3px solid rgba(0,0,0,.1); border-top-color: var(--pfc-accent);
	animation: pfc-spin .8s linear infinite;
}
.pfc-preview {
	position: absolute; inset: 0; z-index: 1;
	width: 100%; height: 100%; object-fit: contain; display: block;
}
.pfc-viewer.pfc-pdf-loading .pfc-zoom,
.pfc-viewer.pfc-pdf-loading .pfc-search-btn { opacity: .35; pointer-events: none; }
.pfc-viewer.pfc-pdf-loading .pfc-stage::after {
	content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; z-index: 5;
	background: linear-gradient(90deg, transparent, var(--pfc-accent), transparent);
	background-size: 40% 100%; background-repeat: no-repeat;
	animation: pfc-bar 1.1s linear infinite;
}
@keyframes pfc-bar { from { background-position: -40% 0; } to { background-position: 140% 0; } }

/* Logo azienda */
.pfc-toolbar { position: relative; }
.pfc-viewer .pfc-brand {
	display: inline-flex; align-items: center; gap: 8px;
	color: var(--pfc-fg); text-decoration: none; font-weight: 600; font-size: 15px; letter-spacing: .2px;
	border-radius: 20px; padding: 3px 10px 3px 3px; margin: 0; white-space: nowrap;
	-webkit-tap-highlight-color: transparent;
}
.pfc-viewer a.pfc-brand:hover, .pfc-viewer a.pfc-brand:focus-visible { background: rgba(255,255,255,.12); color: #fff; outline: none; text-decoration: none; }
.pfc-viewer img.pfc-brand-logo {
	display: block; flex: none; margin: 0; padding: 0;
	width: 32px !important; height: 32px !important; max-width: none !important;
	border-radius: 50%; object-fit: cover; background: #fff;
	box-shadow: 0 0 0 2px rgba(255,255,255,.15);
}
/* desktop: nella barra, a sinistra; i comandi restano centrati */
.pfc-viewer .pfc-brand-bar { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); }

/* visualizzatore stretto (smartphone / colonna piccola): solo il logo, accanto alla freccia sinistra.
   La classe pfc-narrow viene messa dal JS in base alla larghezza reale del visualizzatore. */
.pfc-viewer.pfc-narrow .pfc-brand-bar { position: static; transform: none; padding: 3px; margin-right: 2px; }
.pfc-viewer.pfc-narrow .pfc-brand-name { display: none; }
.pfc-viewer.pfc-narrow .pfc-first,
.pfc-viewer.pfc-narrow .pfc-last,
.pfc-viewer.pfc-narrow .pfc-sep,
.pfc-viewer.pfc-narrow .pfc-btn-label { display: none; }
.pfc-viewer.pfc-narrow .pfc-search-btn { width: 40px; padding: 0; }
.pfc-viewer.pfc-narrow .pfc-toolbar { flex-wrap: nowrap; gap: 0; }
.pfc-viewer.pfc-narrow .pfc-btn { width: 40px; }
/* telefoni molto stretti: la lente si nasconde (resta il pinch-zoom con le dita) */
.pfc-viewer.pfc-tiny .pfc-zoom { display: none; }
.pfc-viewer.pfc-tiny .pfc-btn { width: 38px; }
.pfc-viewer.pfc-tiny .pfc-page-input { width: 38px; }
@media (max-width: 640px) {
	.pfc-viewer .pfc-brand-bar { position: static; transform: none; padding: 3px; margin-right: 2px; }
	.pfc-viewer .pfc-brand-name { display: none; }
}

/* Protezione contenuti */
.pfc-viewer.pfc-protect, .pfc-viewer.pfc-protect * {
	-webkit-touch-callout: none !important;
	-webkit-user-select: none !important; user-select: none !important;
	-webkit-user-drag: none;
}
.pfc-viewer.pfc-protect .pfc-search-input { -webkit-user-select: text !important; user-select: text !important; }
.pfc-viewer.pfc-protect canvas, .pfc-viewer.pfc-protect img.pfc-preview { pointer-events: none; }
.pfc-viewer.pfc-protect .pfc-stage::before {
	content: "Contenuto protetto \2013  clicca per continuare";
	position: absolute; inset: 0; z-index: 30;
	display: none; align-items: center; justify-content: center; text-align: center; padding: 20px;
	background: #2b2d31; color: #f2f3f5; font-size: 15px;
}
.pfc-viewer.pfc-protect.pfc-shield .pfc-stage::before { display: flex; }
.pfc-viewer.pfc-protect.pfc-shield .pfc-book,
.pfc-viewer.pfc-protect.pfc-shield .pfc-zoom-layer { visibility: hidden; }
@media print {
	.pfc-viewer.pfc-protect { visibility: hidden !important; }
	.pfc-viewer.pfc-protect * { display: none !important; }
	body.pfc-embed-body:has(.pfc-protect) { display: none !important; }
}
