/* Scene stage (shared): variant I behind every page, variant J inline on the Historie page. Markup: template-parts/scene.php, logic: assets/js/scene.js. */
/* ============================================================
   Scene stage: one 2400 × 1350 canvas, cover-fitted. --fx is the
   horizontal focus (0.683 = the house) used once the canvas is cropped.
   ============================================================ */
.scene {
  --p: 0; --pe: 0;
  position: fixed; top: 0; left: 0; right: 0; height: 100lvh; z-index: 0;
  overflow: hidden; pointer-events: none; container-type: size;
}
.sc-canvas {
  --ch: 100cqh; --cb: 0px; --fx: 0.5; /* height to cover, distance from the stage bottom */
  --cw: max(100cqw, var(--ch) * 16 / 9);
  position: absolute; width: var(--cw); aspect-ratio: 16 / 9;
  bottom: var(--cb);
  left: clamp(100cqw - var(--cw), 50cqw - var(--cw) * var(--fx), 0px);
}
/* front page: the street ends above the booking bar */
.scene--full .sc-canvas { --ch: calc(100cqh - 5.5rem); --cb: 5.5rem; }
.sc-layer { position: absolute; inset: 0; }
.sc-sky > img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: cover; }

/* placement on the canvas (2400 × 1350 units, in %):
   house 896 × 1200 centred on x 1640, street at the bottom;
   left linden mostly outside the left edge, right linden (mirrored) beside the house */
.sc-house, .sc-tree > img { position: absolute; max-width: none; }
.sc-house { left: 49.667%; top: 11.852%; width: 37.333%; height: 88.889%; }
.sc-house > img, .sc-house > .sc-ov, .sc-backing, .sc-depth, .sc-depth > img, .sc-depth > .sc-ov { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; display: block; }
/* the windows of facade.webp are transparent: empty rooms in paper colour (interior.webp's footprint as mask) … */
.sc-backing {
  background: var(--lh-bg);
  -webkit-mask: url(../scene/interior.webp) 0 0 / 100% 100% no-repeat; mask: url(../scene/interior.webp) 0 0 / 100% 100% no-repeat;
}
/* … and the furnished rooms show only in a soft circle around the mouse (scene.js sets --mx/--my/--rr) */
.sc-interior {
  -webkit-mask-image: radial-gradient(circle var(--rr, 0px) at var(--mx, -50%) var(--my, -50%), #000 35%, transparent 100%);
  mask-image: radial-gradient(circle var(--rr, 0px) at var(--mx, -50%) var(--my, -50%), #000 35%, transparent 100%);
}
.sc-tree-l > img { left: -27%; top: 0; width: 41.083%; height: 97.778%; }
.sc-tree-r > img { left: 72%; top: 22.222%; width: 33.583%; height: 80%; transform: scaleX(-1); } /* mirrored copy */

/* fake 3D: every depth moves by its own amount while scrolling (--p from scene.js).
   Far → near: sky, rooms behind the glass, facade, sidewalk, lindens. The lindens simply scroll away with the page. */
.sc-sky     { transform: translate3d(0, calc(var(--p) * -2%), 0); }
.sc-facade  { transform: translate3d(0, calc(var(--p) * -20%), 0); }
.sc-depth-back  { transform: translate3d(0, calc(var(--p) * 0.6%), 0); }
.sc-depth-front { transform: translate3d(0, calc(var(--p) * -1.225%), 0); }
.sc-tree-l, .sc-tree-r { transform: translate3d(0, calc(var(--p) * -100%), 0); }
.scene--full .sc-sky, .scene--full .sc-facade, .scene--full .sc-depth, .scene--full .sc-tree { will-change: transform; }

.sc-veil {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--lh-bg) 45%, transparent);
  backdrop-filter: blur(10px) saturate(0.9); -webkit-backdrop-filter: blur(10px) saturate(0.9);
  opacity: clamp(0, calc((var(--p) - 0.45) * 2.2), 1);
}

/* ambient, continuous and slow: the sky drifts, the lindens breathe */
.sc-sky > img { scale: 1.06; animation: lhDrift 140s ease-in-out infinite alternate; }
.sc-tree-l > img { transform-origin: 12% 95%; animation: lhSway 13s ease-in-out infinite alternate; }
.sc-tree-r > img { transform-origin: 50% 95%; animation: lhSwayR 11s ease-in-out -6s infinite alternate-reverse; }
@keyframes lhDrift { from { transform: translateX(-2.5%); } to { transform: translateX(2.5%); } }
@keyframes lhSway { from { transform: rotate(-0.5deg); } to { transform: rotate(0.5deg); } }
@keyframes lhSwayR { from { transform: scaleX(-1) rotate(-0.5deg); } to { transform: scaleX(-1) rotate(0.5deg); } }

