/* =========================================================
   Publications list + flipbook viewer  –  Edulateral Foundation
   ========================================================= */

/* ---------- Publications list ---------- */
.pub-list { background: var(--cream); padding: 64px 0 96px; }
.pub-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 40px 32px; }

.pub-card { display: flex; flex-direction: column; }
.pub-card-link { display: block; color: inherit; text-decoration: none; }
.pub-cover {
  position: relative; aspect-ratio: 612 / 792; border-radius: 6px 14px 14px 6px; overflow: hidden;
  background: #fff; box-shadow: 0 16px 40px rgba(14,32,56,.18), -6px 0 0 rgba(14,32,56,.12) inset;
  transition: transform .45s cubic-bezier(.2,.7,.2,1), box-shadow .45s;
  transform-origin: left center;
}
.pub-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pub-cover::after { /* book spine shading */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(0,0,0,.22) 0, rgba(0,0,0,.05) 5%, transparent 9%);
}
.pub-card-link:hover .pub-cover, .pub-card-link:focus-visible .pub-cover {
  transform: perspective(1200px) rotateY(-14deg) translateY(-4px);
  box-shadow: 0 26px 50px rgba(14,32,56,.26);
}
.pub-open {
  position: absolute; left: 50%; bottom: 18px; transform: translate(-50%, 12px); opacity: 0;
  background: var(--gold-fill); color: var(--navy-dark); font-weight: 700; font-size: .85rem;
  padding: 10px 20px; border-radius: 999px; white-space: nowrap; box-shadow: 0 8px 20px rgba(255,191,15,.5);
  transition: opacity .3s, transform .3s;
}
.pub-card-link:hover .pub-open, .pub-card-link:focus-visible .pub-open { opacity: 1; transform: translate(-50%, 0); }
@media (hover: none) { .pub-open { opacity: 1; transform: translate(-50%, 0); } }

.pub-badge {
  display: inline-block; margin: 20px 0 8px; font-size: .72rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--gold-dark);
}
.pub-title { font-size: clamp(1.05rem, 1.5vw, 1.25rem); font-weight: 500; line-height: 1.35; color: var(--navy-dark); margin: 0 0 12px; transition: color .2s; }
.pub-card-link:hover .pub-title { color: var(--gold-dark); }
.pub-meta { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .84rem; color: var(--muted); }
.pub-dl { align-self: flex-start; font-size: .88rem; font-weight: 600; color: var(--navy-dark); text-decoration: none; border-bottom: 2px solid var(--gold); padding-bottom: 2px; }
.pub-dl:hover { color: var(--gold-dark); }

/* ---------- Flipbook viewer ---------- */
.reader { background: linear-gradient(180deg, #0e2038 0%, #17304f 100%); padding: 40px 0 56px; }
.reader:fullscreen { display: flex; flex-direction: column; justify-content: center; overflow: auto; padding: 24px 0; }
.reader-intro { text-align: center; color: rgba(255,255,255,.7); font-size: .92rem; margin: 0 0 24px; }

.fb { --page-w: min(86vw, calc(76vh * .7727), 760px); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: clamp(10px, 3vw, 36px); }
.fb-stage { position: relative; width: var(--page-w); aspect-ratio: 612 / 792; perspective: 2600px; flex: none; touch-action: pan-y; }
.fb-stage::before { /* shadow under the book */
  content: ""; position: absolute; left: 4%; right: 4%; bottom: -22px; height: 26px; border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0,0,0,.5), transparent 70%); filter: blur(6px);
}
.fb-page {
  position: absolute; inset: 0; background: #fff; border-radius: 3px 10px 10px 3px; overflow: hidden;
  transform-origin: left center; backface-visibility: hidden; will-change: transform;
  box-shadow: 0 20px 50px rgba(0,0,0,.45);
  transition: transform .95s cubic-bezier(.45,.05,.25,1), opacity .2s linear;
  cursor: pointer;
}
.fb-page img { width: 100%; height: 100%; object-fit: contain; display: block; user-select: none; -webkit-user-drag: none; }
.fb-page::before { /* spine crease */
  content: ""; position: absolute; inset: 0 auto 0 0; width: 7%; pointer-events: none; z-index: 1;
  background: linear-gradient(90deg, rgba(0,0,0,.18), transparent);
}
.fb-page::after { /* turning shade */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; z-index: 2;
  background: linear-gradient(90deg, rgba(0,0,0,.35), rgba(0,0,0,0) 70%);
  transition: opacity .95s ease;
}
.fb-page.is-turned { transform: rotateY(-115deg); opacity: 0; pointer-events: none; transition: transform .95s cubic-bezier(.45,.05,.25,1), opacity .25s linear .7s; }
.fb-page.is-turned::after { opacity: 1; }
.fb-page.is-hidden { visibility: hidden; }   /* pages far from the current one: skip rendering */

.fb-btn {
  flex: none; width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center;
  background: var(--gold-fill); color: var(--navy-dark); box-shadow: 0 8px 20px rgba(255,191,15,.4);
  transition: transform .2s, background .2s, opacity .2s, box-shadow .2s;
}
.fb-btn:hover:not(:disabled) { background: var(--gold-fill-dark); transform: scale(1.08); }
.fb-btn:focus-visible, .fb-tool:focus-visible, .fb-thumb:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.fb-btn:disabled { opacity: .3; cursor: not-allowed; box-shadow: none; }
.fb-btn svg { width: 24px; height: 24px; }

.fb-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 14px 22px; margin-top: 40px; color: #fff; }
.fb-count { font-weight: 600; font-size: .95rem; min-width: 110px; text-align: center; }
.fb-count b { color: var(--gold); }
.fb-tool {
  display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px; padding: 9px 18px; font: 600 .86rem var(--font-body); text-decoration: none; cursor: pointer; transition: background .2s, border-color .2s;
}
.fb-tool:hover { background: rgba(255,255,255,.2); border-color: var(--gold); }

.fb-thumbs { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 26px auto 0; max-width: 760px; padding: 0; list-style: none; }
.fb-thumb { display: block; width: 58px; border-radius: 4px; overflow: hidden; border: 2px solid transparent; opacity: .55; cursor: pointer; padding: 0; background: #fff; transition: opacity .2s, border-color .2s, transform .2s; }
.fb-thumb img { display: block; width: 100%; height: auto; }
.fb-thumb:hover { opacity: .9; transform: translateY(-3px); }
.fb-thumb[aria-current="true"] { opacity: 1; border-color: var(--gold); }

.reader-back { display: inline-block; margin: 28px 0 0; }
.reader-foot { text-align: center; }
.reader-foot .post-back { color: #fff; }

@media (max-width: 900px) { .pub-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) {
  .pub-grid { grid-template-columns: 1fr; max-width: 360px; margin: 0 auto; }
  .fb { --page-w: min(92vw, calc(70vh * .7727)); gap: 0 28px; }
  .fb-stage { order: 1; }
  .fb-btn { order: 2; margin-top: 34px; width: 56px; height: 56px; }
  .fb-bar { order: 3; margin-top: 26px; }
  .fb-thumbs { order: 4; }
}
@media (prefers-reduced-motion: reduce) {
  .fb-page, .fb-page.is-turned, .fb-page::after { transition: none; }
  .pub-cover { transition: none; }
}
