/* Quinn's Quest: the guinea pig creator (play/pet.js).
   The same field journal as every other screen: the cloth-covered book and cream pages from play/style.css,
   its colours and its round stitched buttons. On the left page her guinea pig sits on a patch of meadow;
   on the right, picture tabs and big picture swatches. Every selector is .pet-* or #petScreen. */

#petScreen { position:fixed; inset:0; z-index:35; display:flex; align-items:center; justify-content:center; overflow:hidden;
  padding:max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 11vh max(12px, env(safe-area-inset-left));
  background: radial-gradient(ellipse at 30% 25%, rgba(255,240,190,.35), transparent 45%), radial-gradient(ellipse at 50% 45%, #6fb26b, #3f8456 62%, #2a5e43);
  animation:fade .3s ease; }
#petScreen[hidden] { display:none !important; }

/* petals and seeds drifting past */
.pet-air { position:absolute; inset:0; pointer-events:none; overflow:hidden; }
.pet-air i { position:absolute; top:-30px; width:14px; height:14px; border-radius:60% 0 60% 0; background:#ffc6d8; opacity:.85; animation:pet-fall 13s linear infinite; }
.pet-air i:nth-child(1) { left:6%; animation-delay:-2s; }
.pet-air i:nth-child(2) { left:22%; animation-delay:-8s; background:#fffaf0; width:10px; height:10px; animation-duration:16s; }
.pet-air i:nth-child(3) { left:41%; animation-delay:-5s; background:#d4bdf2; }
.pet-air i:nth-child(4) { left:63%; animation-delay:-11s; animation-duration:15s; }
.pet-air i:nth-child(5) { left:81%; animation-delay:-1s; background:#ffe28f; width:10px; height:10px; }
.pet-air i:nth-child(6) { left:94%; animation-delay:-7s; background:#fffaf0; animation-duration:18s; }
@keyframes pet-fall { 0% { top:-30px; transform:translateX(0) rotate(0); } 50% { transform:translateX(34px) rotate(200deg); } 100% { top:105%; transform:translateX(-10px) rotate(400deg); } }

/* the book: left page the portrait, right page the choices */
.pet-book.book { --in:18px; display:grid; width:min(1100px, 100%); height:min(740px, 100%); column-gap:56px; row-gap:12px;
  grid-template-columns:minmax(0, 1fr) minmax(0, 1.08fr); grid-template-rows:minmax(0, 1fr); grid-template-areas:"stage side"; }
.pet-book.book::after { background: linear-gradient(90deg, transparent calc(50% - 46px), rgba(150,100,60,.08) calc(50% - 18px), rgba(110,70,40,.28) 50%, rgba(150,100,60,.08) calc(50% + 18px), transparent calc(50% + 46px)),
  var(--paper-tex), var(--fibre-tex), radial-gradient(ellipse at 25% 0%, #fffaf0, transparent 60%), var(--paper); }
#petScreen[data-step="name"] .pet-book.book { grid-template-areas:"stage name"; }

/* the portrait: a soft sunny spot on the page, with a scalloped edge like a pressed-flower frame */
.pet-stage { grid-area:stage; position:relative; min-height:0; border-radius:28px;
  background: radial-gradient(ellipse at 50% 70%, rgba(255,250,236,.95), rgba(255,240,210,.6) 55%, rgba(255,226,236,.0) 75%),
    radial-gradient(circle at 18% 16%, rgba(255,214,107,.32), transparent 30%); }
.pet-stage::before { content:''; position:absolute; inset:6px; border-radius:24px; border:3px dashed rgba(200,70,122,.28); pointer-events:none; }
.pet-view { position:absolute; inset:0; width:100%; height:100%; display:block; image-rendering:pixelated; }
.pet-nametag { position:absolute; left:50%; bottom:6%; transform:translateX(-50%) rotate(-2deg); max-width:92%; padding:6px 22px 8px; border-radius:12px;
  background: var(--paper-tex), #fffdf8; box-shadow:0 2px 0 #e2cca8, 0 6px 14px rgba(60,30,40,.18); color:var(--pink-d);
  font:800 clamp(24px, 4.4vmin, 40px)/1.1 var(--hand); white-space:nowrap; pointer-events:none; }
.pet-nametag:empty, .pet-nametag[hidden] { display:none; }
.pet-dice { --c:var(--butter); --d:var(--butter-d); --s:84px; position:absolute; top:10px; right:10px; z-index:2; }
.pet-dice .ico { width:56%; height:56%; }
.pet-dice:not(:active) { animation:pet-wiggle 4s ease-in-out infinite; }
@keyframes pet-wiggle { 0%, 80%, 100% { transform:rotate(0); } 85% { transform:rotate(-12deg); } 90% { transform:rotate(10deg); } 95% { transform:rotate(-5deg); } }
.pet-rename { --c:#fff1dc; --d:var(--kraft-d); --s:76px; position:absolute; top:10px; left:10px; z-index:2; }
.pet-rename::before { border-color:rgba(200,70,122,.4); }
.pet-rename .ico { width:62%; height:62%; }

/* the choices */
.pet-side { grid-area:side; position:relative; min-height:0; display:flex; flex-direction:column; gap:12px; padding-bottom:6px; }
.pet-side[hidden] { display:none; }
.pet-tabs { display:flex; flex-wrap:wrap; gap:10px; justify-content:flex-start; padding:2px 2px 0; }
.pet-tab { flex:none; width:72px; height:72px; border-radius:20px 20px 14px 14px; border:4px solid #fff; padding:12px; display:grid; place-items:center;
  background: var(--paper-tex), #f6e6cc; box-shadow:0 4px 0 #dcc29c, 0 6px 10px rgba(60,30,40,.14); transition:transform .1s, box-shadow .1s; }
.pet-tab .ico, .pet-tab .pet-chip { width:100%; height:100%; pointer-events:none; }
.pet-tab.on { background: var(--paper-tex), #ffe3ec; border-color:var(--pink); transform:translateY(-4px); box-shadow:0 8px 0 var(--pink-d), 0 10px 16px rgba(60,30,40,.2); }
.pet-tab:active { transform:translateY(2px); box-shadow:0 1px 0 #dcc29c; }
.pet-chip { display:block; border-radius:50%; background: radial-gradient(circle at 34% 30%, rgba(255,255,255,.7), rgba(255,255,255,0) 40%), var(--c);
  box-shadow: inset 0 -5px 0 rgba(0,0,0,.18), 0 0 0 3px #fff, 0 0 0 5px rgba(58,36,49,.35); }
.pet-chip.two { box-shadow: inset 0 -5px 0 rgba(0,0,0,.18), 0 0 0 3px #fff, 0 0 0 5px rgba(58,36,49,.35), 9px -9px 0 -6px #fff, 9px -9px 0 -4px rgba(58,36,49,.3); }

.pet-tray { flex:1; min-height:0; overflow-y:auto; overflow-x:hidden; display:grid; grid-template-columns:repeat(auto-fill, minmax(118px, 1fr)); grid-auto-rows:118px; gap:14px;
  align-content:start; padding:8px 4px 96px; border-radius:16px; -webkit-overflow-scrolling:touch; overscroll-behavior:contain; }
.pet-tray[data-cat="base"], .pet-tray[data-cat="second"], .pet-tray[data-cat="eyes"] { grid-template-columns:repeat(auto-fill, minmax(96px, 1fr)); grid-auto-rows:96px; }
.pet-sw { position:relative; min-width:0; border-radius:22px; border:4px solid #fff; padding:4px; display:grid; place-items:center; overflow:visible;
  background: var(--paper-tex), #fffaf0; box-shadow:0 4px 0 #e2cca8, 0 6px 12px rgba(60,30,40,.14); transition:transform .1s, box-shadow .1s; }
.pet-sw > * { pointer-events:none; }
.pet-sw:active { transform:translateY(3px) scale(.97); box-shadow:0 1px 0 #e2cca8; }
.pet-sw.on { border-color:var(--pink); background: var(--paper-tex), #ffeef4; box-shadow:0 4px 0 var(--pink-d), 0 0 0 4px rgba(240,122,160,.28), 0 8px 16px rgba(60,30,40,.18); }
.pet-sw.on::after { content:''; position:absolute; top:-10px; right:-10px; width:30px; height:30px; border-radius:50%; background:var(--pink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2 5l2 2 4-4' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/70% no-repeat;
  box-shadow:0 0 0 3px #fff, 0 2px 4px rgba(0,0,0,.2); }
.pet-mini { max-width:100%; max-height:100%; image-rendering:pixelated; }
.pet-dab { display:block; width:78%; aspect-ratio:1; border-radius:50% 46% 52% 48%;
  background: radial-gradient(circle at 32% 28%, rgba(255,255,255,.75), rgba(255,255,255,0) 34%), radial-gradient(circle at 60% 80%, rgba(0,0,0,.2), rgba(0,0,0,0) 50%), var(--c);
  box-shadow: inset 0 0 0 2px rgba(58,36,49,.25), 0 2px 0 rgba(58,36,49,.18); }
.pet-eye { position:relative; display:block; width:80%; aspect-ratio:1.5; border-radius:50%; background:#fff; box-shadow:inset 0 0 0 3px #3a2431, 0 2px 0 rgba(58,36,49,.2); }
.pet-eye i { position:absolute; left:50%; top:50%; width:52%; aspect-ratio:1; transform:translate(-50%, -50%); border-radius:50%;
  background: radial-gradient(circle at 34% 30%, #fff 0 14%, transparent 15%), radial-gradient(circle, var(--a) 0 56%, var(--b) 57%); box-shadow:0 0 0 2px #2a1820; }

.pet-next { position:absolute; right:-6px; bottom:5vh; z-index:3; --s:112px; }
.pet-side .pet-tray { padding-bottom:calc(96px + 5vh); }
.pet-next .ico, .pet-ok .ico { width:56%; height:56%; margin:0; }

/* naming */
.pet-naming { grid-area:name; position:relative; min-height:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:22px; padding:70px 6px 6px; }
.pet-naming[hidden] { display:none; }
.pet-back { --c:#fff1dc; --d:var(--kraft-d); --s:72px; position:absolute; top:0; left:0; }
.pet-back::before { border-color:rgba(169,121,74,.55); }
.pet-heard { min-height:1.3em; max-width:100%; padding:10px 26px 14px; border-radius:16px; text-align:center; white-space:nowrap;
  background: var(--paper-tex), #fffdf8; box-shadow:0 2px 0 #e2cca8, 0 10px 22px rgba(60,30,40,.16); transform:rotate(-1.5deg);
  font:800 clamp(40px, 8vmin, 84px)/1.15 var(--hand); color:var(--pink-d); letter-spacing:.02em; }
.pet-heard.empty { min-width:min(360px, 80%); color:transparent; background: var(--paper-tex), repeating-linear-gradient(90deg, rgba(200,70,122,.35) 0 14px, transparent 14px 24px) 26px calc(100% - 22px)/calc(100% - 52px) 4px no-repeat, #fffdf8; }
.pet-heard.typing { display:none; }
.pet-type { width:min(440px, 100%); padding:12px 20px; border-radius:16px; border:4px solid var(--sky-d); background:#fff; color:var(--ink);
  font:800 clamp(24px, 4.6vmin, 40px)/1.2 var(--hand); text-align:center; outline:none; box-shadow:0 6px 0 rgba(75,147,196,.35); -webkit-user-select:text; user-select:text; }
.pet-type[hidden] { display:none; }
.pet-namerow { display:flex; align-items:center; justify-content:center; gap:22px; flex-wrap:wrap; }
.pet-keys { --c:var(--sky); --d:var(--sky-d); --s:84px; }
.pet-keys .ico { width:62%; height:62%; }
.pet-retry { --c:var(--lilac); --d:var(--lilac-d); --s:84px; }
.pet-retry[hidden], .pet-mic[hidden], .pet-rename[hidden] { display:none; }
.pet-ok { --s:112px; }
.pet-mic { --c:var(--pink); --d:var(--pink-d); --s:140px; animation:pet-breathe 2.6s ease-in-out infinite; }
.pet-mic .ico { width:52%; height:52%; }
.pet-mic .ring { position:absolute; inset:-4px; border-radius:50%; border:6px solid var(--pink); opacity:0; pointer-events:none; }
@keyframes pet-breathe { 50% { box-shadow: inset 0 -5px 0 rgba(0,0,0,.12), inset 0 0 0 3px rgba(255,255,255,.35), 0 6px 0 var(--d), 0 10px 16px rgba(40,20,40,.32), 0 0 0 12px rgba(240,122,160,.18); } }
.pet-mic:active { animation:none; }
.pet-mic.listening { --c:#fff4f8; animation:none; transform:scale(1.06); box-shadow: inset 0 0 0 5px var(--pink), 0 6px 0 var(--pink-d), 0 0 0 10px rgba(240,122,160,.3), 0 10px 22px rgba(40,20,40,.35); }
.pet-mic.listening .ico rect[fill="#ffffff"] { fill:var(--pink); }
.pet-mic.listening .ring { animation:ring 1.4s ease-out infinite; }
.pet-mic.listening .ring.r2 { animation-delay:.7s; }

/* standing up (tablet or phone held upright): the portrait on top, the choices underneath */
@media (orientation: portrait) {
  .pet-book.book { height:min(1080px, 100%); grid-template-columns:minmax(0, 1fr); grid-template-rows:minmax(0, 0.95fr) minmax(0, 1.25fr); grid-template-areas:"stage" "side"; column-gap:0; }
  #petScreen[data-step="name"] .pet-book.book { grid-template-areas:"stage" "name"; grid-template-rows:minmax(0, 1fr) minmax(0, 1fr); }
  .pet-book.book::after { background: var(--paper-tex), var(--fibre-tex), radial-gradient(ellipse at 25% 0%, #fffaf0, transparent 60%), var(--paper); }
  .pet-naming { padding-top:70px; }
  .pet-back { --s:64px; }
}
/* phones */
@media (max-width: 560px), (max-height: 480px) {
  .pet-book.book { --pad:10px; --in:10px; column-gap:30px; row-gap:8px; }
  .pet-tabs { gap:8px; }
  .pet-tab { width:64px; height:64px; padding:10px; border-width:3px; }
  .pet-tray { grid-template-columns:repeat(auto-fill, minmax(72px, 1fr)); grid-auto-rows:72px; gap:9px; padding-bottom:84px; }
  .pet-tray[data-cat="base"], .pet-tray[data-cat="second"], .pet-tray[data-cat="eyes"] { grid-template-columns:repeat(auto-fill, minmax(66px, 1fr)); grid-auto-rows:66px; }
  .pet-sw { border-radius:18px; border-width:3px; }
  .pet-next, .pet-ok { --s:84px; }
  .pet-next { right:-4px; bottom:5vh; }
  .pet-side .pet-tray { padding-bottom:calc(84px + 5vh); }
  .pet-dice { --s:66px; top:6px; right:6px; }
  .pet-rename { --s:66px; top:6px; left:6px; }
  .pet-mic { --s:104px; }
  .pet-keys, .pet-retry { --s:68px; }
  .pet-namerow { gap:14px; }
  .pet-naming { gap:12px; padding-top:56px; }
  .pet-back { --s:64px; }
}
@media (max-height: 480px) {
  #petScreen { padding-bottom:16vh; }
  .pet-next { bottom:-6px; }
  .pet-side .pet-tray { padding-bottom:84px; }
  .pet-tabs { flex-wrap:nowrap; }
  .pet-naming { padding-top:8px; padding-left:70px; }
  .pet-back { top:0; bottom:auto; }
}
@media (prefers-reduced-motion: reduce) {
  #petScreen, .pet-air i, .pet-dice, .pet-mic, .pet-mic.listening .ring { animation:none !important; }
  .pet-air { display:none; }
}
