/* Tracts and Kainos News: the list of booklets and the book viewer (assets/js/booklet.js) */
.bk-list { background-color: #f9f6f1; padding-bottom: 5rem; }
.bk-grid { list-style: none; margin: 0 auto; padding: 0; max-width: 64rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2.5rem 2rem; }
.bk-card { display: flex; flex-direction: column; align-items: center; text-align: center; color: inherit; text-decoration: none; border-radius: 6px; outline-offset: 6px; }
.bk-card:focus-visible { outline: 2px solid #c9960e; }
.bk-cover {
  position: relative; display: block; width: 100%; max-width: 230px; border-radius: 2px 6px 6px 2px; overflow: hidden; background: #fff;
  box-shadow: 0 1px 2px rgba(30, 51, 32, .12), 0 10px 24px rgba(30, 51, 32, .16);
  transform: perspective(900px) rotateY(0deg); transform-origin: left center; transition: transform .45s ease, box-shadow .45s ease;
}
/* The spine edge of the cover */
.bk-cover::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 10%; background: linear-gradient(to right, rgba(0, 0, 0, .18), rgba(0, 0, 0, .04) 40%, rgba(255, 255, 255, .12) 55%, transparent); pointer-events: none; }
.bk-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.bk-card:hover .bk-cover, .bk-card:focus-visible .bk-cover { transform: perspective(900px) rotateY(-14deg); box-shadow: 0 1px 2px rgba(30, 51, 32, .12), 14px 16px 30px rgba(30, 51, 32, .22); }
.bk-title { margin-top: 1.1rem; font: 700 1.15rem/1.3 "Playfair Display", Georgia, serif; color: #1e3320; }
.bk-sub { margin-top: .3rem; font: italic 400 .95rem/1.45 "Playfair Display", Georgia, serif; color: #2a4530; }
.bk-meta { margin-top: .5rem; font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #c9960e; }
.bk-empty { max-width: 34rem; margin: 0 auto; padding: 2.5rem 1.5rem; text-align: center; border: 1px dashed rgba(61, 90, 62, .35); border-radius: 6px; color: #3a4a3b; font-size: 1.05rem; }
.bk-nojs { margin-top: .5rem; font-size: .85rem; }
.bk-nojs a { color: #3d5a3e; text-decoration: underline; margin: 0 .25rem; }
@media (max-width: 520px) {
  .bk-grid { grid-template-columns: 1fr 1fr; gap: 2rem 1rem; }
  .bk-title { font-size: 1rem; }
  .bk-sub { font-size: .85rem; }
}
@media (prefers-reduced-motion: reduce) { .bk-cover { transition: none; } }

/* Viewer */
html.bk-locked { overflow: hidden; }
.bk-viewer {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: radial-gradient(ellipse at 50% 40%, #2a4530 0%, #1e3320 55%, #142417 100%); color: #fff;
  display: none; flex-direction: column; overflow: hidden;
}
.bk-viewer[open] { display: flex; }
.bk-viewer::backdrop { background: #142417; }
.bk-bar { display: flex; align-items: center; gap: 1rem; padding: max(12px, env(safe-area-inset-top)) 16px 8px; }
.bk-bar-text { flex: 1; min-width: 0; text-align: center; padding-left: 44px; }
.bk-v-title { font: 700 clamp(1rem, 2.4vw, 1.3rem)/1.25 "Playfair Display", Georgia, serif; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bk-v-count { margin-top: .15rem; font-size: .72rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: #e2b742; }
.bk-viewer button { padding: 0; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .06); color: #fff; cursor: pointer; transition: background-color .2s, opacity .2s; }
.bk-viewer button:hover:not(:disabled) { background: rgba(255, 255, 255, .16); }
.bk-viewer button:focus-visible { outline: 2px solid #c9960e; outline-offset: 2px; }
.bk-viewer button:disabled { opacity: .3; cursor: default; }
.bk-stage { position: relative; flex: 1; min-height: 0; margin: 8px 16px; display: flex; align-items: center; justify-content: center; perspective: 2200px; touch-action: pan-y pinch-zoom; user-select: none; -webkit-user-select: none; cursor: pointer; }
.bk-nav { display: flex; align-items: center; justify-content: center; gap: 1.5rem; padding: 6px 16px max(16px, env(safe-area-inset-bottom)); }
.bk-hint { min-width: 0; font-size: .8rem; color: rgba(255, 255, 255, .6); text-align: center; }

.bk-book { position: relative; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.4, .1, .2, 1), opacity .5s ease; opacity: 0; scale: .9; }
.bk-viewer.is-open .bk-book { opacity: 1; scale: 1; transition: transform .7s cubic-bezier(.4, .1, .2, 1), opacity .5s ease, scale .6s cubic-bezier(.2, .8, .3, 1); }
.bk-leaf {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  transform-origin: left center; transform-style: preserve-3d; transform: rotateY(0deg);
  transition: transform .7s cubic-bezier(.45, .05, .25, 1);
}
.bk-book.is-spread .bk-leaf { left: 50%; width: 50%; }
.bk-leaf.is-turned { transform: rotateY(-180deg); }
.bk-book.no-anim, .bk-book.no-anim .bk-leaf { transition: none !important; }
/* One page at a time: a turned page lifts away to the left, then is put aside */
.bk-book:not(.is-spread) .bk-leaf.is-turned:not(.is-moving) { visibility: hidden; }

.bk-face { position: absolute; inset: 0; overflow: hidden; background: #fbf8f2; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 12px 34px rgba(0, 0, 0, .35); }
.bk-face img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.bk-back { transform: rotateY(180deg); }
.bk-blank { background: linear-gradient(135deg, #f6f1e6, #ece4d3); }
/* Shading towards the spine, so two pages read as an open book */
.bk-face::after { content: ""; position: absolute; inset: 0; pointer-events: none; transition: opacity .7s; }
.bk-book.is-spread .bk-front::after { background: linear-gradient(to right, rgba(0, 0, 0, .22), rgba(0, 0, 0, .06) 6%, transparent 14%); }
.bk-book.is-spread .bk-back::after { background: linear-gradient(to left, rgba(0, 0, 0, .22), rgba(0, 0, 0, .06) 6%, transparent 14%); }
.bk-book:not(.is-spread) .bk-front::after { background: linear-gradient(to right, rgba(0, 0, 0, .14), transparent 6%); }
.bk-front { border-radius: 0 4px 4px 0; }
.bk-back { border-radius: 4px 0 0 4px; }
/* A page darkens a little as it turns */
.bk-leaf.is-moving .bk-face::after { animation: bk-shade .7s ease-in-out; }
@keyframes bk-shade { 50% { box-shadow: inset 0 0 0 999px rgba(0, 0, 0, .18); } }

@media (max-width: 639.98px) {
  .bk-stage { margin: 4px 10px; }
  .bk-nav { gap: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  .bk-book, .bk-viewer.is-open .bk-book, .bk-leaf { transition: none !important; }
  .bk-leaf.is-moving .bk-face::after { animation: none; }
}
