/* Desk Y stage: the picture, the dots and names on it, the clock, and the layer the worlds open in. */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #d9d4d3; overscroll-behavior: none; }
body { font-family: var(--font); color: var(--ink); -webkit-font-smoothing: antialiased; --ui: var(--ink); --ui-bg: rgba(255, 255, 255, .72); --ui-line: rgba(28, 29, 33, .12); }
body.dark { --ui: #f4f5f8; --ui-bg: rgba(26, 26, 29, .5); --ui-line: rgba(255, 255, 255, .16); background: #1a1a1d; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; box-shadow: 0 0 0 5px var(--sun); border-radius: 8px; }
[hidden] { display: none !important; }

#stage { position: fixed; inset: 0; overflow: hidden; touch-action: none; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity .5s var(--ease); }
body.ready #scene { opacity: 1; }
body.nogl #scene { display: none; }

/* the overlay is the picture's own coordinate system: 2688 x 1520, moved and scaled by one transform (--s is the scale) */
#overlay { position: absolute; left: 0; top: 0; width: 2688px; height: 1520px; transform-origin: 0 0; will-change: transform; pointer-events: none; }
#still { position: absolute; inset: 0; }
#still img { position: absolute; inset: 0; width: 100%; height: 100%; }
#still #still-screen { inset: auto; left: 1120.5px; top: 784.5px; width: 380px; height: 229px; }
#still-b { opacity: 0; } #still-lamp { opacity: 0; mix-blend-mode: plus-lighter; transition: opacity .25s; }
#arrows { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
#arrows path { fill: none; stroke: var(--ui); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; opacity: .8; }

/* things placed on the picture keep their size on screen: they are scaled back by 1 / --s */
.pin { position: absolute; left: 0; top: 0; width: 0; height: 0; transform: translate(var(--x), var(--y)) scale(calc(1 / var(--s, 1))); }
#labels, #spots, #arrows { transition: opacity .3s var(--ease); }
#labels, #spots { position: absolute; inset: 0; }
body.state-flying #arrows, body.state-world #arrows, body.state-flying #labels, body.state-world #labels, body.state-flying #spots, body.state-world #spots { opacity: 0; pointer-events: none; }
body.state-flying .spot, body.state-world .spot { pointer-events: none; }

.label { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); white-space: nowrap; font-family: var(--hand); font-weight: 700; font-size: clamp(22px, 2.5vw, 34px); line-height: 1; color: var(--ui); pointer-events: auto; cursor: pointer; padding: 6px 8px; opacity: .92; }
.label.plain { cursor: default; pointer-events: none; }
.label.small { font-size: clamp(20px, 2vw, 28px); }

.spot { position: absolute; left: -22px; top: -22px; width: 44px; height: 44px; border-radius: 50%; pointer-events: auto; display: grid; place-items: center; }
.spot i { width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px rgba(255, 255, 255, .28), 0 1px 6px rgba(20, 22, 30, .45); transition: transform .2s var(--spring); }
.spot i::after { content: ""; position: absolute; inset: 11px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, .7); animation: ping 3.2s var(--ease) infinite; animation-delay: calc(var(--i, 0) * .4s); }
.spot:hover i, .spot:focus-visible i, .spot.is-hot i { transform: scale(1.35); }
.spot b { position: absolute; left: 50%; bottom: 40px; transform: translate(-50%, 4px); white-space: nowrap; font-size: 13px; font-weight: 600; letter-spacing: -.01em; padding: 6px 11px; border-radius: 999px; color: var(--ink); background: rgba(255, 255, 255, .92); box-shadow: 0 2px 10px rgba(20, 22, 30, .18); opacity: 0; transition: opacity .16s var(--ease), transform .16s var(--ease); pointer-events: none; }
.spot:hover b, .spot:focus-visible b, .spot.is-hot b { opacity: 1; transform: translate(-50%, 0); }
@media (hover: none) { .spot b { opacity: 1; transform: translate(-50%, 0); font-size: 12px; padding: 4px 9px; bottom: 34px; } }
@keyframes ping { 0% { transform: scale(.6); opacity: .9; } 70%, 100% { transform: scale(2.1); opacity: 0; } }
body.holding .spot.is-target i { animation: hold 1s var(--ease) infinite alternate; }
@keyframes hold { to { transform: scale(1.5); } }

