/* The game's page: the 3D view fills the screen, with the places along the top and the tools
   of the place along the bottom. Sizes are in rem; colours are dark, as the room is. */

:root {
  /* Every round button over the room is as large as the focus knob (the owner, #45246) */
  --round: 5rem;
  --bg: #0b0505;
  --panel: rgb(14 10 10 / 86%);
  --text: #f0e6e4;
  --muted: #b7a6a3;
  --line: #5c4a47;
  --accent: #ff8a70;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* The tools of a place of work, along the bottom. The room itself has none (the owner,
   #45163): there is no bar at the top, and in the room none at the bottom either. */
#panel {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-flow: column wrap;
  gap: 0.5rem;
  padding: 0.5rem max(0.75rem, env(safe-area-inset-right)) max(0.5rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: var(--panel);
}

#panel[hidden] {
  display: none;
}

/* Two buttons stand by themselves over the room: Settings in the top right corner, Notes in
   the bottom right one, over the tools where there are any (main.js says how high) */
.corner {
  position: fixed;
  right: max(0.75rem, env(safe-area-inset-right));
  display: grid;
  place-items: center;
  width: var(--round);
  height: var(--round);
  padding: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 55%);
  font-size: 2.2rem;
}

.corner img {
  width: 2.4rem;
  height: 2.4rem;
}

/* Under a phone's status bar and its cut-out the system dims and blurs what lies a good way
   below the inset it reports (the owner's picture, #45059): keep clear of all of it */
#settings-open {
  top: max(0.75rem, calc(env(safe-area-inset-top) * 1.75));
}

/* The light table's light, in the top left corner while one is at the table (the owner,
   #45227): black, with a white bulb that burns or is crossed out */
#light {
  top: max(0.75rem, calc(env(safe-area-inset-top) * 1.75));
  right: auto;
  left: max(0.75rem, env(safe-area-inset-left));
  border-color: var(--line);
  box-shadow: none;
  background: #000;
}

#light[hidden],
#light[aria-pressed="true"] .off,
#light[aria-pressed="false"] .on {
  display: none;
}

/* Under it at the enlarger its knobs, one below the other (the owner, #45229) */
#knobs {
  position: fixed;
  top: calc(max(0.75rem, env(safe-area-inset-top) * 1.75) + var(--round) + 0.6rem);
  left: max(0.75rem, env(safe-area-inset-left));
  display: grid;
  gap: 0.6rem;
}

#knobs[hidden] {
  display: none;
}

#aperture .cap {
  text-transform: none;
}

#light:not([hidden]) ~ #elapsed {
  left: calc(max(0.75rem, env(safe-area-inset-left)) + var(--round) + 0.75rem);
}

#notes-open {
  bottom: calc(var(--tools-high, 0px) + max(0.75rem, env(safe-area-inset-bottom)));
}

#notes-open img {
  width: 3.4rem;
  height: 3.4rem;
}

#controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

button,
select,
input {
  min-height: 2.5rem;
  padding: 0 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.2rem;
  background: #171010;
  color: var(--text);
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

button[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

label,
.name {
  color: var(--muted);
}

#seconds {
  width: 4.5rem;
  text-align: center;
  user-select: text;
  -webkit-user-select: text;
}

/* What is said of the place lies over the picture, above the tools and clear of the Notes
   button, so that the picture is not moved when the words change (the owner, #45227) */
#status {
  position: fixed;
  right: calc(max(0.75rem, env(safe-area-inset-right)) + var(--round) + 0.75rem);
  bottom: calc(max(var(--tools-high, 0px), env(safe-area-inset-bottom)) + 0.75rem);
  left: max(0.75rem, env(safe-area-inset-left));
  width: fit-content;
  margin: 0;
  padding: 0.3rem 0.6rem;
  border-radius: 0.3rem;
  background: rgb(0 0 0 / 60%);
  color: var(--text, #e8e2da);
  pointer-events: none;
}

#status[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgb(0 0 0 / 70%);
}

.modal[hidden] {
  display: none;
}

.modal .sheet {
  width: min(30rem, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  background: #140d0d;
}

.modal h2 {
  margin: 0 0 0.75rem;
  font-size: 1.2rem;
}

#look-print {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  image-rendering: auto;
}

#look-findings {
  margin: 0.75rem 0;
  padding-left: 1.2rem;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

#look-note,
#notes-text p {
  margin: 0 0 0.75rem;
  line-height: 1.6;
}

