/* The Talk box and the thinking bubble. Owner: J49. Only ever on screen at home, when serve.mjs marks the page. */
.talk-box {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 112px);
  transform: translateX(-50%);
  z-index: 21;
  box-sizing: border-box;
  width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 22px;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font);
  font-size: 18px;
  box-shadow: 0 2px 0 rgba(74, 63, 74, .10), 0 8px 22px rgba(74, 63, 74, .18);
  pointer-events: auto;
  animation: talk-in .25s ease-out both;
}
.talk-box[hidden], .talk-form[hidden], .talk-dots[hidden] { display: none; }
.talk-box.calm { animation: none; }
@keyframes talk-in {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to { opacity: 1; transform: translateX(-50%); }
}

.talk-head { display: flex; align-items: center; gap: 10px; }
.talk-who {
  flex: 1 1 auto; min-width: 0;
  font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.talk-switch, .talk-bye, .talk-say {
  min-height: 44px;
  border: 0;
  color: var(--ink);
  font: inherit;
  font-size: 18px;
  cursor: pointer;
}
.talk-switch {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0 4px;
  background: none;
  font-weight: 500;
}
.talk-track {
  position: relative;
  flex: none;
  width: 42px; height: 24px;
  border-radius: 12px;
  background: #e8dccb;
  transition: background .2s ease;
}
.talk-track::after {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fffaf2;
  box-shadow: 0 1px 3px rgba(74, 63, 74, .25);
  transition: transform .2s ease;
}
.talk-switch[aria-checked="true"] .talk-track { background: #ffd877; }
.talk-switch[aria-checked="true"] .talk-track::after { transform: translateX(18px); }
.calm .talk-track, .calm .talk-track::after { transition: none; }

.talk-bye {
  flex: none;
  padding: 0 14px;
  border-radius: 22px;
  background: #f4e6d2;
  font-weight: 600;
}
.talk-bye:hover, .talk-say:hover { background: #ffe9ae; }

.talk-form { display: flex; gap: 8px; margin-top: 10px; }
.talk-input {
  flex: 1 1 auto; min-width: 0;
  min-height: 44px;
  box-sizing: border-box;
  padding: 0 14px;
  border: 0;
  border-radius: 22px;
  background: #fffaf2;
  box-shadow: inset 0 0 0 2px #eeddc4;
  color: var(--ink);
  font: inherit;
  font-size: 18px;
}
.talk-input::placeholder { color: rgba(74, 63, 74, .55); }
.talk-say {
  flex: none;
  padding: 0 18px;
  border-radius: 22px;
  background: #fff4c8;
  box-shadow: 0 0 0 2px #ffd877;
  font-weight: 700;
}

.talk-box :focus-visible { outline: 3px solid #e8a23c; outline-offset: 2px; }

.talk-said, .talk-note { margin: 8px 4px 0; font-size: 18px; line-height: 1.26; overflow-wrap: anywhere; }
.talk-said { opacity: .72; }
.talk-note { font-style: italic; }
.talk-said:empty, .talk-note:empty { display: none; }

.talk-dots { z-index: 19; pointer-events: none; }
.talk-dots span {
  display: inline-block;
  min-width: 26px;
  text-align: center;
  font-size: 24px;
  line-height: 1;
  animation: talk-breathe 1.8s ease-in-out infinite;
}
.talk-dots.calm span { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .talk-dots span, .talk-box { animation: none; }
}
@keyframes talk-breathe {
  0%, 100% { opacity: .55; }
  50% { opacity: 1; }
}

/* Phones: clear of the joystick and of the narrator's captions, which sit higher on touch screens. */
@media (max-width: 640px) {
  .talk-box { bottom: calc(env(safe-area-inset-bottom) + 204px); }
  .talk-head { flex-wrap: wrap; row-gap: 2px; }
  .talk-who { flex-basis: 100%; }
  .talk-switch { margin-right: auto; }
}

/* On a computer the box sits right down at the bottom, out of the way of whoever you're talking to. */
@media (min-width: 760px) {
  .talk-box { bottom: calc(env(safe-area-inset-bottom) + 14px); }
}
