/* styles/vr.css - the VR view (scripts/vr.js), every page.
   The room is one document and the page on its monitor another; see the top of scripts/vr.js.
   Nothing here touches a page that is not the room, except the switch itself. Self-contained
   colours, so the switch reads the same on every theme and in XP. */

/* ---- the room ------------------------------------------------------------------------------ */
/* mode.js stamps data-vr="host" before first paint: the page's own content never shows. It is
   held invisible until vr.js has built the room, then removed from layout; if vr.js never runs,
   the hold simply runs out and the plain page appears. Never a blank page. */
:root[data-vr="host"] {
  background: #000;
  overflow: hidden;
}
:root[data-vr="host"] body > :not(.vr) {
  animation: vr-hold 2.5s;
}
:root[data-vr="host"] body:has(> .vr) > :not(.vr) {
  display: none;
}
@keyframes vr-hold {
  from, to { visibility: hidden; }
}

.vr {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  overflow: hidden;
  background: #000;                     /* the room without WebGL, and under the rain */
}
.vr__room {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.vr__stage {
  position: absolute;
  inset: 0;
  perspective-origin: 50% 50%;          /* perspective itself: set by vr.js from the viewport */
}
.vr__world {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-style: preserve-3d;
  will-change: transform;
}
/* The page. vr.js gives it the browser window's size, so at rest it is simply full screen; the
   bezel is a shadow, outside the window until the page pulls back, so the iframe's own box is
   exactly the page and the pointer maths needs no offset. Behind it, a white glow. */
.vr__screen {
  position: absolute;
  display: block;
  border: 0;
  background: #fff;
  border-radius: 6px;
  box-shadow:
    0 0 0 5px #0b0d14,
    0 0 0 6px rgb(255 255 255 / 0.28),
    0 0 26px 4px rgb(255 255 255 / 0.26),
    0 0 90px 18px rgb(255 255 255 / 0.10);
}
/* The words, just above the window and moving with it, in the Matrix's own green. */
.vr__words {
  position: absolute;
  margin: 0;
  transform: translateY(calc(-100% - 1.6vh));
  color: #5dff8f;
  font: 700 clamp(15px, 2.4vh, 26px)/1 "Courier New", ui-monospace, monospace;
  letter-spacing: 0.08em;
  text-align: center;
  text-shadow: 0 0 6px rgb(60 255 120 / 0.85), 0 0 18px rgb(60 255 120 / 0.45);
  pointer-events: none;
  user-select: none;
}
/* What is hidden behind the page: Latin and Masonic marks, a little behind it (--z, from vr.js),
   centred on the points vr.js gives them, in the gap that opens when the page pulls back. vr.js
   fades the lot in with the room. */
.vr__lore {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  transform-style: preserve-3d;
  pointer-events: none;
}
.vr__latin,
.vr__mark {
  position: absolute;
  margin: 0;
  transform: translate(-50%, -50%) translateZ(var(--z, -100px));
}
.vr__latin {
  color: #4dff88;
  font: 700 14px/1 "Courier New", ui-monospace, monospace;
  letter-spacing: 0.22em;
  white-space: nowrap;
  text-shadow: 0 0 5px rgb(60 255 120 / 0.8), 0 0 14px rgb(60 255 120 / 0.35);
  opacity: 0.8;
}
.vr__latin--l,
.vr__latin--r {
  writing-mode: vertical-rl;
}
.vr__latin--l {
  transform: translate(-50%, -50%) translateZ(var(--z, -100px)) rotate(180deg);
}
.vr__mark {
  width: 40px;
  height: 40px;
  fill: none;
  stroke: #4dff88;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 4px rgb(60 255 120 / 0.7));
  opacity: 0.75;
}
.vr__mark circle {
  fill: #4dff88;
  stroke: none;
}

/* The headset: the world seen through a lens, rounded and dark at the edges. Not there at
   rest; vr.js fades it in with the movement. Never in the way of the pointer. */
.vr__lens {
  position: absolute;
  inset: 0.8vmin;
  border-radius: 4vmin;
  pointer-events: none;
  opacity: 0;
  box-shadow:
    0 0 0 100vmax #000,
    inset 0 0 3vmin 0.5vmin rgb(0 0 0 / 0.7);
}

/* ---- the switch ---------------------------------------------------------------------------- */
/* Under the page's header rather than on it, headset on or off: the page is full screen either
   way, and every theme's header reaches the right edge at some width (Dev's always does); in XP
   there is no header, and the corner is free. No words, only the goggles and the switch; the name is still read by
   assistive tech. No backdrop blur: over a moving window it would be recomputed every frame. */
.vr-toggle {
  position: fixed;
  top: 64px;
  right: 12px;
  z-index: 2147483001;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 6px 8px;
  border: 1px solid rgb(255 255 255 / 0.18);
  border-radius: 999px;
  background: rgb(12 14 22 / 0.9);
  color: #f3f4f8;
  font: 600 12px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 4px 18px rgb(0 0 0 / 0.25);
}
:root[data-mode="desktop"] .vr-toggle {
  top: 12px;
}
.vr-toggle__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.vr-toggle:hover {
  background: rgb(24 28 42 / 0.92);
}
.vr-toggle:focus-visible {
  outline: 2px solid #8fb0ff;
  outline-offset: 2px;
}
.vr-toggle__icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
}
.vr-toggle__switch {
  position: relative;
  width: 26px;
  height: 15px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.22);
  transition: background-color 150ms ease;
}
.vr-toggle__switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fff;
  transition: transform 150ms ease;
}
.vr-toggle[aria-pressed="true"] .vr-toggle__switch {
  background: #4f7cff;
}
.vr-toggle[aria-pressed="true"] .vr-toggle__switch::after {
  transform: translateX(11px);
}
@media (prefers-reduced-motion: reduce) {
  .vr-toggle__switch,
  .vr-toggle__switch::after { transition: none; }
}
@media (forced-colors: active) {
  .vr-toggle { border-color: ButtonText; }
  .vr-toggle__switch { background: ButtonText; }
  .vr-toggle[aria-pressed="true"] .vr-toggle__switch { background: Highlight; }
}
@media print {
  .vr-toggle { display: none; }
}

/* ---- the bear (phones, once) --------------------------------------------------------------- */
.pc-ask {
  box-sizing: border-box;
  width: min(340px, calc(100vw - 32px));
  padding: 20px 22px 22px;
  border: 0;
  border-radius: 24px;
  background: #fff;
  color: #1d1b19;
  text-align: center;
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  box-shadow: 0 24px 60px rgb(0 0 0 / 0.35);
}
.pc-ask::backdrop {
  background: rgb(0 0 0 / 0.5);
}
.pc-ask__bear {
  display: block;
  width: 200px;
  height: 200px;
  margin: 0 auto 8px;
  object-fit: contain;
}
.pc-ask__h {
  margin: 0 0 18px;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.3;
}
.pc-ask__ok {
  min-width: 120px;
  min-height: 44px;
  padding: 0 28px;
  border: 0;
  border-radius: 999px;
  background: #1d1b19;
  color: #fff;
  font: 600 16px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  cursor: pointer;
}
.pc-ask__ok:focus-visible {
  outline: 3px solid #4f7cff;
  outline-offset: 3px;
}
