/* 宠物在页面上活起来 (spec §47.28): the pet that lives on a page — the child home's 宠物窗台 (pets/sill-pet.js,
   pets/sill-life.js) and the small pet in the corner of the child's other pages (pets/corner-pet.js). The pet is stage.js's, at the sill's size: everything that moves moves with transform and
   opacity; the particles' canvas reaches past the picture (over the sill, never taking a tap). The sill keeps its
   height (≤ 120px, pets.css): a jump or a burst only draws past it. Light only (spec §45). */
:root {
  --ptl-night-1: #F1EDFF;
  --ptl-night-2: #D9D2FA;
  --ptl-zz: #7A68D6;
  /* the corner pet */
  --ptc-size: 96px;
  --ptc-gap: 16px;
  --ptc-cushion: rgba(255, 138, 101, 0.22);
  --ptc-cushion-0: rgba(255, 138, 101, 0);
  --ptc-cushion-night: rgba(122, 104, 214, 0.24);
  --ptc-cushion-night-0: rgba(122, 104, 214, 0);
}

.pts { overflow: visible; }
.pts-life { position: absolute; inset: 4px; }
.pts-life:empty { display: none; }
.pts-life .pt-stage { width: 100%; height: 100%; touch-action: pan-y; cursor: pointer; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
.pts-life .pt-shadow { left: 26%; right: 26%; bottom: 2%; height: 6%; }
.pts-life .pt-stage.is-paused * { animation-play-state: paused; }
.pts-pet[hidden] { display: none; }
.pts-mood { z-index: 1; }
/* Asleep at bedtime: the picture's corner turns to a soft night (Z float up from the pet). */
.pts[data-state="asleep"] .pts-art { background: radial-gradient(circle at 50% 80%, var(--ptl-night-1), var(--ptl-night-2) 72%); }
/* What the pet just said, for a moment where the growth line is: up to two lines (a portrait iPad has room for about
   16 characters in one), growing up over the growth bar, which steps aside meanwhile. The rows keep their sizes
   (name, bar, one line), so nothing on the sill moves. */
.pts-middle { grid-template-rows: auto 10px 22px; }
.pts-middle > * { grid-column: 1; }
.pts-middle > .pts-row { grid-row: 1; }
.pts-middle > .pts-bar { grid-row: 2; }
.pts-middle > .pts-line { grid-row: 3; }
.pts-middle > .pts-line.is-said { grid-row: 2 / 4; align-self: end; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; white-space: normal; line-height: 19px; color: var(--pt-ink); font-weight: 800; }
.pts-middle:has(> .pts-line.is-said) > .pts-bar { visibility: hidden; }

/* Asleep with 「减弱动态效果」 (stage.js adds .pt-zz only then, only while it sleeps): a still Z by its head instead of
   Z floating up. */
.pt-zz { position: absolute; right: 12%; top: 2%; font-size: 48px; font-weight: 900; line-height: 1; color: var(--ptl-zz); pointer-events: none; }
.pts-life .pt-zz, .ptc .pt-zz { font-size: 20px; right: 8%; top: 0; }

/* ② The corner pet (pets/corner-pet.js): fixed in the bottom-right corner, above the home indicator, over the page
   (its sticky bars are 20) and under the tab bar (40), sheets (100), dialogs (150) and toasts (200). Hidden it drops
   and fades away in a moment and takes no tap; it pops back in. Above a bar at the bottom of the page (the story
   reader's 听故事 bar): --ptc-lift. Everything that moves moves with transform and opacity. */
.ptc {
  position: fixed;
  z-index: 30;
  right: max(var(--ptc-gap), calc(var(--safe-right) + 8px));
  bottom: calc(max(var(--ptc-gap), calc(var(--safe-bottom) + 8px)) + var(--ptc-lift, 0px));
  width: var(--ptc-size);
  height: var(--ptc-size);
  pointer-events: none;
  visibility: hidden;
  transition: visibility 0s linear 220ms;
}
.ptc.is-shown { visibility: visible; transition: none; }
.ptc-in {
  position: absolute;
  inset: 0;
  display: block;
  opacity: 0;
  transform: translateY(18px) scale(0.82);
  transform-origin: 50% 100%;
  transition: opacity 160ms ease-in, transform 180ms ease-in;
}
.ptc.is-shown .ptc-in { opacity: 1; transform: none; transition: opacity 200ms ease-out, transform 420ms var(--ease-spring); }
.ptc-btn {
  position: absolute;
  inset: 0;
  display: block;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.ptc.is-shown .ptc-btn { pointer-events: auto; }
/* A soft round cushion under its feet (night-coloured while it sleeps). */
.ptc-cushion { position: absolute; left: 2%; right: 2%; bottom: -2%; height: 34%; border-radius: 50%; background: radial-gradient(closest-side, var(--ptc-cushion), var(--ptc-cushion-0)); }
.ptc.is-asleep .ptc-cushion { background: radial-gradient(closest-side, var(--ptc-cushion-night), var(--ptc-cushion-night-0)); }
.ptc .pt-stage { width: 100%; height: 100%; touch-action: manipulation; }
.ptc .pt-shadow { left: 26%; right: 26%; bottom: 2%; height: 6%; }
.ptc .pt-stage.is-paused * { animation-play-state: paused; }
/* The end of each page keeps the pet's corner free (whatever is last can be scrolled above it). */
html.has-ptc .page-body { padding-bottom: calc(var(--ptc-size) + 2 * var(--ptc-gap) + var(--safe-bottom)); }
html.has-ptc .page.has-tabbar .page-body { padding-bottom: calc(max(var(--tabbar-h) + 40px, var(--ptc-size) + 2 * var(--ptc-gap)) + var(--safe-bottom)); }
@media (prefers-reduced-motion: reduce) {
  .ptc-in, .ptc.is-shown .ptc-in { transform: none; transition: opacity 200ms linear; }
}

/* The parents' switch 「其他页面右下角显示小宠物」 (pets/parent-corner.js) is a row of the 设置 list, styled with the other
   switches there (row ptp-set-row, pets-parent.css). */
