/* Home only. The other pages keep site.css alone and never load this.
   Default state: no script, no WebGL. The page must be complete and good to look at from this alone. */

:root {
  --paper-wall: #cdb35c;
  --paint: #241803;
  --chalk: #f2ebd3;
  --tile: #dfeae4;
  --tile-paint: #0e3531;
  --water: #4fb8b0;
  --rust: #1c120a;
  --loop: #3d060c;
  --home: #2a1c0d;
}

html { scroll-behavior: auto; }
body.home { background: var(--unlit); }
#lvh { position: fixed; top: 0; left: 0; width: 0; height: 100vh; height: 100lvh; pointer-events: none; }
#radio { display: none; }
.hud { display: none; }
.hint { display: none; }

.hud-btn {
  font: 500 0.95rem/1.1 "Fira Sans", system-ui, sans-serif;
  min-height: 44px;
  padding: 0.3rem 0.85rem;
  color: var(--paper);
  background: rgba(21, 18, 11, 0.74);
  border: 1px solid rgba(241, 232, 208, 0.34);
  border-radius: 2px;
  cursor: pointer;
}
.hud-btn:hover { border-color: var(--lamp); color: var(--lamp); }
.hud-btn[aria-pressed="true"] { color: var(--lamp); border-color: var(--lamp); }

/* ---------- The plain page: each room a band in its own colour, the text painted on it. ---------- */
.room { position: relative; padding: 3.2rem var(--gutter); }
.room > .stage,
.room > figure { max-width: 1080px; margin-left: auto; margin-right: auto; }
.plate { max-width: 34rem; }
.plate h2 { margin: 0 0 0.55em; font-size: clamp(2.6rem, 11vw, 4.6rem); line-height: 0.98; }
.plate p:last-child, .plate ul:last-child { margin-bottom: 0; }
.plate .aside { font-size: 1rem; opacity: 0.86; }
.plate ul { padding-left: 1.15rem; }
.room figure { margin-top: 2rem; margin-bottom: 0; }
.room figure img { width: 100%; max-width: 26rem; aspect-ratio: 864 / 1200; object-fit: cover; }
.room figcaption { font-size: 0.92rem; margin-top: 0.5rem; opacity: 0.82; }

