/* ==========================================================
 * Evento 3D Flipbook — front-end
 * ========================================================== */

/* ---------- Colors (light / dark / auto) ---------- */
.efb, .efb-cards {
	--efb-bg: #e9ecef; --efb-fg: #1d2328; --efb-muted: #5d6871; --efb-line: #c9cfd4;
	--efb-btn: #ffffff; --efb-btn-h: #f1f3f5; --efb-accent: #d9232e; --efb-focus: #1f9e8a;
	--efb-fsbg: #2b2f33;
}
.efb--dark {
	--efb-bg: #1d2226; --efb-fg: #e8ecef; --efb-muted: #9aa5ae; --efb-line: #39424a;
	--efb-btn: #2a3136; --efb-btn-h: #343c42; --efb-accent: #e8424b; --efb-focus: #3fc2ab;
}
@media (prefers-color-scheme: dark) {
	.efb--auto {
		--efb-bg: #1d2226; --efb-fg: #e8ecef; --efb-muted: #9aa5ae; --efb-line: #39424a;
		--efb-btn: #2a3136; --efb-btn-h: #343c42; --efb-accent: #e8424b; --efb-focus: #3fc2ab;
	}
}

/* ---------- Layout ---------- */
.efb { background: var(--efb-bg); color: var(--efb-fg); border-radius: 6px; padding: 16px 12px 10px; margin: 16px 0; box-sizing: border-box; max-width: 100%; overflow: hidden; position: relative; }
.efb *, .efb *::before, .efb *::after { box-sizing: border-box; }
.efb [hidden] { display: none !important; }
.efb__stage { position: relative; display: flex; justify-content: center; align-items: center; min-height: 200px; }
.efb__book { width: 100%; margin: 0 auto; min-width: 0 !important; min-height: 0 !important; touch-action: pan-y; /* page scrolls up/down; left/right swipes turn pages; pinch = our zoom */ }
.efb__page { background: #fff; overflow: hidden; }
.efb__page img { width: 100%; height: 100%; object-fit: cover; display: block; user-select: none; -webkit-user-drag: none; background: #f4f5f6; }
.efb__msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--efb-muted); font-size: 14px; text-align: center; padding: 16px; pointer-events: none; }
.efb__msg a { color: var(--efb-accent); margin-left: 4px; pointer-events: auto; }
.efb__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Icon buttons (toolbar + side arrows) ---------- */
.efb .efb__ib { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0; margin: 0; border: 0; border-radius: 4px; background: transparent; color: var(--efb-fg); cursor: pointer; text-decoration: none; box-shadow: none; line-height: 1; min-height: 0; }
.efb .efb__ib:hover { background: var(--efb-btn-h); color: var(--efb-fg); }
.efb .efb__ib svg { display: block; }
.efb button:focus-visible, .efb a:focus-visible, .efb input:focus-visible { outline: 2px solid var(--efb-focus); outline-offset: 1px; }
.efb .efb__side { position: absolute; top: 50%; transform: translateY(-50%); z-index: 3; width: 44px; height: 64px; color: var(--efb-muted); }
.efb .efb__side svg { width: 34px; height: 34px; }
.efb .efb__side--prev { left: 0; }
.efb .efb__side--next { right: 0; }
/* Width classes are set by the script from the flipbook's OWN width (works in narrow sidebars too) */
.efb.efb--compact .efb__side { display: none; }

