/* The page: one canvas over the whole window (the room, the lamp, the tank, the cabinet). */
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
}

/* view.js sizes it to the window in whole device pixels */
#tank {
  position: fixed;
  left: 0;
  top: 0;
  display: block;
  image-rendering: pixelated;
  /* a finger on the tank pans it (view.js); the browser does not scroll or zoom */
  touch-action: none;
  user-select: none;
}

/* a tank longer than the screen can be dragged along */
#tank.pannable {
  cursor: grab;
}

#tank.pannable.dragging {
  cursor: grabbing;
}

/* the last picture while the stream is not live */
#tank.stale {
  opacity: 0.4;
}

#status {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1em;
  margin: 0;
  text-align: center;
  font: 14px ui-monospace, monospace;
  color: #999;
  /* drags on the tank pass through it */
  pointer-events: none;
}

#status:empty {
  display: none;
}

/* ---- page text over the canvas: system fonts only ---- */

body {
  font: 13px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #efefef;
}

/* the menu and the hover text: not seen at rest (menu.js sets the times and `awake`) */
.fading {
  opacity: 0;
  transition: opacity var(--fade-out, 600ms);
}

body.awake .fading {
  opacity: 1;
  transition: opacity var(--fade-in, 200ms);
}

/* The quick readings on the tank's top left corner (main.js places it). Text over the
   picture, never in it; a dark plate and a shadow keep it readable over lit sand and over
   night. It never takes the pointer: a drag that starts on it pans the tank. */
#hover {
  position: fixed;
  left: 0;
  top: 0;
  margin: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.5);
  text-shadow: 0 0 2px #000, 0 1px 2px #000;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  white-space: nowrap;
}

#hover:empty {
  display: none;
}

#hover .name {
  color: #b8b8b8;
}

/* old values while the stream is not live, like the picture */
body.stale #hover,
body.stale .panel dl {
  opacity: 0.4;
}

#storage-error {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  margin: 0;
  padding: 4px 8px;
  background: #8c1414;
  color: #fff;
  text-align: center;
  pointer-events: none;
}

#storage-error:empty {
  display: none;
}

#menu {
  position: fixed;
  right: 8px;
  top: 8px;
  display: flex;
  gap: 4px;
  /* not seen, it takes no pointer: a drag there pans the tank */
  pointer-events: none;
}

body.awake #menu {
  pointer-events: auto;
}

button,
select,
input {
  font: inherit;
  color: inherit;
  background: rgba(25, 25, 25, 0.85);
  border: 1px solid #555;
  border-radius: 4px;
  padding: 3px 8px;
}

button {
  cursor: pointer;
}

button[aria-expanded="true"],
button[aria-pressed="true"] {
  background: #efefef;
  color: #111;
}

button[aria-disabled="true"],
button:disabled {
  color: #777;
  cursor: default;
}

:focus-visible {
  outline: 2px solid #6aabf1;
  outline-offset: 1px;
}

.panel {
  position: fixed;
  right: 8px;
  top: 44px;
  box-sizing: border-box;
  width: min(340px, calc(100vw - 16px));
  max-height: calc(100vh - 52px);
  overflow-y: auto;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(25, 25, 25, 0.92);
  font-variant-numeric: tabular-nums;
}

.panel h2,
.panel h3 {
  margin: 10px 0 4px;
  font-size: 13px;
  font-weight: 600;
}

.panel h2 {
  margin-top: 0;
  font-size: 15px;
}

.panel p {
  margin: 4px 0;
}

.panel dl {
  display: grid;
  grid-template-columns: auto auto;
  gap: 1px 12px;
  margin: 4px 0;
}

.panel dt {
  color: #b8b8b8;
}

.panel dd {
  margin: 0;
  text-align: right;
}

.panel .choices {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.panel .chart {
  position: relative;
  height: 110px;
  padding: 4px 0;
  border-top: 1px solid #303030;
  border-bottom: 1px solid #303030;
}

.panel .chart svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.panel .chart path {
  fill: none;
  stroke: #338ced;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.panel .chart .cursor {
  stroke: #9c9c9c;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.panel .chart span {
  position: absolute;
  left: 2px;
  color: #b8b8b8;
  font-size: 11px;
  pointer-events: none;
  text-shadow: 0 0 2px #191919, 0 0 2px #191919;
}

.panel .chart .max {
  top: 0;
}

.panel .chart .mid {
  top: 30%;
}

.panel .chart .min {
  bottom: 0;
}

.panel .note,
.panel .none {
  color: #b8b8b8;
}

.panel .bar {
  display: flex;
  gap: 2px;
  height: 14px;
}

.panel .bar span {
  flex: 0 0 0;
  min-width: 2px;
  border-radius: 2px;
}

.panel ul,
.panel ol {
  margin: 4px 0;
  padding: 0;
  list-style: none;
}

.panel .legend li {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 6px;
  align-items: baseline;
}

.panel .swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.panel .legend .figure {
  color: #b8b8b8;
  white-space: nowrap;
}

.panel .events li {
  overflow-wrap: anywhere;
}

/* ---- the lens and the inspector ---- */

/* round, beside the pointer (lens.js places and sizes it in whole device pixels); it never
   takes the pointer */
#lens-glass {
  position: fixed;
  border-radius: 50%;
  border: 1px solid #9c9c9c;
  background: rgba(0, 0, 0, 0.7);
  image-rendering: pixelated;
  pointer-events: none;
}

/* below the quick readings */
.panel.left {
  left: 8px;
  right: auto;
  top: 128px;
  max-height: calc(100vh - 136px);
}

