/* 宠物小屋的仪式 (spec §47.8): the adoption (pets/ceremony.js: the room dims, the gift basket in a pool of light, the
   reveal, the pet jumping out), naming (the 96 px microphone, three equal suggested names, the confirm card), the
   领养证书 (pets/certificate.js: the card, the frame on the room's wall, the big one over the room) and the room's
   certificate's read-aloud buttons. Light only (spec §45); only transform and opacity move (spec §47.12); side by
   side buttons are equal (grids of minmax(0, 1fr), spec §12); no long-press menu on the iPad (spec §47.5). */
:root {
  --ptc-veil: rgba(30, 20, 52, 0.66);
  --ptc-spot: rgba(255, 233, 176, 0.6);
  --ptc-spot-0: rgba(255, 233, 176, 0);
  --ptc-ring: rgba(255, 214, 102, 0.9);
  --ptc-light: #FFFFFF;
  --ptc-say-shadow: rgba(20, 10, 40, 0.5);
  --ptc-paper-1: #FFFDF6;
  --ptc-paper-2: #FFF0CF;
  --ptc-gold: #D99A1E;
  --ptc-gold-2: #F2C766;
  --ptc-gold-ink: #7A4A00;
  --ptc-ink: #4A3415;
  --ptc-label: #86622C;
  --ptc-stamp: #D2412F;
  --ptc-stamp-soft: rgba(210, 65, 47, 0.07);
  --ptc-frame-1: #E9B45A;
  --ptc-frame-2: #B9782A;
  --ptc-overlay: rgba(30, 20, 52, 0.58);
  --ptc-mic-1: #FFA27E;
  --ptc-mic-2: #FF6F4A;
  --ptc-mic-ring: rgba(255, 138, 101, 0.32);
  --ptc-mic-shadow: rgba(255, 111, 74, 0.38);
  --ptc-card-shadow: rgba(62, 40, 20, 0.28);
  --ptc-drop-veil: rgba(255, 249, 238, 0.78);
  --ptc-drop-veil-0: rgba(255, 249, 238, 0.35);
}

/* ---------- the ceremony's frame (in the room's grid, under the top bar) ---------- */
.pt-ceremony-box { grid-row: 2 / -1; grid-column: 1 / -1; min-height: 0; display: grid; }
.pt-room[data-phase="adopt"]::before, .pt-room[data-phase="reveal"]::before { background: var(--ptc-veil); opacity: 1; }
.pt-ceremony {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto auto;
  justify-items: center;
  align-items: center;
  gap: 14px;
  min-height: 0;
  padding-bottom: 6px;
}
/* One size and place through every phase (the pet jumps out where the basket stood): on the floor of the room. */
.pt-ceremony-stage { position: relative; align-self: end; width: min(460px, 76vw, 46vh); aspect-ratio: 1; }
.pt-ceremony-spot {
  position: absolute;
  inset: -22%;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--ptc-spot), var(--ptc-spot-0));
  opacity: 0;
  pointer-events: none;
  transition: opacity 700ms var(--ease-out);
}
.pt-ceremony.is-basket .pt-ceremony-spot, .pt-ceremony[data-phase="reveal"] .pt-ceremony-spot { opacity: 1; }
.pt-ceremony-fx { position: absolute; left: -15%; top: -15%; z-index: 3; width: 130%; height: 130%; pointer-events: none; }
.pt-ceremony .pt-stage.pt-ceremony-pet { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; }
.pt-ceremony .pt-stage.pt-ceremony-pet.is-offstage { pointer-events: none; }
.pt-ceremony.is-flash::after { content: ""; position: absolute; inset: -60px; z-index: 8; background: var(--pt-white); pointer-events: none; animation: pt-flash 700ms ease-out forwards; }
@keyframes pt-flash { 0% { opacity: 0; } 25% { opacity: 0.9; } 100% { opacity: 0; } }
.pt-ceremony-say {
  margin: 0;
  max-width: 760px;
  min-height: 1.4em;
  padding: 0 16px;
  text-align: center;
  font-size: 26px;
  font-weight: 900;
  line-height: 1.4;
  color: var(--pt-ink);
}
.pt-ceremony.is-basket .pt-ceremony-say, .pt-ceremony[data-phase="reveal"] .pt-ceremony-say { color: var(--ptc-light); text-shadow: 0 2px 12px var(--ptc-say-shadow); }
.pt-ceremony-panel { width: min(900px, 100%); }
.pt-ceremony-panel:empty { display: none; }
.pt-skip {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 9;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 52px;
  padding: 0 18px 0 22px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--pt-card);
  box-shadow: var(--pt-shadow);
  font: inherit;
  font-size: 18px;
  font-weight: 800;
  color: var(--text-2);
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: manipulation;
}
.pt-skip[hidden] { display: none; }
.pt-skip svg { width: 22px; height: 22px; }

