/* Mini Mysteries: a 1-bit, Newton-flavoured look. Black, white, and dither only. */

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 8px;
  color: #000;
  background-color: #fff;
  /* 25% dither: one black 2px dot in every 4px cell */
  background-image: conic-gradient(#000 25%, #fff 0);
  background-size: 4px 4px;
  font-family: "Chicago", "ChicagoFLF", "Charcoal", "Geneva", "Verdana", sans-serif;
  font-weight: 700;
}

/* The whole game is one portrait "device". Its width also has to leave room
   for the screen's height (1.42 x width) plus the title and the tab bar. */
.device {
  --w: max(280px, min(560px, calc(100vw - 16px), calc((100dvh - 104px) / 1.42)));
  width: var(--w);
  font-size: clamp(12.5px, calc(var(--w) * 0.034), 18px);
  line-height: 1.3;
}

p { margin: 0 0 0.6em; }
p:last-child { margin-bottom: 0; }
h1, h2 { margin: 0; font-size: inherit; }

/* ---------- frame ---------- */

.titlebar { display: flex; justify-content: center; }

.titlebar h1 {
  position: relative;
  z-index: 1;
  margin-bottom: -3px;
  padding: 3px 16px 2px;
  font-size: 1.15em;
  background: #fff;
  border: 3px solid #000;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
}

.screen {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: calc(var(--w) * 1.42);
  overflow: hidden;
  background: #fff;
  border: 3px solid #000;
  border-radius: 16px;
  box-shadow: 5px 5px 0 #000;
}

.desk { flex: 1; padding: 10px 14px; overflow: hidden; }
.desk .question { font-size: 1.1em; }
.count { margin-top: 0.4em; }
.hint { font-weight: 400; }

/* ---------- pictures ---------- */

.pic {
  position: relative;
  overflow: hidden;
  background: #fff;
  user-select: none;
  -webkit-user-select: none;
}