#lens-legend li {
  display: block;
}

.panel h2 button {
  float: right;
  font-size: 12px;
  font-weight: 400;
}

.panel .legend button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 1px 0;
}

.panel .legend button .swatch {
  display: inline-block;
}

.panel .descent li::before {
  content: "from ";
  color: #b8b8b8;
}

.panel .descent li:last-child::before {
  content: "";
}

.panel .numbers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0 8px;
  list-style: decimal inside;
  color: #b8b8b8;
}

.panel .network {
  display: block;
  width: 100%;
}

.panel .network line {
  stroke-width: 1;
}

.panel .network circle {
  fill: #efefef;
  stroke: #9c9c9c;
}

.panel .network circle[data-layer="hidden"] {
  fill: none;
}

.panel .spectrum {
  display: block;
  width: 100%;
  height: 60px;
}

.panel .spectrum rect {
  fill: #338ced;
}

/* ---- the species sheets: docs/art/ui/style-guide.md (square panel, one-pixel frame; met and
   not met said in words, in the active and the warning colour) ---- */

.panel.quiet {
  border: 1px solid #536166;
  border-radius: 0;
  background: #0d1416;
  color: #e5eceb;
}

.panel.quiet button {
  border-radius: 0;
  border-color: #536166;
  background: #0d1416;
}

.panel.quiet button:hover {
  border-color: #a7d9cd;
  background: #28473f;
}

.panel.quiet .note,
.panel.quiet .none {
  color: #93a3a6;
}

.panel.quiet h2 button {
  float: none;
  margin-right: 8px;
}

.species-list button {
  display: block;
  width: 100%;
  margin: 2px 0;
  text-align: left;
}

.species-list .latin {
  font-style: italic;
}

.species-list .forms {
  float: right;
  color: #93a3a6;
}

.panel .portraits {
  display: flex;
  gap: 8px;
}

.panel figure {
  margin: 0;
  text-align: center;
  color: #93a3a6;
  font-size: 11px;
}

/* the shop's pictures in whole pixels: portraits 96 px, origins 48 x 32 shown twice as large */
.panel.quiet img {
  display: block;
  image-rendering: pixelated;
}

.panel .origin {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.panel .origin img {
  width: 96px;
  height: 64px;
  flex: none;
}

.panel .care li {
  margin: 4px 0;
}

.panel .care .source {
  display: block;
  color: #93a3a6;
  font-size: 11px;
}

.panel .needs li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 8px;
  margin: 6px 0;
}

.panel .needs .label {
  text-transform: capitalize;
}

.panel .needs .mark {
  text-align: right;
}

.panel .needs .value,
.panel .needs .note {
  grid-column: 1 / -1;
}

.panel .needs .note {
  font-size: 11px;
}

.panel .met-true {
  color: #a7d9cd;
}

.panel .met-false {
  color: #d7b77a;
}

.panel .met-null {
  color: #93a3a6;
}

.panel .colony-line button {
  width: 100%;
  text-align: left;
}

/* ---- the controls ---- */

#controls fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

#controls form {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 6px;
  margin: 4px 0;
}

#controls form .title {
  flex: 1 0 100%;
  color: #b8b8b8;
}

#controls input[type="number"] {
  width: 5.5em;
}

#controls input[type="text"] {
  width: 9em;
}

#controls .result {
  min-height: 1.4em;
}

#controls .result.bad {
  color: #eb6263;
}

#controls fieldset:disabled {
  opacity: 0.5;
}

/* `hidden` wins over any display set above */
[hidden] {
  display: none !important;
}

/* What everyone is told on the tank: no aquarium yet, the run-in's day. */
#caption {
  position: fixed;
  left: 50%;
  top: 44px;
  transform: translateX(-50%);
  margin: 0;
  padding: 4px 10px;
  background: rgba(13, 20, 22, 0.8);
  color: #e5eceb;
  font-size: 15px;
  pointer-events: none;
}

#caption:empty {
  display: none;
}

/* Without a tank: the empty glass, dark, and the one line in its middle. */
body.no-tank #tank,
body.no-tank #hover {
  visibility: hidden;
}

body.no-tank #caption {
  top: 45%;
  font-size: 20px;
}

/* The new aquarium's steps. */
.tank-outline {
  box-sizing: border-box;
  margin: 6px 0;
  border: 1px solid #a7d9cd;
  border-top: 0;
}

.rockscapes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 6px 0;
}

.rockscapes button {
  padding: 2px;
  min-height: 48px;
}

.rockscapes button[aria-checked="true"] {
  outline: 2px solid #a7d9cd;
}

.rockscapes img {
  display: block;
  width: 100%;
  image-rendering: pixelated;
}

/* The shop's cards and the frag that follows the pointer. */
.cards .card {
  margin: 0 0 12px;
  padding: 8px;
  border: 1px solid #536166;
}

.cards .card h3 {
  margin: 6px 0 2px;
}

.cards .card ul {
  margin: 4px 0;
  padding-left: 18px;
}

.cards .card .fit {
  font-weight: bold;
}

.cards .card .frag {
  touch-action: none;
  cursor: grab;
}

.frag-ghost {
  position: fixed;
  z-index: 10;
  max-width: 240px;
  padding: 4px 8px;
  border: 1px solid #a7d9cd;
  background: #0d1416;
  color: #e5eceb;
  font-size: 13px;
  pointer-events: none;
}

.frag-ghost p {
  margin: 2px 0 0;
}