/* ---------- the gift basket ---------- */
.pt-basket-wrap { position: absolute; inset: 0; z-index: 1; }
.pt-basket-wrap[hidden] { display: none; }
.pt-basket {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: manipulation;
  transform-origin: 50% 88%;
}
.pt-ceremony.is-basket .pt-basket { animation: ptc-bob 2.6s ease-in-out infinite; }
.pt-basket.is-waiting { animation: ptc-sway 1.5s ease-in-out infinite; }
@keyframes ptc-bob { 0%, 100% { transform: translateY(0) rotate(0deg); } 30% { transform: translateY(-1.5%) rotate(-1.2deg); } 60% { transform: translateY(0) rotate(1deg); } }
@keyframes ptc-sway { 0%, 100% { transform: rotate(-2.5deg); } 50% { transform: rotate(2.5deg); } }
.pt-basket-part { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.pt-basket-clip { inset: auto; object-fit: fill; }
.pt-basket-glow {
  position: absolute;
  inset: 2%;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--pt-glow), var(--pt-glow-0));
  opacity: 0.3;
  transform: scale(var(--pt-glow-scale, 1));
  transition: opacity var(--dur-3) var(--ease-out), transform var(--dur-3) var(--ease-out);
}
.pt-basket-ring { position: absolute; inset: 18%; border: 6px solid var(--ptc-ring); border-radius: 50%; opacity: 0; pointer-events: none; }

/* ---------- naming ---------- */
.pt-name-panel {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  padding: 16px 20px;
  border-radius: var(--r-xl);
  background: var(--pt-card);
  box-shadow: var(--pt-shadow);
}
.pt-name-panel.is-no-mic { grid-template-columns: minmax(0, 1fr); }
.pt-mic-box { display: grid; justify-items: center; gap: 10px; }
.pt-mic-box[hidden] { display: none; }
.pt-mic {
  position: relative;
  width: 96px;
  height: 96px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--ptc-mic-1), var(--ptc-mic-2));
  box-shadow: 0 10px 24px var(--ptc-mic-shadow);
  color: var(--pt-white);
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: none;
  transition: transform 140ms var(--ease-spring);
}
.pt-mic-ring {
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  background: var(--ptc-mic-ring);
  opacity: 0;
  transform: scale(calc(0.9 + var(--pt-level, 0) * 0.45));
  transition: transform 90ms linear, opacity var(--dur-2) var(--ease-out);
}
.pt-mic-face { position: relative; display: grid; place-items: center; width: 100%; height: 100%; }
.pt-mic-icon { width: 46px; height: 46px; }
.pt-mic-box[data-state="recording"] .pt-mic { transform: scale(1.08); }
.pt-mic-box[data-state="recording"] .pt-mic-ring { opacity: 1; }
.pt-mic-box[data-state="sending"] .pt-mic-ring, .pt-mic-box[data-state="starting"] .pt-mic-ring { opacity: 1; animation: ptc-pulse 1s ease-in-out infinite; }
@keyframes ptc-pulse { 0%, 100% { transform: scale(0.92); } 50% { transform: scale(1.12); } }
.pt-mic-label { min-height: 2.6em; text-align: center; font-size: 18px; font-weight: 900; line-height: 1.3; }
.pt-name-side { display: grid; justify-items: center; gap: 12px; min-width: 0; }
.pt-names { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--pt-gap); width: 100%; }
.pt-name-pick, .pt-name-act {
  min-width: 0;
  min-height: 76px;
  border: 0;
  border-radius: var(--r-l);
  background: var(--pt-white);
  box-shadow: var(--pt-shadow);
  font: inherit;
  font-size: 28px;
  font-weight: 900;
  color: var(--pt-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: manipulation;
  transition: transform 140ms var(--ease-spring);
}
.pt-name-more {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 24px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--peach-soft);
  font: inherit;
  font-size: 19px;
  font-weight: 800;
  color: var(--peach-ink);
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: manipulation;
}
.pt-name-more svg { width: 22px; height: 22px; }
/* The confirm card lies exactly over the naming panel (ceremony.js measures it; these are the fallback), which rests
   under it: the same size and place, never up over the pet's feet. */
