/* KynFlip catalogue viewer (assets/js/tools/flipbook.js): /outils/catalogue-reliure and /catalogues/<slug> */
.kf { --kf-h: min(78vh, 760px); position: relative; width: 100%; min-width: 0; max-width: 100%; display: flex; flex-direction: column; background: #fff; border-radius: 20px; overflow: hidden;
  box-shadow: 0 0 0 1px var(--line, rgba(17,17,17,.1)); outline: none; direction: ltr; }
.kf:focus-visible { box-shadow: 0 0 0 1px var(--line, rgba(17,17,17,.1)), 0 0 0 3px rgba(17,17,17,.12); }
.kf__stage { position: relative; height: var(--kf-h); min-height: 300px; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 40%, #f6f2ec 0%, #e9e3da 70%, #e0d9ce 100%); }
.kf__scroll { position: absolute; inset: 0; overflow: auto; touch-action: pan-y; overscroll-behavior: contain; scrollbar-width: thin; }
.kf--zoomed .kf__scroll { touch-action: pan-x pan-y; cursor: grab; }
.kf__scroll.is-pan { cursor: grabbing; user-select: none; }
.kf__inner { display: flex; min-width: 100%; min-height: 100%; width: max-content; height: max-content; }
.kf__book { position: relative; display: flex; margin: auto; padding: 24px; perspective: 2600px; }
@media (max-width: 600px) { .kf__book { padding: 12px; } }
.kf__p { position: relative; flex: none; background: #fff; box-shadow: 0 18px 40px -22px rgba(17,17,17,.55), 0 2px 6px rgba(17,17,17,.12); }
.kf__p canvas { display: block; width: 100%; height: 100%; }
.kf__p--void { background: transparent; box-shadow: none; }
.kf__p:has(> canvas:not([data-w]))::before { content: ""; position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%;
  border: 3px solid rgba(17,17,17,.1); border-top-color: var(--red, #E30000); animation: kfspin .8s linear infinite; }
/* centre fold: shadow on the inner edges of a spread */
.kf__book--spread .kf__p:not(.kf__p--void)::after { content: ""; position: absolute; top: 0; bottom: 0; width: 9%; pointer-events: none; }
.kf__book--spread .kf__p:first-child::after { right: 0; background: linear-gradient(to left, rgba(0,0,0,.22), rgba(0,0,0,.06) 35%, transparent); }
.kf__book--spread .kf__p:last-of-type::after { left: 0; background: linear-gradient(to right, rgba(0,0,0,.2), rgba(0,0,0,.05) 35%, transparent); }
.kf__book--cover .kf__p:last-of-type::after, .kf__book--end .kf__p:first-child::after { display: none; }
.kf__leaf { position: absolute; z-index: 3; transform-style: preserve-3d; will-change: transform; pointer-events: none; }
.kf__face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: #fff; overflow: hidden;
  box-shadow: 0 10px 40px -10px rgba(17,17,17,.45); }
.kf__face canvas { display: block; width: 100%; height: 100%; }
.kf__face--back { transform: rotateY(180deg); }
.kf__face--paper { background: linear-gradient(90deg, #f4f1ec, #fff 40%, #f7f5f1); }
.kf__shade { position: absolute; inset: 0; opacity: 0; pointer-events: none; background: linear-gradient(90deg, rgba(0,0,0,.35), rgba(0,0,0,.05) 60%, rgba(0,0,0,.18)); }
/* mirrored book for right-to-left catalogues (Arabic): the pages are mirrored back */
.kf--rtl .kf__book { transform: scaleX(-1); }
.kf--rtl .kf__p canvas, .kf--rtl .kf__face canvas { transform: scaleX(-1); }
.kf--rtl .kf__thumbs { direction: rtl; }
.kf--rtl .kf__grp:first-child { flex-direction: row-reverse; }
.kf--rtl .kf__grp:first-child svg, .kf--rtl .kf__nav svg { transform: scaleX(-1); }
.kf--rtl .kf__nav--prev { left: auto; right: 10px; }
.kf--rtl .kf__nav--next { right: auto; left: 10px; }

.kf__nav { position: absolute; top: 50%; z-index: 4; width: 48px; height: 48px; margin-top: -24px; border: 0; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.92); color: var(--ink, #111); box-shadow: 0 6px 20px -8px rgba(17,17,17,.45); cursor: pointer; transition: background .2s, color .2s, opacity .2s, transform .2s; }
.kf__nav:hover { background: var(--ink, #111); color: #fff; }
.kf__nav:active { transform: scale(.94); }
.kf__nav:disabled { opacity: 0; pointer-events: none; }
.kf__nav--prev { left: 10px; }
.kf__nav--next { right: 10px; }
@media (hover: none) and (max-width: 700px) { .kf__nav { width: 40px; height: 40px; margin-top: -20px; background: rgba(255,255,255,.8); } }

.kf__bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 12px; padding: 8px 10px; border-top: 1px solid var(--line, rgba(17,17,17,.1)); background: #fff; }
.kf__grp { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.kf__b { display: inline-grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 12px; background: transparent; color: var(--ink, #111); cursor: pointer; text-decoration: none; transition: background .2s; }
.kf__b:hover { background: #F1EEE9; }
.kf__b:disabled { opacity: .3; cursor: default; background: transparent; }
.kf__b[aria-pressed="true"] { background: #F1EEE9; }
.kf__pg { display: inline-flex; align-items: center; gap: 6px; padding: 0 6px; font-size: 14px; font-weight: 600; color: #3a3631; }
.kf__num { width: 64px; height: 36px; padding: 0 6px; border-radius: 10px; border: 1px solid rgba(17,17,17,.16); text-align: center; font: inherit; font-size: 15px; background: #fff; }
.kf__tot { color: var(--muted, #6E6862); white-space: nowrap; }
.kf__zv { min-width: 52px; text-align: center; font-size: 13px; font-weight: 600; color: var(--muted, #6E6862); }
@media (max-width: 520px) {
  .kf__bar { justify-content: center; padding: 6px; }
  .kf__b { width: 40px; height: 40px; }
  .kf__b[data-a="first"], .kf__b[data-a="last"], .kf__zv { display: none; }
  .kf__pgl { display: none; }
}

.kf__thumbs { min-width: 0; display: flex; gap: 14px; overflow-x: auto; padding: 10px 12px 12px; background: #FBFAF8; border-top: 1px solid var(--line, rgba(17,17,17,.1)); scrollbar-width: thin; scroll-snap-type: x proximity; }
.kf__tg { display: flex; gap: 1px; flex: none; padding: 3px; border-radius: 6px; scroll-snap-align: center; transition: background .2s; }
.kf__tg.is-on { background: var(--red, #E30000); }
.kf__t { position: relative; height: 76px; padding: 0; border: 0; background: #fff; cursor: pointer; box-shadow: 0 1px 4px rgba(17,17,17,.18); overflow: hidden; }
.kf__t canvas { display: block; width: 100%; height: 100%; }
.kf__t span { position: absolute; bottom: 2px; right: 2px; min-width: 18px; padding: 0 4px; border-radius: 4px; background: rgba(17,17,17,.7); color: #fff; font-size: 10.5px; font-weight: 600; line-height: 16px; text-align: center; }
.kf__t:hover { outline: 2px solid var(--ink, #111); outline-offset: -2px; }

.kf__load { position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; background: rgba(246,242,236,.8); font-weight: 600; color: #3a3631; }
.kf__spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(17,17,17,.12); border-top-color: var(--red, #E30000); animation: kfspin .8s linear infinite; }
@keyframes kfspin { to { transform: rotate(360deg); } }
.kf__err { position: absolute; left: 50%; top: 50%; z-index: 7; transform: translate(-50%, -50%); width: min(90%, 460px); margin: 0; padding: 14px 18px; border-radius: 14px; background: #FDECEC; color: #A30000; font-weight: 600; text-align: center; }

/* full screen (API or CSS fallback) */
.kf:fullscreen, .kf.kf--full { border-radius: 0; width: 100vw; height: 100vh; height: 100dvh; }
.kf:fullscreen .kf__stage, .kf.kf--full .kf__stage { height: auto; flex: 1 1 auto; }
.kf.kf--full { position: fixed; inset: 0; z-index: 1000; }
html.kf-lock, html.kf-lock body { overflow: hidden; }
@media (prefers-reduced-motion: reduce) { .kf__spin { animation-duration: 2s; } }
