/* 电子宠物 shop, wardrobe, the pet figure, the small room and the parents' 「最近买的」 (spec §47.10, §47.11, step
   47-B2): views/pets-shop.js, views/pets-wardrobe.js, views/pets-bought.js, pets/figure.js, pets/mini-room.js,
   pets/room-items.js, pets/treats.js, pets/purchases.js. Tokens only (tokens.css; the coin and the progress bar are
   奖励站's). §12: the cards of a grid are one size (minmax(0, 1fr) columns, equal rows, fixed parts, one-line names);
   paired buttons are equal. Light only (§45). Only transform and opacity move (§47.12). */

:root {
  --ps-card-pic: 1fr;
  /* The band above the pet where its words go, in the boxes that cut what sticks out (the hero tile, the try-on
     stage): one line of the bubble (.pf-say), a second one runs into the figure's headroom. */
  --ps-say-band: 34px;
  --ps-hero-h: 162px;
  --ps-figure-h: 124px;
  --ps-cols: 3;
  --ps-name: 16px;
  --ps-price: 18px;
  --ps-btn-h: 56px;
  --ps-stage-h: 248px;
  --ps-room-ratio: 4 / 3;
  --ps-bubble: rgba(255, 255, 255, 0.96);
}
@media (min-width: 700px) {
  :root { --ps-cols: 4; --ps-name: 18px; --ps-price: 20px; --ps-hero-h: 178px; --ps-figure-h: 140px; --ps-btn-h: 64px; --ps-stage-h: 320px; --ps-room-ratio: 16 / 10; }
}
@media (min-width: 1000px) {
  :root { --ps-cols: 5; }
}

/* ---------- The page ---------- */
.psh-content { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); padding-top: 8px; }
.psh-hero { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.psh-hero .psh-stat { min-height: var(--ps-hero-h); height: 100%; }
.page--pets-shop .pz-stat-value { font-size: 40px; }
.page--pets-shop .pz-stat-label { font-size: 15px; }
/* The pet: at the bottom, the band for its words above it (--ps-hero-h = the band + the figure + 4px). */
.psh-pet-tile { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); place-items: end center; padding: calc(var(--ps-say-band) + 2px) 6px 2px; overflow: hidden; }
.psh-pet-tile .pf { width: auto; height: var(--ps-figure-h); }

.psh-notice-card { display: grid; gap: 4px; padding: var(--card-pad); text-align: center; font-size: 18px; }
.psh-notice-card span { color: var(--text-2); font-size: 16px; }