.pt-name-card {
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 0;
  z-index: 6;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 12px;
  padding: 16px 22px;
  border-radius: var(--r-xl);
  background: var(--pt-white);
  box-shadow: var(--shadow-3);
  text-align: center;
  overflow: hidden;
}
.pt-name-card[hidden] { display: none; }
.pt-name-panel.is-covered { opacity: 0; transition: opacity var(--dur-2) var(--ease-out); }
.pt-name-card-paw { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--peach-soft); color: var(--peach-ink); }
.pt-name-card-paw svg { width: 26px; height: 26px; }
.pt-name-big { display: inline-flex; align-items: center; gap: 14px; max-width: 100%; font-size: 52px; font-weight: 900; letter-spacing: 0.08em; line-height: 1.15; overflow-wrap: anywhere; }
.pt-name-acts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--pt-gap); width: 100%; }
.pt-name-act { font-size: 24px; }
.pt-name-act--yes { background: linear-gradient(135deg, var(--cta-1), var(--cta-2) 55%, var(--cta-3)); color: var(--cta-text); box-shadow: var(--shadow-cta); }
.pt-name-act.is-busy { opacity: 0.7; }

/* Pressed the moment a finger is down (press.js), read when held. */
.pt-name-pick.is-pressed, .pt-name-act.is-pressed, .pt-name-more.is-pressed, .pt-skip.is-pressed, .pt-cert-act.is-pressed, .ptc-act.is-pressed, .ptc-frame.is-pressed { transform: scale(0.95); transition: none; }
.pt-name-pick.is-reading, .pt-name-act.is-reading, .pt-name-more.is-reading, .pt-skip.is-reading, .pt-cert-act.is-reading, .ptc-act.is-reading { box-shadow: 0 0 0 4px var(--pt-reading-ring), var(--pt-shadow); }
.pt-name-pick.is-bounce, .pt-name-act.is-bounce, .pt-cert-act.is-bounce, .ptc-act.is-bounce { animation: pt-bounce 320ms var(--ease-spring); }

/* ---------- the certificate floating down after naming ---------- */
.pt-cert-drop { position: absolute; inset: 0; z-index: 7; display: grid; align-content: center; justify-items: center; gap: 18px; padding: 8px; border-radius: var(--r-xl); background: radial-gradient(closest-side, var(--ptc-drop-veil), var(--ptc-drop-veil-0)); }
.pt-cert-acts, .ptc-acts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--pt-gap); width: min(580px, 100%); }
.ptc-acts--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pt-cert-act, .ptc-act {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  min-height: 72px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-l);
  background: var(--pt-white);
  box-shadow: var(--pt-shadow);
  font: inherit;
  font-size: 21px;
  font-weight: 900;
  color: var(--pt-ink);
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: manipulation;
  transition: transform 140ms var(--ease-spring);
}
.pt-cert-act span, .ptc-act span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-cert-act svg, .ptc-act svg { flex: none; width: 26px; height: 26px; }
.pt-cert-act--hang { background: linear-gradient(135deg, var(--cta-1), var(--cta-2) 55%, var(--cta-3)); color: var(--cta-text); box-shadow: var(--shadow-cta); }
/* At bedtime 再看领养那天 rests (no bells, flash or confetti at night): dimmed like the room's buttons; tapped, the pet
   whispers why. */
