/* ==========================================================================
   Syntropise · The Cabinet · THE EXAMINATION ROOM (a special exhibition)
   A vintage optician's door in the gallery wall. Open it and step inside:
   the eye test's machine (pg-eyetest.css/js) waits on the far wall.
   Everything here is er-.

   The stage is one picture, 1200 x 760 units, scaled so its height fills
   the stage: --er-u is one unit. The door, the room, the furniture and the
   machine are all placed in those units from the centre line (x 600), so
   they stay lined up at every size and the picture's sides crop away on
   narrow screens. The drawings come from dev/make-examroom.py: keep the
   numbers in step (doorway 480..720 x 200..690).
   ========================================================================== */
.er .sec-head{margin-bottom:clamp(26px,3.4vw,44px)}
.er-site{--er-sh:clamp(560px,calc(var(--vh,100svh) - var(--nav-h) - 56px),760px);--er-u:calc(var(--er-sh) / 760)}
.er-stage{position:relative;box-sizing:content-box;width:min(calc(100% - 5px),calc(var(--er-sh) * 1.5789));height:var(--er-sh);margin:0 auto;overflow:hidden;isolation:isolate;
  border:2.5px solid var(--ink);box-shadow:8px 8px 0 var(--coral-2);background:#e9e2d6;container:erst/size;-webkit-tap-highlight-color:transparent}

/* two layers: the room, and in front of it the wall with the door. With JavaScript the wall stands closed until the door is opened. */
.er-room,.er-front{position:absolute;inset:0;transform-origin:50% calc(445 * var(--er-u))}
.er-room{z-index:1}
.er-front{z-index:2;display:none}
.er-live .er-front{display:block}
.er-live .er-room{transform:scale(.84)}
.er-bd,.er-facade{position:absolute;inset:0;display:block;width:100%;height:100%}

/* the furniture and the machine, in units from the centre line */
.er-machine{position:absolute;z-index:3;left:50%;top:calc(118 * var(--er-u));width:min(calc(560 * var(--er-u)),100%);transform:translateX(-50%)}
.er-chair,.er-cart{position:absolute;z-index:2;display:none}
.er-chair{left:calc(50% - 540 * var(--er-u));bottom:calc(12 * var(--er-u));width:calc(270 * var(--er-u))}
.er-cart{left:calc(50% + 296 * var(--er-u));bottom:calc(14 * var(--er-u));width:calc(280 * var(--er-u))}
.er-chair svg,.er-cart svg{display:block;width:100%;height:auto;overflow:visible}
/* only where the picture is wide enough to show them whole; a little smaller just before they'd crop */
@container erst (min-aspect-ratio: 1.42){.er-chair,.er-cart{display:block}}
@container erst (min-aspect-ratio: 1.42) and (max-aspect-ratio: 1.53){
  .er-chair{transform:scale(.86);transform-origin:100% 100%}
  .er-cart{transform:scale(.86);transform-origin:0 100%}
}

/* the clock and the framed eye come down from the wall before the picture would cut them in half */
@container erst (max-aspect-ratio: 1.04){.er-eyeframe{display:none}}
@container erst (max-aspect-ratio: .9){.er-clock{display:none}}

/* the prescription, once four lenses are in: it lands in the room where it fits (the homepage places it beside the copy) */
.er .et-rx{left:50%;top:calc(-60 * var(--er-u));width:min(330px,94%);transform:translate(-50%,40%) rotate(8deg) scale(.86)}
.er .et-rx.is-in{transform:translate(-50%,0) rotate(-2deg)}
@container erst (min-aspect-ratio: 1.42){
  .er .et-rx{left:calc(-222 * var(--er-u));top:calc(-38 * var(--er-u));width:min(330px,calc(340 * var(--er-u)));transform:translate(14%,46%) rotate(9deg) scale(.86)}
  .er .et-rx.is-in{transform:rotate(-3deg)}
}

/* ---------- the door: a real button over the doorway, hinged on the left ---------- */
.er-door{position:absolute;z-index:3;left:calc(50% - 120 * var(--er-u));top:calc(200 * var(--er-u));width:calc(240 * var(--er-u));height:calc(490 * var(--er-u));
  perspective:calc(1500 * var(--er-u));perspective-origin:50% 42%;cursor:pointer}
.er-door:focus{outline:none}
.er-door:focus-visible{outline:3px solid var(--coral-ink);outline-offset:calc(8 * var(--er-u))}
.er-leaf{position:absolute;inset:0;display:block;transform-origin:0 50%;transition:transform .8s var(--ease)}
.er-leaf svg{display:block;width:100%;height:100%;overflow:visible}
@media (hover:hover){.er-door:hover .er-leaf{transform:rotateY(11deg)}}
.er-door:focus-visible .er-leaf{transform:rotateY(11deg)}

/* the lettering on the glass, the sign, the plates */
.er-gl-the{font:650 11px var(--sans);letter-spacing:.42em;text-anchor:middle;fill:var(--ink)}
.er-gl-big{font:400 16.8px 'Young Serif',var(--serif);letter-spacing:.06em;text-anchor:middle;fill:var(--ink)}
.er-gl-room{font:400 34px 'Young Serif',var(--serif);letter-spacing:.16em;text-anchor:middle;fill:var(--ink)}
.er-gl-c{fill:var(--coral-2)}
.er-gl-it{font:italic 400 15.5px var(--serif);text-anchor:middle;fill:var(--ink-2)}
.er-sign-s{font:italic 400 10px var(--serif);text-anchor:middle;fill:var(--ink-2)}
.er-sign-b{font:700 11.5px var(--display);letter-spacing:.06em;text-anchor:middle;fill:var(--ink)}
.er-push{font:400 12.5px 'Young Serif',var(--serif);letter-spacing:.34em;text-anchor:middle;fill:var(--ink)}
.er-plq{font:650 9.4px var(--sans);letter-spacing:.18em;text-anchor:middle;fill:var(--ink)}

/* ---------- opening: the latch, the bell, the swing; then you step inside ---------- */
.er-dusk{opacity:0;transition:opacity 1.3s}
.er-spill{opacity:0;transition:opacity 1s ease .25s}
.er-bell{transform-box:view-box;transform-origin:692px 150px}
.er-sign{transform-box:view-box;transform-origin:120px 215px}
.er-lever{transform-box:view-box;transform-origin:226px 300px}
.er-specs{transform-box:view-box;transform-origin:600px 14px}
.er-site.er-opening .er-leaf{transform:rotateY(84deg);transition:transform 1.3s cubic-bezier(.5,0,.15,1)}
.er-site.er-opening .er-dusk{opacity:.3}
.er-site.er-opening .er-spill{opacity:1}
.er-site.er-opening .er-lever{animation:er-lever .7s ease}
.er-site.er-opening .er-bell{animation:er-bell 1.6s ease-out .12s}
.er-site.er-opening .er-sign{animation:er-swing 1.7s ease-out .05s}
.er-site.er-opening .er-specs{animation:er-sway 2.4s ease-in-out .2s}
@keyframes er-lever{0%,100%{transform:none}30%,55%{transform:rotate(-24deg)}}
@keyframes er-bell{0%,100%{transform:none}12%{transform:rotate(17deg)}30%{transform:rotate(-13deg)}48%{transform:rotate(8deg)}66%{transform:rotate(-5deg)}84%{transform:rotate(2deg)}}
@keyframes er-swing{0%,100%{transform:none}16%{transform:rotate(-9deg)}38%{transform:rotate(6deg)}60%{transform:rotate(-3deg)}80%{transform:rotate(1.2deg)}}
@keyframes er-sway{0%,100%{transform:none}25%{transform:rotate(1.4deg)}60%{transform:rotate(-.9deg)}}
.er-site.er-inside .er-front{transform:scale(4.2);opacity:0;transition:transform 1.2s cubic-bezier(.62,0,.3,1),opacity .55s ease .6s}
.er-site.er-inside .er-room{transform:none;transition:transform 1.2s cubic-bezier(.62,0,.3,1)}
.er-site.er-in .er-front{visibility:hidden}

/* ---------- phones: the picture crops to the door, and the machine takes the full width ---------- */
@media (max-width:640px){
  .er-site{--er-sh:clamp(540px,calc(var(--vh,100svh) - var(--nav-h) - 40px),620px)}
  .er-machine{top:calc(100 * var(--er-u));width:100%}
  .er-plaque,.er-bay{display:none}
}

/* ---------- reduced motion: the door simply opens ---------- */
@media (prefers-reduced-motion:reduce){
  .er-leaf,.er-front,.er-room,.er-dusk,.er-spill{transition:none!important}
  .er-front *{animation:none!important}
  .er-door:hover .er-leaf,.er-door:focus-visible .er-leaf{transform:none}
}
