/* The record room: the animated opening screen.
   Everything here is scoped to .room so it cannot affect the rest of the site. */

:root{--u:.0625vw}
.room{position:relative;height:100vh;height:100svh;min-height:480px;overflow:hidden;background:#4d4240;color:#fff;isolation:isolate}
.room-stage{position:absolute;inset:0;overflow:hidden;isolation:isolate;will-change:transform;contain:paint}
.room-stage.is-away{visibility:hidden}
.room-stage.is-scrolling .layer,.room-stage.is-away .layer{animation-play-state:paused}

.layer{position:absolute;inset:0;width:100%;height:100%;display:block;pointer-events:none}
.layer-figure,.layer-curtains,.layer-ivy,.layer-foreground{will-change:transform}

.layer-shadow,.layer-beams{animation:sun-breathe 17s ease-in-out infinite alternate}
.layer-shadow,.layer-beams,.layer-motes,.layer-bloom{mix-blend-mode:screen}
/* The copy of the figure, flattened to a silhouette and softened into a shadow */
.layer-figshadow{mix-blend-mode:multiply;opacity:.64;filter:brightness(0) blur(calc(var(--u)*8));will-change:transform}
.layer-gradeshade{mix-blend-mode:multiply}
.layer-gradetone{mix-blend-mode:soft-light;opacity:.8}

/* A passing cloud slowly dims and returns the sun */
@keyframes sun-breathe{from{opacity:1}to{opacity:.74}}

.layer-curtains{transform-origin:16% 0;animation:curtain-drift 11s ease-in-out infinite alternate}
.layer-ivy{transform-origin:30% 0;animation:ivy-sway 8s ease-in-out infinite alternate}
.layer-foreground{transform-origin:0 100%;animation:leaf-sway 7s ease-in-out infinite alternate}
@keyframes curtain-drift{from{transform:skewX(-.3deg)}to{transform:skewX(.32deg)}}
@keyframes ivy-sway{from{transform:skewX(-.22deg)}to{transform:skewX(.24deg)}}
@keyframes leaf-sway{from{transform:rotate(-.35deg)}to{transform:rotate(.4deg)}}

/* Records */
.rec{cursor:pointer;outline:none}
.rec-hit{fill:transparent;pointer-events:all}
.rec-art{transform-box:fill-box;transform-origin:50% 100%;transition:transform .26s cubic-bezier(.2,.7,.2,1)}
/* The same passing light on the whiteboard, and on Ruko the first time he comes into view */
.board-sheen,.ruko-sheen{opacity:0;transform:skewX(-14deg)}
.board-link.is-nudge .board-sheen,.board-link.is-nudge-soft .board-sheen{animation:board-sheen 1.2s ease-in-out}
.ruko-spark{opacity:0;transform-box:fill-box;transform-origin:50% 50%}
.ruko-toy.is-shine .ruko-sheen{animation:ruko-sheen 1s ease-in-out .1s}
.ruko-toy.is-shine .ruko-body{animation:ruko-pop .9s cubic-bezier(.3,.7,.3,1)}
.ruko-toy.is-shine .ruko-spark{animation:ruko-spark 1.1s ease-out .25s}
@keyframes ruko-pop{0%,100%{transform:none}35%{transform:translateY(-14px) scale(1.07)}}
@keyframes ruko-spark{0%{opacity:0;transform:scale(.2) rotate(0)}35%{opacity:1;transform:scale(1.2) rotate(35deg)}100%{opacity:0;transform:scale(.4) rotate(70deg)}}
.room-stage.is-scrolling .board-sheen,.room-stage.is-scrolling .ruko-sheen{animation-play-state:paused}
@keyframes board-sheen{0%{opacity:0;transform:skewX(-14deg) translateX(0)}15%{opacity:1}85%{opacity:1}100%{opacity:0;transform:skewX(-14deg) translateX(640px)}}
@keyframes ruko-sheen{0%{opacity:0;transform:skewX(-14deg) translateX(0)}18%{opacity:1}82%{opacity:1}100%{opacity:0;transform:skewX(-14deg) translateX(130px)}}
.rec.is-touched .rec-art{transform:translateY(-9px)}
/* While his hand is on a record, its edge glows */
.rec-glow{opacity:0;transition:opacity .25s;filter:drop-shadow(0 0 4px #ffcf80) drop-shadow(0 0 10px rgba(255,190,110,.7))}
.rec.is-touched .rec-glow{opacity:1}
.rec.is-tilted .rec-art{transform:translateY(-15px) rotate(-3.2deg)}
/* The arrival nudge: a small lift with window light passing across the cover */
.rec-sheen{opacity:0;transform:skewX(-14deg)}
.rec.is-nudge .rec-art{animation:rec-lift .9s cubic-bezier(.3,.7,.3,1)}
.rec.is-nudge-soft .rec-art{animation:rec-lift-soft .9s cubic-bezier(.3,.7,.3,1)}
.rec.is-nudge .rec-sheen,.rec.is-nudge-soft .rec-sheen{animation:rec-sheen 1s ease-in-out}
.room-stage.is-scrolling .rec-art,.room-stage.is-scrolling .rec-sheen{animation-play-state:paused}
@keyframes rec-lift{0%,100%{transform:none}38%{transform:translateY(-8px)}}
@keyframes rec-lift-soft{0%,100%{transform:none}38%{transform:translateY(-4px)}}
@keyframes rec-sheen{0%{opacity:0;transform:skewX(-14deg) translateX(0)}18%{opacity:1}82%{opacity:1}100%{opacity:0;transform:skewX(-14deg) translateX(360px)}}
/* Whiteboard link: a warm edge appears on hover or keyboard focus */
.board-link{cursor:pointer;outline:none}
.board-hit{fill:transparent;pointer-events:all}
.board-glow{fill:none;stroke:#ffcf94;stroke-width:4;opacity:0;transition:opacity .2s}
.board-link:hover .board-glow{opacity:.9}
.board-link:focus-visible .board-glow{opacity:1;stroke:var(--accent)}

/* Ruko figurine: a small wave now and then, a hop on hover */
.ruko-toy{cursor:pointer;outline:none}
.ruko-hit{fill:transparent;pointer-events:all}
.ruko-ring{fill:none;stroke:var(--accent);stroke-width:3;opacity:0}
.ruko-toy:focus-visible .ruko-ring{opacity:1}
.ruko-body{transform-box:fill-box;transform-origin:50% 100%;transition:transform .22s cubic-bezier(.2,.7,.2,1)}
.ruko-toy:hover .ruko-body{transform:translateY(-6px)}
.ruko-arm{transform-box:fill-box;transform-origin:0% 100%;animation:ruko-wave 7s ease-in-out infinite}
.ruko-toy:hover .ruko-arm{animation-duration:.9s}
.room-stage.is-scrolling .ruko-arm,.room-stage.is-away .ruko-arm{animation-play-state:paused}
@keyframes ruko-wave{0%,76%,100%{transform:none}82%{transform:rotate(14deg)}88%{transform:rotate(-8deg)}94%{transform:rotate(12deg)}}
.rec-ring{fill:none;stroke:var(--accent);stroke-width:4;opacity:0}
.rec:focus-visible .rec-ring{opacity:1}
/* The orange line under the active record is not shown; a focused record keeps its ring */
.shelf-rule{display:none}

/* Site navigation over the scene */
.room-bar{position:absolute;z-index:4;top:0;left:0;right:0;display:flex;justify-content:space-between;align-items:center;gap:24px;padding:20px var(--m) 52px;background:linear-gradient(rgba(22,13,8,.72),rgba(22,13,8,0));pointer-events:none}
.room-bar a{pointer-events:auto}

/* The room falls into its own warm shadow behind the name. Multiply keeps the light underneath.
   It is part of the stage, so the whole scene scrolls as one cached picture. */
.room-stage::after{content:"";position:absolute;inset:0;pointer-events:none;mix-blend-mode:multiply;background:radial-gradient(ellipse 64% 88% at 92% 100%,#2c1a10 0,#3a2316 48%,#8a6245 74%,#fff 100%)}

/* --name-w is the width of NANDAKUMAR in ems, so any font fills the same space */
.room-name{position:absolute;z-index:3;left:46%;right:var(--m);bottom:clamp(20px,4svh,44px);--name-w:7.4;font-family:"Marcellus",Georgia,serif;text-shadow:0 2px 26px rgba(20,10,6,.5);pointer-events:none}
.room-name h1{font-family:inherit;font-weight:400;letter-spacing:0;font-size:min(calc((54vw - var(--m))/var(--name-w)),17svh);line-height:1.02}
.room-name h1 span{display:block}
.room-foot{display:flex;align-items:center;gap:clamp(20px,2.4vw,32px);margin-top:clamp(12px,1.6vw,22px)}
.room-role{font-size:var(--step-lead);line-height:1.2}
.room-link{display:inline-flex;align-items:center;min-height:44px;color:#fff;font-size:var(--step-lead);font-weight:400;text-decoration:underline;text-underline-offset:.28em;text-decoration-thickness:1px;pointer-events:auto;transition:color .18s}
.room-link:hover{color:var(--accent)}

.record-links{display:none}
.room-noscript{position:absolute;z-index:3;left:var(--m);bottom:24px;display:flex;gap:20px}
.room-noscript a{color:#fff;font-weight:600}

/* Stacked: name first, then the scene, then three plain links */
@media (max-width:820px),(max-aspect-ratio:5/4){
  .room{display:flex;flex-direction:column;height:auto;min-height:0;background:var(--ink)}
  .room-stage::after{display:none}
  .room-bar{position:static;order:0;padding-bottom:0;background:none}
  .room-name{position:static;order:1;padding:18px var(--m) 20px}
  .room-name h1{font-size:min(calc((100vw - 2*var(--m))/var(--name-w)),7rem)}
  .room-foot{justify-content:space-between}
  .room-stage{position:relative;inset:auto;order:2;width:100%;aspect-ratio:990/1200;max-height:72vh;max-height:72svh}
  .record-links{order:3;display:grid;grid-template-columns:repeat(3,1fr);background:var(--ink)}
  .record-links a{display:flex;align-items:center;justify-content:center;min-height:56px;color:#fff;font-weight:600;text-decoration:none}
  .room-noscript{position:static;order:3;padding:12px var(--m) 20px}
}

/* CPU mode: set by room.js when there is no GPU. Still layers become flat pictures
   of the whole scene, placed to match the view; the slow sways hold still so
   nothing large changes every frame. */
.room-stage.is-cpu .layer{animation:none;will-change:auto}
.room-stage img.layer-picture{inset:auto;left:var(--pic-x,0);top:var(--pic-y,0);width:var(--pic-w,100%);height:var(--pic-h,100%);max-width:none}
/* A dark multiply and a dark overlay look almost the same, and the overlay costs far less */
.room-stage.is-cpu .layer-figshadow{mix-blend-mode:normal;opacity:.58}
.room-stage .layer-grain{background-repeat:repeat;background-size:var(--grain) var(--grain);background-position:var(--pic-x,0) var(--pic-y,0)}

@media (prefers-reduced-motion:reduce){
  .layer{animation:none!important}
  .rec-art,.shelf-rule{transition:none}
}
/* The room-fixed sun on the figure: the blended, blurred version with a GPU, and a plain
   one (no blend, no blur) in CPU mode */
.room-stage.is-cpu #figSun,.room-stage.is-cpu #figSunHead,.room-stage:not(.is-cpu) #figSunLite,.room-stage:not(.is-cpu) #figSunLiteHead{display:none}
