/* Flip-book catalog viewer. Pages are A4 and sized from --pw/--ph (set by JS);
   all inner sizes use --u (1% of page width) so content scales with the page. */
html, body.fb { height: 100%; }
body.fb { margin: 0; overflow: hidden; background: #dfe5e7; display: flex; flex-direction: column; padding-bottom: 0; }
@media (prefers-color-scheme: dark) { body.fb { background: #0a1a1e; } }

/* top bar - brand coloured, like the reference catalogs */
.fb-top { flex: none; display: flex; align-items: center; gap: .4rem; height: 52px; padding: 0 .6rem; padding-top: env(safe-area-inset-top); background: var(--primary-700); color: #fff; z-index: 20; }
.fb-title { flex: 1; display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 800; min-width: 0; }
.fb-title img { height: 28px; width: auto; filter: brightness(0) invert(1); }
.fb-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-title small { font-weight: 400; opacity: .8; margin-inline-start: .3rem; }
.fb-ico { width: 42px; height: 42px; display: grid; place-items: center; color: #fff; background: none; border: 0; border-radius: 12px; font-size: 1.1rem; cursor: pointer; }
.fb-ico:hover { background: rgb(255 255 255 / .14); }

/* stage */
.fb-stage { position: relative; flex: 1; min-height: 0; display: flex; overflow: hidden; }
.fb-stage.zoomed { overflow: auto; }
.fb-book { margin: auto; display: flex; align-items: stretch; box-shadow: 0 20px 50px -14px rgb(0 49 57 / .5); border-radius: 4px; --pw: 300px; --ph: 424px; }
.cpage { position: relative; width: var(--pw); height: var(--ph); flex: none; background: #fff; color: #0f172a; overflow: hidden; --u: calc(var(--pw) / 100); font-size: calc(var(--u) * 3); line-height: 1.5; }
.cpage[hidden] { display: none; }
.cpage + .cpage { box-shadow: inset 6px 0 14px -8px rgb(0 0 0 / .35); }
[dir="rtl"] .cpage + .cpage { box-shadow: inset -6px 0 14px -8px rgb(0 0 0 / .35); }
.cpage.in-next { animation: fbin-next .35s var(--ease); }
.cpage.in-prev { animation: fbin-prev .35s var(--ease); }
@keyframes fbin-next { from { opacity: 0; transform: translateX(3%); } }
@keyframes fbin-prev { from { opacity: 0; transform: translateX(-3%); } }
[dir="rtl"] .cpage.in-next { animation-name: fbin-prev; }
[dir="rtl"] .cpage.in-prev { animation-name: fbin-next; }

.fb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgb(0 49 57 / .65); color: #fff; cursor: pointer; z-index: 10; backdrop-filter: blur(6px); transition: opacity .2s; }
.fb-nav:disabled { opacity: 0; pointer-events: none; }
.fb-nav.prev { inset-inline-start: .6rem; } .fb-nav.next { inset-inline-end: .6rem; }
@media (max-width: 720px) { .fb-nav { display: none; } }

/* bottom */
.fb-count { position: absolute; left: 50%; bottom: 64px; transform: translateX(-50%); z-index: 15; padding: .15rem .9rem; border-radius: 10px 10px 0 0; background: rgb(0 0 0 / .45); color: #fff; font-size: .8rem; font-weight: 700; direction: ltr; backdrop-filter: blur(6px); }
.fb-bar { flex: none; display: flex; justify-content: center; gap: .2rem; padding: .35rem .6rem calc(.35rem + env(safe-area-inset-bottom)); background: #2a2a2a; z-index: 20; }
.fb-bar > * { width: 46px; height: 42px; display: grid; place-items: center; background: none; border: 0; color: #fff; font-size: 1.1rem; border-radius: 10px; cursor: pointer; }
.fb-bar > *:hover { background: rgb(255 255 255 / .12); }
.fb-bar a { color: #fff; }

/* sheets */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgb(0 20 24 / .55); backdrop-filter: blur(3px); display: flex; justify-content: flex-start; }
.sheet[hidden] { display: none; }
.sheet-in { width: min(380px, 92vw); height: 100%; overflow: auto; background: var(--surface); color: var(--text); padding: 1rem; animation: sheetin .25s var(--ease); }
.sheet.wide { justify-content: center; align-items: center; }
.sheet.wide .sheet-in { width: min(900px, 96vw); height: min(80vh, 720px); border-radius: 20px; }
@keyframes sheetin { from { opacity: 0; transform: translateY(10px); } }
.sheet-h { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .8rem; position: sticky; top: -1rem; background: var(--surface); padding: .4rem 0; }
.sheet .x { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border); background: none; color: var(--text); cursor: pointer; flex: none; }
.sheet-list { list-style: none; margin: 0; padding: 0; }
.sheet-list a { display: flex; justify-content: space-between; gap: 1rem; padding: .75rem .4rem; color: var(--text); border-bottom: 1px solid var(--border); }
.sheet-list a:hover { color: var(--accent-strong); }
.sheet-list em { font-style: normal; color: var(--muted); }
.fb-search { flex: 1; display: flex; align-items: center; gap: .6rem; background: var(--bg-soft); border: 1.5px solid var(--border); border-radius: 999px; padding: 0 1rem; }
.fb-search input { flex: 1; min-width: 0; border: 0; background: none; font: inherit; font-size: 16px; color: var(--text); padding: .6rem 0; outline: none; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: .7rem; }
.thumb { aspect-ratio: 1 / 1.414; border: 1.5px solid var(--border); border-radius: 8px; background: #fff; color: #0f172a; position: relative; cursor: pointer; padding: .5rem; display: flex; align-items: center; justify-content: center; text-align: center; font: inherit; font-size: .72rem; font-weight: 600; transition: .2s; }
.thumb:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: var(--shadow); }
.thumb em { position: absolute; bottom: .3rem; inset-inline: 0; font-style: normal; color: var(--primary-700); font-size: .72rem; }
.fb-toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: #111; color: #fff; padding: .5rem 1.1rem; border-radius: 999px; z-index: 70; font-size: .85rem; }

/* ── page content ────────────────────────────────────────────────────── */
.pad { position: absolute; inset: 0; padding: calc(var(--u) * 6) calc(var(--u) * 6) calc(var(--u) * 5); display: flex; flex-direction: column; }
.ph { display: flex; align-items: baseline; justify-content: space-between; gap: 1em; margin: 0 0 calc(var(--u) * 3); padding-bottom: calc(var(--u) * 2); border-bottom: calc(var(--u) * .5) solid var(--primary-500); font-size: calc(var(--u) * 4.4); font-weight: 800; color: var(--primary-800); }
.ph em { font-style: normal; font-size: .6em; color: var(--muted); font-weight: 500; }
.pgrid { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(2, 1fr); gap: calc(var(--u) * 3); }
.pcell { display: flex; flex-direction: column; min-height: 0; color: inherit; border-radius: calc(var(--u) * 1.6); border: 1px solid #e2e8f0; overflow: hidden; background: #fff; transition: box-shadow .2s; }
.pcell:hover { box-shadow: 0 6px 18px -6px rgb(0 49 57 / .3); }
.pcell.flash { animation: flash 1s ease 2; }
@keyframes flash { 50% { box-shadow: 0 0 0 calc(var(--u) * 1) var(--primary-400); } }
.pimg { position: relative; flex: 1 1 0; min-height: 0; overflow: hidden; background: radial-gradient(circle at 50% 40%, #fff, #f1f5f9); }
.pimg img { position: absolute; inset: 7%; width: 86%; height: 86%; object-fit: contain; }
.pnew { position: absolute; top: calc(var(--u) * 1); inset-inline-start: calc(var(--u) * 1); background: var(--primary-600); color: #fff; font-size: calc(var(--u) * 2.2); padding: 0 calc(var(--u) * 1.6); border-radius: 999px; }
.pinfo { flex: none; padding: calc(var(--u) * 1.6) calc(var(--u) * 2); display: flex; flex-direction: column; gap: calc(var(--u) * .3); }
.pinfo h3 { margin: 0; font-size: calc(var(--u) * 3.1); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.psub { font-size: calc(var(--u) * 2.1); color: var(--primary-600); font-weight: 600; }
.pinfo ul { margin: 0; padding: 0; list-style: none; font-size: calc(var(--u) * 2.1); color: #475569; }
.pinfo li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pdim, .psku { font-size: calc(var(--u) * 2.1); color: #64748b; }
.psku { color: var(--primary-700); font-weight: 700; }
.pfoot { display: flex; justify-content: space-between; margin-top: calc(var(--u) * 2); font-size: calc(var(--u) * 2.2); color: #94a3b8; }

.toc { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: calc(var(--u) * 2); }
.toc a { display: flex; align-items: baseline; gap: .5em; color: #0f172a; font-size: calc(var(--u) * 3.4); font-weight: 700; }
.toc .dots { flex: 1; border-bottom: 2px dotted #cbd5e1; transform: translateY(-.25em); }
.toc .num { color: var(--primary-700); }
.toc small { color: #64748b; font-size: calc(var(--u) * 2.3); }

.cv { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; align-items: center; text-align: center; padding: calc(var(--u) * 10) calc(var(--u) * 8) calc(var(--u) * 7); color: #fff;
  background: radial-gradient(120% 70% at 85% 0, rgb(38 191 206 / .6), transparent 60%), linear-gradient(165deg, var(--primary-900), var(--primary-700)); }
.cv::before { content: ""; position: absolute; inset: 0; background: var(--cv) center / cover; opacity: .28; mix-blend-mode: luminosity; }
.cv > * { position: relative; }
.cv-logo { height: calc(var(--u) * 12); width: auto; filter: brightness(0) invert(1); }
.cv-mid h1 { font-size: calc(var(--u) * 13); margin: 0 0 .2em; font-weight: 900; }
.cv-mid h2 { font-size: calc(var(--u) * 7); margin: 0 0 .4em; }
.cv-mid p { font-size: calc(var(--u) * 3.6); opacity: .85; margin: 0 0 .6em; }
.cv-foot { font-size: calc(var(--u) * 2.8); opacity: .75; direction: ltr; }
.bk-btn { display: inline-block; margin: calc(var(--u) * 2) 0 calc(var(--u) * 3); padding: .5em 1.6em; border-radius: 999px; background: #fff; color: var(--primary-800); font-weight: 800; font-size: calc(var(--u) * 3.2); }
.bk-line { font-size: calc(var(--u) * 3.2) !important; margin: .2em 0 !important; }
img.broken { visibility: hidden; }

/* ── print / Save as PDF: every page, A4 ─────────────────────────────── */
@media print {
  @page { size: A4; margin: 0; }
  html, body.fb { height: auto; overflow: visible; background: #fff; display: block; }
  .fb-top, .fb-bar, .fb-count, .fb-nav, .sheet, .fb-toast { display: none !important; }
  .fb-stage { display: block; overflow: visible; }
  .fb-book { display: block; box-shadow: none; --pw: 210mm; --ph: 297mm; }
  .cpage, .cpage[hidden] { display: block !important; width: 210mm; height: 297mm; page-break-after: always; break-after: page; box-shadow: none !important; animation: none !important; }
  .cpage, .cv, .pimg { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
