/* Mey, the pixel guide (mey.js). Uses the page tokens with fallbacks so it works on its own. */
.mey {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 60; /* above sections, below the taskbar */
  width: 64px;
  height: 96px;
  pointer-events: none;
}

.mey canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* small pixel name tag */
.mey__tag {
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%);
  margin-bottom: 4px;
  padding: 0 5px 1px;
  background: var(--ink, #1E1B2E);
  color: var(--cream, #F4F1EA);
  font-family: "VT323", monospace;
  font-size: 16px;
  line-height: 1.1;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* small X: hides Mey for the session */
.mey__close {
  position: absolute;
  right: -10px;
  bottom: calc(100% + 4px);
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  pointer-events: auto;
  cursor: var(--cur-hand, pointer);
  background-color: var(--cream, #F4F1EA);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 8px 8px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h2v1h1v1h2V1h1V0h2v2H7v1H6v2h1v1h1v2H6V7H5V6H3v1H2v1H0V6h1V5h1V3H1V2H0z' fill='%231E1B2E'/%3E%3C/svg%3E");
  box-shadow:
    inset -1px -1px 0 var(--ink, #1E1B2E),
    inset 1px 1px 0 #FFFFFF;
  opacity: 0.85;
}

.mey__close:hover,
.mey__close:focus-visible { opacity: 1; }

.mey__close:focus-visible { outline: 2px dotted var(--ink, #1E1B2E); outline-offset: 2px; }

/* speech bubble */
.mey__bubble {
  position: absolute;
  width: max-content;
  max-width: 140px;
  padding: 6px 9px 7px;
  background: var(--cream, #F4F1EA);
  color: var(--ink, #1E1B2E);
  border: 2px solid var(--ink, #1E1B2E);
  box-shadow: 3px 3px 0 var(--ink, #1E1B2E);
  font-family: "VT323", monospace;
  font-size: 19px;
  line-height: 1.05;
  pointer-events: auto;
}

.mey__bubble[hidden] { display: none; }

.mey__bubble::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--cream, #F4F1EA);
  border: 2px solid var(--ink, #1E1B2E);
  border-top: 0;
  border-left: 0;
}

.mey__bubble--above { left: 50%; bottom: calc(100% + 30px); transform: translateX(-50%); }
.mey__bubble--above::after { left: calc(50% - 5px); bottom: -6px; transform: rotate(45deg); }

.mey__bubble--above-end { right: 0; bottom: calc(100% + 30px); }
.mey__bubble--above-end::after { right: 22px; bottom: -6px; transform: rotate(45deg); }

.mey__bubble--above-start { left: 0; bottom: calc(100% + 30px); }
.mey__bubble--above-start::after { left: 22px; bottom: -6px; transform: rotate(45deg); }

.mey__bubble--left { right: calc(100% + 10px); top: 4px; }
.mey__bubble--left::after { right: -6px; top: 10px; transform: rotate(-45deg); }

.mey__bubble--right { left: calc(100% + 10px); top: 4px; }
.mey__bubble--right::after { left: -6px; top: 10px; transform: rotate(135deg); }

.mey__bubble-btn {
  display: block;
  margin-top: 6px;
  padding: 3px 8px 4px;
  border: 2px solid var(--ink, #1E1B2E);
  background: var(--grey, #C0C0C0); /* it is a CTA: same grey as the main button */
  box-shadow: inset 2px 2px 0 #FFFFFF, inset -2px -2px 0 var(--ink, #1E1B2E);
  color: var(--ink, #1E1B2E);
  font-family: "Pixelify Sans", "VT323", monospace;
  font-size: 15px;
  cursor: var(--cur-hand, pointer);
}

.mey__bubble-btn:active { box-shadow: inset 2px 2px 0 var(--ink, #1E1B2E), inset -2px -2px 0 #FFFFFF; }

/* corner mode: mobile, or no free spot in a section */
.mey--corner {
  position: fixed;
  left: 8px;
  top: auto !important;
  bottom: 8px;
  width: 40px;
  height: 60px;
}

/* in the corner the bubble sits beside her, low, so it covers as little as possible */
.mey--corner .mey__bubble--right { top: auto; bottom: 0; }
.mey--corner .mey__bubble--right::after { top: auto; bottom: 12px; }

/* phones: room under the footer so its links clear Mey */
@media (max-width: 860px) {
  html.has-mey body { padding-bottom: 112px; }
}

@media print {
  .mey { display: none; }
}
