/*
 * OFM Digital Editions page flipper. Every rule is scoped inside .ofm-flip (or .ofm-ed-actions), one level
 * deeper than a theme's own button and link rules, and states (hover, focus, disabled) are all set here,
 * so no theme or plugin can repaint the viewer.
 */
.ofm-flip {
  --ofm-accent: #25a6e1;
  --ofm-accent-dark: #188bc0;
  --ofm-ink: #1d2733;
  --ofm-stage: #2a323c;
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 0;
  background: var(--ofm-stage);
  color: #fff;
  border-radius: 12px;
  overflow: hidden;
  font: 500 14px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  box-sizing: border-box;
}
.ofm-flip *, .ofm-flip *::before, .ofm-flip *::after { box-sizing: border-box; }
.ofm-flip:not(.is-ready) { min-height: 60vh; }
.ofm-flip svg { display: block; flex: 0 0 auto; }

/* bar */
.ofm-flip .ofm-flip-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px 14px; flex-wrap: wrap;
  padding: 8px 10px; background: var(--ofm-ink); border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.ofm-flip .ofm-flip-nav { display: flex; align-items: center; gap: 8px; flex: 1 1 320px; min-width: 0; }
.ofm-flip .ofm-flip-where { display: flex; align-items: center; gap: 12px; flex: 1 1 auto; min-width: 0; }
.ofm-flip .ofm-flip-label { white-space: nowrap; font-weight: 700; letter-spacing: .01em; min-width: 9.5em; color: #fff; }
.ofm-flip .ofm-flip-slider {
  flex: 1 1 auto; min-width: 60px; width: auto; margin: 0; padding: 0; border: 0; background: transparent;
  accent-color: var(--ofm-accent); cursor: pointer;
}
.ofm-flip .ofm-flip-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* buttons: every state set here */
.ofm-flip .ofm-flip-btn,
.ofm-flip .ofm-flip-btn:visited {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; min-width: 38px; padding: 0 12px; margin: 0;
  border: 1px solid rgba(255, 255, 255, .2); border-radius: 999px;
  background: transparent; color: #fff; box-shadow: none; outline: none;
  font: 600 13px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; letter-spacing: .01em;
  text-decoration: none; text-transform: none; white-space: nowrap; cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.ofm-flip .ofm-flip-btn:hover,
.ofm-flip .ofm-flip-btn:focus { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .45); color: #fff; text-decoration: none; }
.ofm-flip .ofm-flip-btn:focus-visible { outline: 3px solid var(--ofm-accent); outline-offset: 2px; box-shadow: none; }
.ofm-flip .ofm-flip-btn.is-on,
.ofm-flip .ofm-flip-btn.is-on:hover,
.ofm-flip .ofm-flip-btn.is-on:focus { background: var(--ofm-accent); border-color: var(--ofm-accent); color: #fff; }
.ofm-flip .ofm-flip-btn[disabled],
.ofm-flip .ofm-flip-btn[disabled]:hover,
.ofm-flip .ofm-flip-btn[disabled]:focus { opacity: .35; cursor: default; background: transparent; border-color: rgba(255, 255, 255, .2); }
.ofm-flip .ofm-flip-prev, .ofm-flip .ofm-flip-next { padding: 0; width: 40px; }
.ofm-flip .ofm-flip-icon-only { padding: 0; width: 40px; }
.ofm-flip .ofm-flip-pdf,
.ofm-flip .ofm-flip-pdf:visited { background: var(--ofm-accent); border-color: var(--ofm-accent); color: #fff; }
.ofm-flip .ofm-flip-pdf:hover,
.ofm-flip .ofm-flip-pdf:focus { background: var(--ofm-accent-dark); border-color: var(--ofm-accent-dark); color: #fff; }

/* stage: the pages always fit inside it */
.ofm-flip .ofm-flip-stage {
  position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden;
  min-height: 260px; padding: 8px; outline: none;
  background: radial-gradient(ellipse at center, #36404c 0%, var(--ofm-stage) 70%);
  touch-action: pan-y pinch-zoom;
}
.ofm-flip .ofm-flip-stage:focus-visible { outline: 3px solid var(--ofm-accent); outline-offset: -3px; box-shadow: none; }
.ofm-flip .ofm-flip-book { display: flex; align-items: center; justify-content: center; margin: auto; }
.ofm-flip .ofm-flip-page {
  display: block; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: #fff; box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
  user-select: none; -webkit-user-select: none; cursor: zoom-in;
}
.ofm-flip .ofm-flip-page.is-left { box-shadow: -6px 6px 24px rgba(0, 0, 0, .35); }
.ofm-flip .ofm-flip-page.is-right { box-shadow: 6px 6px 24px rgba(0, 0, 0, .35); border-left: 1px solid rgba(0, 0, 0, .12); }
.ofm-flip .ofm-flip-page.is-broken { min-width: 200px; min-height: 260px; background: #e9ecef; }
.ofm-flip.is-zoomed .ofm-flip-stage { overflow: auto; cursor: grab; touch-action: auto; }
.ofm-flip.is-zoomed .ofm-flip-page { cursor: zoom-out; }
.ofm-flip .ofm-flip-stage.is-dragging { cursor: grabbing; }

/* big tap areas at the sides of the stage */
.ofm-flip .ofm-flip-hit,
.ofm-flip .ofm-flip-hit:focus {
  position: absolute; top: 0; bottom: 0; z-index: 2; width: 64px;
  display: flex; align-items: center; justify-content: center;
  margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; outline: none;
  background: transparent; color: #fff; opacity: 0; cursor: pointer; transition: opacity .15s, background-color .15s;
}
.ofm-flip .ofm-flip-hit svg { width: 34px; height: 34px; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .6)); }
.ofm-flip .ofm-flip-hit-prev { left: 0; }
.ofm-flip .ofm-flip-hit-next { right: 0; }
.ofm-flip .ofm-flip-stage:hover .ofm-flip-hit { opacity: .85; }
.ofm-flip .ofm-flip-hit:hover { background: rgba(0, 0, 0, .18); color: #fff; opacity: 1; }
.ofm-flip.is-first .ofm-flip-hit-prev,
.ofm-flip.is-last .ofm-flip-hit-next,
.ofm-flip.is-zoomed .ofm-flip-hit { display: none; }

/* thumbnails */
.ofm-flip .ofm-flip-thumbs {
  display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding: 10px;
  background: var(--ofm-ink); border-top: 1px solid rgba(255, 255, 255, .08); scrollbar-width: thin;
}
.ofm-flip .ofm-flip-thumbs[hidden] { display: none; }
.ofm-flip .ofm-flip-thumb,
.ofm-flip .ofm-flip-thumb:hover,
.ofm-flip .ofm-flip-thumb:focus {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 74px;
  margin: 0; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; outline: none;
  color: #cfd6de; font: 700 11px/1 system-ui, sans-serif; cursor: pointer;
}
.ofm-flip .ofm-flip-thumb:focus-visible { outline: 3px solid var(--ofm-accent); outline-offset: 2px; }
.ofm-flip .ofm-flip-thumb img { display: block; width: 74px; height: 94px; max-width: none; object-fit: cover; background: #fff; border: 2px solid transparent; border-radius: 3px; }
.ofm-flip .ofm-flip-thumb:hover img { border-color: rgba(255, 255, 255, .6); }
.ofm-flip .ofm-flip-thumb.is-on img { border-color: var(--ofm-accent); }
.ofm-flip .ofm-flip-thumb.is-on { color: #fff; }

/* full screen (the real one, and the stand-in for phones without it) */
.ofm-flip:fullscreen { width: 100vw; height: 100vh; border-radius: 0; }
.ofm-flip:-webkit-full-screen { width: 100vw; height: 100vh; border-radius: 0; }
.ofm-flip.is-pseudo-full { position: fixed; inset: 0; z-index: 2147483000; width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; }
html.ofm-flip-lock, html.ofm-flip-lock body { overflow: hidden !important; }

/* the PDF fallback */
.ofm-flip .ofm-flip-pdfstage { padding: 0; }
.ofm-flip .ofm-flip-iframe { display: block; width: 100%; height: 100%; border: 0; background: #525659; }

/* little message */
.ofm-flip .ofm-flip-toast {
  position: absolute; left: 50%; bottom: 18px; z-index: 5; transform: translate(-50%, 20px);
  padding: 9px 16px; border-radius: 999px; background: #fff; color: var(--ofm-ink); font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .3); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.ofm-flip .ofm-flip-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.ofm-flip .ofm-flip-noscript, .ofm-flip-missing { display: inline-block; margin: 16px; color: inherit; }

/* phones: compact bar, icons only */
@media (max-width: 720px) {
  .ofm-flip { border-radius: 0; }
  .ofm-flip .ofm-flip-bar { padding: 6px; gap: 6px; }
  .ofm-flip .ofm-flip-nav { flex-basis: 100%; }
  .ofm-flip .ofm-flip-label { min-width: 0; font-size: 13px; }
  .ofm-flip .ofm-flip-tools { width: 100%; justify-content: space-between; }
  .ofm-flip .ofm-flip-btn-text { display: none; }
  .ofm-flip .ofm-flip-btn { min-width: 44px; min-height: 40px; padding: 0 10px; }
  .ofm-flip .ofm-flip-hit { width: 44px; opacity: .55; }
  .ofm-flip .ofm-flip-stage { padding: 4px; }
}

/* the issue page buttons outside the viewer ([ofm_issue_actions]) */
.ofm-ed-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.ofm-ed-actions .ofm-ed-btn,
.ofm-ed-actions .ofm-ed-btn:visited {
  display: inline-flex; align-items: center; min-height: 40px; margin: 0; padding: 0 18px; border-radius: 999px;
  border: 1.5px solid #25a6e1; background: #fff; color: #188bc0; box-shadow: none; cursor: pointer;
  font: 800 12.5px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; letter-spacing: .06em;
  text-transform: uppercase; text-decoration: none; white-space: nowrap;
}
.ofm-ed-actions .ofm-ed-btn:hover,
.ofm-ed-actions .ofm-ed-btn:focus { background: #25a6e1; border-color: #25a6e1; color: #fff; text-decoration: none; }
.ofm-ed-actions .ofm-ed-btn-dark,
.ofm-ed-actions .ofm-ed-btn-dark:visited { background: #1d2733; border-color: #1d2733; color: #fff; }
.ofm-ed-actions .ofm-ed-btn-dark:hover,
.ofm-ed-actions .ofm-ed-btn-dark:focus { background: #188bc0; border-color: #188bc0; color: #fff; }
.ofm-ed-actions .ofm-ed-btn:focus-visible { outline: 3px solid #25a6e1; outline-offset: 2px; box-shadow: none; }
.ofm-ed-actions .ofm-ed-pages { color: #5b6672; font: 600 14px system-ui, sans-serif; }
