/* ACTA Ingesta publication reader: page-turning flipbook (Heyzine-style) + study page layout */

@font-face {
  font-family: "DM Serif Display";
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url("/fonts/dm-serif-display-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}
@font-face {
  font-family: "Playfair Display";
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url("/fonts/playfair-display-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}
@font-face {
  font-family: "Open Sans";
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url("/fonts/open-sans-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}

/* ---------- study page layout ---------- */

.pub-reader {
  flex: 1;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3.5rem;
}

.pub-crumb {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
}

.pub-crumb a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--color-action);
  font-weight: 400;
  text-decoration: none;
}

.pub-crumb a:hover {
  text-decoration: underline;
}

.pub-crumb svg {
  width: 16px;
  height: 16px;
}

.pub-hero {
  max-width: 1100px;
  margin: 0 auto 0.85rem;
  text-align: center;
}

.pub-kicker {
  color: #6b7280;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pub-hero h1 {
  margin-top: 0.35rem;
  color: var(--title-color);
  font-size: clamp(1.2rem, 2.2vw, 1.7rem);
  font-weight: 400;
  line-height: 1.25;
}

/* ---------- flipbook stage ---------- */

.fb {
  --fb-ink: #1f2937;
  --fb-muted: #6b7280;
  --fb-panel: #fff;
  --fb-radius: 12px;
}

.fb-stage {
  position: relative;
  height: clamp(540px, calc(100svh - 13rem), 980px);
  overflow: hidden;
  border-radius: var(--radius-md, 18px);
  background:
    linear-gradient(118deg, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0) 34%),
    linear-gradient(118deg, transparent 52%, rgba(0, 0, 0, 0.035) 52%, rgba(0, 0, 0, 0.035) 78%, transparent 78%),
    linear-gradient(135deg, #f5f5f5 0%, #ebebeb 55%, #e2e2e2 100%);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.fb-stage:focus-visible {
  box-shadow: 0 0 0 3px rgba(10, 103, 167, 0.35);
}

.fb-stage:fullscreen,
.fb-stage.is-pseudo-fs {
  height: 100vh;
  height: 100dvh;
  border-radius: 0;
}

.fb-stage.is-pseudo-fs {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

body.fb-lock {
  overflow: hidden;
}

.fb-viewport {
  position: absolute;
  inset: 20px 0 58px;
  overflow: hidden;
}

.fb-pan {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
}

.fb-book {
  width: 100%;
  height: 100%;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: none !important;
  transition: transform 0.55s cubic-bezier(0.4, 0.1, 0.2, 1);
}

.fb-book .stf__wrapper {
  position: relative;
  width: 100%;
  height: 100%;
}

.fb-book .stf__block {
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.16));
}

.fb-page {
  position: relative;
  overflow: hidden;
  background: #fafafa;
}

.fb-bg,
.fb-text {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.fb-bg {
  object-fit: fill;
  -webkit-user-drag: none;
  user-select: none;
}

.fb-text {
  overflow: hidden;
}

.fb-text text {
  white-space: pre;
}

.fb-text a rect {
  fill: transparent;
  cursor: pointer;
}

/* ---------- controls ---------- */

.fb-toolbar {
  position: absolute;
  top: 18px;
  right: 22px;
  z-index: 20;
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 8px;
  background: var(--fb-panel);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 14px rgba(0, 0, 0, 0.06);
}

.fb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--fb-ink);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, opacity 0.2s ease;
}

.fb-btn:hover {
  background: #f1f3f5;
}

.fb-btn:focus-visible {
  outline: 2px solid var(--color-action);
  outline-offset: -2px;
}

.fb-btn svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fb-btn[aria-pressed="true"] {
  background: #e7f1f8;
  color: var(--color-action);
}

.fb-btn .i-alt {
  display: none;
}

.fb-btn.is-alt .i-main {
  display: none;
}

.fb-btn.is-alt .i-alt {
  display: block;
}

.fb-btn[hidden] {
  display: none;
}

.fb-nav {
  position: absolute;
  top: 50%;
  z-index: 15;
  width: 44px;
  height: 44px;
  margin-top: -22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.15s ease;
}

.fb-nav:hover {
  background: #fff;
}

.fb-prev {
  left: 14px;
}

.fb-next {
  right: 14px;
}

.fb-stage:hover .fb-nav,
.fb-stage:focus-within .fb-nav {
  opacity: 1;
}

.fb-nav[disabled] {
  opacity: 0 !important;
  pointer-events: none;
}

.fb-share {
  position: absolute;
  right: 18px;
  bottom: 62px;
  z-index: 15;
  color: #8a8f98;
  opacity: 0;
  transition: opacity 0.2s ease, color 0.15s ease;
}

.fb-stage:hover .fb-share,
.fb-stage:focus-within .fb-share {
  opacity: 1;
}

.fb-share:hover {
  color: var(--fb-ink);
  background: transparent;
}

.fb-share svg {
  width: 30px;
  height: 30px;
}

.fb-foot {
  position: absolute;
  right: 0;
  bottom: 14px;
  left: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 0 22px;
}

.fb-count {
  min-width: 5.5rem;
  color: var(--fb-muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  font-weight: 400;
  text-align: right;
  white-space: nowrap;
}

.fb-slider {
  width: min(700px, 62%);
  height: 24px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.fb-slider:focus-visible {
  outline: 2px solid var(--color-action);
  outline-offset: 2px;
  border-radius: 6px;
}

.fb-slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 4px;
  background: #d3d4d7;
}

.fb-slider::-moz-range-track {
  height: 8px;
  border-radius: 4px;
  background: #d3d4d7;
}

.fb-slider::-webkit-slider-thumb {
  width: 84px;
  height: 8px;
  border-radius: 4px;
  background: #6c6f75;
  -webkit-appearance: none;
  appearance: none;
}

.fb-slider::-moz-range-thumb {
  width: 84px;
  height: 8px;
  border: 0;
  border-radius: 4px;
  background: #6c6f75;
}

.fb-toc {
  position: absolute;
  top: 70px;
  right: 22px;
  bottom: 62px;
  z-index: 25;
  display: flex;
  flex-direction: column;
  width: min(300px, calc(100% - 44px));
  border-radius: var(--fb-radius);
  background: var(--fb-panel);
  box-shadow: 0 4px 22px rgba(0, 0, 0, 0.16);
}

.fb-toc[hidden] {
  display: none;
}

.fb-toc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px 6px 18px;
  color: var(--fb-muted);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.fb-toc-head .fb-btn {
  width: 34px;
  height: 34px;
}

.fb-toc-head .fb-btn svg {
  width: 20px;
  height: 20px;
}

.fb-toc-list {
  margin: 0;
  padding: 2px 8px 10px;
  overflow-y: auto;
  list-style: none;
}

.fb-toc-list button {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--fb-ink);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
}

.fb-toc-list button:hover {
  background: #f1f3f5;
}

.fb-toc-list button.is-current {
  background: #e7f1f8;
  color: var(--blue-dark, #054e83);
}

.fb-toc-list .pg {
  flex: none;
  color: var(--fb-muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.fb-toast {
  position: absolute;
  bottom: 96px;
  left: 50%;
  z-index: 30;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(31, 41, 55, 0.92);
  color: #fff;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.fb-toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* drag layer used while zoomed: owns the pointer so the page does not flip under the finger */
.fb-pan-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  cursor: grab;
  touch-action: none;
}

.fb.is-zoomed .fb-pan-layer {
  display: block;
}

.fb.is-dragging .fb-pan-layer {
  cursor: grabbing;
}

.fb.is-zoomed .fb-book {
  transition: none;
}

/* before the script runs (or without it): pages simply stack */
.fb:not(.is-ready) .fb-toolbar,
.fb:not(.is-ready) .fb-foot,
.fb:not(.is-ready) .fb-nav,
.fb:not(.is-ready) .fb-share,
.fb:not(.is-ready) .fb-toc {
  display: none;
}

.fb:not(.is-ready) .fb-stage {
  height: auto;
  max-height: 80vh;
  overflow-y: auto;
}

.fb:not(.is-ready) .fb-viewport,
.fb:not(.is-ready) .fb-pan {
  position: static;
}

.fb:not(.is-ready) .fb-book {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 20px 12px;
}

.fb:not(.is-ready) .fb-page {
  width: min(100%, 640px);
  aspect-ratio: var(--fb-ratio, 0.7071);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
}

/* ---------- about this study ---------- */

.pub-about {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 2rem;
  max-width: 1040px;
  margin: 2.5rem auto 0;
}

.pub-card {
  padding: 1.75rem;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-lg);
  background: #fff;
}

.pub-card h2 {
  margin: 0 0 0.9rem;
  color: var(--title-color);
  font-size: 1.25rem;
  font-weight: 500;
}

.pub-card p {
  color: #4b5563;
  font-size: 0.95rem;
  line-height: 1.65;
}

.pub-card p + p {
  margin-top: 0.8rem;
}

.pub-note {
  color: #6b7280;
  font-size: 0.85rem;
}

.pub-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem 1.1rem;
  margin: 0;
  font-size: 0.9rem;
}

.pub-meta dt {
  color: #6b7280;
  font-weight: 500;
}

.pub-meta dd {
  margin: 0;
  color: var(--text-color);
  overflow-wrap: anywhere;
}

.pub-meta a {
  color: var(--color-action);
  text-decoration: none;
}

.pub-meta a:hover {
  text-decoration: underline;
}

.pub-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-top: 1.25rem;
}

.pub-links img {
  display: block;
  width: 150px;
  height: auto;
  border-radius: 4px;
}

.pub-cite {
  grid-column: 1 / -1;
}

.pub-cite blockquote {
  margin: 0;
  padding: 0.9rem 1rem;
  border-left: 3px solid var(--color-action);
  border-radius: 0 10px 10px 0;
  background: var(--bg-soft, #f4fbff);
  color: #374151;
  font-size: 0.9rem;
  line-height: 1.6;
}

.pub-copy {
  display: inline-block;
  width: auto;
  margin-top: 0.8rem;
  padding: 0.45rem 0.95rem;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #fff;
  color: var(--color-action);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 400;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.pub-copy:hover {
  background: #f4fbff;
}

/* ---------- small screens ---------- */

@media (max-width: 820px) {
  .pub-about {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .pub-card {
    padding: 1.35rem;
  }
}

@media (max-width: 640px) {
  .pub-reader {
    padding: 0.9rem 0.6rem 2.5rem;
  }

  .fb-stage {
    height: clamp(460px, calc(100svh - 10.5rem), 900px);
    border-radius: 14px;
  }

  .fb-viewport {
    inset: 62px 0 52px;
  }

  .fb-toolbar {
    top: 10px;
    right: 10px;
  }

  .fb-btn {
    width: 38px;
    height: 38px;
  }

  .fb-nav {
    opacity: 0.9;
    width: 38px;
    height: 38px;
    margin-top: -19px;
  }

  .fb-prev {
    left: 6px;
  }

  .fb-next {
    right: 6px;
  }

  .fb-share {
    display: none;
  }

  .fb-foot {
    bottom: 10px;
    gap: 10px;
    padding: 0 12px;
  }

  .fb-count {
    min-width: 4.4rem;
    font-size: 0.75rem;
  }

  .fb-slider {
    width: 58%;
  }

  .fb-slider::-webkit-slider-thumb,
  .fb-slider::-moz-range-thumb {
    width: 56px;
  }

  .fb-toc {
    top: 56px;
    right: 10px;
    bottom: 52px;
    width: calc(100% - 20px);
  }
}

@media (hover: none) {
  .fb-nav {
    opacity: 0.9;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fb-book,
  .fb-toast,
  .fb-nav,
  .fb-share {
    transition: none;
  }
}
