/* Invitation idea 9: Pop-up invite.
   A closed invitation (dark card stock, the logo stamped in green and blue foil, the headline set on it) lies under
   the words. Scrolling opens it like a pop-up book: the card slides out to its place, tips back onto the
   table and the cover swings up on its spine with the sky printed inside. Austin rises off the page in paper
   cut from Kevin's photo: the skyline, the far shore and bridge, kayaks bobbing on the lake, the trees as side
   flaps. Then the room rises on its own platform, its 250 chairs fold up row by row ("Room for N" counts them)
   and the stage lights the scene orange.
   The book is 640 x 520 px in its own units; 9.js scales and places it. Set from 9.js:
   --cx --cy --cs (where the book sits and its size), --T 0..1 (tipped back), --a 0..1 (cover open),
   --u1 --u2 --ul --ur (skyline, shore, left and right trees standing up, may overshoot 1), --up (room raised),
   --rz (the book's turn on the table), --L 0..1 (stage light), --sheen (foil glint), --lx --ly --lw --lr (centre, width
   and turn of the foil stamp on the cover);
   on each kayak --u, --b, --w and on each seat --r.
   The defaults below are the finished, open card: what shows with motion off or without JavaScript. */
.p9{--len:620vh;--cx:0;--cy:30;--cs:.8;--T:1;--a:1;--u0:1;--u1:1;--u2:1;--ul:1;--ur:1;--up:1;--L:1;--sheen:.5;--lx:510;--ly:400;--lw:180;--lr:0deg;--rz:-8;
  --tilt:50;--open:166;
  /* This section is always dark, whatever the page theme */
  --ink:#f3f3f0;--bg:#121211;--mut:#c4c4bc;--line:rgba(243,243,240,.16);--seat:rgba(243,243,240,.2);--card:#1c1c1a;
  --paper:#f5f0e4;--stock:#1e1d1a;
  --grain:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .45 0 0 0 0 .4 0 0 0 .55 -.18'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  color:#f3f3f0;color-scheme:dark}
/* Before the first paint, with motion on: the closed card (9.js then places it under the words) */
html.js:not(.still) .p9{--T:0;--a:0;--u0:0;--u1:0;--u2:0;--ul:0;--ur:0;--up:0;--L:0;--sheen:0}
html.js:not(.still) .p9:not(.ready) .p9-cam{opacity:0}

.p9 .pin-stage{display:flex;background:radial-gradient(120% 90% at 60% 40%,#1b1a18 0%,#121211 60%,#0d0d0c 100%);isolation:isolate}
.p9 .hero{width:100%;height:100%;padding-block:clamp(16px,3vh,36px);align-items:center;grid-template-rows:minmax(0,1fr)}
.p9-words{position:relative;z-index:3}
.p9 h1{color:#f6f4ee}
.p9 .sub{color:rgba(243,243,240,.84)}

/* The figure is the slot the open card sits in; the card itself can travel outside it (under the words) */
.p9 .room{position:relative;z-index:1;height:100%;display:flex;flex-direction:column;background:none;border:0;padding:0;border-radius:0}
.p9 .view{position:relative;flex:1;min-height:0}
.p9 .cap{flex:none;position:relative;z-index:2;color:var(--mut);margin-top:10px;opacity:var(--capo,1)}
.p9 .cap b{font-variant-numeric:tabular-nums;display:inline-block;min-width:2.2em}

/* ---------- the book ---------- */
.p9-cam{position:absolute;left:50%;top:50%;width:640px;height:520px;margin:-260px 0 0 -320px;pointer-events:none;
  transform:translate(calc(var(--cx) * 1px),calc(var(--cy) * 1px)) scale(var(--cs));perspective:1700px;perspective-origin:50% 0%;transition:opacity .5s}
.p9.mv .p9-cam{will-change:transform}
.p9-book{position:absolute;inset:0;transform-style:preserve-3d;transform-origin:50% 50%;
  transform:rotateX(calc(var(--T) * var(--tilt) * 1deg)) rotateZ(calc(var(--rz) * 1deg))}
.p9-book>*{position:absolute}
/* Its shadow on the table, and the stage light spilling round it */
.p9-shadow{inset:1% 0 -2%;border-radius:12px;background:rgba(0,0,0,.62);filter:blur(22px);transform:translateZ(-3px)}
.p9-shadow::after{content:"";position:absolute;inset:-30% -35% -45%;background:radial-gradient(closest-side at 50% 62%,rgba(43,159,216,.5),rgba(43,159,216,.14) 55%,transparent);opacity:var(--L)}
/* The page inside: cream card stock with the lake printed on it */
.p9-base{inset:0;border-radius:8px;overflow:hidden;background:var(--grain),linear-gradient(180deg,#efe9db,var(--paper) 30%,#f8f4ea);
  box-shadow:inset 0 0 0 1px rgba(60,40,20,.08),inset 0 -3px 0 rgba(0,0,0,.06)}
.p9-lake{position:absolute;left:8px;top:100px;width:624px;height:368.6px;max-width:none;display:block;border-radius:2px}
.p9-glow{position:absolute;inset:40% -10% -20%;background:radial-gradient(60% 55% at 50% 30%,rgba(43,159,216,.55),transparent 70%);mix-blend-mode:multiply;opacity:var(--L)}
/* Soft shadows the standing pieces cast backwards onto the page */
.p9-cast{left:20px;right:20px;height:46px;border-radius:50%;background:radial-gradient(closest-side,rgba(40,25,10,.38),transparent);transform:translateZ(.3px)}
.p9-cast-sky{top:30px;opacity:calc(var(--u1) * .9)}
.p9-cast-shore{top:66px;height:40px;opacity:calc(var(--u2) * .8)}

/* A pop-up piece: hinged at its bottom edge, flat on the page at --u 0, standing at 1 */
.p9-pc{transform-origin:50% 100%;transform:translateZ(.6px) rotateX(calc(var(--u) * -90deg));opacity:clamp(0,calc(var(--u) * 6),1)}
.p9-pc img{display:block;width:100%;height:100%;max-width:none}
.p9-sky{--u:var(--u0);left:2.8px;top:-360.7px;width:634.4px;height:372.7px}
.p9-sky .p9-dusk{position:absolute;inset:0;opacity:var(--L)}
.p9-skyline{--u:var(--u1);left:9.7px;top:-198.7px;width:620.6px;height:244.7px}
.p9-shore{--u:var(--u2);left:9.7px;top:5.7px;width:620.6px;height:94.3px}
/* The trees stand at the sides, turned in like the wings of a stage */
.p9-tree-l{--u:var(--ul);left:-8px;top:118.7px;width:226px;height:181.3px;transform-origin:0 100%;transform:translateZ(.8px) rotateZ(-24deg) rotateX(calc(var(--u) * -90deg))}
.p9-tree-r{--u:var(--ur);right:-8px;top:151.4px;width:226px;height:148.6px;transform-origin:100% 100%;transform:translateZ(.8px) rotateZ(24deg) rotateX(calc(var(--u) * -90deg))}

/* Kayaks: little paper pieces, twice their size in the photo, that fold up off the lake and bob */
.p9-kays{inset:0;transform-style:preserve-3d;pointer-events:none}
.p9-kay{position:absolute;left:calc(var(--x) * 1px - 18px);top:calc(var(--y) * 1px - 22px);width:36px;height:22.2px;
  background:url(../media/i9-kayaks.webp) calc(var(--k) * 12.5%) 0/900% 100% no-repeat;
  transform-origin:50% 100%;transform:translateZ(calc(1px + var(--b,0) * 1px)) rotateX(calc(var(--u,1) * -64deg + var(--w,0) * 1deg));opacity:clamp(0,calc(var(--u,1) * 5),1)}

/* Evening: as the stage lights, every cut-out takes the dusk light. Each has a second copy of its own
   picture (the same file, so nothing more to download) graded warm and darker by a filter that never
   changes; only its opacity follows --L. The page and kayaks get the same light as a multiplied wash. */
.p9-pc .p9-eve{position:absolute;inset:0;filter:brightness(.56) sepia(.42) saturate(1.35) hue-rotate(-14deg);opacity:var(--L)}
.p9-base::after{content:"";position:absolute;inset:0;mix-blend-mode:multiply;opacity:calc(var(--L) * .92);
  background:linear-gradient(180deg,#6f6c9c 0%,#8a7896 30%,#b48a7c 70%,#c39478 100%)}
.p9-glow{z-index:1}
.p9-kay::after{content:"";position:absolute;inset:0;background:inherit;filter:brightness(.48) sepia(.4) hue-rotate(-10deg);opacity:var(--L)}

/* ---------- the cover: dark stock outside with the foil stamp, the sky printed inside ---------- */
.p9-cover{inset:0;transform-style:preserve-3d;transform-origin:50% 0;
  transform:translateZ(calc(5px - var(--a) * 4px)) rotateX(calc(var(--a) * var(--open) * 1deg))}
.p9-out,.p9-in{position:absolute;inset:0;border-radius:8px;backface-visibility:hidden;overflow:hidden}
.p9-out{background:var(--grain),radial-gradient(130% 100% at 30% 20%,#262420,var(--stock) 60%,#171613);
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.05),0 1px 0 rgba(255,255,255,.04)}
/* A hairline of foil round the edge, like a printed invitation */
.p9-out::before{content:"";position:absolute;inset:16px;border:1.5px solid rgba(43,159,216,.5);border-radius:4px}
.p9-stamp{position:absolute;left:calc(var(--lx) * 1px);top:calc(var(--ly) * 1px);width:calc(var(--lw) * 1px);aspect-ratio:172/102;transform:translate(-50%,-50%) rotate(var(--lr));
  filter:drop-shadow(0 1px 0 rgba(0,0,0,.8)) drop-shadow(0 -1px 0 rgba(214,236,255,.18))}
.p9-foil{position:absolute;inset:0;-webkit-mask:url(../media/i9-logo.svg) center/100% 100% no-repeat;mask:url(../media/i9-logo.svg) center/100% 100% no-repeat;
  background:linear-gradient(105deg,#2f6b24 0%,#5aa441 22%,#2b9fd8 40%,#d6f0ff 46%,#5cc0f0 52%,#1f7fb5 66%,#5aa441 84%,#2f6b24 100%) calc(var(--sheen) * 100%) 0/320% 100%}
.p9-in{transform:rotateX(180deg);background:var(--grain),radial-gradient(120% 90% at 50% 100%,#2a2723,var(--stock) 70%)}
.p9-in::before{content:"";position:absolute;inset:16px;border:1.5px solid rgba(43,159,216,.4);border-radius:4px}
/* As the stage lights, the sky warms to early evening (a second print of it, faded in) */

/* ---------- the room: rises on its own platform at the front of the page ---------- */
.p9-plat{left:80px;top:316px;width:480px;transform-style:preserve-3d;transform-origin:50% 100%;opacity:clamp(0,calc(var(--a) * 4 - 2),1);
  transform:translateZ(calc(1px + var(--up) * 16px)) rotateX(calc(var(--lift,0) * -1deg))}
.p9-wall{position:absolute;left:10px;right:10px;top:100%;height:17px;transform-origin:50% 0;
  transform:rotateX(-90deg) scaleY(var(--up));background:linear-gradient(180deg,#e9e2d2,#d6cdb9);border-radius:0 0 2px 2px}
.p9 .floor{position:relative;background:var(--grain),#fbf8f1;border:1px solid rgba(60,40,20,.12);border-radius:8px;padding:10px;transform-style:preserve-3d;
  --seat:rgba(30,26,20,.16);--ink:#1b1a17;--bg:#fbf8f1;
  box-shadow:0 10px 18px rgba(0,0,0,calc(.2 + var(--up) * .25))}
.p9 .floor .stage{height:30px;margin-bottom:8px;border-radius:5px;font-size:17px;font-weight:900;letter-spacing:-.01em;position:relative;transform-style:preserve-3d;transform:translateZ(calc(var(--L) * 6px));
  box-shadow:0 0 calc(var(--L) * 40px) calc(var(--L) * 8px) rgba(43,159,216,calc(var(--L) * .75));
  background:color-mix(in srgb,var(--acc) calc(var(--L) * 100%),var(--ink));color:color-mix(in srgb,#140700 calc(var(--L) * 100%),var(--bg))}
/* A wash of stage light over the front rows */
.p9 .floor::after{content:"";position:absolute;inset:0;border-radius:8px;pointer-events:none;background:radial-gradient(70% 60% at 50% 0%,rgba(43,159,216,.3),transparent 70%);opacity:var(--L)}
.p9 .seats{gap:3px;transform-style:preserve-3d}
.p9 .seats i{aspect-ratio:1.5;border-radius:2px;position:relative;transform-style:preserve-3d;
  background:color-mix(in srgb,var(--acc) calc(var(--r,1) * 100%),var(--seat));transform:translateZ(calc(var(--r,1) * 3px))}
/* The chair back: lies flat, then folds up at the seat's back edge (the edge away from the stage) */
.p9 .seats i::before{content:"";position:absolute;left:6%;right:6%;bottom:0;height:150%;border-radius:3px 3px 1px 1px;background:linear-gradient(#5cc0f0,#1a6f9e 75%);
  transform-origin:50% 100%;transform:rotateX(calc(var(--r,1) * -84deg));opacity:clamp(0,calc(var(--r,1) * 3),1)}

.p9 .scroll-cue{z-index:4;bottom:28px;color:var(--mut);opacity:calc(1 - var(--p,0) * 14)}

@media(max-width:860px){
  .p9 .hero{grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr);gap:8px;align-items:stretch;padding-block:clamp(14px,2.5vh,28px) 10px}
  .p9 h1{font-size:clamp(40px,11vw,64px)}
  .p9 .sub{font-size:16px;margin:12px 0 16px}
  .p9 .cap{font-size:13px;gap:6px;margin-top:4px}
  .p9 .scroll-cue{font-size:12px;white-space:nowrap;bottom:20px}
}
@media(max-width:860px) and (max-height:760px){
  .p9 .sub{display:none}
}

/* Motion off, or no JavaScript: the open card, lit, in an ordinary (unpinned) section */
html:not(.js) .p9.pin{height:auto}
html:not(.js) .p9 .pin-stage{position:relative;height:auto;min-height:calc(100dvh - var(--bar,0px))}
.still .p9 .hero,html:not(.js) .p9 .hero{height:auto;min-height:calc(100dvh - var(--bar,0px))}
.still .p9 .room,html:not(.js) .p9 .room{height:auto}
.still .p9 .view,html:not(.js) .p9 .view{flex:none;height:clamp(360px,calc(100dvh - var(--bar,0px) - 110px),780px)}
.still .p9-cam{transition:none}
html:not(.js) .p9 .scroll-cue{display:none}
@media(max-width:860px){
  .still .p9 .view,html:not(.js) .p9 .view{height:min(108vw,560px)}
  html:not(.js) .p9{--cs:.52;--cy:44}
}
