/* Milo's speech bubble, shared by both pages (see say.js): a pixel-cornered note whose tail points at him. It never
   catches a tap, so the boxes under it stay free. */
.say-bubble {
  --say-px: 4px; /* one pixel of the stepped edge and the tail */
  --say-paper: #f2f1ec;
  position: fixed;
  z-index: 101; /* over the page and Milo (100), under the guide (1000), the splash (2000) and an open box */
  left: 0;
  top: 0;
  box-sizing: border-box;
  width: max-content; /* as wide as its words */
  max-width: min(420px, calc(100vw - 32px));
  margin: 0;
  padding: 9px 14px 10px;
  color: #151515;
  background: var(--say-paper);
  /* the paper again, one pixel out on each side: square corners with the corner pixel missing */
  box-shadow:
    0 calc(var(--say-px) * -1) 0 var(--say-paper),
    0 var(--say-px) 0 var(--say-paper),
    calc(var(--say-px) * -1) 0 0 var(--say-paper),
    var(--say-px) 0 0 var(--say-paper);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(15px, 4vw, 17px);
  font-weight: 500;
  line-height: 1.32;
  letter-spacing: -0.005em;
  text-align: center;
  text-wrap: balance; /* two even lines rather than a word left alone */
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  opacity: 0;
  transform: translate3d(0, 10px, 0) scale(0.6);
  transform-origin: var(--tail, 50%) calc(100% + 12px); /* it grows out of its tail */
  transition: opacity 0.16s ease-in, transform 0.16s ease-in;
}

.say-bubble[data-under] {
  transform: translate3d(0, -10px, 0) scale(0.6);
  transform-origin: var(--tail, 50%) -12px;
}

.say-bubble[data-dock] {
  transform-origin: 50% 100%;
}

/* the tail: a stepped pixel triangle pointing down at him (or up, when the bubble sits under him) */
.say-bubble::before {
  content: "";
  position: absolute;
  left: calc(var(--tail, 50%) - var(--say-px) * 2);
  top: calc(100% + var(--say-px));
  width: calc(var(--say-px) * 4);
  height: calc(var(--say-px) * 2);
  background: var(--say-paper);
  clip-path: polygon(0 0, 100% 0, 100% 50%, 75% 50%, 75% 100%, 25% 100%, 25% 50%, 0 50%);
}

.say-bubble[data-under]::before {
  top: auto;
  bottom: calc(100% + var(--say-px));
  clip-path: polygon(25% 0, 75% 0, 75% 50%, 100% 50%, 100% 100%, 0 100%, 0 50%, 25% 50%);
}

.say-bubble[data-dock]::before {
  display: none;
}

.say-bubble[data-shown] {
  opacity: 1;
  transform: none;
  transition: opacity 0.2s ease-out, transform 0.46s cubic-bezier(0.3, 1.55, 0.5, 1);
}

/* it goes only when a box is opened */
.say-bubble[data-shown][data-leaving] {
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.16s ease-in, transform 0.16s ease-in;
}

.say-bubble p {
  margin: 0;
}

/* the greeting small and soft, what to do big and bold */
.say-bubble .say-bubble__hello {
  color: #4a4945;
  font-size: 0.86em;
}

.say-bubble .say-bubble__ask {
  margin-top: 0.15em;
  font-weight: 650;
}

.say-bubble__rest {
  color: transparent;
}

/* his cursor, like the >_ on his chest, while he types */
.say-bubble [data-caret] .say-bubble__typed::after {
  content: "";
  position: absolute;
  width: 0.48em;
  height: 1.05em;
  margin: 0.17em 0 0 0.12em;
  background: currentColor;
}

/* read out once, in full, for screen readers */
.say-live {
  position: fixed;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .say-bubble,
  .say-bubble[data-under],
  .say-bubble[data-shown],
  .say-bubble[data-shown][data-leaving] {
    transform: none;
    transition: none;
  }
}
