/* Quinn's Quest: the shop (play/shop.js).
   The same field journal as the guinea pig creator: the cloth-covered book, cream pages, picture tabs, big picture
   tiles and round stitched buttons from play/style.css. Behind it, the inside of the shop: striped paper, bunting,
   warm light. On the left page the fitting room; on the right the shelves. Every selector is .shop-* or #shopScreen.
   Nothing she can tap sits in the bottom 15% of the screen. */

#shopScreen { 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)) 16vh max(12px, env(safe-area-inset-left));
  background:
    radial-gradient(ellipse at 50% 18%, rgba(255,236,190,.55), transparent 55%),
    linear-gradient(180deg, rgba(60,30,40,0) 70%, rgba(60,30,40,.35)),
    repeating-linear-gradient(90deg, #f7d8e2 0 26px, #fdf0ea 26px 52px);
  animation:fade .3s ease; }
#shopScreen[hidden] { display:none !important; }
/* bunting along the top, and a soft lamp glow */
.shop-bunting { position:absolute; left:-20px; right:-20px; top:0; height:46px; pointer-events:none;
  background:
    radial-gradient(ellipse at 50% -30px, transparent 62px, rgba(120,70,60,.55) 63px, rgba(120,70,60,.55) 65px, transparent 66px) 0 -8px/150px 60px repeat-x,
    conic-gradient(from 150deg at 50% 0, transparent 0 0, #ff9cc0 0 60deg, transparent 60deg) 0 6px/50px 34px repeat-x;
  filter:drop-shadow(0 3px 2px rgba(60,30,40,.18)); }
.shop-bunting::after { content:''; position:absolute; inset:0; background: conic-gradient(from 150deg at 50% 0, transparent 0 0, #ffe28f 0 60deg, transparent 60deg) 25px 6px/50px 34px repeat-x; opacity:.95;
  -webkit-mask: linear-gradient(90deg, #000 0 50%, transparent 50%) 0 0/100px 100% repeat-x; mask: linear-gradient(90deg, #000 0 50%, transparent 50%) 0 0/100px 100% repeat-x; }
.shop-glow { position:absolute; inset:0; pointer-events:none; background: radial-gradient(circle at 12% 70%, rgba(255,214,107,.22), transparent 30%), radial-gradient(circle at 88% 30%, rgba(212,189,242,.28), transparent 32%);
  animation:shop-glow 7s ease-in-out infinite alternate; }
@keyframes shop-glow { to { opacity:.6; transform:translateY(-8px); } }

/* the book: the fitting room on the left page, the shelves on the right */
.shop-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.12fr); grid-template-rows:minmax(0, 1fr); grid-template-areas:"stage side"; }
.shop-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); }

/* the fitting room: a little stage with a curtain at the back, a spotlight on the floor */
.shop-stage { grid-area:stage; position:relative; min-height:0; border-radius:28px; overflow:visible;
  background:
    radial-gradient(ellipse at 50% 82%, rgba(255,250,236,.9), rgba(255,240,210,.35) 45%, transparent 70%),
    repeating-linear-gradient(90deg, rgba(200,70,122,.10) 0 14px, rgba(200,70,122,.03) 14px 28px) 0 0/100% 62% no-repeat,
    linear-gradient(180deg, rgba(240,122,160,.14), transparent 62%); }
.shop-stage::before { content:''; position:absolute; inset:6px; border-radius:24px; border:3px dashed rgba(200,70,122,.28); pointer-events:none; }
.shop-stage::after { content:''; position:absolute; left:8%; right:8%; top:62%; height:3px; border-radius:2px; background:rgba(169,121,74,.25); pointer-events:none; }
.shop-view { position:absolute; inset:0; z-index:1; width:100%; height:100%; display:block; image-rendering:pixelated; }
#shopScreen[data-shelf="me"] .shop-view, #shopScreen[data-shelf="pet"] .shop-view { cursor:pointer; }
.shop-tab:focus-visible, .shop-tile:focus-visible, .shop-buy:focus-visible, .shop-close:focus-visible { outline:3px solid var(--pink-d); outline-offset:3px; }

