/* Pip the puffin (N6b). Self-contained. Animations: transform/opacity only. */
.pip {
  --pip-ink: #14212b;        /* bubble text on #fff: 16.4:1 */
  --pip-bubble-line: #075a75; /* = --accent-ink, bubble border */
  display: inline-flex;
  align-items: flex-end;
  gap: 6px;
  position: relative;
  font-family: Andika, "Comic Neue", system-ui, sans-serif;
}
.pip[data-bubble="left"] { flex-direction: row-reverse; }
.pip[data-bubble="top"] { flex-direction: column-reverse; align-items: flex-start; gap: 12px; }

.pip-figure { flex: none; line-height: 0; }
.pip-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.pip-svg * { transform-box: view-box; }

/* speech bubble: solid backing, never transparent */
.pip-bubble {
  position: relative;
  align-self: center;
  background: #ffffff;
  color: var(--pip-ink);
  border: 3px solid var(--pip-bubble-line);
  border-radius: 20px;
  padding: 12px 18px;
  font-size: 22px;   /* kid text: 22px minimum is also the project floor of 18px */
  line-height: 1.3;
  font-weight: 400;
  max-width: min(22em, 70vw);
  box-shadow: 0 3px 0 rgba(7, 90, 117, .25);
  animation: pip-pop .28s cubic-bezier(.2, 1.4, .4, 1) both;
}
.pip-bubble[hidden] { display: none; }
.pip-bubble::before { /* tail */
  content: "";
  position: absolute;
  left: -11px; top: 50%;
  width: 18px; height: 18px;
  margin-top: -9px;
  background: #ffffff;
  border-left: 3px solid var(--pip-bubble-line);
  border-bottom: 3px solid var(--pip-bubble-line);
  transform: rotate(45deg);
  border-bottom-left-radius: 4px;
}
.pip[data-bubble="left"] .pip-bubble::before { left: auto; right: -11px; transform: rotate(-135deg); }
.pip[data-bubble="top"] .pip-bubble::before { left: 40px; top: auto; bottom: -11px; margin: 0; transform: rotate(-45deg); }
.pip[data-bubble="top"] .pip-bubble { align-self: flex-start; }
@keyframes pip-pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }

/* idle bob (the only infinite animation) */
.pip-bob { animation: pip-bob 3.4s ease-in-out infinite; }
@keyframes pip-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.pip-paused .pip-bob { animation-play-state: paused; }
.pip[data-pose="sleep"] .pip-bob { animation-duration: 5.2s; }

/* parts */
.pip-wing, .pip-head { transition: transform .3s cubic-bezier(.3, 1.3, .5, 1); }
.pip-wing-l { transform-origin: 60px 116px; }
.pip-wing-r { transform-origin: 140px 116px; }
.pip-head { transform-origin: 100px 118px; }
.pip-eye { transition: transform .25s; }
.pip-eyes-shut, .pip-zzz, .pip-q { opacity: 0; transition: opacity .2s; }
.pip-blink .pip-eyes-open, .pip[data-pose="sleep"] .pip-eyes-open { opacity: 0; }
.pip-blink .pip-eyes-shut, .pip[data-pose="sleep"] .pip-eyes-shut { opacity: 1; }
.pip-shadow { transform-origin: 100px 212px; }

/* poses. Hanging wing: rotate(+) swings the left tip outward/up, rotate(-) the right tip. */
.pip[data-pose="wave"] .pip-wing-r { transform: rotate(-126deg); }
.pip[data-pose="cheer"] .pip-wing-l { transform: rotate(140deg); }
.pip[data-pose="cheer"] .pip-wing-r { transform: rotate(-140deg); }
.pip[data-pose="think"] .pip-wing-r { transform: rotate(88deg); }
.pip[data-pose="think"] .pip-head { transform: rotate(-7deg); }
.pip[data-pose="think"] .pip-eye { transform: translate(-3px, -4px); }
.pip[data-pose="think"] .pip-q { opacity: 1; }
.pip[data-pose="point"] .pip-wing-r { transform: rotate(-98deg); }
.pip[data-pose="point"] .pip-head { transform: rotate(5deg); }
.pip[data-pose="point"] .pip-eye { transform: translate(3px, 0); }
.pip[data-pose="sleep"] .pip-head { transform: rotate(9deg) translateY(4px); }
.pip[data-pose="sleep"] .pip-zzz { opacity: 1; }
.pip[data-pose="sleep"] .pip-smile { opacity: .0; }

/* one-shot flourishes when a pose is set (finite) */
.pip-flourish[data-pose="wave"] .pip-wing-r { animation: pip-wave .5s ease-in-out 3 .25s; }
.pip-flourish[data-pose="cheer"] .pip-wing-l { animation: pip-cheer-l .34s ease-in-out 3; }
.pip-flourish[data-pose="cheer"] .pip-wing-r { animation: pip-cheer-r .34s ease-in-out 3; }
.pip-flourish[data-pose="cheer"] .pip-svg { animation: pip-hop .34s ease-out 3; }
.pip-flourish[data-pose="point"] .pip-wing-r { animation: pip-point .45s ease-in-out 2 .2s; }
.pip-flourish[data-pose="think"] .pip-q { animation: pip-qpop .5s cubic-bezier(.2, 1.4, .4, 1) both; }
.pip-flourish[data-pose="sleep"] .pip-zzz { animation: pip-z 2.2s ease-in-out 2; }
@keyframes pip-wave { 0%, 100% { transform: rotate(-126deg); } 50% { transform: rotate(-98deg); } }
@keyframes pip-cheer-l { 0%, 100% { transform: rotate(140deg); } 50% { transform: rotate(108deg); } }
@keyframes pip-cheer-r { 0%, 100% { transform: rotate(-140deg); } 50% { transform: rotate(-108deg); } }
@keyframes pip-hop { 0%, 100% { transform: translateY(0); } 45% { transform: translateY(-12px); } }
@keyframes pip-point { 0%, 100% { transform: rotate(-98deg); } 50% { transform: rotate(-86deg); } }
@keyframes pip-qpop { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: scale(1); } }
@keyframes pip-z { 0%, 100% { opacity: .5; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-5px); } }
.pip-flourish[data-pose="think"] .pip-q { transform-origin: 160px 30px; }

@media (prefers-reduced-motion: reduce) {
  .pip *, .pip *::before { animation: none !important; transition: none !important; }
  .pip-bubble { animation: none !important; }
}
