/* Preview-only chapter openings. The complete still is also the no-script state. */
.chapter-transition {
  --arrival: url("/assets/first-counter-1200.webp");
  --framing: 50% 24%;
  --entry: 0;
  position: relative;
  isolation: isolate;
  overflow: clip;
  pointer-events: none;
  scroll-margin-top: 48vh;
}
#into-roastery {
  --arrival: url("/assets/roaster-release-1600.webp");
  --framing: 50% 64%;
}
.chapter-transition + .chapter {
  border-top: 0;
  padding-top: clamp(2.25rem, 4.8vw, 5rem);
}
.chapter-transition .transition-surface {
  position: absolute;
  inset: 0;
  background: var(--arrival) var(--framing) / cover no-repeat;
}

/* A strip of the next print shows between two leaves, above the chapter. */
.page-turn {
  height: clamp(140px, 14vw, 215px);
  background: #193c2f;
  perspective: 800px;
}
.page-turn .transition-surface {
  inset: 0 max(5%, calc((100% - 1300px) / 2));
  background-position: var(--framing);
  opacity: .86;
  clip-path: polygon(0 9%, 100% 0, 100% 94%, 0 100%);
}
.page-turn::before, .page-turn::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: 1;
}
.page-turn::before {
  inset: -18% -3% 3%;
  transform-origin: 0 0;
  transform: skewY(-1.4deg) scaleY(calc(.42 + .47 * var(--entry))) rotateX(calc(52deg - 35deg * var(--entry)));
  background: linear-gradient(178deg, var(--paper) 24%, #f2eddf 62%, #e3dcc8 87%, #bbae8b 100%);
  box-shadow: 0 7px 15px #16211855;
}
.page-turn::after {
  inset: 88% -2% -60%;
  transform: skewY(-1.6deg);
  background: var(--paper);
  border-top: 4px double #c1bba6;
  box-shadow: 0 -4px 7px #17221932;
}
#into-roastery.page-turn::before { transform: skewY(.7deg) scaleY(calc(.4 + .47 * var(--entry))) rotateX(calc(52deg - 35deg * var(--entry))); }
#into-roastery.page-turn::after { transform: skewY(1.2deg); }

/* A circle centered on a real detail opens into the next photograph. */
.match-cut {
  --focus: 37%;
  height: clamp(185px, 21vw, 340px);
  background: var(--paper);
}
.match-cut .transition-surface {
  inset-inline: max(5%, calc((100% - 1190px) / 2));
  --iris: clamp(0, calc((var(--entry) - .12) * 1.4), 1);
  clip-path: ellipse(calc(86% - 76% * var(--iris)) calc(132% - 92% * var(--iris)) at var(--focus) 50%);
}
#into-roastery.match-cut { --focus: 53%; }
.match-cut .transition-surface::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #323632 url("/assets/transition-counter-sign.webp") var(--focus) center / auto 112% no-repeat;
  opacity: clamp(0, calc(5 * var(--entry) - 2.8), 1);
}
#into-roastery.match-cut .transition-surface::after {
  background-image: url("/assets/transition-portafilter.webp");
}
@media (max-width: 720px) {
  .page-turn { height: clamp(124px, 34vw, 160px); }
  .match-cut { height: clamp(160px, 44vw, 240px); }
  .match-cut .transition-surface {
    clip-path: ellipse(calc(92% - 75% * var(--iris)) calc(124% - 86% * var(--iris)) at var(--focus) 50%);
  }
}
@media (prefers-reduced-motion: no-preference) {
  .chapter-transition { --entry: var(--entry-left, 0); }
}
.review-switch {
  position: fixed;
  z-index: 5;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: 0 3px 12px #183a2c26;
}
.review-switch a {
  display: grid;
  place-items: center;
  padding: 0 13px;
  min-height: 44px;
  font: 550 .88rem DM, sans-serif;
  text-decoration: none;
}
.review-switch a[aria-current] { background: var(--ink); color: var(--paper); text-decoration: none; }