/* her gems: always in sight, top right of the fitting room (not something to tap) */
.shop-purse { position:absolute; top:10px; right:12px; z-index:2; display:flex; align-items:center; gap:8px; padding:8px 18px 8px 10px; border-radius:999px;
  background: var(--paper-tex), #fff1dc; border:3px solid #fff; box-shadow:0 4px 0 rgba(58,36,49,.22); font:800 30px/1 var(--hand); color:var(--ink); pointer-events:none; }
.shop-purse .ico { width:38px; height:38px; image-rendering:pixelated; }
.shop-purse.wobble, .shop-buy.wobble { animation:shop-wobble .7s ease-in-out; }
@keyframes shop-wobble { 15% { transform:rotate(-6deg) scale(1.06); } 35% { transform:rotate(5deg) scale(1.06); } 55% { transform:rotate(-3deg); } 75% { transform:rotate(2deg); } }

.shop-close { --c:#fff1dc; --d:var(--kraft-d); --s:72px; position:absolute; top:6px; left:6px; z-index:3; }
.shop-close::before { border-color:rgba(169,121,74,.55); }
.shop-close .ico { width:60%; height:60%; }

/* the one big buy button: a gem and the price */
.shop-buy { --s:96px; position:absolute; left:50%; bottom:14px; z-index:3; width:auto; min-width:150px; padding:0 28px 0 18px; border-radius:999px; transform:translateX(-50%);
  display:flex; align-items:center; justify-content:center; gap:10px; font:800 44px/1 var(--hand); color:#fff; text-shadow:0 2px 0 rgba(134,52,92,.6); }
.shop-buy::before { border-radius:999px; }
.shop-buy .ico { width:52px; height:52px; margin:0; filter:drop-shadow(0 2px 0 rgba(58,36,49,.25)); }
.shop-buy:active, .shop-buy.pressed { transform:translateX(-50%) translateY(5px) scale(.97); }
.shop-buy.wobble { animation:shop-wobble-x .7s ease-in-out; }
@keyframes shop-wobble-x { 15% { transform:translateX(-50%) rotate(-6deg) scale(1.06); } 35% { transform:translateX(-50%) rotate(5deg) scale(1.06); } 55% { transform:translateX(-50%) rotate(-3deg); } 75% { transform:translateX(-50%) rotate(2deg); } 100% { transform:translateX(-50%); } }
.shop-buy:not(:active):not(.wobble):not(.poor) { animation:shop-beckon 2.8s ease-in-out infinite; }
@keyframes shop-beckon { 0%, 70%, 100% { transform:translateX(-50%); } 80% { transform:translateX(-50%) scale(1.06); } 90% { transform:translateX(-50%) scale(.98); } }
.shop-buy.poor { --c:#e6c6d4; --d:#b48aa0; color:#fff; }
.shop-buy[hidden] { display:none; }

/* a celebration: stars, hearts and gems bursting out of the fitting room */
.shop-party { position:absolute; left:50%; top:52%; width:0; height:0; z-index:4; pointer-events:none; }
.shop-bit { position:absolute; left:-12px; top:-12px; width:24px; height:24px; opacity:0; }
.shop-party.go .shop-bit { animation:shop-burst 1.1s cubic-bezier(.2,.7,.3,1) forwards; }
@keyframes shop-burst { 0% { opacity:1; transform:translate(0,0) scale(.3) rotate(0); } 70% { opacity:1; } 100% { opacity:0; transform:translate(var(--dx), var(--dy)) scale(1) rotate(200deg); } }
.shop-bit.star { background: conic-gradient(from 0deg, #ffd66b 0 10%, transparent 10% 20%, #ffd66b 20% 30%, transparent 30% 40%, #ffd66b 40% 50%, transparent 50% 60%, #ffd66b 60% 70%, transparent 70% 80%, #ffd66b 80% 90%, transparent 90%); border-radius:50%; -webkit-mask: radial-gradient(circle, #000 55%, transparent 56%); mask: radial-gradient(circle, #000 55%, transparent 56%); }
.shop-bit.heart { background:#ff7fae; transform:rotate(45deg); border-radius:6px 50% 6px 50%; width:18px; height:18px; clip-path: path('M9 16 L2 9 A4.2 4.2 0 0 1 9 3 A4.2 4.2 0 0 1 16 9 Z'); }
.shop-bit.gem { background: linear-gradient(135deg, #bfe0ff 0 35%, #6aa8f0 35% 70%, #4b7fd0 70%); clip-path: polygon(25% 10%, 75% 10%, 95% 38%, 50% 95%, 5% 38%); }
.shop-bit.spark { background: radial-gradient(circle, #fffaf0 0 30%, rgba(255,250,240,0) 31%), linear-gradient(90deg, transparent 44%, #fffaf0 44% 56%, transparent 56%), linear-gradient(0deg, transparent 44%, #fffaf0 44% 56%, transparent 56%); }

/* the shelves */
.shop-side { grid-area:side; position:relative; min-height:0; display:flex; flex-direction:column; gap:12px; }
.shop-tabs { display:flex; gap:12px; padding:2px 2px 0; }
.shop-tabs[hidden] { display:none; }
.shop-tab { flex:none; width:80px; height:80px; border-radius:22px 22px 14px 14px; border:4px solid #fff; padding:6px; 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; }
.shop-tab > * { pointer-events:none; }
.shop-tabpic { display:block; image-rendering:pixelated; }
.shop-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); }
.shop-tab:active { transform:translateY(2px); box-shadow:0 1px 0 #dcc29c; }

.shop-tray { flex:1; min-height:0; overflow-y:auto; overflow-x:hidden; display:grid; grid-template-columns:repeat(auto-fill, minmax(124px, 1fr)); grid-auto-rows:124px; gap:16px;
  align-content:start; padding:22px 12px 24px; -webkit-overflow-scrolling:touch; overscroll-behavior:contain;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 6px, #000 calc(100% - 10px), transparent 100%); mask-image: linear-gradient(180deg, transparent 0, #000 6px, #000 calc(100% - 10px), transparent 100%); }
.shop-tile { position:relative; min-width:0; border-radius:22px; border:4px solid #fff; padding:0; display:grid; place-items:center; overflow:visible;
  background: radial-gradient(ellipse at 50% 78%, rgba(255,240,214,.95), rgba(255,250,240,0) 70%), var(--paper-tex), #fffaf0;
  box-shadow:0 4px 0 #e2cca8, 0 6px 12px rgba(60,30,40,.14); transition:transform .1s, box-shadow .1s; }
.shop-tile > * { pointer-events:none; }
.shop-tile:active { transform:translateY(3px) scale(.97); box-shadow:0 1px 0 #e2cca8; }
.shop-tile.sel { border-color:var(--sky-d); box-shadow:0 4px 0 #2f6f99, 0 0 0 4px rgba(75,147,196,.25), 0 8px 16px rgba(60,30,40,.18); }
.shop-tile.on { border-color:var(--pink); background: radial-gradient(ellipse at 50% 78%, rgba(255,214,228,.9), rgba(255,238,244,0) 70%), 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); }
.shop-pic { display:block; image-rendering:pixelated; margin-top:-8px; }
/* the price: a gem and a number, on a little paper tag */
.shop-tag { position:absolute; right:-8px; bottom:-10px; display:flex; align-items:center; gap:3px; padding:4px 10px 4px 5px; border-radius:999px;
  background: var(--paper-tex), #fff1dc; border:3px solid #fff; box-shadow:0 3px 0 rgba(58,36,49,.22); font:800 22px/1 var(--hand); color:var(--ink); }
.shop-tag .ico { width:24px; height:24px; image-rendering:pixelated; }
/* hers: a tick */
.shop-tick { position:absolute; right:-9px; top:-9px; width:36px; height:36px; border-radius:50%; background:var(--mint); display:grid; place-items:center; box-shadow:0 0 0 3px #fff, 0 3px 4px rgba(0,0,0,.2); }
.shop-tick .ico { width:72%; height:72%; }
/* how many more gems: empty gem pictures in a little paper pill along the top */
.shop-need { position:absolute; left:50%; top:-13px; transform:translateX(-50%); display:inline-flex; justify-content:center; align-items:center; gap:2px; padding:2px 7px; border-radius:999px;
  background:#fff6ec; border:2px solid #d4a4b8; box-shadow:0 2px 0 rgba(58,36,49,.16); font:800 17px/1 var(--hand); color:var(--ink); white-space:nowrap; z-index:2; animation:shop-pop .35s cubic-bezier(.2,1.6,.4,1); }
.shop-need .ico { width:18px; height:18px; filter:drop-shadow(0 1px 0 rgba(58,36,49,.15)); }
.shop-need b { margin-left:1px; }
@keyframes shop-pop { from { transform:translateX(-50%) scale(.4); opacity:0; } to { transform:translateX(-50%) scale(1); opacity:1; } }
/* a room thing's levels: three little dots */
.shop-pips { position:absolute; left:8px; top:6px; display:flex; gap:4px; }
.shop-pips i { width:12px; height:12px; border-radius:50%; background:#ead9c2; box-shadow:inset 0 0 0 2px #fff; }
.shop-pips i.on { background:var(--pink); }
.shop-empty { grid-column:1 / -1; justify-self:center; width:120px; height:90px; opacity:.5; }
.shop-empty .ico { width:100%; height:100%; }

/* her wardrobe: only her own clothes, nothing to buy */
#shopScreen.mine .shop-purse { display:none; }
#shopScreen.mine .shop-stage { background: radial-gradient(ellipse at 50% 82%, rgba(255,250,236,.9), rgba(255,240,210,.35) 45%, transparent 70%), repeating-linear-gradient(90deg, rgba(169,121,74,.12) 0 18px, rgba(169,121,74,.04) 18px 36px) 0 0/100% 62% no-repeat; }

/* standing up (tablet or phone held upright): the fitting room on top, the shelves underneath */
@media (orientation: portrait) {
  .shop-book.book { height:min(1080px, 100%); grid-template-columns:minmax(0, 1fr); grid-template-rows:minmax(0, 0.9fr) minmax(0, 1.2fr); grid-template-areas:"stage" "side"; column-gap:0; }
  .shop-book.book::after { background: var(--paper-tex), var(--fibre-tex), radial-gradient(ellipse at 25% 0%, #fffaf0, transparent 60%), var(--paper); }
  .shop-buy { left:auto; right:12px; bottom:12px; transform:none; }
  .shop-buy:active, .shop-buy.pressed { transform:translateY(5px) scale(.97); }
  .shop-buy.wobble { animation:shop-wobble .7s ease-in-out; }
  .shop-buy:not(:active):not(.wobble):not(.poor) { animation:shop-beckon-p 2.8s ease-in-out infinite; }
  @keyframes shop-beckon-p { 0%, 70%, 100% { transform:none; } 80% { transform:scale(1.06); } 90% { transform:scale(.98); } }
}
/* phones */
@media (max-width: 560px), (max-height: 480px) {
  .shop-book.book { --pad:10px; --in:10px; column-gap:28px; row-gap:8px; }
  .shop-tabs { gap:10px; }
  .shop-tab { width:66px; height:66px; border-width:3px; padding:4px; }
  .shop-tray { grid-template-columns:repeat(auto-fill, minmax(84px, 1fr)); grid-auto-rows:84px; gap:14px; padding:18px 8px 16px; }
  .shop-tile { border-radius:18px; border-width:3px; }
  .shop-tag { font-size:17px; padding:3px 7px 3px 3px; right:-6px; bottom:-8px; border-width:2px; }
  .shop-tag .ico { width:18px; height:18px; }
  .shop-tick { width:28px; height:28px; right:-7px; top:-7px; }
  .shop-need .ico { width:15px; height:15px; }
  .shop-pips i { width:9px; height:9px; }
  .shop-purse { font-size:22px; padding:5px 12px 5px 7px; top:6px; right:6px; }
  .shop-purse .ico { width:28px; height:28px; }
  .shop-close { --s:64px; top:4px; left:4px; }
  .shop-buy { --s:72px; min-width:120px; font-size:34px; padding:0 20px 0 12px; bottom:8px; }
  .shop-buy .ico { width:38px; height:38px; }
}
@media (max-height: 480px) {
  #shopScreen { padding-top:8px; padding-bottom:16vh; }
  .shop-book.book { column-gap:22px; grid-template-columns:minmax(0, 0.85fr) minmax(0, 1.25fr); }
  .shop-side { gap:6px; }
  .shop-tab { width:64px; height:64px; }
  .shop-stage .shop-purse { top:auto; bottom:8px; right:auto; left:8px; }
}
@media (prefers-reduced-motion: reduce) {
  #shopScreen, .shop-glow, .shop-buy, .shop-purse, .shop-need, .shop-party.go .shop-bit { animation:none !important; }
}
