/* AI Buddy · the room behind the dark sections: backdrop, lamp beam, a small crew of robot heads, vignette.

   Layout   .after::before   the page backdrop behind every section after the film: one static gradient, dark violet
                             towards the end. It sits above the inline background story.js still writes, so the page
                             looks the same with or without that script.
            .room            one sticky layer, a window tall, behind the sections (z 0). Dark sections are transparent,
                             so the room shows through them; the light section (prices) is opaque and slides over it.
              .room-light    everything the lamp gives off; its opacity is the room's presence (0 to 1)
                .room-src    soft glow around the lamp
                .room-beam   the beam, a square of side --room-l whose top centre is the lamp; it is moved and turned
                             by transform only. Inside it: .room-cone, a static conic gradient that fades with distance
                             (mask), painted once; and .room-dust, a few drifting motes on their own small layers.
                .room-pool   the pool of light on what is being read
              .room-floor    a faint floor at the bottom of the window (static)
              .room-crew-at  the cluster's place across the window: the script moves it by transform only, resting in
                             the right gutter in one dark section and the left gutter in the next, gliding between them
                canvas.room-crew  the four heads (one lead holding the lamp, three crew), a canvas the size of the cluster.
                             Its slow bob is a CSS animation (transform only), so the script redraws it only for eyes,
                             blinks and the lean of a glide
            .room-vig        the vignette over the content (z 5), lighter while a light section is in the middle
            .sbg             each section's own backdrop: shown only on the light section and on very tall windows,
                             where the sticky room is switched off (.s5.tall)
   Sizes    --room-l         beam length: the page width plus the window height, longer than the window's diagonal
   States   .is-live        assets/room.js is running: the lamp, beam and pool are placed by transform from the
                             window's real geometry. Without the script (or before it runs) the lamp hangs at the top
                             right and lights the content column from a fixed angle, and no heads are drawn.
            .has-crew        both gutters are wide enough for the heads (56 px or more, not on phones or the phone preview)
            .is-asleep       no dark section is on screen: the motes pause
            .is-unlit        a narrow page (phones, the phone preview): no lamp light at all, set by the script.
                             The container rule below hides the light the same way without the script
            .room-vig.is-lt  a light section is under the middle of the window */