/* time of day (scene.js: is-evening from 18:00, is-open Wed–Sat evenings) */
.sc-dusk {
  background: linear-gradient(rgba(96, 88, 132, 0.35), rgba(226, 150, 104, 0.2) 55%, rgba(226, 150, 104, 0));
  opacity: 0; transition: opacity 3s ease;
}
.scene.is-evening .sc-dusk { opacity: 1; }
.ov-glow, .ov-light { opacity: 0; transition: opacity 3s ease; }
.scene.is-evening .ov-glow:not(.ov-glow-dim):not(.ov-glow-r),
.scene.is-evening.is-open .ov-glow-r { opacity: 1; }
.scene.is-evening .ov-light { opacity: 1; }

/* ---------- the window above the door (shared by the watering event) ---------- */
.ov-pane { transform-box: fill-box; }
.ov-pane-l { transform-origin: 0 50%; }
.ov-pane-r { transform-origin: 100% 50%; }
.ov-fig { transform: translateY(150px); }
.ov-room { opacity: 0; }
@keyframes lhRoom { 0%, 4% { opacity: 0; } 14%, 86% { opacity: 1; } 96%, 100% { opacity: 0; } }
@keyframes lhPane { 0% { transform: scaleX(1); } 15%, 84% { transform: scaleX(0.14); } 100% { transform: scaleX(1); } }
@keyframes lhFig { 0%, 13% { transform: translateY(150px); } 26%, 70% { transform: translateY(0); } 82%, 100% { transform: translateY(150px); } }

/* ---------- event: the window opens and the guest waters the flower box (13 s) ---------- */
.ov-can, .ov-water { opacity: 0; }
.ov-can-tilt { transform-box: view-box; transform-origin: 920px 1494px; } /* the hand on the handle */
.scene[data-ev="water"] .ov-room { animation: lhRoom 13s ease-in-out both; }
.scene[data-ev="water"] .ov-pane { animation: lhPane 13s ease-in-out both; }
.scene[data-ev="water"] .ov-fig { animation: lhFig 13s ease-in-out both; }
.scene[data-ev="water"] .ov-can { animation: lhCan 13s ease-in-out both; }
.scene[data-ev="water"] .ov-can-tilt { animation: lhTilt 13s ease-in-out both; }
.scene[data-ev="water"] .ov-water { animation: lhWater 13s linear both; }
.scene[data-ev="water"] .ov-water path { animation: lhFlow 0.6s linear infinite; }
@keyframes lhCan { 0%, 27% { opacity: 0; } 31%, 66% { opacity: 1; } 70%, 100% { opacity: 0; } }
@keyframes lhTilt { 0%, 34% { transform: rotate(0deg); } 42%, 58% { transform: rotate(-30deg); } 64%, 100% { transform: rotate(0deg); } }
@keyframes lhWater { 0%, 42% { opacity: 0; } 45%, 56% { opacity: 1; } 59%, 100% { opacity: 0; } }
@keyframes lhFlow { to { stroke-dashoffset: -22; } }

/* ---------- event: the front door opens slowly, the host peeks out and closes it again (16 s) ---------- */
.ov-door { transform-box: fill-box; transform-origin: 0 50%; } /* hinged on the left, swings inwards */
.ov-door-shade, .ov-droom { opacity: 0; }
.ov-peek { opacity: 0; transform: translateX(-60px); }
.ov-peek-head { transform-box: fill-box; transform-origin: 50% 100%; }
.scene[data-ev="door"] .ov-door { animation: lhDoor 16s ease-in-out both; }
.scene[data-ev="door"] .ov-door-shade { animation: lhDoorShade 16s ease-in-out both; }
.scene[data-ev="door"] .ov-droom { animation: lhDoorRoom 16s ease-in-out both; }
.scene[data-ev="door"] .ov-peek { animation: lhPeek 16s ease-in-out both; }
.scene[data-ev="door"] .ov-peek-head { animation: lhLook 16s ease-in-out both; }
@keyframes lhDoor { 0%, 6% { transform: scaleX(1); } 22%, 74% { transform: scaleX(0.5); } 90%, 100% { transform: scaleX(1); } }
@keyframes lhDoorShade { 0%, 6% { opacity: 0; } 22%, 74% { opacity: 0.22; } 90%, 100% { opacity: 0; } }
@keyframes lhDoorRoom { 0%, 5% { opacity: 0; } 14%, 86% { opacity: 1; } 92%, 100% { opacity: 0; } }
@keyframes lhPeek { 0%, 24% { opacity: 0; transform: translateX(-60px); } 33%, 63% { opacity: 1; transform: translateX(0); } 72%, 100% { opacity: 0; transform: translateX(-60px); } }
@keyframes lhLook { 0%, 37% { transform: rotate(0deg); } 42%, 47% { transform: rotate(-8deg); } 52%, 57% { transform: rotate(7deg); } 61%, 100% { transform: rotate(0deg); } }