.ptc-act[aria-disabled="true"] { opacity: 0.6; }

/* ---------- 领养证书 (certificate.js) ---------- */
.ptc-card {
  position: relative;
  width: min(560px, 100%);
  padding: 26px 28px 22px;
  border: 3px solid var(--ptc-gold);
  border-radius: 26px;
  background: linear-gradient(160deg, var(--ptc-paper-1), var(--ptc-paper-2));
  box-shadow: inset 0 0 0 6px var(--ptc-paper-1), inset 0 0 0 8px var(--ptc-gold-2), 0 18px 40px var(--ptc-card-shadow);
  color: var(--ptc-ink);
}
.ptc-corner { position: absolute; top: 18px; display: grid; color: var(--ptc-gold-2); }
.ptc-corner svg { width: 24px; height: 24px; }
.ptc-corner--tl { left: 20px; }
.ptc-corner--tr { right: 20px; }
.ptc-head { display: flex; align-items: center; justify-content: center; gap: 12px; }
.ptc-ribbon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--peach-soft); color: var(--peach-ink); }
.ptc-ribbon svg { width: 28px; height: 28px; }
.ptc-title { margin: 0; font-size: 34px; font-weight: 900; letter-spacing: 0.24em; color: var(--ptc-gold-ink); }
.ptc-body { display: grid; grid-template-columns: 40% minmax(0, 1fr); align-items: center; gap: 20px; margin-top: 18px; }
.ptc-photo { display: grid; place-items: center; aspect-ratio: 1; overflow: hidden; border-radius: 22px; background: radial-gradient(circle at 50% 38%, var(--ptc-paper-1), var(--peach-soft)); box-shadow: inset 0 0 0 3px var(--ptc-gold-2); }
.ptc-pet { width: 100%; height: 100%; object-fit: contain; }
.ptc-side { display: grid; align-content: center; gap: 4px; min-width: 0; }
.ptc-rows { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; gap: 10px 14px; margin: 0; font-size: 20px; }
.ptc-label { color: var(--ptc-label); font-weight: 800; white-space: nowrap; }
.ptc-value { min-width: 0; margin: 0; overflow: hidden; font-weight: 900; white-space: nowrap; text-overflow: ellipsis; }
.ptc-grew { display: grid; gap: 8px; margin: 16px 0 0; padding: 12px 0 0; border-top: 2px dashed var(--ptc-gold-2); list-style: none; font-size: 18px; font-weight: 800; }
.ptc-grew-line { display: flex; align-items: center; gap: 8px; }
.ptc-grew-line svg { flex: none; width: 20px; height: 20px; color: var(--peach-ink); }
.ptc-stamp {
  display: grid;
  place-items: center;
  align-content: center;
  justify-self: end;
  width: 96px;
  height: 96px;
  margin: 0 4px -6px 0;
  border: 3px solid var(--ptc-stamp);
  border-radius: 50%;
  background: var(--ptc-stamp-soft);
  box-shadow: inset 0 0 0 4px var(--ptc-paper-1), inset 0 0 0 6px var(--ptc-stamp);
  color: var(--ptc-stamp);
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  transform: rotate(-14deg);
}
.ptc-stamp-line:first-child { font-size: 12px; }
.ptc-stamp-line:last-child { font-size: 15px; letter-spacing: 0.08em; }