#look-note,
#notes-text .note {
  padding-left: 0.75rem;
  border-left: 2px solid var(--line);
  color: var(--muted);
  font-style: italic;
}

#notes-text h3 {
  margin: 1rem 0 0.25rem;
  font-size: 1rem;
}

/* The focus knob (the owner, #45154): a black knob with a knurled skirt, as an amplifier has,
   its name on its cap. It turns less than once round, from stop to stop, and a mark on the
   skirt shows how it stands; the two stops are marked beside it. */
.wheel {
  position: relative;
  flex: none;
  width: var(--round);
  height: var(--round);
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
}

.wheel .turns {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: repeating-conic-gradient(#2a2424 0deg 5deg, #0d0b0b 5deg 10deg);
}

.wheel .mark {
  position: absolute;
  top: 3%;
  left: calc(50% - 0.14rem);
  width: 0.28rem;
  height: 16%;
  border-radius: 0.14rem;
  background: var(--accent);
}

.wheel .cap {
  position: absolute;
  inset: 17%;
  display: grid;
  place-items: center;
  border: 1px solid #2a2424;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 32%, #1d1919, #0a0808 70%);
  color: #f2efe9;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: none;
}

/* The stops: a dot at each end of the knob's way, under it to the left and to the right */
.wheel::before,
.wheel::after {
  position: absolute;
  bottom: 2%;
  width: 0.22rem;
  height: 0.22rem;
  border-radius: 50%;
  background: var(--muted);
  content: "";
}

.wheel::before {
  left: 16%;
}

.wheel::after {
  right: 16%;
}

/* What the focus finder shows: and the loupe: a round view kept over the thing itself (main.js) */
#finder-view,
#loupe-view {
  position: fixed;
  transform: translate(-50%, -50%);
  width: min(11rem, 40vw);
  height: min(11rem, 40vw);
  border: 0.35rem solid #050303;
  border-radius: 50%;
  outline: 1px solid var(--line);
  background: #000;
  pointer-events: none;
}

#finder-view[hidden],
#loupe-view[hidden] {
  display: none;
}

/* A poster looked at: as it is in the room light, and red under the safelight */
#poster .sheet {
  width: min(44rem, 100%);
}

#poster-page {
  margin-bottom: 0.75rem;
  border: 1px solid var(--line);
  background: #fff;
}

#poster-picture {
  display: block;
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  background: #000;
}

#poster-page.safelit {
  background: #ff2408;
}

#poster-page.safelit #poster-picture {
  filter: grayscale(1);
  mix-blend-mode: multiply;
}

#look-note {
  margin: 0 0 0.75rem;
  line-height: 1.6;
}

#posters {
  max-width: 14rem;
}

/* On a narrow screen the top bar keeps to two rows */
/* On a phone the five places stay on one row, and the switches on another */
.credits {
  margin-top: 1.5rem;
  color: var(--muted, #9a938c);
  font-size: 0.85rem;
}

/* Settings: a name, a slider as wide as the sheet allows, and what it is set to */
.setting {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 0.75rem;
  align-items: center;
}

.setting label {
  grid-column: 1 / -1;
}

.setting input[type="range"] {
  width: 100%;
  accent-color: var(--accent, #ff7a5c);
}

/* The sheet of settings leaves the room in sight, to see what a setting does */
#settings {
  align-items: end;
  background: none;
}

/* How long the sheet has had the lamp or lain in its bath, large over the room */
#elapsed {
  position: fixed;
  left: max(0.75rem, env(safe-area-inset-left));
  top: max(0.75rem, calc(env(safe-area-inset-top) * 1.75));
  margin: 0;
  padding: 0.2rem 0.6rem;
  border-radius: 0.3rem;
  background: rgb(0 0 0 / 55%);
  color: #ff5a3c;
  font: 600 1.5rem/1.3 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

#elapsed[hidden] {
  display: none;
}


/* While the room's things are fetched (the owner, #45464): the words and a bar of how much
   has come, over the whole page. They show only after a moment, so that a start with
   everything at hand does not flash them. */
#loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

#loading > * {
  margin: 0;
  animation: loading-in 0.3s 0.4s both;
}

#loading .bar {
  width: min(14rem, 60vw);
  height: 0.25rem;
  border-radius: 0.125rem;
  background: var(--line);
  overflow: hidden;
}

#loading-done {
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s;
}

@keyframes loading-in {
  from {
    opacity: 0;
  }
}

.setting input[type="number"] {
  width: 6rem;
  padding: 0.3rem 0.4rem;
  font: inherit;
}
