:root {
  color-scheme: dark;
  --bg: #080c13;
  --ink: #c9d1dc;
  --muted: #8592a4;
  --accent: #dbad70;
  --pixel: 'VT323', ui-monospace, monospace;
  --mono: 'SF Mono', Menlo, Consolas, ui-monospace, monospace;
  /* The art is 3:2. The stage covers the viewport like object-fit: cover. */
  --stage-w: max(100vw, 150dvh);
  --stage-h: calc(var(--stage-w) / 1.5);
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ---------- The room ---------- */

.viewport { position: fixed; inset: 0; overflow: hidden; }

.stage {
  position: absolute;
  width: var(--stage-w);
  height: var(--stage-h);
  left: calc((100vw - var(--stage-w)) / 2);
  top: calc((100dvh - var(--stage-h)) / 2);
  transform-origin: 0 0;
}
.stage img, .stage video {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
}
.stage video { opacity: 0; }

/* Narrow screens: full height, swipe sideways to look around. */
@media (max-aspect-ratio: 1/1) {
  .viewport { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; overscroll-behavior-x: contain; }
  .viewport::-webkit-scrollbar { display: none; }
  .stage { left: 0; top: 0; height: 100dvh; width: 150dvh; }
  body.reading .viewport { overflow-x: hidden; }
}

/* The visible room: an ASCII rendering of the layers above (see ascii.mjs). Clicks pass through to the hotspots. */
.ascii { position: fixed; inset: 0; width: 100vw; height: 100dvh; pointer-events: none; background: #04050a; }
.ascii.overlay { background: transparent; }
.ascii[hidden] { display: none; }

/* ---------- Things that respond ---------- */

.hotspots { position: absolute; inset: 0; z-index: 5; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.object-link { pointer-events: visiblePainted; cursor: pointer; outline: none; }
.object-link path { fill: transparent; stroke: none; }
.object-link[hidden] { display: none; }
body.reading .hotspots { visibility: hidden; }

.hint {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  translate: -50% 0;
  margin: 0;
  padding: 6px 14px;
  border-radius: 20px;
  background: #05080db3;
  font: 19px var(--pixel);
  letter-spacing: .05em;
  color: #e7dcc8;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s;
}
.hint em { font-style: normal; color: var(--muted); }
.hint.show { opacity: 1; }
@media (max-width: 520px) { .hint span { display: none; } .hint em { display: block; font-size: 16px; } .hint { text-align: center; } }

/* ---------- Reading: minimal pages that sit by their objects ---------- */
/* Letters fly in from the object that was clicked (ascii.mjs); while they fly the real text waits, hidden.
   room.mjs places each page (About beside the character, Thoughts on the glass, Work on the monitor);
   a post being read, and narrow screens, use the plain column below. */

dialog {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  overflow-y: auto;
  overscroll-behavior: contain;
}
dialog:not([open]) { display: none; }
dialog::backdrop { background: transparent; }

#close {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: 18px;
  z-index: 2;
  border: 0;
  background: transparent;
  padding: 6px 8px;
  font: 12px var(--mono);
  letter-spacing: .08em;
  color: #8592a499;
}
#close:hover { color: #fff; }

.page {
  position: relative;
  max-width: 64ch;
  margin: 0 auto;
  padding: max(12vh, 64px) 24px 16vh;
  font: 15px/1.75 var(--mono);
  color: #c9d1dc;
  text-shadow: 0 0 12px #000, 0 0 3px #000;
  outline: none;
  transition: opacity .25s;
}
dialog.assembling .page { visibility: hidden; opacity: 0; }

/* Placed pages: a soft dark pool behind the text instead of a box. */
.page.placed { position: absolute; top: 0; left: 0; max-width: none; margin: 0; padding: 0; }
.page.placed::before {
  content: '';
  position: absolute;
  inset: -48px -64px;
  z-index: -1;
  background: radial-gradient(closest-side, #04050ae0, #04050aa8 62%, transparent);
  pointer-events: none;
}

/* Only a post shows its title; elsewhere the object already said what this is. */
.page h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
dialog.article .page h2 { position: static; width: auto; height: auto; clip-path: none; white-space: normal; margin: 0 0 6px; font: 400 40px/1.1 var(--pixel); letter-spacing: .02em; color: #f0e3cb; }

.page h3 { margin: 28px 0 4px; font: inherit; color: #efe8dc; }
.page p { margin: 0 0 14px; }
.page a { color: inherit; text-decoration: underline; text-decoration-color: #ffffff40; text-underline-offset: 3px; }
.page a:hover { color: #fff; text-decoration-color: currentColor; }
.page blockquote { margin: 18px 0; padding-left: 16px; border-left: 1px solid #ffffff2a; color: #aeb8c6; }
.page pre { background: #000a; padding: 12px 14px; overflow-x: auto; }
.page code { font: 14px var(--mono); }
.empty { color: var(--muted); }
.date { color: var(--muted); font-size: 13px; }
.back { border: 0; background: transparent; padding: 0; margin-bottom: 28px; color: var(--muted); font: 13px var(--mono); text-shadow: inherit; }
.back:hover { color: #fff; }
/* A post: back link, then title, then date and text. */
dialog.article .page { display: flex; flex-direction: column; }
dialog.article #section-body { display: contents; }
dialog.article .back { order: -1; align-self: flex-start; }

/* About: a name card beside the character. */
dialog[data-layout="about"] .page p:first-child { color: #f0e3cb; }
/* "currently" and its list read like terminal output: a muted label, then indented lines. */
dialog[data-layout="about"] .page :is(p + p, ul + p) { margin: 22px 0 4px; color: var(--muted); }
dialog[data-layout="about"] .page ul { list-style: none; margin: 0; padding: 0 0 0 2ch; }
dialog[data-layout="about"] .page li { margin: 0 0 6px; }

/* Thoughts: a date and a title per line, written on the glass. */
.posts { list-style: none; margin: 0; padding: 0; }
.posts button {
  display: flex; gap: 2ch; width: 100%; text-align: left;
  border: 0; background: transparent; padding: 3px 0;
  font: inherit; color: #dfe7f2; text-shadow: inherit;
}
.posts .date { flex: none; font-size: inherit; }
.posts button:hover .title { color: #fff; text-decoration: underline; text-decoration-color: #ffffff50; text-underline-offset: 3px; }
.posts em { font-style: normal; color: var(--accent); font-size: 12px; }

/* Work: `ls projects/` output on the wall above the monitors. */
.prompt { color: #6f8fb3; margin: 0 0 .6em; }
.prompt.cursor { margin-top: .9em; }
.prompt.cursor::after { content: '█'; color: #9fd0ff; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
dialog[data-layout="projects"] .page ul { list-style: none; margin: 0; padding: 0; }
dialog[data-layout="projects"] .page li { display: flex; align-items: baseline; }
dialog[data-layout="projects"] .page li a { flex: none; min-width: 14ch; margin-right: 2ch; }
dialog[data-layout="projects"] .page li a { color: #9fd0ff; text-decoration: none; }
dialog[data-layout="projects"] .page li a:hover { color: #fff; }

@media (max-width: 600px) {
  .page { padding: 64px 20px 14vh; font-size: 14px; }
  dialog.article .page h2 { font-size: 32px; }
  /* Narrow screens: About and Thoughts read as a sheet at the bottom, over a dark pool. */
  dialog:is([data-layout="about"], [data-layout="thoughts"]) .page { position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 22px calc(28px + env(safe-area-inset-bottom)); background: linear-gradient(#04050a00, #04050ae8 28%); }
}

#error {
  position: fixed; top: 14px; left: 50%; translate: -50% 0; margin: 0;
  padding: 8px 14px; border-radius: 8px; background: #1a1209e6; color: #e8bb86; font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; transition-delay: 0s !important; animation: none !important; }
}