/* The small frame on the room's wall. */
.pt-wall { position: absolute; left: 1%; top: 1%; z-index: 1; }
.ptc-frame {
  position: relative;
  display: block;
  width: 112px;
  aspect-ratio: 4 / 5;
  padding: 8px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--ptc-frame-1), var(--ptc-frame-2));
  box-shadow: var(--pt-shadow);
  rotate: -3deg;
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: manipulation;
  transition: transform 140ms var(--ease-spring);
}
.ptc-frame::before { content: ""; position: absolute; left: calc(50% - 6px); top: -12px; width: 12px; height: 12px; border-radius: 50%; background: var(--ptc-frame-2); }
.ptc-frame-paper { display: grid; grid-template-rows: minmax(0, 1fr) auto; place-items: center; width: 100%; height: 100%; padding: 6px; border-radius: 6px; background: linear-gradient(160deg, var(--ptc-paper-1), var(--ptc-paper-2)); }
.ptc-frame-pet { width: 100%; height: 100%; object-fit: contain; }
.ptc-frame-title { font-size: 15px; font-weight: 900; letter-spacing: 0.2em; color: var(--ptc-gold-ink); }

/* The certificate big, over the room. */
.ptc-overlay { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; padding: calc(var(--safe-top) + 16px) 16px calc(var(--safe-bottom) + 16px); background: var(--ptc-overlay); overflow: auto; }
.ptc-sheet { position: relative; display: grid; justify-items: center; gap: 18px; width: min(600px, 100%); animation: pt-pop-in 260ms var(--ease-spring); }
.ptc-close { position: absolute; top: -10px; right: -6px; z-index: 2; display: grid; place-items: center; width: 52px; height: 52px; border: 0; border-radius: 50%; background: var(--pt-white); box-shadow: var(--shadow-2); color: var(--pt-ink); }
.ptc-close svg { width: 26px; height: 26px; }

/* 放进我的房间: the certificate flies from where it was onto its frame on the wall (room.js measures both). */
.pt-room > .pt-cert-flyer { position: fixed; z-index: 30; pointer-events: none; transform-origin: 50% 50%; will-change: transform; }
.pt-cert-flyer .ptc-card { width: 100%; }

/* 「再看领养那天」 over the room: the ceremony again where the room was (the top bar stays). */
.pt-replay { grid-row: 2 / -1; grid-column: 1 / -1; z-index: 4; display: grid; min-height: 0; }
.pt-room.is-replay > .pt-meters, .pt-room.is-replay > .pt-scene, .pt-room.is-replay > .pt-actions { visibility: hidden; }

/* A phone, or a small window. */
@media (max-width: 600px) {
  .pt-ceremony-say { font-size: 20px; }
  .pt-name-panel { grid-template-columns: minmax(0, 1fr); padding: 14px; }
  .pt-name-pick { min-height: 64px; font-size: 22px; }
  .pt-name-big { font-size: 42px; }
  .ptc-card { padding: 22px 14px 18px; }
  .ptc-title { font-size: 26px; }
  .ptc-body { grid-template-columns: 32% minmax(0, 1fr); gap: 12px; }
  .ptc-rows { gap: 8px 10px; font-size: 14px; }
  .ptc-stamp { width: 78px; height: 78px; }
  .ptc-stamp-line:first-child { font-size: 10px; }
  .ptc-stamp-line:last-child { font-size: 12px; }
  .ptc-frame { width: 84px; }
  .pt-cert-act, .ptc-act { min-height: 60px; font-size: 17px; }
}
/* Landscape iPad: the naming panel beside nothing taller than the room allows. */
@media (orientation: landscape) and (max-height: 860px) {
  .pt-ceremony { gap: 10px; }
  .pt-ceremony-say { font-size: 24px; }
  .pt-name-pick, .pt-name-act { min-height: 68px; }
}

@media (prefers-reduced-motion: reduce) {
  .pt-ceremony.is-basket .pt-basket, .pt-basket.is-waiting, .pt-mic-box .pt-mic-ring, .ptc-sheet { animation: none; }
  .pt-ceremony.is-flash::after { animation: none; opacity: 0; }
}
