/* ArnOok pop-up book. --pop: 0 = folded flat into the page, 1 = standing up. */
@property --pop { syntax: '<number>'; inherits: true; initial-value: 1; }
.popup-stage {
  position: relative; flex: none; height: clamp(118px, 21vh, 184px); margin: 18px -6px 0;
  perspective: 620px; perspective-origin: 50% 0%; isolation: isolate;
  border-radius: 10px 10px 4px 4px;
  background: radial-gradient(120% 90% at 50% 100%, #f6ead3 0, rgba(246,234,211,0) 70%);
}
/* --pop is inherited from the page (flipbook.js sets it on turning faces); --px/--py come from the parallax handler. */
.reader-desk, .popup-preview, .popup-stage { --px: 0; --py: 0; }
.reader-desk .popup-stage, .popup-preview .popup-stage { --px: inherit; --py: inherit; }
.popup-scene { position: absolute; inset: 0 0 6px; transform-style: preserve-3d; }
.popup-crease { position: absolute; left: 4%; right: 4%; bottom: 3px; height: 4px; border-radius: 4px;
  background: linear-gradient(#e2d2b5, #f3e8d4); box-shadow: 0 1px 0 #fff inset; opacity: calc(.35 + var(--pop) * .65); }
.popup-piece {
  --layer: 1; --d: 0;
  position: absolute; bottom: 6px; display: block; transform-origin: 50% 100%;
  transform: translateX(calc(var(--px) * (var(--layer) + .4) * 5px)) rotateX(calc((1 - var(--pop)) * -88deg)) scale(calc(.94 + var(--layer) * .03));
  z-index: calc(var(--layer) + 1); pointer-events: none;
  filter: drop-shadow(0 calc(2px + var(--layer) * 2px) calc(2px + var(--layer) * 1.5px) rgba(70, 44, 14, calc(.12 + var(--pop) * .16)));
}
.popup-cut svg { width: 100%; height: 100%; overflow: visible; }
/* White die-cut border like a real cut-out. */
.popup-ink { stroke: #fffdf6; stroke-width: 3px; stroke-linejoin: round; paint-order: stroke; vector-effect: non-scaling-stroke; }
.popup-ink [stroke]:not([stroke="#fffdf6"]) { paint-order: normal; }
.popup-cut[style*="--layer:0"] { opacity: .92; }
.popup-prop {
  bottom: 8px; font-size: clamp(30px, 4.2vw, 46px); line-height: 1; margin-left: -.5em; width: 1em; text-align: center;
  filter: drop-shadow(2px 0 0 #fffdf6) drop-shadow(-2px 0 0 #fffdf6) drop-shadow(0 2px 0 #fffdf6) drop-shadow(0 -2px 0 #fffdf6) drop-shadow(0 5px 4px rgba(70, 44, 14, .28));
}
.popup-photo { left: 50%; bottom: 8px; width: auto; height: 82%; margin: 0; padding: 5px; background: #fffdf6; border-radius: 6px;
  transform: translateX(-50%) translateX(calc(var(--px) * 7px)) rotateX(calc((1 - var(--pop)) * -88deg)); }
.popup-photo img { display: block; height: 100%; width: auto; max-width: 260px; object-fit: cover; border-radius: 3px; }
.popup-stage.has-flap .popup-scene { right: min(48%, 244px); }
.popup-flap {
  --layer: 2; right: 2%; bottom: 10px; width: min(46%, 230px); height: 72%; padding: 0; border: 0; background: none; cursor: pointer;
  pointer-events: auto; perspective: 500px; font: inherit; color: inherit; z-index: 6;
}
.popup-flap:focus-visible { outline: 3px solid var(--color-marker-orange, #ff6f1e); outline-offset: 4px; border-radius: 10px; }
.flap-card { position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; transform-origin: 50% 50%;
  transition: transform .7s cubic-bezier(.34, 1.4, .5, 1); }
.popup-flap[aria-expanded="true"] .flap-card { transform: rotateY(180deg); }
.flap-front, .flap-back { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 8px 12px; border-radius: 10px; backface-visibility: hidden; -webkit-backface-visibility: hidden; text-align: center; line-height: 1.45; overflow: hidden; }
.flap-front { background: #ffd35c; border: 2px dashed #c98a12; box-shadow: 0 0 0 3px #fffdf6; color: #3b2a0e; font-size: 15px; }
.flap-front small { font-size: 11px; opacity: .75; }
.flap-back { transform: rotateY(180deg); background: #fffdf6; border: 2px solid #ff9f43; color: #382918; font-size: 14px; }
.popup-flap[aria-expanded="true"] { z-index: 8; }
/* Rising animation when a book opens. Pieces overshoot a little, like paper springing up. */
.popup-enter .popup-piece { animation: popup-rise .9s cubic-bezier(.3, 1.55, .55, 1) both; animation-delay: calc(.12s + var(--d) * .07s); }
.popup-enter .popup-photo { animation-name: popup-rise-photo; }
@keyframes popup-rise { from { transform: rotateX(-88deg) scale(.9); } to { transform: translateX(calc(var(--px) * (var(--layer) + .4) * 5px)) rotateX(0deg) scale(calc(.94 + var(--layer) * .03)); } }
@keyframes popup-rise-photo { from { transform: translateX(-50%) rotateX(-88deg); } to { transform: translateX(-50%) rotateX(0deg); } }
/* Idle motion after standing up. */
.popup-drift svg { animation: popup-drift 9s ease-in-out infinite alternate; }
.popup-bob svg { animation: popup-bob 3.2s ease-in-out infinite; }
.popup-float svg { animation: popup-bob 4s ease-in-out infinite; }
.popup-flutter svg { animation: popup-flutter 1.6s ease-in-out infinite; transform-origin: 50% 50%; }
.popup-twinkle svg { animation: popup-twinkle 2.8s ease-in-out infinite; }
@keyframes popup-drift { to { transform: translateX(18%); } }
@keyframes popup-bob { 50% { transform: translateY(-5%) rotate(-1.5deg); } }
@keyframes popup-flutter { 50% { transform: translateY(-10%) scaleX(.7); } }
@keyframes popup-twinkle { 50% { opacity: .55; } }
/* While a leaf turns, flipbook.js sets --pop on each face so its scene folds and unfolds. */
.flip-face .popup-piece { animation: none !important; }
.flip-face .popup-stage { perspective: none; }
.popup-toggle[aria-pressed="false"] { opacity: .7; }
/* Editor */
.popup-editor { border: 1px dashed #e0cfb1; border-radius: 14px; padding: 14px 16px; margin: 16px 0; background: #fffaf0; display: grid; gap: 10px; }
.popup-editor legend { font-weight: 700; padding: 0 6px; }
.popup-editor .form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.popup-emoji-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.popup-emoji-picks button { font-size: 20px; width: 40px; height: 40px; border-radius: 10px; border: 1px solid #e5d7bf; background: #fff; cursor: pointer; }
.popup-preview { background: #fffdf6; border: 1px solid #e1d3bc; border-radius: 8px; padding: 6px 10px 2px; }
.popup-preview .popup-stage { margin: 0; }
.popup-preview .popup-empty { height: 80px; display: grid; place-items: center; color: #9c866b; font-size: 14px; }
@media (max-width: 800px) {
  .popup-stage { height: clamp(104px, 17vh, 150px); margin-top: 12px; }
  .popup-flap { width: 50%; }
  .flap-front { font-size: 13px; } .flap-back { font-size: 12.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .popup-enter .popup-piece, .popup-drift svg, .popup-bob svg, .popup-float svg, .popup-flutter svg, .popup-twinkle svg { animation: none !important; }
  .flap-card { transition: none; }
  .popup-piece { transform: rotateX(calc((1 - var(--pop)) * -88deg)); }
  .popup-photo { transform: translateX(-50%); }
}
@media print { .popup-stage { display: none; } }
.popup-editor label.check { display: flex; flex-direction: row; align-items: center; gap: 8px; }