.pic.live { cursor: crosshair; }
.pic img { display: block; width: 100%; height: 100%; object-fit: cover; }
.scene { flex: none; aspect-ratio: 1 / 1; border-bottom: 3px solid #000; }

/* Knock out every other pixel so the ink turns to dotted grey, as a 1-bit
   screen would dim a picture. */
.pic.dim::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: conic-gradient(#fff 25%, transparent 0 50%, #fff 0 75%, transparent 0);
  background-size: 4px 4px;
}

.hotspot {
  position: absolute;
  z-index: 2;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: inherit;
}

.pic:not(.live) .hotspot { pointer-events: none; }
.hotspot:focus-visible { outline: 3px dashed #000; outline-offset: -3px; }
.reveal .hotspot { outline: 3px solid #000; outline-offset: -3px; }

.reveal .hotspot.found::after {
  content: "\2713";
  position: absolute;
  top: 0;
  right: 0;
  padding: 0 3px;
  font-size: 0.8em;
  line-height: 1.2;
  color: #fff;
  background: #000;
}

.miss {
  position: absolute;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 1.6em;
  height: 1.6em;
  pointer-events: none;
  background: #fff;
  border: 2px solid #000;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: puff 0.5s steps(5) forwards;
}

@keyframes puff {
  to { opacity: 0; transform: translate(-50%, -130%); }
}

@media (prefers-reduced-motion: reduce) {
  .miss { animation-duration: 0.01s; }
}

/* ---------- clue cards ---------- */

.card {
  position: absolute;
  z-index: 5;
  top: 2.5%;
  left: 4%;
  right: 4%;
  max-height: 95%;
  overflow-y: auto;
  background: #fff;
  border: 3px solid #000;
  border-radius: 12px;
  box-shadow: 4px 4px 0 #000;
}

.card .pic { aspect-ratio: 4 / 3; }

.card-title {
  position: relative;
  padding: 5px 2.4em;
  text-align: center;
  font-size: 1.05em;
  border-top: 3px solid #000;
  border-bottom: 3px solid #000;
}

.card > .card-title:first-child { border-top: 0; }
.card-text { padding: 8px 12px 10px; }

.doc {
  margin: 12px 14px;
  padding: 10px 12px;
  overflow-x: auto;
  font: 700 0.9em/1.3 "Courier New", Courier, monospace;
  white-space: pre;
  background: #fff;
  border: 2px solid #000;
  box-shadow: 3px 3px 0 #000;
}

.close {
  position: absolute;
  top: 50%;
  right: 5px;
  width: 1.7em;
  height: 1.7em;
  padding: 0;
  font: inherit;
  line-height: 1;
  color: #000;
  background: #fff;
  border: 2px solid #000;
  border-radius: 5px;
  cursor: pointer;
  transform: translateY(-50%);
}

.close:active { color: #fff; background: #000; }

/* ---------- panels (intro, help, notes, solve, verdict) ---------- */

.panel {
  position: absolute;
  z-index: 10;
  inset: 3%;
  padding: 12px 14px;
  overflow-y: auto;
  background: #fff;
  border: 3px solid #000;
  border-radius: 12px;
  box-shadow: 4px 4px 0 #000;
}

.panel > .close { top: 6px; right: 6px; transform: none; }
.panel h2 { margin: 0 2em 0.6em; font-size: 1.1em; text-align: center; text-decoration: underline; }

/* The intro slides up over the bottom of the picture, like the original. */
.panel.sheet {
  inset: auto 0 0 0;
  max-height: 66%;
  padding-right: 2.6em;
  border-width: 3px 0 0;
  border-radius: 0;
  box-shadow: none;
}

.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 0.9em; }

/* Keeps the tally and the buttons in view while a long evidence list scrolls. */
.foot {
  position: sticky;
  bottom: -12px;
  margin: 8px -14px -12px;
  padding: 8px 14px 12px;
  text-align: center;
  background: #fff;
  border-top: 3px solid #000;
}

.foot .count { margin: 0; }
.foot .actions { margin-top: 0.5em; }

.btn {
  padding: 4px 14px;
  font: inherit;
  color: #000;
  background: #fff;
  border: 2.5px solid #000;
  border-radius: 10px;
  box-shadow: 2px 2px 0 #000;
  cursor: pointer;
}

.btn:active, .btn.on { color: #fff; background: #000; }
.btn:disabled { border-style: dotted; box-shadow: none; cursor: not-allowed; }
.btn:focus-visible, .choice:focus-visible, .close:focus-visible, .case-btn:focus-visible { outline: 3px dashed #000; outline-offset: 2px; }

.choice {
  display: flex;
  gap: 0.6em;
  align-items: flex-start;
  width: 100%;
  margin: 0 0 6px;
  padding: 6px 10px;
  font: inherit;
  text-align: left;
  color: #000;
  background: #fff;
  border: 2px solid #000;
  border-radius: 8px;
  cursor: pointer;
}

.choice .box { flex: none; width: 1em; height: 1em; margin-top: 0.15em; border: 2px solid #000; background: #fff; }
.choice[aria-pressed="true"] { color: #fff; background: #000; }
.choice[aria-pressed="true"] .box { border-color: #fff; box-shadow: inset 0 0 0 3px #000; }

/* ---------- tab bar ---------- */

.tabs { display: flex; gap: 5px; margin-top: 12px; }
.tabs .btn { flex: 1 1 auto; min-width: 0; padding: 6px 2px; }
.tabs .back { flex: 0 0 2.4em; border-radius: 50%; }

/* ---------- case list ---------- */

.home { height: 100%; padding: 14px; overflow-y: auto; }
.lede { margin-bottom: 14px; text-align: center; }

.case-btn {
  display: block;
  width: 100%;
  margin-bottom: 14px;
  padding: 10px 12px 12px;
  font: inherit;
  text-align: left;
  color: #000;
  background: #fff;
  border: 3px solid #000;
  border-radius: 12px;
  box-shadow: 4px 4px 0 #000;
  cursor: pointer;
}

.case-btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #000; }
.case-title { display: block; font-size: 1.25em; }
.case-blurb { display: block; margin-top: 4px; font-weight: 400; }

.case-status {
  float: right;
  margin-left: 8px;
  padding: 0 7px;
  font-size: 0.8em;
  border: 2px solid #000;
  border-radius: 6px;
}

.case-status.solved { color: #fff; background: #000; }

/* ---------- hotspot editor (?edit) ---------- */

.editing .hotspot { outline: 2px dashed #c00; outline-offset: -2px; }

.editing .hotspot::before {
  content: attr(data-clue);
  position: absolute;
  top: 0;
  left: 0;
  padding: 0 2px;
  font: 400 10px/1.3 monospace;
  color: #fff;
  background: #c00;
}

.edit-rect { position: absolute; z-index: 9; pointer-events: none; border: 2px solid #06c; background: rgba(0, 102, 204, 0.2); }
.edit-out { display: block; width: 100%; margin-top: 12px; font: 12px/1.4 monospace; }
