/* ===========================================================================
   Pati, drawn in HTML and CSS.

   The mascot everywhere else in the product is a set of PNGs (one per mood).
   On this page he is a handful of divs instead, for three reasons: he can
   look at the pointer, he weighs nothing next to a 200 KB illustration, and
   he stays sharp at any zoom on any screen.

   He is the same bird as the artwork: a round off-white body with the head
   merged into it, a leaf curl on top, big black eyes, a coral beak and feet,
   pink cheeks, and the green neckerchief that carries the JHCSC colour.

   Geometry sits on a 190 x 176 box. The body is one blob at (35, 26) sized
   120 x 124, and every feature is placed inside that blob, so moving the body
   moves the face with it. Keep the two in step if you resize anything.

   The bird keeps his own colours in both themes, exactly as a printed mascot
   would. Only the hairline that separates his white from a white page swaps
   (--pati-edge), because in the dark theme the page is darker than he is.

   Moods are set with data-mode on .pati, by assets/pati-bird.js:
     idle   breathing, blinking, eyes following the pointer
     hop    one hop, for a new remark
     wave   the right wing waves, eyes shut in a smile
     happy  eyes shut in a smile
     sleep  eyes closed, a slow bob, three z's rising
   =========================================================================== */

/* The perch holds the bird and the bubble he speaks into. The bubble is a
   sibling of the button rather than a child of it, so his line is not read
   out as part of the button's own label. */
.pati-perch { position: relative; display: inline-block; }

.pati-stage {
  position: relative;
  display: inline-block;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pati-stage:focus { outline: none; }
.pati-stage:focus-visible .pati-body { box-shadow: 0 0 0 3px var(--green-ring, rgba(43, 154, 102, .3)); }

.pati {
  /* A span by default, and an inline box has no width to hang anything off:
     every part below is placed against THIS box, so it has to be a block. */
  display: block;
  --lx: 0;
  --ly: 0;
  --pati-edge: rgba(17, 24, 28, .08);
  --pati-white: #FDFDFB;
  --pati-shade: #E9EAE4;
  --pati-ink: #1A211D;
  --pati-coral: #F08A5D;
  --pati-coral-deep: #D9703F;
  position: relative;
  width: 190px;
  height: 176px;
  flex: none;
}
html[data-theme="dark"] .pati { --pati-edge: rgba(255, 255, 255, .16); }

/* A soft puddle of shadow, so he stands on the page instead of floating over
   it. It squashes a little when he lands from a hop. */
.pati::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 104px;
  height: 14px;
  margin-left: -52px;
  border-radius: 50%;
  background: radial-gradient(50% 50% at 50% 50%, rgba(17, 24, 28, .16), transparent 70%);
  transition: transform .3s var(--ease-out, ease-out), opacity .3s var(--ease-out, ease-out);
}

.pati-bird {
  position: absolute;
  inset: 0;
  transform-origin: 50% 100%;
  animation: pati-breathe 4.6s ease-in-out infinite;
}