/* backdrop of the whole part after the film */
.s5 .after::before{
  content:"";position:absolute;inset:0;z-index:-1;pointer-events:none;
  background:linear-gradient(#0a0a0c 0%,#0b0b0d 30%,#0c0b10 55%,#0e0c12 80%,#100d14 calc(100% - var(--vh,100vh) - 170px),#17110f 100%);
}

/* the sticky layers: a window tall, taking no room in the flow */
.room,.room-vig{
  position:sticky;top:0;display:block;
  height:var(--vh,100vh);margin-bottom:calc(-1 * var(--vh,100vh));
  pointer-events:none;overflow:hidden;
}
.room{--room-l:calc(100cqw + var(--vh,100vh));z-index:0}
.room-vig{z-index:5;background:radial-gradient(120% 90% at 50% 45%,rgba(0,0,0,0) 50%,rgba(0,0,0,.5) 100%);transition:opacity .8s}
.room-vig.is-lt{opacity:.4}
.s5.tall .room,.s5.tall .room-vig{display:none}

/* the light. Unarmed positions: lamp at 88% / 11%, pool on the content column */
.room-light{position:absolute;inset:0}
.room-src,.room-beam,.room-pool{position:absolute;left:88%;top:11%}
.room-src{width:420px;height:420px;margin:-210px 0 0 -210px;border-radius:50%;background:radial-gradient(closest-side,rgba(214,196,255,.12),rgba(214,196,255,.04) 50%,rgba(214,196,255,0) 100%)}
.room-beam{
  width:var(--room-l);height:var(--room-l);margin-left:calc(var(--room-l) / -2);
  transform-origin:50% 0;transform:rotate(52deg);
}
/* the cone is its own still layer under the motes: the motes animate without the masked cone being painted again */
.room-cone{
  position:absolute;inset:0;
  /* 0deg of a conic gradient points up; the cone is centred on 180deg (straight down) and 52deg wide */
  background:conic-gradient(from 154deg at 50% 0,rgba(170,140,255,0) 0deg,rgba(170,140,255,.03) 7.8deg,rgba(255,244,232,.06) 17.2deg,rgba(255,248,240,.088) 26deg,rgba(255,244,232,.06) 34.8deg,rgba(170,140,255,.03) 44.2deg,rgba(170,140,255,0) 52deg,rgba(0,0,0,0) 360deg);
  -webkit-mask-image:radial-gradient(circle var(--room-l) at 50% 0,#000 0,rgba(0,0,0,.75) 30%,rgba(0,0,0,.35) 62%,rgba(0,0,0,.12) 90%,rgba(0,0,0,0) 100%);
  mask-image:radial-gradient(circle var(--room-l) at 50% 0,#000 0,rgba(0,0,0,.75) 30%,rgba(0,0,0,.35) 62%,rgba(0,0,0,.12) 90%,rgba(0,0,0,0) 100%);
}
.room-pool{left:38%;top:62%;width:1000px;height:520px;margin:-260px 0 0 -500px;border-radius:50%;background:radial-gradient(closest-side,rgba(255,246,236,.07),rgba(200,180,255,.025) 55%,rgba(200,180,255,0) 100%)}
.room-floor{position:absolute;left:0;right:0;bottom:0;height:20%;background:linear-gradient(to top,rgba(255,255,255,.022),rgba(255,255,255,0))}

/* armed: the script places lamp, beam and pool with transforms measured from the window */
.room.is-live .room-light{will-change:opacity}
.room.is-live .room-src,.room.is-live .room-beam,.room.is-live .room-pool{left:0;top:0;will-change:transform}

/* narrow pages (phones, the phone preview) have no lamp light: no glow, beam, motes or pool. The floor and the vignette stay */
.room.is-unlit .room-light{display:none}
@container (max-width:900px){.room-light{display:none}}

/* motes: created by the script only when motion is on; each drifts down the beam and fades */
.room-dust{position:absolute;inset:0}
.room-dust i{position:absolute;width:2px;height:2px;margin:-1px;border-radius:50%;background:rgba(255,246,236,.5);opacity:0;animation:room-mote 24s linear infinite}
.room.is-asleep .room-dust i{animation-play-state:paused}
@keyframes room-mote{
  0%{opacity:0;transform:translate3d(0,0,0)}
  20%{opacity:.7}
  80%{opacity:.5}
  100%{opacity:0;transform:translate3d(14px,340px,0)}
}

/* the heads: drawn by the script, only where the gutters have room */
.room-crew-at{position:absolute;left:0;top:0}
.room.has-crew .room-crew-at{will-change:transform}
.room-crew{position:absolute;left:0;top:0;display:none;animation:room-bob 2.3s ease-in-out infinite alternate}
.room.is-asleep .room-crew{animation-play-state:paused}
@keyframes room-bob{from{transform:translate3d(0,-1.6px,0)}to{transform:translate3d(0,1.6px,0)}}
.room.has-crew .room-crew{display:block}

/* a section's own backdrop: the light section, and every section when the room is off on very tall windows */
.s5 .after .sbg{position:absolute;inset:0;z-index:0;display:none;overflow:hidden;pointer-events:none}
.s5 .after .lt>.sbg,.s5.tall .after .sec>.sbg{display:block}
.sbg::before{
  content:"";position:absolute;top:-30%;right:4%;width:min(44cqw,660px);height:170%;transform-origin:50% 0;transform:rotate(38deg);
  background:linear-gradient(90deg,rgba(236,230,255,0) 0%,rgba(236,230,255,.03) 22%,rgba(236,230,255,.075) 50%,rgba(236,230,255,.03) 78%,rgba(236,230,255,0) 100%);
}
.sbg::after{
  content:"";position:absolute;left:0;right:0;bottom:0;height:clamp(110px,12cqw,200px);
  background:radial-gradient(30% 60% at 32% 0%,rgba(230,222,255,.07),rgba(230,222,255,0) 100%),linear-gradient(90deg,rgba(255,255,255,0),rgba(255,255,255,.075) 18%,rgba(255,255,255,.075) 82%,rgba(255,255,255,0)) 0 0/100% 1px no-repeat,linear-gradient(to bottom,rgba(255,255,255,.024),rgba(255,255,255,0) 85%);
}
.lt>.sbg::before{background:linear-gradient(90deg,rgba(255,255,255,0) 0%,rgba(255,255,255,.28) 24%,rgba(255,255,255,.6) 50%,rgba(255,255,255,.28) 76%,rgba(255,255,255,0) 100%)}
.lt>.sbg::after{background:radial-gradient(30% 60% at 32% 0%,rgba(255,255,255,.6),rgba(255,255,255,0) 100%),linear-gradient(90deg,rgba(17,17,19,0),rgba(17,17,19,.09) 18%,rgba(17,17,19,.09) 82%,rgba(17,17,19,0)) 0 0/100% 1px no-repeat,linear-gradient(to bottom,rgba(17,17,19,.035),rgba(17,17,19,0) 85%)}
@container (max-width:900px){.sbg::before{width:90cqw;right:-20%}}

/* motion off: no motes (the script does not create them either) */
html.calm .room-dust{display:none !important}
html.calm .room-crew{animation:none !important}
@media (prefers-reduced-motion:reduce){.room-dust{display:none !important}.room-crew{animation:none !important}}