/* ---------- Toolbar ---------- */
.efb__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 10px; margin: 12px auto 0; padding: 4px 8px; background: var(--efb-btn); border: 1px solid var(--efb-line); border-radius: 6px; width: fit-content; max-width: 100%; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.efb__grp { display: flex; align-items: center; gap: 2px; }
.efb__grp + .efb__grp { border-left: 1px solid var(--efb-line); padding-left: 10px; }
.efb__pg { display: inline-flex; align-items: center; gap: 4px; margin: 0 4px; font-size: 14px; font-variant-numeric: tabular-nums; color: var(--efb-fg); }
.efb .efb__pgin { width: 52px; height: 32px; padding: 0 4px; text-align: center; font: inherit; color: var(--efb-fg); background: var(--efb-bg); border: 1px solid var(--efb-line); border-radius: 4px; -moz-appearance: textfield; box-shadow: none; margin: 0; }
.efb .efb__pgin::-webkit-outer-spin-button, .efb .efb__pgin::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.efb__pgof { color: var(--efb-muted); white-space: nowrap; }
/* Labeled buttons (Prev / Next / Fullscreen) */
.efb .efb__btn { display: inline-flex; align-items: center; gap: 5px; height: 38px; padding: 0 12px; margin: 0; border: 1px solid var(--efb-line); border-radius: 4px; background: var(--efb-btn); color: var(--efb-fg); font: 600 14px/1 inherit; cursor: pointer; box-shadow: none; text-transform: none; letter-spacing: 0; }
.efb .efb__btn:hover { background: var(--efb-btn-h); color: var(--efb-fg); }
.efb .efb__btn svg { width: 18px; height: 18px; display: block; }
.efb .efb__btn--main { background: var(--efb-accent); border-color: var(--efb-accent); color: #fff; }
.efb .efb__btn--main:hover { background: var(--efb-accent); color: #fff; filter: brightness(1.08); }
.efb__lbl { white-space: nowrap; }

/* ---------- Thumbnails ---------- */
.efb__thumbs { display: flex; gap: 6px; overflow-x: auto; padding: 10px 2px 4px; scrollbar-width: thin; }
.efb .efb__thumb { position: relative; flex: 0 0 auto; width: 56px; height: 76px; padding: 0; border: 2px solid var(--efb-line); border-radius: 3px; background: var(--efb-btn); cursor: pointer; overflow: hidden; }
.efb .efb__thumb img { width: 100%; height: 100%; object-fit: contain; display: block; background: #fff; }
.efb .efb__thumb span { position: absolute; right: 2px; bottom: 2px; font-size: 10px; line-height: 1; padding: 2px 3px; border-radius: 2px; background: rgba(0,0,0,.55); color: #fff; }
.efb .efb__thumb[aria-current="true"] { border-color: var(--efb-accent); }

/* ---------- Zoom ---------- */
.efb__zoom { position: absolute; inset: 0; z-index: 4; display: flex; overflow: auto; background: var(--efb-bg); cursor: grab; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; overscroll-behavior: contain; }
.efb__zoom.is-drag { cursor: grabbing; }
.efb__zoomin { display: flex; flex: none; margin: auto; }
.efb__zoomin img { flex: 1 1 0; min-width: 0; width: 100%; height: 100%; object-fit: contain; display: block; user-select: none; -webkit-user-drag: none; background: #fff; }
.efb__hint { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 6; padding: 8px 14px; border-radius: 4px; background: rgba(0,0,0,.72); color: #fff; font-size: 14px; pointer-events: none; white-space: nowrap; }
.efb--zoomed .efb__side { display: none; }

/* ---------- Fullscreen (real + CSS for iPhone + lightbox) ---------- */
.efb.efb--fs { border-radius: 0; margin: 0; display: flex; flex-direction: column; background: var(--efb-fsbg); --efb-muted: #c4ccd3; }
.efb.efb--fs .efb__stage { flex: 1 1 auto; min-height: 0; }
.efb.efb--fs .efb__side { color: #e8ecef; }
.efb.efb--fs .efb__side:hover { background: rgba(255,255,255,.08); color: #fff; }
.efb.efb--fs .efb__zoom { background: var(--efb-fsbg); }
.efb:fullscreen { width: 100vw; height: 100vh; padding: 16px; }
.efb.efb--pseudo, .efb.efb--lb { position: fixed; inset: 0; z-index: 999999; width: auto; height: auto; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
html.efb-lock, html.efb-lock body { overflow: hidden !important; }
.efb-lb { position: fixed; inset: 0; z-index: 999998; background: rgba(0,0,0,.6); }

/* ---------- Thumbnail cards (mode="thumbnail" / category grid) ---------- */
.efb-cards { display: grid; grid-template-columns: repeat(var(--efb-cols, 3), minmax(0, 1fr)); gap: 20px; margin: 16px 0; }
.efb-cards--one { display: inline-grid; grid-template-columns: minmax(0, 240px); }
@media (max-width: 640px) { .efb-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }
.efb-card { display: flex; flex-direction: column; gap: 8px; padding: 0; margin: 0; border: 0; background: none; cursor: pointer; text-align: left; color: inherit; font: inherit; }
.efb-card__img { position: relative; display: block; width: 100%; aspect-ratio: 3 / 4; overflow: hidden; border-radius: 4px; background: #f1f3f5; box-shadow: 0 2px 10px rgba(0,0,0,.12); transition: transform .2s, box-shadow .2s; }
.efb-card__img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.efb-card:hover .efb-card__img { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,.18); }
.efb-card:focus-visible { outline: 2px solid #1f9e8a; outline-offset: 3px; }
.efb-card__title { font-weight: 600; line-height: 1.3; }

/* ---------- Fallback + text version ---------- */
.efb-fallback { margin: 12px 0; }
.efb-fallback .efb-download-only { display: inline-block; padding: 10px 16px; background: #d9232e; color: #fff; border-radius: 4px; text-decoration: none; font-weight: 600; }
/* Title shown as a colored button right above the flipbook; !important + high specificity so
   the MyListing listing layout (which recolors links) cannot strip the button styling. */
.efb-title { --efb-title-bg: #d9232e; --efb-title-fg: #ffffff; margin: 16px 0 10px; }
p.efb-title a.efb-open, .efb-title a.efb-open {
	display: inline-block !important;
	padding: 10px 18px !important;
	background: var(--efb-title-bg) !important;
	color: var(--efb-title-fg) !important;
	border-radius: 4px !important;
	font-weight: 700 !important;
	line-height: 1.2 !important;
	text-decoration: none !important;
	box-shadow: none !important;
	border: 0 !important;
}
p.efb-title a.efb-open:hover, .efb-title a.efb-open:hover { color: var(--efb-title-fg) !important; filter: brightness(1.08); text-decoration: none !important; }
.efb-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: normal; border: 0; }

/* ---------- Turning back on phones (1 page): previous page swings in from the spine ---------- */
.efb__swing { position: absolute; z-index: 3; perspective: 1800px; pointer-events: none; }
.efb__swingpage { position: absolute; inset: 0; transform-origin: left center; backface-visibility: hidden; animation: efb-swing var(--efb-swing, 1000ms) cubic-bezier(.25,.7,.3,1) forwards; box-shadow: -6px 0 24px rgba(0,0,0,.25); background: #fff; }
.efb__swingpage img { width: 100%; height: 100%; object-fit: cover; display: block; }
.efb__swingpage::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to left, rgba(0,0,0,.35), rgba(0,0,0,0) 60%); animation: efb-shade var(--efb-swing, 1000ms) ease-out forwards; }
@keyframes efb-swing { from { transform: rotateY(-92deg); } to { transform: rotateY(0deg); } }
@keyframes efb-shade { from { opacity: 1; } to { opacity: 0; } }

/* Narrow (< 600px): row 1 = page navigation, row 2 = zoom + thumbnails + fullscreen + download + close */
.efb.efb--narrow .efb__bar { width: 100%; gap: 2px 0; padding: 2px 4px; }
.efb.efb--narrow .efb__grp + .efb__grp { border-left: 0; padding-left: 0; }
.efb.efb--narrow .efb__grp--nav { order: 1; flex: 1 0 100%; justify-content: center; border-bottom: 1px solid var(--efb-line); padding-bottom: 2px; }
.efb.efb--narrow .efb__grp--zoom { order: 2; margin-right: 12px; }
.efb.efb--narrow .efb__grp--tools { order: 3; }
.efb.efb--narrow .efb__btn { padding: 0 10px; }
.efb.efb--narrow .efb__fsbtn .efb__lbl { display: none; } /* fullscreen shrinks to icon on phones */
.efb.efb--narrow .efb__fsbtn { padding: 0; width: 38px; justify-content: center; }
/* Tiny (< 420px): Prev/Next keep their red colour but shrink to icon only */
.efb.efb--tiny { padding: 10px 6px 8px; }
.efb.efb--tiny .efb__ib { width: 34px; height: 34px; }
.efb.efb--tiny .efb__pgin { width: 44px; }
.efb.efb--tiny .efb__btn--main .efb__lbl { display: none; }
.efb.efb--tiny .efb__btn { padding: 0 9px; }
@media (prefers-reduced-motion: reduce) {
	.efb *, .efb-card__img { transition: none !important; }
}
