/* ---------- the basement ---------- */
.room { position: absolute; inset: 0; overflow: hidden; background: #000; user-select: none; -webkit-user-select: none; }
.room-cam {
  position: absolute; inset: 0;
  transition: transform .64s var(--ease-in-out), filter .64s var(--ease-in-out);
  will-change: transform;
}
.room-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
/* phones: the room fills the height and swipes sideways */
.room.is-pan { overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.room.is-pan::-webkit-scrollbar { display: none; }
.room.is-pan .room-cam { right: auto; }
.room.is-pan .room-hint { position: fixed; white-space: normal; width: max-content; max-width: calc(100vw - 32px); text-align: center; line-height: 1.4; }
.room-stage > img, .room-stage > canvas { position: absolute; pointer-events: none; -webkit-user-drag: none; }
.room-bg { left: 0; top: 0; width: 100%; height: 100%; transition: filter .45s ease; }

/* soft edges, so any letterboxing melts into the dark */
.room-stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background:
    linear-gradient(to top, rgba(0,0,0,.42), transparent 8%),
    linear-gradient(to right, rgba(0,0,0,.3), transparent 5%),
    linear-gradient(to left, rgba(0,0,0,.3), transparent 5%),
    radial-gradient(ellipse 80% 75% at 52% 48%, transparent 62%, rgba(0,0,0,.3) 100%);
}

/* ---------- objects ---------- */
.room-obj { transition: filter .3s ease, opacity .22s ease; }

/* When a group lights up, everything else steps back into the dark. */
.room-stage[data-active]:not([data-active=""]) .room-bg,
.room-stage[data-active]:not([data-active=""]) .room-obj:not(.is-lit) {
  filter: brightness(.58) saturate(.78);
}

.room-obj.is-lit {
  filter:
    brightness(1.08) saturate(1.06)
    drop-shadow(0 0 1px #fff6dc)
    drop-shadow(0 0 1px #fff6dc)
    drop-shadow(0 0 8px rgba(255, 206, 110, .95))
    drop-shadow(0 0 20px rgba(255, 190, 80, .5));
  animation: lift 1.6s ease-in-out infinite;
}
/* Everything in a group floats on the same clock, so it all moves together. */
@keyframes lift { 0%, 100% { translate: 0 0; } 50% { translate: 0 -3px; } }
@keyframes lift-small { 0%, 100% { translate: 0 0; } 50% { translate: 0 -1.5px; } }
.room-obj[data-id="payphone"].is-lit,
.room-obj[data-id="ipod"].is-lit,
.room-obj[data-id="laptop"].is-lit,
.room-obj[data-group="skateboards"].is-lit,
.room-obj[data-group="about"].is-lit { animation-name: lift-small; }

/* The wallet's cover flips open while it's lit: room.js sets the opacity, clip and transform of these each frame. */
.room-open { opacity: 0; }
.room-obj[data-id="wallet"], .room-open { transition: filter .3s ease; }

/* ---------- whiteboard: the live date ---------- */
/* room.js draws the date on this canvas (and erases it where the mouse wipes) */
.wb-date { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; transition: filter .26s ease; }
.room-stage[data-active]:not([data-active=""]) .wb-date { filter: brightness(.58); }

/* ---------- a little life ---------- */
.amb { position: absolute; pointer-events: none; transition: opacity .3s ease; }
/* the lamp on the record console glows and flickers now and then */
.amb-lamp { width: 190px; height: 190px; margin: -95px 0 0 -95px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 214, 140, .5) 0%, rgba(255, 196, 110, .16) 38%, transparent 70%); mix-blend-mode: screen;
  animation: lamp 6s ease-in-out infinite; }
@keyframes lamp { 0%, 100% { opacity: .85; } 46% { opacity: 1; } 49% { opacity: .74; } 52% { opacity: .98; } }
/* the record turns */
.amb-vinyl { width: 54px; height: 54px; margin: -27px 0 0 -27px; transform: scaleY(.44) rotate(-10deg); }
.amb-vinyl i { position: absolute; inset: 0; border-radius: 50%; mix-blend-mode: screen; opacity: .45;
  background: conic-gradient(from 0deg, transparent 0 20deg, rgba(255,255,255,.55) 35deg, transparent 55deg 200deg, rgba(255,255,255,.4) 215deg, transparent 235deg);
  -webkit-mask: radial-gradient(circle, transparent 17%, #000 19%, #000 68%, transparent 70%); mask: radial-gradient(circle, transparent 17%, #000 19%, #000 68%, transparent 70%);
  animation: spin 1.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.room-stage[data-active]:not([data-active=""]) :is(.amb-lamp, .amb-vinyl) { opacity: .3; }
/* click the record: it stops (and starts again) */
.room-stage.record-stopped .amb-vinyl i { animation-play-state: paused; opacity: .22; }
/* click the lamp: the basement goes dark, and whatever you hover still lights up */
.room-stage.lights-off .amb-lamp { animation: none; opacity: 0; }
.room-stage.lights-off .room-bg,
.room-stage.lights-off .room-obj:not(.is-lit) { filter: brightness(.42) saturate(.72); }
.room-stage.lights-off[data-active]:not([data-active=""]) .room-bg,
.room-stage.lights-off[data-active]:not([data-active=""]) .room-obj:not(.is-lit) { filter: brightness(.3) saturate(.6); }
.room-stage.lights-off .wb-date { filter: brightness(.45); }
.room-stage.lights-off .amb-ipod { opacity: .55; }
/* the iPod screen wakes up with the rest of the music gear */
.amb-ipod { width: 46px; height: 34px; margin: -17px 0 0 -23px; border-radius: 50%; opacity: 0;
  background: radial-gradient(ellipse, rgba(190, 230, 255, .75), rgba(150, 210, 255, .2) 45%, transparent 70%); mix-blend-mode: screen; }
.room-stage[data-active="music"] .amb-ipod { opacity: 1; }
/* ---------- the key light (click the softbox) ----------
   With the lamp on it adds a soft patch of light on the desk and chair. With the lamp off it's the only light:
   the rest of the basement stays dark and just the desk area comes up (a clean copy of the room, masked to the
   light's pool, sits over the darkened one). Light also spills around the softbox's edges. */
.key-pool { left: 0; top: 0; width: 100%; height: 100%; opacity: 0; transition: opacity .5s ease, filter .45s ease;
  filter: brightness(1.22) saturate(1.05); }
.amb-key { left: 0; top: 0; width: 100%; height: 100%; opacity: 0; mix-blend-mode: screen; background: rgb(255, 246, 228); transition: opacity .5s ease; }
.amb-key-rim { width: 330px; height: 330px; margin: -165px 0 0 -165px; border-radius: 50%; opacity: 0; mix-blend-mode: screen;
  background: radial-gradient(circle, rgba(255, 252, 242, .95) 0%, rgba(255, 246, 226, .55) 30%, rgba(255, 238, 210, .16) 52%, transparent 70%); }
.room-stage.key-on .key-pool { opacity: 1; }
.room-stage.key-on .amb-key { opacity: .2; }
.room-stage.key-on .amb-key-rim { opacity: .8; }
.room-stage.key-on.lights-off .key-pool { filter: brightness(1) saturate(.96); }
.room-stage.key-on.lights-off .amb-key { opacity: .1; }
.room-stage.key-on.lights-off .amb-key-rim { opacity: 1; }
/* what sits in the pool comes up with it */
.room-stage.key-on .room-obj:is([data-id="laptop"], [data-id="wallet"]):not(.is-lit) { filter: brightness(1.1); }
.room-stage.key-on.lights-off .room-obj:is([data-id="laptop"], [data-id="wallet"]):not(.is-lit) { filter: brightness(.95) saturate(.95); }
/* hovering a room still steps everything else back, the lit desk included */
.room-stage.key-on[data-active]:not([data-active=""]) .key-pool { filter: brightness(.68) saturate(.8); }
.room-stage.key-on.lights-off[data-active]:not([data-active=""]) .key-pool { filter: brightness(.5) saturate(.7); }
.room-stage.key-on[data-active]:not([data-active=""]) .amb-key-rim { opacity: .45; }
.room-stage.key-on[data-active]:not([data-active=""]) .room-obj:is([data-id="laptop"], [data-id="wallet"]):not(.is-lit) { filter: brightness(.6) saturate(.8); }
/* the softbox is a switch: hovering it just perks it up a little */
.room-obj[data-id="softbox"].is-hover { filter: brightness(1.18); }

/* ---------- headline on the open stretch of red carpet ---------- */
/* Laid flat on the floor with the room's own isometric angles, like it's painted on the rug. */
.room-hero { position: absolute; left: 864px; top: 450px; pointer-events: none; text-align: center; white-space: nowrap;
  transform: translate(-50%, -50%) matrix(.89, .455, -.89, .455, 0, 0);
  text-shadow: 2px 3px 0 rgba(70, 10, 8, .6); transition: opacity .3s ease, filter .45s ease; }
.room-stage.lights-off .room-hero { filter: brightness(.5); }
.room-stage[data-active]:not([data-active=""]) .room-hero { opacity: .55; }
.room-kicker {
  margin: 0 0 6px; font-size: 17px; font-weight: 700; letter-spacing: .3em; text-transform: uppercase; color: rgba(245,239,230,.6);
}
.room-headline {
  margin: 0; font-size: 64px; line-height: .98; font-weight: 800; letter-spacing: -.02em; color: var(--ink);
}
.room-headline span { color: var(--glow); font-weight: 700; padding: 0 .04em; }

/* ---------- paper label ---------- */
.room-label {
  position: absolute; z-index: 7; pointer-events: none;
  display: inline-flex; align-items: baseline; gap: 8px; white-space: nowrap;
  padding: 7px 14px 6px; border-radius: 3px;
  background: #fffdf4; color: #241b15;
  font-family: var(--hand); font-size: 25px; line-height: 1;
  box-shadow: 0 2px 0 rgba(0,0,0,.08), 0 10px 22px rgba(0,0,0,.45);
  transform: translate(-50%, 6px) rotate(-2deg) scale(.92);
  opacity: 0; transition: opacity .18s ease, transform .3s var(--ease-out), left .22s var(--ease-out), top .22s var(--ease-out);
}
.room-label::before { /* a strip of tape */
  content: ""; position: absolute; left: 50%; top: -9px; width: 44px; height: 16px; transform: translateX(-50%) rotate(3deg);
  background: rgba(255, 236, 170, .78); box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.room-label em { font-style: normal; font-size: 21px; color: #6b5a4c; }
.room-label em::before { content: "– "; }
.room-label.is-on { opacity: 1; transform: translate(-50%, 12px) rotate(-2deg) scale(1); }
.room-label.is-above { transform: translate(-50%, calc(-100% - 6px)) rotate(-2deg) scale(.92); }
.room-label.is-above.is-on { transform: translate(-50%, calc(-100% - 12px)) rotate(-2deg) scale(1); }

/* ---------- keyboard hotspots ---------- */
.room-hotspot {
  position: absolute; z-index: 8; width: 1px; height: 1px; overflow: hidden; opacity: 0;
  color: transparent; text-decoration: none;
}
.room-hotspot:focus-visible { opacity: 1; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; outline: 4px solid var(--focus); outline-offset: 2px; }

.room-hint {
  position: absolute; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  margin: 0; padding: 8px 16px; border-radius: 999px; z-index: 9;
  background: rgba(10,8,7,.6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 13px; font-weight: 500; color: rgba(245,239,230,.84); letter-spacing: .01em; white-space: nowrap;
  transition: opacity .6s ease, transform .6s var(--ease-out); pointer-events: none;
  animation: hint-in .8s 1.2s var(--ease-out) both;
}
.room-hint b { font-weight: 650; color: var(--glow); }
.room-hint.is-gone { opacity: 0; transform: translate(-50%, 8px); }
@keyframes hint-in { from { opacity: 0; transform: translate(-50%, 10px); } }

@media (prefers-reduced-motion: reduce) {
  .room-obj.is-lit, .amb-lamp, .amb-vinyl i { animation: none !important; }
}