/* The wish: the only card that says how many are still missing. */
.psh-wish {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  width: 100%;
  min-height: 112px;
  padding: var(--card-pad);
  border: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
  transition: transform var(--dur-1) var(--ease-out);
}
.psh-wish:active { transform: scale(0.98); }
.psh-wish-pic { display: block; width: 88px; height: 88px; border-radius: var(--r-s); background: var(--surface-2); overflow: hidden; }
.psh-wish-pic img { width: 100%; height: 100%; object-fit: contain; }
.psh-wish-main { display: grid; gap: 6px; min-width: 0; }
.psh-wish-label { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 700; color: var(--coral); }
.psh-wish-label svg { width: 16px; height: 16px; }
.psh-wish-name { font-size: 20px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.psh-wish-left { font-size: 16px; font-weight: 700; color: var(--text-2); }
.psh-wish.is-ready .psh-wish-left { color: var(--positive-text); }

/* The tabs: one row of equal segments, big enough for a child's finger. */
.psh-seg .seg-item { min-height: 52px; font-size: 18px; font-weight: 700; }

/* ---------- Cards ---------- */
.psh-grid {
  display: grid;
  grid-template-columns: repeat(var(--ps-cols), minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: var(--gap);
}
.psh-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: start;
  gap: 6px;
  height: 100%;
  min-width: 0;
  padding: 10px 10px 12px;
  border: 0;
  border-radius: var(--r-m);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  font: inherit;
  color: var(--text);
  text-align: center;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
  transition: transform var(--dur-1) var(--ease-out);
}
.psh-card:active { transform: scale(0.97); }
/* Held (press.js, like the room's buttons): pressed at once, then the reading ring while its words are read out. */
.psh-card.is-pressed, .psh-wish.is-pressed, .pt-choice.is-pressed { transform: scale(0.97); transition: none; }
.psh-card.is-reading, .psh-wish.is-reading, .psh-sheet-btn.is-reading, .psh-buy.is-reading, .pt-choice.is-reading, .pt-choice-meal.is-reading { box-shadow: 0 0 0 4px var(--pt-reading-ring), var(--shadow-1); }
.psh-card--skel { aspect-ratio: 3 / 4; box-shadow: none; }
.psh-pic { position: relative; display: block; width: 100%; aspect-ratio: 1; border-radius: var(--r-s); background: var(--surface-2); overflow: hidden; }
.psh-pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.psh-pic-ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-3); }
.psh-pic-ph svg { width: 40%; height: 40%; }
.psh-name { display: block; font-size: var(--ps-name); font-weight: 700; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.psh-price { display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 26px; font-size: var(--ps-price); font-weight: 800; }
.psh-coin-box { display: inline-grid; place-items: center; flex-shrink: 0; }
.psh-coin { width: 22px; height: 22px; }
.psh-lock { display: inline-grid; place-items: center; color: var(--text-3); }
.psh-lock svg { width: 18px; height: 18px; }
.psh-price.is-locked .psh-coin { opacity: 0.6; }
.psh-card.is-owned .psh-price { opacity: 0.5; }
.psh-card.is-worn { box-shadow: 0 0 0 3px var(--mangosteen), var(--shadow-1); }
.psh-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: calc(100% - 16px);
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  background: var(--positive-soft);
  color: var(--positive-text);
}
.psh-badge svg { width: 14px; height: 14px; }
.psh-badge--worn { background: var(--mangosteen); color: var(--text-on-brand); }
.psh-badge--held { background: var(--pineapple-soft); color: var(--text); }
.psh-wished { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface); color: var(--coral); box-shadow: var(--shadow-1); }
.psh-wished svg { width: 16px; height: 16px; fill: currentColor; }

/* ---------- The item sheet ---------- */
.psh-sheet { display: grid; gap: 10px; justify-items: center; text-align: center; }
.psh-sheet-stage { display: grid; place-items: center; width: 100%; height: var(--ps-stage-h); border-radius: var(--r-l); background: var(--surface-2); overflow: hidden; }
.psh-big { position: relative; display: block; height: 92%; aspect-ratio: 1; }
.psh-big img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.psh-big-ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-3); }
.psh-big-ph svg { width: 30%; height: 30%; }
.psh-sheet-stage .pf { width: auto; height: calc(100% - var(--ps-say-band)); align-self: end; }
.psh-sheet-price { display: inline-flex; align-items: center; gap: 4px; margin: 0; font-size: 22px; font-weight: 800; }
/* The words and their speaker (the room's round button, pets.css .pt-round): read out on a tap. */
.psh-sheet-intro { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; margin: 0; font-size: 18px; line-height: 1.5; color: var(--text-2); text-align: left; }
.psh-sheet-read { -webkit-touch-callout: none; touch-action: manipulation; }
.psh-sheet-status { display: inline-flex; align-items: center; gap: 4px; margin: 0; padding: 4px 12px; border-radius: var(--r-pill); font-size: 16px; font-weight: 800; }
.psh-sheet-status svg { width: 16px; height: 16px; }
.psh-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); width: 100%; }
.psh-two--one { grid-template-columns: minmax(0, 1fr); }
.psh-sheet-btn, .psh-buy { min-height: var(--ps-btn-h); font-size: 20px; gap: 8px; -webkit-touch-callout: none; user-select: none; touch-action: manipulation; }
.psh-sheet-btn svg { width: 22px; height: 22px; }
.psh-sheet-btn.is-on { color: var(--coral); }
.psh-buy { width: 100%; }
.psh-buy.is-off { color: var(--text-3); box-shadow: none; }
.psh-buy.is-off .psh-coin { opacity: 0.5; }
.psh-foot { display: grid; gap: 10px; }
.psh-confirm { margin: 0; text-align: center; font-size: 21px; font-weight: 800; }

