/* CMG Flipbook viewer — layout modelled on the Quad/Coverstand reader. */
:root { --cfb-accent: #79942d; --cfb-bar: #f4f4f5; --cfb-ink: #1f2933; --cfb-line: #d9dbe0; --cfb-stage: #5b5f66; --cfb-bar-h: 48px; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body.cfb { font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--cfb-ink); background: var(--cfb-stage); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Bars */
.cfb-top, .cfb-bottom { position: fixed; left: 0; right: 0; height: var(--cfb-bar-h); display: flex; align-items: center; gap: 4px; padding: 0 6px; background: var(--cfb-bar); z-index: 20; }
.cfb-top { top: 0; border-bottom: 1px solid var(--cfb-line); }
.cfb-bottom { bottom: 0; border-top: 1px solid var(--cfb-line); justify-content: space-between; padding-bottom: env(safe-area-inset-bottom); }
.cfb-ico { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 6px; color: var(--cfb-accent); text-decoration: none; }
.cfb-ico:hover, .cfb-ico:focus-visible { background: rgba(0,0,0,.06); outline: none; }
.cfb-ico.is-on { background: var(--cfb-accent); color: #fff; }
.cfb-brand { display: flex; align-items: center; height: 100%; padding: 6px 4px; }
.cfb-brand img { max-height: 30px; max-width: 150px; width: auto; display: block; }
.cfb-title { margin: 0 auto 0 8px; font-size: 20px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cfb-top-right, .cfb-bottom-left, .cfb-bottom-right { display: flex; gap: 2px; }
.cfb-pageinfo { font-size: 18px; font-weight: 600; white-space: nowrap; }

/* Stage + book */
.cfb-stage { position: fixed; top: var(--cfb-bar-h); bottom: var(--cfb-bar-h); left: 0; right: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.cfb-book { margin: 0 auto; }
.cfb-page { position: relative; background: #fff; overflow: hidden; }
.cfb-page canvas { width: 100%; height: 100%; display: block; }
.cfb-page .cfb-ph { position: absolute; inset: 0; display: grid; place-items: center; color: #9aa0a6; font-size: 13px; }
.cfb-links { position: absolute; inset: 0; pointer-events: none; }
.cfb-links a { position: absolute; display: block; pointer-events: auto; border-radius: 2px; }
.cfb-links a:hover, .cfb-links a:focus-visible { background: color-mix(in srgb, var(--cfb-accent) 22%, transparent); outline: 1px solid var(--cfb-accent); }
.cfb-hit { position: absolute; background: rgba(255, 213, 0, .45); mix-blend-mode: multiply; pointer-events: none; border-radius: 2px; }
.cfb-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 5; width: 44px; height: 64px; display: grid; place-items: center; color: #fff; background: rgba(0,0,0,.25); border-radius: 6px; }
.cfb-nav:hover { background: rgba(0,0,0,.45); }
.cfb-nav:disabled { opacity: 0; pointer-events: none; }
.cfb-nav-prev { left: 8px; } .cfb-nav-next { right: 8px; }
.cfb-nav svg { width: 28px; height: 28px; }
.cfb-loading { position: absolute; color: #fff; font-size: 14px; }
.cfb-noscript { color: #fff; }

/* Drawer (Quad's left menu) */
.cfb-drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(320px, 86vw); background: #fff; z-index: 40; box-shadow: 2px 0 18px rgba(0,0,0,.25); overflow-y: auto; transform: translateX(-102%); transition: transform .2s ease; }
.cfb-drawer.is-open { transform: none; }
.cfb-drawer[hidden] { display: block; visibility: hidden; }
.cfb-drawer.is-open[hidden] { visibility: visible; }
.cfb-drawer-head { display: flex; align-items: center; gap: 12px; padding: 14px 12px; border-bottom: 1px solid var(--cfb-line); }
.cfb-drawer-head img { max-height: 44px; max-width: 200px; }
.cfb-drawer ul { list-style: none; margin: 0; padding: 0; }
.cfb-drawer li > * { display: flex; align-items: center; gap: 14px; width: 100%; padding: 13px 18px; font-size: 18px; color: var(--cfb-accent); text-decoration: none; text-align: left; border-bottom: 1px solid #eee; border-left: 4px solid transparent; }
.cfb-drawer li > *:hover { background: #f6f6f7; }
.cfb-drawer li > .is-active { border-left-color: var(--cfb-accent); background: #f6f6f7; }
.cfb-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30; }

/* Panels: contents, archive, advertisers, search */
.cfb-panel { position: fixed; top: var(--cfb-bar-h); bottom: var(--cfb-bar-h); right: 0; width: min(760px, 100vw); background: #fff; z-index: 25; display: flex; flex-direction: column; box-shadow: -2px 0 18px rgba(0,0,0,.25); }
.cfb-panel[hidden] { display: none; }
.cfb-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 18px; border-bottom: 1px solid var(--cfb-line); }
.cfb-panel-head h2 { margin: 0; font-size: 18px; }
.cfb-panel-body { overflow-y: auto; padding: 16px; flex: 1; }
.cfb-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 14px; }
.cfb-thumb { display: block; text-align: center; font-size: 12px; color: #444; text-decoration: none; }
.cfb-thumb .cfb-thumb-img { aspect-ratio: 3/4; background: #eef0f2; display: grid; place-items: center; border: 2px solid transparent; overflow: hidden; }
.cfb-thumb canvas, .cfb-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cfb-thumb.is-current .cfb-thumb-img { border-color: var(--cfb-accent); }
.cfb-thumb:hover .cfb-thumb-img { border-color: color-mix(in srgb, var(--cfb-accent) 50%, transparent); }
.cfb-list { list-style: none; margin: 0; padding: 0; }
.cfb-list li button, .cfb-list li a { display: flex; justify-content: space-between; gap: 12px; width: 100%; text-align: left; padding: 11px 6px; border-bottom: 1px solid #eee; text-decoration: none; }
.cfb-list li button:hover, .cfb-list li a:hover { background: #f6f6f7; }
.cfb-list .cfb-pg { color: var(--cfb-accent); font-weight: 600; white-space: nowrap; }
.cfb-search { display: flex; gap: 8px; margin-bottom: 12px; }
.cfb-search input { flex: 1; font: inherit; padding: 9px 12px; border: 1px solid var(--cfb-line); border-radius: 6px; }
.cfb-search button { padding: 9px 16px; border-radius: 6px; background: var(--cfb-accent); color: #fff; }
.cfb-snip { color: #555; font-size: 13px; }
.cfb-snip mark { background: rgba(255,213,0,.6); }
.cfb-muted { color: #777; }

/* Zoom */
.cfb-zoom { position: fixed; inset: 0; z-index: 50; background: rgba(20,20,20,.94); overflow: auto; }
.cfb-zoom[hidden] { display: none; }
.cfb-zoom-inner { display: flex; gap: 8px; justify-content: center; padding: 56px 20px 20px; width: max-content; min-width: 100%; }
.cfb-zoom canvas { background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.5); }
.cfb-zoom-close { position: fixed; top: 8px; right: 12px; color: #fff; z-index: 51; }

.cfb-toast { position: fixed; bottom: calc(var(--cfb-bar-h) + 12px); left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.8); color: #fff; padding: 8px 14px; border-radius: 6px; z-index: 60; font-size: 14px; }

@media (max-width: 640px) {
	.cfb-title { font-size: 16px; margin-left: 4px; }
	.cfb-brand { display: none; }
	.cfb-pageinfo { font-size: 15px; }
	.cfb-nav { display: none; }
	#cfb-mode { display: none; }
	.cfb-ico { width: 36px; }
}
@media (prefers-reduced-motion: reduce) { .cfb-drawer { transition: none; } }
