/*
 * lapis-flip.css — styles for the LAPIS page-flip issue reader.
 * Pairs with lapis-flip.js. Written Oct 12–13, 2026.
 *
 * Location on server:
 *   /wp-content/themes/lapis-theme/vendor/lapis-flip/lapis-flip.css
 *
 * Uses the theme's colour and font variables, with fallbacks so it still
 * looks right if a variable is ever renamed.
 * Page-turn length: 750ms below — keep in step with TURN_MS in lapis-flip.js.
 */

.lapis-flip {
  --lf-navy: var(--navy, #1E3A6E);
  --lf-ink: var(--navy-ink, #0d1f3f);
  --lf-gold: var(--gold, #C8962A);
  --lf-font: var(--font-display, 'Oswald', 'Arial Narrow', sans-serif);
  --lf-turn: 750ms;
  position: relative;
  width: 100%;
  min-width: 0;
  /* The reader sizes itself to the column; it must never push the column
     wider (that would break the page layout when zoomed). */
  contain: inline-size;
  outline: none;
}
.lapis-flip[hidden] { display: none !important; }
.lapis-flip:focus-visible { box-shadow: 0 0 0 3px var(--lf-gold); }

/* ── Loading state ───────────────────────────────────────────────────── */
.lf-loading {
  min-height: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--gray-100, #f0eee8);
  border-top: 3px solid var(--lf-gold);
}
.lf-loading[hidden] { display: none; }
.lf-loading__text {
  font-family: var(--lf-font);
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--lf-navy);
}
.lf-loading__bar {
  width: 120px;
  height: 3px;
  background: linear-gradient(90deg, transparent 0%, var(--lf-gold) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: lf-loading 1.2s linear infinite;
}
@keyframes lf-loading { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ── Stage and book ──────────────────────────────────────────────────── */
.lf-stage {
  display: flex;
  justify-content: center;
  padding: 12px 0 22px;
  touch-action: pan-y pinch-zoom;  /* vertical scrolling and pinch-zoom still work on touch */
  user-select: none;
  -webkit-user-select: none;
}
.lf-stage[hidden] { display: none; }

.lf-book {
  position: relative;
  perspective: 2600px;
  transition: transform var(--lf-turn) cubic-bezier(.45, .05, .35, 1);
}
/* Cover (or a last page on its own): slide the book so that page is centred. */
.lf-book.lf-at-start { transform: translateX(calc(var(--lf-page-w) / -2)); }
.lf-book.lf-at-end   { transform: translateX(calc(var(--lf-page-w) / 2)); }
.lf-book--one.lf-at-start,
.lf-book--one.lf-at-end { transform: none; }

.lf-slot {
  position: absolute;
  top: 0;
  width: var(--lf-page-w);
  height: 100%;
  background: #fff;
  box-shadow: 0 22px 44px -22px rgba(13, 31, 63, 0.55), 0 2px 6px rgba(13, 31, 63, 0.12);
}
.lf-slot--left  { left: 0; }
.lf-slot--right { left: var(--lf-page-w); }
.lf-book--one .lf-slot--left  { display: none; }
.lf-book--one .lf-slot--right { left: 0; }
.lf-slot.is-empty { background: transparent; box-shadow: none; }

.lf-slot img,
.lf-face img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* Gutter shading: a soft shadow where the pages meet the spine. */
.lf-side--left::after,
.lf-side--right::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.lf-side--left::after  { background: linear-gradient(to left,  rgba(0,0,0,0.20) 0%, rgba(0,0,0,0.05) 4%, rgba(0,0,0,0) 9%); }
.lf-side--right::after { background: linear-gradient(to right, rgba(0,0,0,0.20) 0%, rgba(0,0,0,0.05) 4%, rgba(0,0,0,0) 9%); }
.lf-book--one .lf-side--right::after { background: none; }

/* ── The turning page ────────────────────────────────────────────────── */
.lf-leaf {
  position: absolute;
  top: 0;
  width: var(--lf-page-w);
  height: 100%;
  z-index: 5;
  transform-style: preserve-3d;
  transition: transform var(--lf-turn) cubic-bezier(.45, .05, .35, 1);
  will-change: transform;
}
/* Spread layout: the right page turns over to the left, or the left page back to the right. */
.lf-leaf--spread-fwd  { left: var(--lf-page-w); transform-origin: left center;  transform: rotateY(0deg); }
.lf-leaf--spread-back { left: 0;                transform-origin: right center; transform: rotateY(0deg); }
.lf-leaf--spread-fwd.is-turning  { transform: rotateY(-180deg); }
.lf-leaf--spread-back.is-turning { transform: rotateY(180deg); }

/* One page at a time: the page turns away from its left edge, or turns back into place. */
.lf-leaf--single-fwd  { left: 0; transform-origin: left center; transform: rotateY(0deg); }
.lf-leaf--single-back { left: 0; transform-origin: left center; transform: rotateY(-180deg); }
.lf-leaf--single-fwd.is-turning  { transform: rotateY(-180deg); }
.lf-leaf--single-back.is-turning { transform: rotateY(0deg); }

.lf-face {
  position: absolute;
  inset: 0;
  background: #fff;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.lf-face--back { transform: rotateY(180deg); }
.lf-face.is-empty { background: transparent; }

/* Light falls off the page as it lifts, then returns as it lands. */
.lf-face::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: #0d1f3f;
  opacity: 0;
}
.lf-leaf.is-turning .lf-face--front::before { animation: lf-shade-out var(--lf-turn) ease-in forwards; }
.lf-leaf.is-turning .lf-face--back::before  { animation: lf-shade-in  var(--lf-turn) ease-out forwards; }
.lf-leaf--single-back.is-turning .lf-face--front::before { animation: lf-shade-in var(--lf-turn) ease-out forwards; }
@keyframes lf-shade-out { 0% { opacity: 0; } 50% { opacity: 0.32; } 100% { opacity: 0.32; } }
@keyframes lf-shade-in  { 0% { opacity: 0.32; } 50% { opacity: 0.32; } 100% { opacity: 0; } }

/* ── Click/tap areas over each page ──────────────────────────────────── */
.lf-hit {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  z-index: 3;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.lf-hit--prev { left: 0; }
.lf-hit--next { right: 0; }
.lf-book--one .lf-hit { width: 50%; }
.lf-hit:disabled { cursor: default; }
@media (hover: hover) {
  .lf-hit--prev:not(:disabled):hover { background: linear-gradient(to right, rgba(200,150,42,0.16), rgba(200,150,42,0) 18%); }
  .lf-hit--next:not(:disabled):hover { background: linear-gradient(to left,  rgba(200,150,42,0.16), rgba(200,150,42,0) 18%); }
}

/* ── Toolbar ─────────────────────────────────────────────────────────── */
.lf-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 12px 8px 4px;
  border-top: 1px solid var(--gray-200, #e2dfd6);
}
.lf-bar[hidden] { display: none; }
.lf-count {
  min-width: 170px;
  text-align: center;
  font-family: var(--lf-font);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--lf-ink);
  font-variant-numeric: tabular-nums;
}
.lf-bar__sep {
  width: 1px;
  height: 22px;
  background: var(--gray-200, #e2dfd6);
}
.lf-btn {
  font-family: var(--lf-font);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--lf-navy);
  background: transparent;
  border: 1px solid var(--lf-navy);
  border-radius: 2px;
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.lf-btn--prev,
.lf-btn--next {
  width: 44px;
  padding: 0;
  font-size: 26px;
  line-height: 1;
  color: var(--lf-ink);
  background: var(--lf-gold);
  border-color: var(--lf-gold);
}
.lf-btn:hover:not(:disabled),
.lf-btn:focus-visible { background: var(--lf-navy); border-color: var(--lf-navy); color: #fff; }
.lf-btn:focus-visible { outline: 2px solid var(--lf-gold); outline-offset: 2px; }
.lf-btn:disabled { opacity: 0.35; cursor: default; }
.lf-btn[hidden] { display: none; }

/* ── Zoom ────────────────────────────────────────────────────────────── */
.lf-btn--zoom {
  width: 40px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}
.lf-zoom {
  min-width: 58px;
  min-height: 40px;
  padding: 0 6px;
  font-family: var(--lf-font);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--lf-ink);
  background: transparent;
  border: 0;
  border-radius: 2px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.lf-zoom:hover { text-decoration: underline; text-underline-offset: 3px; }
.lf-zoom:focus-visible { outline: 2px solid var(--lf-gold); outline-offset: 2px; }
.lapis-flip.is-fullscreen .lf-zoom { color: #fff; }
.lapis-flip.is-fullscreen .lf-btn--zoom { color: #fff; border-color: rgba(255, 255, 255, 0.5); }

/* While zoomed, the reading area keeps its normal height and scrolls inside;
   drag with the mouse (or scroll / swipe) to move around the page. */
.lapis-flip.is-zoomed .lf-stage {
  display: block;
  overflow: auto;
  padding: 12px 0;
  cursor: grab;
  touch-action: auto;
  overscroll-behavior: contain;
  background: var(--gray-100, #f0eee8);
}
.lapis-flip.is-zoomed .lf-stage.is-dragging { cursor: grabbing; }
.lapis-flip.is-zoomed .lf-book { margin: 0 auto; transform: none; transition: none; }
.lapis-flip.is-zoomed .lf-hit { display: none; }
.lapis-flip.is-zoomed .lf-side--left::after,
.lapis-flip.is-zoomed .lf-side--right::after { opacity: 0.45; }   /* lighter spine shadow up close */
.lapis-flip.is-fullscreen.is-zoomed .lf-stage { flex: 1 1 auto; height: auto !important; background: transparent; }

/* ── Full screen ─────────────────────────────────────────────────────── */
.lapis-flip.is-fullscreen {
  background: var(--lf-ink);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}
.lapis-flip.is-fullscreen .lf-bar { border-top-color: rgba(255, 255, 255, 0.15); }
.lapis-flip.is-fullscreen .lf-count { color: #fff; }
.lapis-flip.is-fullscreen .lf-bar__sep { background: rgba(255, 255, 255, 0.2); }
.lapis-flip.is-fullscreen .lf-btn--text { color: #fff; border-color: rgba(255, 255, 255, 0.5); }
.lapis-flip.is-fullscreen .lf-btn--text:hover,
.lapis-flip.is-fullscreen .lf-btn--text:focus-visible { background: #fff; color: var(--lf-ink); }

/* ── Reduced motion: no turning or sliding, just instant page changes ── */
@media (prefers-reduced-motion: reduce) {
  .lf-book, .lf-leaf { transition: none; }
  .lf-loading__bar { animation: none; background: var(--lf-gold); }
}