.room-hero {
  padding-top: 0;
  background: radial-gradient(90% 360px at 50% 0, rgba(245, 200, 66, 0.22), transparent 75%), var(--unlit);
}
.room-hero::before {
  content: "";
  display: block;
  width: min(72%, 420px);
  height: 14px;
  margin: 0 auto 1.1rem;
  background: linear-gradient(#fff6d6, #ffe68d);
  box-shadow: 0 6px 60px 14px rgba(255, 224, 120, 0.42), 0 0 0 3px #3b3323;
}
.hero h1 { font-size: 1rem; margin-top: 1rem; }
.hero .logo { display: block; width: min(100%, 520px); height: auto; }
.logo-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.hero .line { font-size: 1.45rem; line-height: 1.3; margin: 1.2rem 0 0.6rem; max-width: 26ch; color: #fff4cf; }
.hero .what { color: var(--paper); margin: 0 0 1.1rem; max-width: 30ch; }
.hero .status { color: var(--lamp); margin: 0; font-size: 1rem; }

/* Wallpaper from one local vector tile. */
.room-lobby, .room-mouth {
  color: var(--paint);
  background: #cdb35c url("wallpaper.svg") repeat;
  background-size: 140px;
}
.room-lobby a, .room-mouth a { color: #5a1408; }
.room-mouth { background-color: #b49e58; box-shadow: inset 0 40px 60px -30px rgba(21, 18, 11, 0.75), inset 0 -40px 60px -30px rgba(21, 18, 11, 0.75); }
.room-mouth h2 { color: #6e100b; }
.room-pool {
  color: var(--tile-paint);
  background:
    linear-gradient(transparent 62%, rgba(79, 184, 176, 0.5) 62%),
    repeating-linear-gradient(0deg, rgba(90, 130, 120, 0.3) 0 1px, transparent 1px 34px),
    repeating-linear-gradient(90deg, rgba(90, 130, 120, 0.3) 0 1px, transparent 1px 34px),
    var(--tile);
}
.room-pool a { color: #0a4a44; }
.room-pipes {
  color: var(--chalk);
  background:
    linear-gradient(90deg, rgba(120, 60, 24, 0.24) 0 12px, transparent 12px 44px, rgba(150, 140, 120, 0.12) 44px 60px, transparent 60px) repeat-x 0 0 / 300px 100%,
    var(--rust);
}
.room-loop { color: #ffe9e0; background: linear-gradient(90deg, rgba(0, 0, 0, 0.4), transparent 22%, transparent 78%, rgba(0, 0, 0, 0.4)), var(--loop); }
.room-loop a { color: #ffd7a8; }
.room-crew { color: var(--chalk); background: radial-gradient(420px 300px at 76% 30%, rgba(255, 230, 160, 0.13), transparent 70%), radial-gradient(360px 260px at 14% 72%, rgba(255, 230, 160, 0.1), transparent 70%), #0b0a08; }
.room-home, .room-final { color: var(--chalk); background: var(--home); }
.room-final { background: radial-gradient(70% 280px at 50% 0, rgba(245, 200, 66, 0.24), transparent 75%), var(--home); }
.room-home a, .room-final a { color: var(--lamp); }
.soon { color: var(--lamp); font-size: 1.25rem; }
.room-final .plate h2 { color: #fff4cf; }

@media (min-width: 720px) {
  .room { padding-top: 5rem; padding-bottom: 5rem; display: grid; grid-template-columns: minmax(0, 34rem) minmax(0, 22rem); justify-content: center; align-items: center; gap: 3.5rem; }
  .room-hero { display: block; padding-top: 0; }
  .room > .stage, .room > figure { margin: 0; }
  .room-mouth > figure, .room-pipes > figure { order: -1; }
  .hero { max-width: 1080px; margin: 0 auto; }
}

@media (prefers-reduced-motion: no-preference) {
  .plain .room-hero::before { animation: tube 1.2s steps(1) 1; }
  @keyframes tube { 0% { opacity: 0.2; } 30% { opacity: 1; } 55% { opacity: 0.45; } 80% { opacity: 1; } }
}

/* ---------- JS and a real GPU: the buttons exist. ---------- */
/* The buttons exist only on the walk. */
.lr3d .hud { display: flex; gap: 0.5rem; position: fixed; z-index: 30; right: 12px; bottom: 12px; align-items: center; }
/* Walk is the big one: bottom right, under the thumb, on every screen. */
#walk { min-height: 52px; min-width: 96px; padding: 0.4rem 1.15rem; font-size: 1.1rem; background: var(--lamp); color: #1d1705; border: 0; border-bottom: 3px solid var(--lamp-low); }
#walk:hover { background: #ffdc6a; color: #1d1705; border-color: var(--lamp-low); }
#walk[aria-pressed="true"] { background: var(--paper); color: #1d1705; border-color: var(--dim); }
#world { display: none; }
.lr3d #world { display: block; }

/* ---------- While the walk is loading: the hero alone on the dark, nothing shifts when the light comes on. ---------- */
.will3d .room:not(.room-hero) { visibility: hidden; height: 100vh; padding: 0; }
.will3d .room figure { display: none; }
.will3d .foot { visibility: hidden; }

/* ---------- The walk. ---------- */
#world { position: fixed; top: 0; left: 0; width: 100%; height: 100vh; height: 100lvh; z-index: 0; }
.lr3d main { position: relative; z-index: 1; display: block; }
/* Reading stops. Native scrolling settles on the next wall when it comes to rest near one. */
html.lr3d { scroll-snap-type: y proximity; }
html.lr3d.auto { scroll-snap-type: none; }
.stop { display: none; }
.lr3d .stop { display: block; position: absolute; left: 0; width: 1px; height: 0; scroll-snap-align: start; }
.lr3d .room, .will3d .room {
  display: block;
  padding: 0;
  background: none;
  box-shadow: none;
  color: inherit;
}
.lr3d .room-hero::before { display: none; }
.will3d .stage { position: sticky; top: 0; height: 100vh; height: 100lvh; max-width: none; }
.will3d .room-hero::before { display: none; }
.lr3d .stage { position: sticky; top: 0; height: 100vh; height: 100lvh; max-width: none; overflow: hidden; overflow: clip; pointer-events: none; }
.lr3d .hero { pointer-events: auto; }

/* The figure stays in the document for assistive tech; the same frame hangs on the wall as a print. */
.lr3d .room figure { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); margin: 0; }
.lr3d .foot { position: relative; z-index: 2; }

/* Text on a wall is ordinary HTML on a transform. Its origin is the top left, as the matrix expects. */
.lr3d .plate {
  position: absolute;
  top: 0;
  left: 0;
  width: min(calc(100vw - 40px), 33rem);
  max-width: none;
  margin: 0;
  transform-origin: 0 0;
  opacity: 0;
  pointer-events: none;
  padding: 0.2rem 0;
  font-size: clamp(1rem, 0.95rem + 0.2vw, 1.0625rem);
  line-height: 1.5;
  
  will-change: transform;
}
/* A scrubbed patch of wall under the text: the torch and the flicker can change the room, never the reading. */
.lr3d .plate::before {
  content: "";
  position: absolute;
  inset: -0.5rem -0.7rem;
  z-index: -1;
  background: var(--patch);
  box-shadow: 0 0 26px 15px var(--patch);
  border-radius: 6px;
}
.lr3d .plate { isolation: isolate; }
.lr3d .paint-dark { --patch: rgba(226, 204, 128, 0.84); }
.lr3d .paint-tile { --patch: rgba(226, 238, 232, 0.8); }
.lr3d .paint-chalk { --patch: rgba(9, 7, 5, 0.66); }
.lr3d .room-loop { --patch: rgba(16, 2, 4, 0.66); }
.lr3d .room-home { --patch: rgba(226, 196, 138, 0.86); }
.lr3d .room-final { --patch: rgba(26, 17, 7, 0.68); }
.lr3d .plate h2 { font-size: clamp(2.6rem, 10vw, 3.6rem); margin: 0 0 0.45em; transform: rotate(-0.5deg); transform-origin: 0 100%; }
.lr3d .plate p { margin-bottom: 0.7em; }
.lr3d .plate .aside { font-size: 0.98rem; }

.lr3d .paint-dark .plate { color: #1d1302; }
.lr3d .paint-dark .plate a { color: #5a1408; }
.lr3d .room-mouth .plate h2 { color: #6e100b; }
.lr3d .paint-tile .plate { color: #082b27; }
.lr3d .paint-chalk .plate { color: #f6efd8; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75), 0 0 12px rgba(0, 0, 0, 0.5); }
.lr3d .paint-chalk .plate a { color: #ffe08a; }
.lr3d .room-home .plate { color: #1f1405; }
.lr3d .room-final .plate { color: #fff3d0; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8), 0 0 16px rgba(0, 0, 0, 0.55); }
.lr3d .room-final .plate h2 { color: #fff4cf; font-size: clamp(2.4rem, 9vw, 3.2rem); }
.lr3d .room-final .plate a { color: #ffd868; }
.lr3d .room-final .plate { text-align: center; width: min(calc(100vw - 40px), 26rem); font-size: 1rem; }
.lr3d .soon { color: #ffd868; font-size: 1.2rem; }

/* The hero is the one thing not on a wall. */
.lr3d .hero, .will3d .hero {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 var(--gutter) max(4.5rem, 12vh);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85), 0 0 22px rgba(0, 0, 0, 0.6);
  transition: none;
}
.lr3d .hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(transparent 20%, rgba(8, 6, 2, 0.72) 42%, rgba(8, 6, 2, 0.72) 100%);
}
.lr3d .hero { isolation: isolate; }
.lr3d .hero, .will3d .hero { justify-content: flex-end; }
.lr3d .hero h1, .will3d .hero h1 { width: min(88%, 620px); margin: 0 0 0.6rem; }
.lr3d .hero .logo, .will3d .hero .logo { width: 100%; filter: drop-shadow(0 2px 14px rgba(0, 0, 0, 0.7)); }
.lr3d .hero .line, .will3d .hero .line { margin: 0 0 0.45rem; font-size: clamp(1.25rem, 4.6vw, 1.6rem); max-width: 28ch; }
.lr3d .hero .what, .will3d .hero .what { margin: 0 0 0.4rem; font-size: 1rem; max-width: 34ch; }
.lr3d .hero .status, .will3d .hero .status { font-size: 1rem; }
.lr3d .hint { margin: 0.9rem 0 0; color: #fff4cf; font-size: 0.96rem; }
.lr3d .hint-mouse { display: block; }
.lr3d .hint-touch { display: none; }
@media (pointer: coarse) {
  .lr3d .hint-mouse { display: none; }
  .lr3d .hint-touch { display: block; }
}
.will3d body { background: #000; }


/* The radio's line, styled after the game's Lamp bar. */
.lr3d #radio {
  display: block;
  position: fixed;
  z-index: 20;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 24px);
  margin: 0;
  padding: 0.35rem 0.75rem;
  background: rgba(10, 9, 8, 0.78);
  color: var(--paper);
  font-size: 0.95rem;
  line-height: 1.3;
  opacity: 0;
  transition: opacity 0.35s linear;
  pointer-events: none;
}
.lr3d #radio b { color: var(--lamp); font-weight: 500; margin-right: 0.35rem; }
.lr3d #radio.on { opacity: 1; }

@media print {
  #world, .hud, #radio { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .lr3d #radio { transition: none; }
}

/* The closed test: one key under the status line. */
.hero .join { margin: 1.1rem 0 0; }
.hero .join .key { text-shadow: none; }
.lr3d .hero .join, .will3d .hero .join { margin: 0.8rem 0 0; }
/* On the walk a room's box is empty and overlaps the stage before it, so it would take the hero's taps.
   The hero and the lit plates opt back in. */
.lr3d .room { pointer-events: none; }
/* A short screen, such as a phone on its side, keeps the whole logo in view: a smaller logo, a compact key,
   and no hint, since the Walk button beside it says the same. */
@media (max-height: 500px) {
  .lr3d .hero h1, .will3d .hero h1 { width: min(88%, 620px, 85vh); }
  .lr3d .hero .hint { display: none; }
  .lr3d .hero .join, .will3d .hero .join { margin-top: 0.5rem; }
  .lr3d .hero .join .key, .will3d .hero .join .key { min-height: 44px; padding: 0.3rem 1.1rem; font-size: 1.15rem; }
}