/* name pill and clock */
#who, #clock, #places { position: fixed; z-index: 5; color: var(--ui); transition: opacity .3s var(--ease), color .4s; }
body.state-flying #who, body.state-world #who, body.state-flying #clock, body.state-world #clock, body.state-flying #places, body.state-world #places { opacity: 0; pointer-events: none; }
#who { top: max(18px, env(safe-area-inset-top)); left: max(20px, env(safe-area-inset-left)); display: flex; align-items: baseline; gap: 10px; padding: 9px 16px; border-radius: 999px; background: var(--ui-bg); -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3); box-shadow: inset 0 0 0 1px var(--ui-line); }
#who h1 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
#who p { margin: 0; font-size: 12px; opacity: .72; }
#clock { right: max(20px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 14px; border-radius: 999px; background: var(--ui-bg); -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3); box-shadow: inset 0 0 0 1px var(--ui-line); font-family: var(--mono); font-size: 11px; letter-spacing: .02em; }
#clock .tod { text-transform: uppercase; letter-spacing: .06em; min-width: 9ch; }
#clock .hm { font-variant-numeric: tabular-nums; min-width: 5ch; }
#clock input { -webkit-appearance: none; appearance: none; width: 150px; height: 20px; background: transparent; margin: 0; cursor: pointer; }
#clock input::-webkit-slider-runnable-track { height: 2px; background: currentColor; opacity: .35; border-radius: 2px; }
#clock input::-moz-range-track { height: 2px; background: currentColor; opacity: .35; border-radius: 2px; }
#clock input::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -5px; border-radius: 50%; background: var(--sun); box-shadow: 0 0 0 2px var(--ui-bg), 0 0 0 3px var(--ui-line); }
#clock input::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--sun); }
#clock .live { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; padding: 4px 9px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--ui-line); opacity: .75; }
#clock .live[aria-pressed="true"] { background: var(--sun); color: var(--ink); box-shadow: none; opacity: 1; }

/* phones: a small row of place names glides to each object */
#places { display: none; left: 0; right: 0; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 46px); justify-content: center; gap: 6px; padding: 0 10px; flex-wrap: nowrap; }
body.pan #places { display: flex; }
#places button { font-size: 12px; font-weight: 600; padding: 7px 10px; border-radius: 999px; color: var(--ui); background: var(--ui-bg); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: inset 0 0 0 1px var(--ui-line); white-space: nowrap; }
@media (max-width: 520px) {
  #who p { display: none; }
  #clock { left: 12px; right: 12px; justify-content: space-between; } #clock input { flex: 1; width: auto; min-width: 60px; }
}

/* worlds: full-screen pages above the desk */
#worlds { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.world { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: transparent; color-scheme: light; opacity: 0; pointer-events: none; }
.world.is-on { opacity: 1; pointer-events: auto; }

#needs-server, .noscript { position: fixed; inset: 0; margin: 0; display: grid; place-content: center; text-align: center; padding: 24px; font-size: 17px; line-height: 1.5; background: var(--ground); color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .spot i::after { animation: none; } #scene { transition: none; } }