/* ---------- The pet figure (pets/figure.js): the pose square at the bottom, headroom for a tall hat on top ---------- */
.pf { position: relative; width: 100%; aspect-ratio: 1 / 1.16; }
.pf-motion { position: absolute; inset: 0; transform-origin: 50% 94%; }
.pf-box { position: absolute; left: 0; bottom: 0; width: 100%; aspect-ratio: 1; }
.pf-pose { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.pf-pose.is-on { opacity: 1; }
/* A new pose over the old one: it fades in on top (110 ms) while the old one stays opaque underneath. */
.pf-pose.is-top { z-index: 1; transition: opacity 110ms linear; }
.pf-ph-box { position: absolute; inset: 8%; }
/* A grey silhouette, one even shade (the opacity on the whole drawing), that shows on the hero, the stage, the wall and the floor. */
.pf-ph { width: 100%; height: 100%; fill: var(--text); opacity: 0.16; }
.pf-acc { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.pf:not(.is-ready) .pf-acc, .pf:not(.is-ready) .pf-pose { opacity: 0; }
.pf-wear { position: absolute; max-width: none; height: auto; transform-origin: 0 0; user-select: none; -webkit-user-drag: none; }
.pf-fx { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.pf-spark { position: absolute; display: grid; place-items: center; width: 20px; height: 20px; margin: -10px 0 0 -10px; color: var(--pz-gold); opacity: 0; animation: pf-spark 900ms var(--ease-out) var(--delay, 0ms) both; }
.pf-spark svg { width: 100%; height: 100%; fill: currentColor; }
.pf-spark--hearts { color: var(--coral); }
.pf-spark--crumbs { width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--pineapple-deep); }
@keyframes pf-spark {
  0% { opacity: 0; transform: translate(0, 0) scale(0.4); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx, 0), var(--dy, -18px)) scale(1); }
}
/* The pet's words: as wide as they need (two lines at most, never 「…」 after a few characters), centred over the
   pet, a little above its head (the room has the space). In the hero tile and the try-on stage, which cut what
   sticks out, the bubble sits in the band above the pet instead, as wide as that box (container units). */
.pf-say {
  position: absolute;
  left: 50%;
  top: 0;
  z-index: 4;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  width: max-content;
  max-width: 96%;
  margin: 0;
  padding: 6px 12px;
  border-radius: var(--r-m);
  background: var(--ps-bubble);
  box-shadow: var(--shadow-2);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  text-align: center;
  white-space: normal;
  overflow: hidden;
  opacity: 0;
  transform: translate(-50%, -40%);
  transition: opacity var(--dur-2) var(--ease-out);
  pointer-events: none;
}
.pf-say.is-on { opacity: 1; }
.psh-pet-tile, .psh-sheet-stage { container-type: inline-size; }
.psh-pet-tile .pf-say, .psh-sheet-stage .pf-say { top: calc(4px - var(--ps-say-band)); max-width: calc(100cqi - 12px); transform: translateX(-50%); }