/* ---------- the house dog visits (48 s, scene.js toggles data-dog): walks in, lies down, walks out ---------- */
.dg-walker, .dg-lying, .dg-path { opacity: 0; }
.dg-walker { transform-box: fill-box; transform-origin: 50% 100%; }
.dg-leg { transform-box: fill-box; transform-origin: 50% 0; }
.dg-tail { transform-box: fill-box; transform-origin: 0 100%; }
.dg-tail-l { transform-box: fill-box; transform-origin: 0 50%; }
.dg-ear { transform-box: fill-box; transform-origin: 30% 0; }
.dg-head, .dg-head-l { transform-box: fill-box; transform-origin: 85% 85%; }
.dg-rest { transform-box: fill-box; transform-origin: 50% 100%; }
.dg-lid { opacity: 0; }
.scene[data-dog="1"] .dg-path { animation: lhDogPath 48s linear both; }
.scene[data-dog="1"] .dg-walker { animation: lhWalker 48s ease-in-out both; }
.scene[data-dog="1"] .dg-lying { animation: lhLying 48s ease-in-out both; }
.scene[data-dog="1"] .dg-bob { animation: lhBob 0.45s ease-in-out infinite alternate; }
.scene[data-dog="1"] .dg-leg.dg-a { animation: lhStep 0.9s ease-in-out infinite alternate; }
.scene[data-dog="1"] .dg-leg.dg-b { animation: lhStep 0.9s ease-in-out infinite alternate-reverse; }
.scene[data-dog="1"] .dg-tail { animation: lhWagFast 0.7s ease-in-out infinite alternate; }
.scene[data-dog="1"] .dg-tail-l { animation: lhThump 9s ease-in-out infinite; }
.scene[data-dog="1"] .dg-rest { animation: lhBreath 3.4s ease-in-out infinite alternate; }
.scene[data-dog="1"] .dg-head-l { animation: lhRest 24s ease-in-out 12s both; }
.scene[data-dog="1"] .dg-ear { animation: lhEar 7s ease-in-out 3s infinite; }
.scene[data-dog="1"] .dg-lid { animation: lhBlink 6.5s linear infinite; }
.scene[data-dog="1"][data-ev="door"] .dg-tail-l { animation: lhWagFast 0.5s ease-in-out infinite alternate; }
@keyframes lhDogPath { 0% { opacity: 1; transform: translate(220px, -6px); } 22%, 78% { opacity: 1; transform: translate(0, 0); } 100% { opacity: 1; transform: translate(220px, -6px); } }
@keyframes lhWalker {
  0%, 21.5% { opacity: 1; transform: none; }
  25% { opacity: 0; transform: translateY(8px) scaleY(0.82); }
  75% { opacity: 0; transform: scaleX(-1) translateY(8px) scaleY(0.82); }
  78.5%, 100% { opacity: 1; transform: scaleX(-1); }
}
@keyframes lhLying { 0%, 22% { opacity: 0; } 25.5%, 74.5% { opacity: 1; } 77.5%, 100% { opacity: 0; } }
@keyframes lhStep { from { transform: rotate(14deg); } to { transform: rotate(-14deg); } }
@keyframes lhBreath { from { transform: scaleY(1); } to { transform: scaleY(1.018); } }
@keyframes lhWagFast { from { transform: rotate(-14deg); } to { transform: rotate(10deg); } }
@keyframes lhThump { 0%, 70%, 86%, 100% { transform: rotate(0deg); } 74%, 82% { transform: rotate(-12deg); } 78% { transform: rotate(4deg); } }
@keyframes lhEar { 0%, 84%, 92%, 100% { transform: rotate(0deg); } 86% { transform: rotate(-12deg); } 89% { transform: rotate(4deg); } }
@keyframes lhRest { 0%, 10% { transform: rotate(0deg); } 22%, 70% { transform: translateY(5px) rotate(-9deg); } 82%, 100% { transform: rotate(0deg); } }
@keyframes lhBlink { 0%, 95%, 99%, 100% { opacity: 0; } 96%, 98% { opacity: 1; } }

/* ---------- event: a cyclist rides along the front pavement (26 s) ---------- */
.ov-cyclist { visibility: hidden; }
.ov-wheel { transform-box: fill-box; transform-origin: 50% 50%; }
.scene[data-ev="cyclist"] .ov-cyclist { visibility: visible; animation: lhRide 26s linear both; }
.scene[data-ev="cyclist"] .ov-wheel { animation: lhSpin 2s linear infinite; }
.scene[data-ev="cyclist"] .ov-rider { animation: lhBob 1s ease-in-out infinite alternate; }
.ov-scarf { transform-box: fill-box; transform-origin: 100% 40%; }
.scene[data-ev="cyclist"] .ov-scarf { animation: lhScarf 1.6s ease-in-out infinite alternate; }
@keyframes lhRide { from { transform: translateX(-200px); } to { transform: translateX(2000px); } } /* faded at the street ends by #lh-ride-mask */
@keyframes lhSpin { to { transform: rotate(360deg); } }
@keyframes lhBob { to { transform: translateY(-2px); } }
@keyframes lhScarf { from { transform: rotate(-7deg); } to { transform: rotate(5deg); } }

/* ---------- falling leaves / blossom / snow (scene.js spawns them) ---------- */
.lh-fall { position: fixed; top: 0; left: 0; width: 18px; height: 18px; z-index: 40; pointer-events: none; will-change: transform; }
.lh-fall svg { width: 100%; height: 100%; display: block; overflow: visible; }