/* ---- body, tail, leaf ---- */
.pati-body {
  position: absolute;
  left: 35px;
  top: 26px;
  width: 120px;
  height: 124px;
  border-radius: 50% 50% 48% 48% / 54% 54% 46% 46%;
  background: radial-gradient(120% 96% at 46% 12%, #FFFFFF 0%, var(--pati-white) 48%, var(--pati-shade) 100%);
  box-shadow:
    inset -8px -11px 22px rgba(17, 24, 28, .07),
    inset 0 0 0 1px var(--pati-edge),
    0 16px 28px -16px rgba(17, 24, 28, .45);
  transition: box-shadow .2s var(--ease-out, ease-out);
  z-index: 2;
}

.pati-tail {
  position: absolute;
  left: 6px;
  top: 100px;
  width: 46px;
  height: 26px;
  border-radius: 60% 18% 22% 70% / 70% 30% 50% 40%;
  background: linear-gradient(110deg, var(--pati-shade), var(--pati-white));
  box-shadow: inset 0 0 0 1px var(--pati-edge);
  transform: rotate(-16deg);
  transform-origin: 100% 40%;
  transition: transform .35s var(--ease-out, ease-out);
  z-index: 1;
}

/* The curl of feather on his crown. Two mirrored corners make the comma. */
.pati-leaf {
  position: absolute;
  left: 46px;
  top: -20px;
  width: 26px;
  height: 30px;
  border-radius: 100% 4px 100% 4px;
  background: linear-gradient(150deg, #FFFFFF, var(--pati-shade));
  box-shadow: inset 0 0 0 1px var(--pati-edge);
  transform: rotate(14deg);
  transform-origin: 50% 100%;
  transition: transform .4s var(--ease-spring, ease-out);
}

/* ---- face ---- */
/* The whole face leans a pixel or two toward whatever he is looking at, so it
   reads as the head turning rather than the eyes sliding about on their own. */
.pati-face {
  position: absolute;
  inset: 0;
  transform: translate(calc(var(--lx) * 3px), calc(var(--ly) * 2px));
  transition: transform .22s var(--ease-out, ease-out);
}

.pati-eye-wrap {
  position: absolute;
  top: 36px;
  width: 27px;
  height: 27px;
  transform: translate(calc(var(--lx) * 2.2px), calc(var(--ly) * 2.2px));
  transition: transform .16s var(--ease-out, ease-out);
}
.pati-eye-l { left: 24px; }
.pati-eye-r { left: 69px; }

.pati-eye {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(70% 70% at 36% 30%, #2C3531, var(--pati-ink) 70%);
  /* Blinking uses the `scale` property, not `transform`, so a mood is free to
     use transform on the same element without the two fighting. */
  animation: pati-blink 6.2s infinite;
  transition: transform .2s var(--ease-out, ease-out);
}
.pati-eye-r .pati-eye { animation-delay: .06s; }

.pati-glint {
  position: absolute;
  left: 5px;
  top: 4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fff;
  opacity: .95;
}
.pati-glint::after {
  content: '';
  position: absolute;
  left: 11px;
  top: 13px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fff;
  opacity: .7;
}

.pati-beak {
  position: absolute;
  left: calc(50% - 10px);
  top: 56px;
  width: 20px;
  height: 15px;
  background: linear-gradient(180deg, var(--pati-coral), var(--pati-coral-deep));
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: 50% 0;
  transition: transform .18s var(--ease-out, ease-out);
}

.pati-blush {
  position: absolute;
  top: 62px;
  width: 20px;
  height: 11px;
  border-radius: 50%;
  background: #F7A8AE;
  opacity: .55;
  filter: blur(.4px);
  transition: opacity .25s var(--ease-out, ease-out);
}
.pati-blush-l { left: 5px; }
.pati-blush-r { right: 5px; }

/* ---- neckerchief ---- */
.pati-scarf {
  position: absolute;
  left: 24px;
  top: 73px;
  width: 72px;
  height: 13px;
  border-radius: 44% 44% 46% 46% / 52% 52% 48% 48%;
  transform: rotate(-3deg);
  background: linear-gradient(170deg, #4C9E5B 0%, var(--primary, #1B7A3D) 70%, #166B36 100%);
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, .18);
  z-index: 3;
}
.pati-scarf-tip {
  position: absolute;
  left: 34%;
  top: 7px;
  width: 26px;
  height: 24px;
  rotate: 7deg;
  background: linear-gradient(180deg, var(--primary, #1B7A3D), #145F30);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: 50% 0;
  transition: transform .4s var(--ease-spring, ease-out);
}

/* ---- wings and feet ---- */
/* A wing hinges near its top, so lifting it swings the TIP outward and up,
   the way a wing actually moves. Sliding the whole shape up read as a shrug. */
.pati-wing {
  position: absolute;
  top: 82px;
  width: 27px;
  height: 50px;
  border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%;
  background: linear-gradient(190deg, #FFFFFF 0%, var(--pati-white) 45%, var(--pati-shade) 100%);
  box-shadow: inset 0 0 0 1px var(--pati-edge);
  transform-origin: 50% 14%;
  transition: transform .46s var(--ease-spring, ease-out);
  z-index: 4;
}
.pati-wing-l { left: 24px; transform: rotate(10deg); }
.pati-wing-r { right: 24px; transform: rotate(-10deg); }

.pati-foot {
  position: absolute;
  top: 147px;
  width: 21px;
  height: 13px;
  border-radius: 46% 46% 40% 40%;
  background: linear-gradient(180deg, var(--pati-coral), var(--pati-coral-deep));
  z-index: 1;
}
.pati-foot::before,
.pati-foot::after {
  content: '';
  position: absolute;
  bottom: 0;
  width: 7px;
  height: 6px;
  border-radius: 0 0 50% 50%;
  background: var(--pati-coral-deep);
}
.pati-foot::before { left: 1px; }
.pati-foot::after { right: 1px; }
.pati-foot-l { left: 65px; }
.pati-foot-r { right: 65px; }

/* ---- sleeping z's ---- */
.pati-zzz {
  position: absolute;
  right: 18px;
  top: 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-muted, #889096);
  opacity: 0;
  pointer-events: none;
}
.pati-zzz::before,
.pati-zzz::after { content: 'z'; position: absolute; }
.pati-zzz::before { left: 9px; top: -11px; font-size: 12px; }
.pati-zzz::after { left: 18px; top: -24px; font-size: 18px; }

/* ===========================================================================
   Moods
   =========================================================================== */

/* Hovered or focused: he perks up. Head tips toward you, crown lifts, cheeks
   warm, wings come off his sides a little. */
.pati-stage:hover .pati-bird,
.pati-stage:focus-visible .pati-bird { transform: rotate(-4deg) translateY(-2px); }
.pati-stage:hover .pati-leaf,
.pati-stage:focus-visible .pati-leaf { transform: rotate(-6deg) scale(1.06); }
.pati-stage:hover .pati-eye,
.pati-stage:focus-visible .pati-eye { transform: scale(1.07); }
.pati-stage:hover .pati-blush,
.pati-stage:focus-visible .pati-blush { opacity: .78; }
.pati-stage:hover .pati-wing-l { transform: rotate(20deg); }
.pati-stage:hover .pati-wing-r { transform: rotate(-20deg); }
.pati-stage:hover .pati-tail { transform: rotate(-18deg); }
.pati-bird { transition: transform .4s var(--ease-out, ease-out); }

/* Pressed: he squashes, the way anything soft does. */
.pati-stage:active .pati-bird { transform: translateY(2px) scaleY(.97) scaleX(1.02); }

/* A new remark: one hop. */
.pati[data-mode='hop'] { animation: pati-hop .54s var(--ease-out, ease-out); }
.pati[data-mode='hop']::after { transform: scaleX(.86); opacity: .7; }

/* Pleased: eyes shut in a smile. */
.pati[data-mode='happy'] .pati-eye,
.pati[data-mode='wave'] .pati-eye,
.pati[data-mode='sleep'] .pati-eye {
  transform: scaleY(.16) translateY(9px);
  animation: none;
  border-radius: 40%;
}
.pati[data-mode='happy'] .pati-blush,
.pati[data-mode='wave'] .pati-blush { opacity: .8; }

/* Hello: the right wing waves. */
.pati[data-mode='wave'] .pati-wing-r { animation: pati-wave .46s ease-in-out .1s 3 alternate both; }

/* Talking: the beak opens and shuts while the bubble is up. */
.pati.is-talking .pati-beak { animation: pati-beak .26s ease-in-out 4 alternate; }

/* Asleep: he settles, the crown droops, the z's rise. */
.pati[data-mode='sleep'] .pati-bird { animation: pati-doze 5s ease-in-out infinite; transform: rotate(3deg); }
.pati[data-mode='sleep'] .pati-leaf { transform: rotate(32deg); }
.pati[data-mode='sleep'] .pati-zzz { animation: pati-zzz 3.4s ease-in-out infinite; }
.pati[data-mode='sleep'] .pati-blush { opacity: .35; }

@keyframes pati-breathe {
  0%, 100% { transform: translateY(0) scaleY(1); }
  50% { transform: translateY(-2.5px) scaleY(1.012); }
}
@keyframes pati-doze {
  0%, 100% { transform: rotate(3deg) translateY(0); }
  50% { transform: rotate(3deg) translateY(3px) scaleY(.985); }
}
@keyframes pati-blink {
  0%, 93%, 100% { scale: 1 1; }
  96% { scale: 1 .08; }
}
@keyframes pati-hop {
  0%, 100% { transform: none; }
  34% { transform: translateY(-16px); }
  62% { transform: translateY(0) scaleY(.94) scaleX(1.04); }
  80% { transform: translateY(-3px); }
}
@keyframes pati-wave {
  from { transform: rotate(-26deg); }
  to { transform: rotate(-96deg); }
}
@keyframes pati-beak {
  from { transform: scaleY(1); }
  to { transform: scaleY(1.5); }
}
@keyframes pati-zzz {
  0% { opacity: 0; transform: translateY(6px); }
  30% { opacity: .9; }
  100% { opacity: 0; transform: translateY(-14px); }
}

/* ===========================================================================
   What he says. The bubble sits above him with its tail pointing down at the
   crown, so it reads as his line and not as a tooltip on the page.
   =========================================================================== */
.pati-say {
  position: absolute;
  left: 50%;
  bottom: calc(100% - 6px);
  width: max-content;
  max-width: 250px;
  margin: 0;
  /* Centred with the `translate` property, not with transform: the entrance
     animation below owns transform, and the two would otherwise cancel each
     other out and leave the bubble half a width to the right. */
  translate: -50% 0;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--card, #fff);
  border: 1px solid var(--border, #E6E8EB);
  box-shadow: 0 14px 30px -18px rgba(17, 24, 28, .5);
  color: var(--text, #11181C);
  font-size: .88rem;
  line-height: 1.45;
  text-align: center;
  transform-origin: 50% 100%;
  animation: pati-say-in .36s var(--ease-spring, ease-out) both;
  z-index: 5;
}
.pati-say::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  background: var(--card, #fff);
  border-right: 1px solid var(--border, #E6E8EB);
  border-bottom: 1px solid var(--border, #E6E8EB);
  transform: rotate(45deg);
}
.pati-say[hidden] { display: none; }
@keyframes pati-say-in {
  from { opacity: 0; transform: translateY(8px) scale(.86); }
}

/* ===========================================================================
   Smaller screens, and readers who asked for less movement.
   =========================================================================== */
@media (max-width: 420px) {
  .pati { zoom: .86; }
}

@media (prefers-reduced-motion: reduce) {
  .pati-bird,
  .pati-eye,
  .pati-zzz,
  .pati-say,
  .pati[data-mode='hop'],
  .pati[data-mode='wave'] .pati-wing-r,
  .pati.is-talking .pati-beak { animation: none !important; }
  .pati-face,
  .pati-eye-wrap,
  .pati-wing,
  .pati-leaf,
  .pati-tail,
  .pati-bird { transition-duration: .01s; }
}