/* ---------- The small room (pets/mini-room.js): wall, floor, the things behind the pet, the pet ---------- */
.pw-room-host { display: grid; }
.pw-room {
  position: relative;
  width: 100%;
  aspect-ratio: var(--ps-room-ratio);
  max-height: 52vh;
  border-radius: var(--r-l);
  overflow: hidden;
  box-shadow: var(--shadow-2);
  background: var(--cream);
}
.pw-room--skel { box-shadow: none; }
.pw-wall { position: absolute; inset: 0 0 34% 0; background-color: var(--pineapple-soft); background-size: cover; background-position: center bottom; }
.pw-floor { position: absolute; inset: 66% 0 0 0; background-color: var(--surface-3); background-size: cover; background-position: center top; }
.pw-items { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.pr-item { position: absolute; object-fit: fill; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.pr-item[hidden] { display: none; }
.pw-pet { position: absolute; z-index: 2; }
.pw-pet .pf { width: 100%; }
.pw-room .pf-say { font-size: 16px; }

/* ---------- The wardrobe ---------- */
.pw-content { gap: 18px; padding-top: 14px; }
.pw-section { display: grid; gap: 10px; }
.pw-section .section-label { margin: 0; font-size: 18px; }
.pw-card.is-worn, .pw-card.is-shown { box-shadow: 0 0 0 3px var(--mangosteen), var(--shadow-1); }
.pw-state { display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 26px; font-size: 16px; font-weight: 700; color: var(--text-2); }
.pw-state svg { width: 18px; height: 18px; }
.pw-state.is-on { color: var(--mangosteen); }
.pw-empty { margin: 0; padding: 14px; border-radius: var(--r-m); background: var(--surface); color: var(--text-2); font-size: 17px; text-align: center; }

/* ---------- 「吃饭 | 零食」 (pets/treats.js) ---------- */
.pt-choice-body { display: grid; gap: 12px; }
.pt-choice-meal { width: 100%; min-height: var(--ps-btn-h); font-size: 20px; }
.pt-choice-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: var(--gap); }
.pt-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: var(--ps-btn-h);
  height: 100%;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-m);
  background: var(--surface-2);
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
}
.pt-choice:active { transform: scale(0.97); }
.pt-choice-meal svg { width: 24px; height: 24px; }
.pt-choice-pic { display: grid; place-items: center; flex-shrink: 0; width: 44px; height: 44px; border-radius: var(--r-xs); background: var(--surface); overflow: hidden; }
.pt-choice-pic img { width: 100%; height: 100%; object-fit: contain; }
.pt-choice-name { flex: 1; min-width: 0; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-choice-count { flex-shrink: 0; color: var(--text-2); }

/* ---------- Parents: 「最近买的」 ---------- */
.pb-content { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; padding-top: 8px; }
.pb-head { margin: 18px 4px 10px; }
.pb-hint { font-weight: 500; color: var(--text-3); }
.pb-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: var(--gap); }
.pb-tile { display: grid; justify-items: center; align-content: center; gap: 2px; height: 100%; min-height: 72px; padding: 10px 6px; border-radius: var(--r-m); background: var(--surface); box-shadow: var(--shadow-1); }
.pb-tile-value { font-size: 24px; font-weight: 800; color: var(--text); }
.pb-tile-label { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pb-tile--pets .pb-tile-value { color: var(--mangosteen); }
.pb-skel { height: 220px; border-radius: var(--r-m); }
.pb-row { min-height: 76px; }
.pb-row .row-main { gap: 1px; }
.pb-pic { display: grid; place-items: center; flex-shrink: 0; width: 44px; height: 44px; border-radius: var(--r-xs); background: var(--surface-2); color: var(--text-3); overflow: hidden; }
.pb-pic img { width: 100%; height: 100%; object-fit: contain; }
.pb-pic svg { width: 22px; height: 22px; }
.pb-refund, .pb-state { flex-shrink: 0; width: 80px; min-height: 44px; }
.pb-state { display: inline-grid; place-items: center end; font-size: 14px; color: var(--text-3); text-align: right; }
.pb-state--used, .pb-state--refunded { color: var(--text-2); }
.pb-empty { margin: 0; padding: 14px 16px; border-radius: var(--r-m); background: var(--surface); color: var(--text-2); font-size: 15px; }
/* The parents' pet page shows the latest few; 「全部 N 件」 opens #/pets/bought. */
.pb-more { margin-top: 10px; gap: 4px; }
.pb-more[hidden] { display: none; }
.pb-more svg { width: 18px; height: 18px; }

/* Reduced motion (spec §47.12): no Q bounce, no flight; sparks only fade. */
@media (prefers-reduced-motion: reduce) {
  .pf-spark { animation-name: pf-fade; }
  .psh-card:active, .psh-wish:active, .pt-choice:active { transform: none; }
}
@keyframes pf-fade { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 0; } }

