/* pet — your pet's place: its room, needs, care, shop, style, visits and games.
   The room is drawn in SVG (js/pet/catalog.js); this file lays it out and
   animates the pet with the same keyframes as the pets on screen (app.css). */

/* the pets walking over the app stay out of the room: your pet is right here */
.pet-page .cat, .pet-page .cat-bubble { display: none !important; }

/* ── header: your pet, how it feels, bond and coins ───────────────────────── */
.pet-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 10px; }
.pet-head h2 { margin: 0; font-family: var(--display); font-size: 1.35rem; line-height: 1.2; }
.pet-feel { margin: 0; color: var(--ink-soft); font-size: .92rem; }
.pet-bond { display: grid; gap: 2px; margin-top: 4px; max-width: 220px; }
.pet-bond small { font-weight: 700; color: var(--ink-soft); font-size: .75rem; }
.pet-bond-bar { height: 8px; border-radius: 99px; background: var(--paper-2); overflow: hidden; border: 1px solid var(--rule); }
.pet-bond-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--me), var(--you)); }
.pet-coins { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px 6px 8px; border-radius: 99px; background: var(--raised); border: 1px solid var(--rule); color: var(--ink); text-decoration: none; font-weight: 800; white-space: nowrap; box-shadow: 0 3px 0 var(--rule); }
.pet-coins .pi { color: #d9a52c; }

/* the pet as a picture (header, Home card): same animations as in the room */
.pet-sprite { width: 72px; height: 63px; flex: none; }
.pet-sprite svg { width: 100%; height: 100%; overflow: visible; }
.svgwrap :is(.zzz, .eye-closed, .paw-up) { display: none; }

/* ── tabs inside the pet area ──────────────────────────────────────────── */
.pet-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 0 12px; padding: 2px; }
.pet-tabs::-webkit-scrollbar { display: none; }
.pet-tabs a { flex: 1 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 6px 12px; border-radius: 99px; background: var(--paper-2); color: var(--ink); text-decoration: none; font-weight: 700; font-size: .88rem; border: 1px solid transparent; }
.pet-tabs a.on { background: var(--me); color: #fff; box-shadow: 0 3px 0 var(--me-strong); }
.pet-tabs a:focus-visible { outline: 3px solid var(--me); outline-offset: 2px; }

/* icons in the pet area (line, or emoji in the emoji icon style) */
.pi { display: inline-grid; place-items: center; width: 1.3em; height: 1.3em; line-height: 1; }
.pi svg { width: 100%; height: 100%; }
.pi-emoji { font-size: 1.1em; }

/* ── the room ──────────────────────────────────────────────────────────── */
.room-wrap { position: relative; margin: 0 0 12px; }
.room { position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: 22px; overflow: hidden; background: #fff6ea; isolation: isolate;
  border: 3px solid var(--raised); box-shadow: 0 0 0 1px var(--rule), 0 10px 26px rgba(91, 44, 63, .12); touch-action: manipulation; user-select: none; -webkit-user-select: none; }
[data-mode="dark"] .room { box-shadow: 0 0 0 1px var(--rule), 0 12px 30px rgba(0, 0, 0, .4); filter: brightness(.93) saturate(.95); }
.room-back, .room-back svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.room-layer, .room-fx { position: absolute; inset: 0; }
.ritem { position: absolute; pointer-events: none; }
.ritem-art { width: 100%; height: 100%; transform-origin: 50% 100%; }
.ritem[data-zone="wall"] .ritem-art { transform-origin: 50% 50%; }
.ritem svg { width: 100%; height: 100%; display: block; overflow: visible; }
.ritem[data-zone="floor"] .ritem-art { filter: drop-shadow(0 3px 0 rgba(120, 80, 60, .10)); }
/* lights: the room dims at night and when the lights are off; lamps glow */
.room-dark { position: absolute; inset: 0; z-index: 900; background: radial-gradient(120% 90% at 50% 40%, #2a2d63, #15173a); opacity: 0; pointer-events: none; transition: opacity 1.2s ease; }
.room-glow { position: absolute; inset: 0; z-index: 901; pointer-events: none; }
.room-glow i { position: absolute; border-radius: 50%; background: radial-gradient(closest-side, rgba(255, 228, 160, .55), rgba(255, 210, 140, .18) 55%, transparent); mix-blend-mode: screen; }
.room-fx { z-index: 950; pointer-events: none; }
.twinkle { animation: twinkle 3s ease-in-out infinite; animation-delay: var(--d, 0s); }
.bulb { animation: bulb 2.4s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes twinkle { 50% { opacity: .3; } }
@keyframes bulb { 50% { filter: brightness(1.35) drop-shadow(0 0 3px #fff3c4); } }

/* the pet in its room */
.rpet { position: absolute; width: 16%; height: 18.6667%; touch-action: none; cursor: grab; pointer-events: auto; }
.rpet svg { width: 100%; height: 100%; overflow: visible; transform: scaleX(var(--dir, 1)); transition: transform .15s; }
.rpet::after { content: ""; position: absolute; left: 18%; right: 18%; bottom: -3%; height: 9%; border-radius: 50%; background: rgba(90, 60, 50, .16); z-index: -1; }
.rpet-name { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); padding: 0 6px; border-radius: 8px; background: color-mix(in srgb, var(--raised) 80%, transparent); font: 800 .62rem/1.45 var(--text); color: var(--ink-soft); white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .3s; }
.rpet.guest .rpet-name, .room:hover .rpet-name { opacity: 1; }
.ct-pet { cursor: default; }

/* the shared skeleton's moves (same keyframes as the pets on screen) */
:is(.rpet, .pet-sprite) .leg { transform-box: fill-box; transform-origin: top center; }
:is(.rpet, .pet-sprite) .tail { transform-box: fill-box; transform-origin: 0% 100%; animation: tail 1.6s ease-in-out infinite; }
:is(.rpet, .pet-sprite) .body-g { transform-box: fill-box; transform-origin: bottom center; }
:is(.rpet, .pet-sprite) :is(.eye-closed, .zzz, .paw-up) { display: none; }
:is(.rpet, .pet-sprite) .acc { pointer-events: none; }
.rpet:is(.walk, .chase) .leg.a { animation: leg .36s ease-in-out infinite; }
.rpet:is(.walk, .chase) .leg.b { animation: leg .36s ease-in-out infinite reverse; }
.rpet:is(.walk, .chase) .body-g { animation: trot .36s ease-in-out infinite; }
.rpet.chase :is(.leg.a, .leg.b) { animation-duration: .24s; }
:is(.rpet, .pet-sprite).sit .body-g { transform: scaleY(.9) translateY(2px); }
:is(.rpet, .pet-sprite).sit .leg.back { transform: scaleY(.4); }
:is(.rpet, .pet-sprite):is(.sleep, .groom, .eat) .eye-open { display: none; }
:is(.rpet, .pet-sprite):is(.sleep, .groom, .eat) .eye-closed { display: block; }
:is(.rpet, .pet-sprite).sleep .body-g { animation: breathe 2.4s ease-in-out infinite; transform: scaleY(.8) translateY(5px); }
:is(.rpet, .pet-sprite).sleep .leg { transform: scaleY(.25); }
:is(.rpet, .pet-sprite).sleep .zzz { display: block; animation: zzz 2.4s ease-in-out infinite; }
:is(.rpet, .pet-sprite).sleep .tail { animation-duration: 4s; }
.rpet.groom .paw-up { display: block; animation: lick .5s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: bottom center; }
.rpet.groom .leg.front.a { opacity: 0; }
.rpet.land .body-g { animation: squash .45s var(--spring); }
:is(.rpet, .pet-sprite).happy .body-g { animation: purr .12s linear 8; }
:is(.rpet, .pet-sprite).happy svg { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--me) 60%, transparent)); }
.rpet.stretch .body-g { animation: stretch 2.2s ease-in-out; transform-origin: 30% 100%; }
.rpet.stretch .leg.front { animation: reach 2.2s ease-in-out; }
.rpet.eat .body-g { animation: munch .3s ease-in-out infinite alternate; transform-origin: 70% 100%; }
.rpet.dance svg { animation: cat-dance .5s ease-in-out infinite alternate; }
.pet-sprite.low .body-g { transform: scaleY(.88) translateY(3px); }

/* little effects: food dropping into the bowl, the ball, bubbles, the laser dot */
.room-pop { position: absolute; width: 6%; aspect-ratio: 1; }
.room-pop svg { width: 100%; height: 100%; }
.room-pop.drop { animation: pet-drop .6s cubic-bezier(.4, 0, .9, .6) both; }
.room-pop.toy { width: 7%; }
@keyframes pet-drop { from { transform: translateY(-90px); opacity: 0; } 30% { opacity: 1; } to { transform: none; } }
/* Toys are moved with transform every frame (no layout, no lag); left/top stay at 0. */
.room-ball { position: absolute; left: 0; top: 0; width: 4.5%; aspect-ratio: 1; will-change: transform; }
.room-ball svg { width: 100%; height: 100%; }
.room-ball.rolling svg { animation: spin .45s linear infinite; }
.room-laser { position: absolute; left: 0; top: 0; width: 2.2%; aspect-ratio: 1; border-radius: 50%; background: #ff3b5c; box-shadow: 0 0 8px 3px rgba(255, 59, 92, .55); will-change: transform; }
.room-laser.auto { transition: transform .35s ease-in-out; }   /* only when it wanders by itself */
.room-bubble { position: absolute; width: calc(4% * var(--s, 1)); aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 30% 30%, #fff 0 18%, rgba(201, 228, 246, .55) 40%, rgba(255, 255, 255, .25) 70%); border: 1px solid rgba(134, 179, 214, .6); animation: pet-bubble 2.2s ease-out both; }
@keyframes pet-bubble { from { transform: translateY(10px) scale(.3); opacity: 0; } 20% { opacity: 1; } to { transform: translateY(-60px) scale(1.1); opacity: 0; } }

/* buttons on the room */
.room-tools { position: absolute; top: 10px; right: 10px; z-index: 960; display: flex; gap: 6px; }
.room-tool { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--rule); background: color-mix(in srgb, var(--raised) 88%, transparent); color: var(--ink); display: grid; place-items: center; cursor: pointer; box-shadow: 0 3px 0 var(--rule); font-size: 1.05rem; }
.room-tool:focus-visible { outline: 3px solid var(--me); outline-offset: 2px; }

/* decorating */
.room.editing { cursor: default; }
.room.editing .ritem { pointer-events: auto; cursor: grab; touch-action: none; }
.room.editing .ritem:hover, .room.editing .ritem:focus-visible { outline: 2px dashed color-mix(in srgb, var(--me) 70%, transparent); outline-offset: 2px; border-radius: 6px; }
.room.editing .ritem.sel { outline: 2.5px solid var(--me); outline-offset: 2px; border-radius: 6px; }
.room.editing .ritem.drag { cursor: grabbing; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .18)); }
.room.editing .rpet { pointer-events: none; opacity: .55; }
.room.grid .room-layer { background-image: linear-gradient(to right, rgba(91, 44, 63, .08) 1px, transparent 1px), linear-gradient(to bottom, rgba(91, 44, 63, .08) 1px, transparent 1px); background-size: 2.5% 3.3333%; }
.pet-edit { display: grid; gap: 10px; margin-bottom: 12px; padding: 12px; border-radius: var(--r); background: var(--raised); border: 1px solid var(--rule); }
.pet-edit h3 { margin: 0; }
.pet-sel { display: grid; gap: 6px; min-height: 44px; }
.pet-sel-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.pet-sel-btns .btn { min-width: 40px; min-height: 40px; }
.pet-sel-btns .danger { color: var(--bad); }
.pet-tray { display: grid; gap: 8px; }
.pet-snap input { margin: 0 4px 0 0; }

/* ── needs and care ────────────────────────────────────────────────────── */
.pet-needs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
.pet-need { display: grid; justify-items: center; gap: 2px; padding: 6px 4px; border-radius: 14px; background: var(--raised); border: 1px solid var(--rule); min-width: 0; }
.pet-need .e { font-size: 1.1rem; line-height: 1.2; }
.pet-need small { font-size: .7rem; font-weight: 700; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; max-width: 100%; white-space: nowrap; }
.pet-need .bar { width: 100%; height: 6px; border-radius: 99px; background: var(--paper-2); overflow: hidden; }
.pet-need .bar i { display: block; height: 100%; border-radius: 99px; background: var(--matcha, #8cc9a0); transition: width .6s ease; }
.pet-need.low .bar i { background: var(--you); }
.pet-actions { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; margin-bottom: 14px; }
.pet-act { display: grid; justify-items: center; align-content: center; gap: 4px; min-height: 66px; padding: 8px 4px; border-radius: 18px; border: 1px solid var(--rule); background: var(--raised); color: var(--ink); font: inherit; font-weight: 700; font-size: .8rem; cursor: pointer; box-shadow: 0 4px 0 var(--rule); transition: transform .12s; }
.pet-act .pi { width: 1.7rem; height: 1.7rem; color: var(--me); }
.pet-act .pi-emoji { font-size: 1.5rem; }
.pet-act:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--rule); }
.pet-act.on { background: var(--me-tint); border-color: var(--me); }
.pet-act:focus-visible, .pet-pick-i:focus-visible, .pet-shop-i:focus-visible { outline: 3px solid var(--me); outline-offset: 2px; }
.pet-gift { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; font: inherit; color: var(--ink); cursor: pointer; margin-bottom: 4px; }
.pet-gift .pi { width: 2rem; height: 2rem; color: var(--me); }
.pet-gift-go { font-weight: 800; color: var(--me); }
.pet-selfcare .list li { display: flex; align-items: center; gap: 10px; }
.pet-selfcare .list li a { color: var(--ink); text-decoration: none; }
.pet-selfcare .list li:not(.done) { opacity: .62; }
.pet-selfcare .list li.done a { font-weight: 700; }
.pet-sc-coins { font-weight: 800; color: var(--me-strong); }
.pet-notify { margin-top: 12px; }

/* pick lists (food, toys, things to place) */
.pet-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.pet-pick.wide { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.pet-pick-i { display: grid; justify-items: center; gap: 2px; padding: 10px 6px; border-radius: 16px; border: 2px solid transparent; background: var(--paper-2); color: var(--ink); font: inherit; cursor: pointer; text-align: center; }
.pet-pick-i b { font-size: .82rem; line-height: 1.2; }
.pet-pick-i small { font-size: .72rem; color: var(--ink-soft); }
.pet-pick-i.on { border-color: var(--me); background: var(--me-tint); }
.pet-pick-i.off { opacity: .5; cursor: default; }
.pet-pick-i .art, .pet-shop-i .art { display: grid; place-items: center; width: 56px; height: 52px; }
.pet-pick-i .art .pi { width: 36px; height: 36px; color: var(--me); }
.art .svgwrap { display: block; width: 100%; height: 100%; }
.art .svgwrap svg { display: block; width: 100%; height: 100%; overflow: visible; }
.art.swatch { width: 100%; height: 52px; border-radius: 10px; overflow: hidden; border: 1px solid var(--rule); }
.art.swatch .svgwrap svg { width: 100%; height: 100%; }

/* ── shop ──────────────────────────────────────────────────────────────── */
.pet-cats { position: relative; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: thin; }
.pet-cats .chip { flex: none; }
.pet-shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; margin-bottom: 14px; }
.pet-shop-i { position: relative; display: grid; justify-items: center; gap: 2px; padding: 12px 6px 10px; border-radius: 18px; border: 1px solid var(--rule); background: var(--raised); color: var(--ink); font: inherit; cursor: pointer; text-align: center; box-shadow: 0 4px 0 var(--rule); }
.pet-shop-i .art { width: 72px; height: 66px; }
.pet-shop-i.wide { grid-column: span 2; }
.pet-shop-i.wide .art { width: 100%; height: 66px; border-radius: 12px; overflow: hidden; border: 1px solid var(--rule); }
.pet-shop-i.wide .art .svgwrap svg { width: 100%; height: 100%; }
.pet-shop-i b { font-size: .84rem; line-height: 1.2; }
.pet-shop-i small { font-size: .72rem; color: var(--ink-soft); }
.pet-shop-i.owned { cursor: default; box-shadow: none; }
.price { display: inline-flex; align-items: center; gap: 3px; margin-top: 2px; padding: 2px 10px 2px 6px; border-radius: 99px; background: var(--paper-2); font-weight: 800; font-size: .82rem; }
.price .pi { color: #d9a52c; width: 1.1em; height: 1.1em; }
.price.short { opacity: .6; }
.price.free { padding: 2px 10px; color: var(--good); }
.pet-buy-art { display: grid; place-items: center; height: 140px; }
.pet-buy-art .svgwrap { height: 100%; }
.pet-buy-art svg { height: 100%; width: auto; max-width: 100%; overflow: visible; }
.chip.locked { opacity: .75; }

/* ── visiting ──────────────────────────────────────────────────────────── */
.pet-visit-info { margin-bottom: 10px; }
.pet-visit-info h3 { margin: 0; }
.pet-empty { display: grid; justify-items: center; gap: 6px; padding: 24px 16px; }
.pet-empty .pet-sprite { width: 110px; height: 96px; }

/* ── games ─────────────────────────────────────────────────────────────── */
.pet-game { margin-bottom: 12px; }
.pet-game-card { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ct { display: grid; gap: 8px; }
.ct-top { display: flex; justify-content: space-between; font-weight: 700; }
.ct-field { position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: 20px; overflow: hidden; touch-action: none; cursor: pointer;
  background: linear-gradient(#d9eefb, #fff6ea 70%, #e9c49c 70.5%, #e2b98f); border: 3px solid var(--raised); box-shadow: 0 0 0 1px var(--rule); }
.ct-field:focus-visible { outline: 3px solid var(--me); outline-offset: 3px; }
.ct-pet { position: absolute; bottom: 3%; width: 16%; height: 18.6667%; }
.ct-treat { position: absolute; width: 6%; aspect-ratio: 1; }
.ct-treat svg { width: 100%; height: 100%; }
.ct-treat.got { animation: pop .3s ease-out forwards; }
.ct-pad { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ct-btn { min-height: 52px; font-size: 1.3rem; }

/* ── Home card ─────────────────────────────────────────────────────────── */
.pet-home { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pet-home .grow { min-width: 150px; }
.pet-home-go { display: block; border-radius: 18px; background: var(--paper-2); padding: 4px 6px; }
.pet-home-name { color: var(--ink); text-decoration: none; }
.pet-mini { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.pet-mini span { display: inline-flex; align-items: center; gap: 2px; font-size: .8rem; }
.pet-mini i { display: block; width: 26px; height: 5px; border-radius: 99px; background: var(--paper-2); overflow: hidden; }
.pet-mini b { display: block; height: 100%; background: var(--matcha, #8cc9a0); }
.pet-mini .low b { background: var(--you); }
.pet-home-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.pet-home-acts .btn { display: inline-flex; align-items: center; gap: 4px; }

/* phones: a bit tighter */
@media (max-width: 520px) {
  .pet-tabs { gap: 4px; }
  .pet-tabs a { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 0; padding: 5px 2px; font-size: .72rem; border-radius: 16px; }
  .pet-tabs a .pi { width: 1.25rem; height: 1.25rem; }
}
@media (max-width: 420px) {
  .pet-head h2 { font-size: 1.15rem; }
  .pet-sprite { width: 60px; height: 52px; }
  .pet-act { font-size: .72rem; min-height: 60px; }
  .room-tool { width: 36px; height: 36px; }
}
/* desktop: the room gets roomy, the care panel sits beside the needs */
@media (min-width: 900px) {
  .room { border-radius: 28px; max-width: min(100%, calc(60vh * 4 / 3)); margin: 0 auto; }
}

/* motion: gentle and still */
[data-fx="off"] :is(.rpet, .pet-sprite, .ct-pet) *, [data-fx="off"] .twinkle, [data-fx="off"] .bulb, [data-fx="off"] .room-bubble,
[data-fx="off"] .room-ball svg { animation: none !important; }
[data-fx="off"] .room-ball, [data-fx="off"] .room-laser { transition: none; }
@media (prefers-reduced-motion: reduce) {
  :is(.rpet, .pet-sprite) *, .twinkle, .bulb, .room-bubble, .room-ball svg, .room-pop.drop { animation: none !important; }
  .room-ball, .room-laser, .room-dark { transition: none; }
}

/* play modes (ball, laser): what to do, and a Done button */
.room-mode { position: absolute; left: 10px; top: 10px; z-index: 970; display: flex; align-items: center; gap: 10px;
  max-width: calc(100% - 120px); padding: 5px 5px 5px 12px; border-radius: 99px; background: color-mix(in srgb, var(--raised) 92%, transparent);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .14); font-size: .82rem; font-weight: 700; color: var(--ink); backdrop-filter: blur(6px); }
.room-mode span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-mode-stop { flex: none; border: 0; border-radius: 99px; padding: 7px 16px; background: var(--me-strong); color: var(--on-me, #fff); font: inherit; font-weight: 800; cursor: pointer; }
.room-mode-stop:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.room-ball { z-index: 800; pointer-events: none; }
.room-laser { z-index: 850; pointer-events: none; }