/* the companion's chat: a light card beside the figure, a sheet at the bottom on phones */
#chat { position: fixed; z-index: 12; width: 348px; max-height: min(460px, calc(100vh - 32px)); display: flex; flex-direction: column; background: var(--surface); color: var(--ink); border-radius: 16px; box-shadow: 0 18px 50px rgba(20, 24, 40, .28), 0 2px 6px rgba(20, 24, 40, .12), inset 0 0 0 1px var(--hairline); font-family: var(--font); font-size: 14px; line-height: 1.45; opacity: 0; transform: translateY(8px) scale(.98); transform-origin: left bottom; transition: opacity .22s var(--ease), transform .28s var(--ease); }
#chat[hidden] { display: none; }
#chat.is-open { opacity: 1; transform: none; }
#chat header { display: flex; align-items: baseline; gap: 8px; padding: 12px 12px 10px 16px; border-bottom: 1px solid var(--hairline); }
#chat header b { font-size: 15px; font-weight: 650; }
#chat header span { flex: 1; font-family: var(--mono); font-size: 11px; letter-spacing: .02em; color: var(--ink-2); }
#chat .x { align-self: center; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; color: var(--ink-2); }
#chat .x:hover { background: var(--grey-1); color: var(--ink); }
#chat .log { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 8px; overscroll-behavior: contain; }
#chat .log p { flex: none; margin: 0; max-width: 88%; padding: 9px 12px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
#chat .log .me { align-self: flex-end; background: var(--sun); color: var(--ink); border-bottom-right-radius: 5px; font-weight: 500; min-height: 38px; }
#chat .log .bot { align-self: flex-start; background: var(--ground); box-shadow: inset 0 0 0 1px var(--hairline-2); border-bottom-left-radius: 5px; }
#chat .log a { color: var(--ink); font-weight: 600; text-decoration: underline; text-decoration-color: var(--sun); text-decoration-thickness: 2px; text-underline-offset: 3px; }
#chat .log a.book { display: block; width: fit-content; margin-top: 9px; padding: 7px 12px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 13px; text-decoration: none; }
#chat .log a.book:hover { background: #000; }
#chat .dots { min-width: 46px; min-height: 38px; background-image: radial-gradient(circle, var(--ink-3) 2.5px, transparent 3px), radial-gradient(circle, var(--ink-3) 2.5px, transparent 3px), radial-gradient(circle, var(--ink-3) 2.5px, transparent 3px) !important; background-repeat: no-repeat; background-size: 8px 8px; background-position: 13px 50%, 23px 50%, 33px 50%; background-color: var(--ground) !important; animation: chat-dots 1s infinite; }
#chat .log .look { color: var(--ink-2); font-style: normal; }
#chat .log .look::after { content: '…'; display: inline-block; width: 1.2em; text-align: left; animation: chat-look 1.2s steps(4, end) infinite; overflow: hidden; vertical-align: bottom; }
@keyframes chat-look { from { width: 0; } to { width: 1.2em; } }
@keyframes chat-dots { 0%, 100% { background-position: 13px 50%, 23px 50%, 33px 50%; } 25% { background-position: 13px 36%, 23px 50%, 33px 50%; } 50% { background-position: 13px 50%, 23px 36%, 33px 50%; } 75% { background-position: 13px 50%, 23px 50%, 33px 36%; } }
#chat form { padding: 8px 12px 12px; }
#chat form[hidden] { display: none; }
#chat textarea { display: block; width: 100%; box-sizing: border-box; resize: none; border: 0; border-radius: 12px; padding: 10px 12px; background: var(--ground); box-shadow: inset 0 0 0 1px var(--hairline); color: var(--ink); font: inherit; }
#chat textarea:focus { outline: 2px solid var(--sun); outline-offset: 1px; }
#chat form div { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
#chat form .n { font-family: var(--mono); font-size: 11px; color: var(--ink-2); }
#chat form button { padding: 8px 16px; border-radius: 999px; background: var(--sun); color: var(--ink); font-weight: 650; font-size: 14px; }
#chat form button:hover { background: var(--sun-deep); }
@media (max-width: 639px) { #chat { left: 10px; right: 10px; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 0px); width: auto; max-height: 62vh; transform-origin: center bottom; z-index: 14; } #chat textarea { font-size: 16px; } }
@media (prefers-reduced-motion: reduce) { #chat { transition: none; } #chat .dots, #chat .log .look::after { animation: none; } }
