/* ─── Kitchen and Bathroom games (js/kitchen-bath.js) ─────────────────
   Pack the Picnic Basket, Wash the Toys, the Bubble Bath scrub tools, the
   tea-party pour and the cupcake tasting. Kept apart from playhouse.css so
   the rooms' shared stylesheet stays small; the tokens are the same ones. */

/* Room entries */
.room-basket {
    position: absolute;
    z-index: 3;
    pointer-events: none;
    filter: drop-shadow(0 4px 6px rgba(30, 58, 49, 0.28));
}
.room-washline {
    position: absolute;
    z-index: 3;
    aspect-ratio: 1;
    pointer-events: none;
}
.room-washline > img:first-child { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 4px 6px rgba(30, 58, 49, 0.25)); }
.room-washline-toy {
    position: absolute;
    top: 30%;
    width: 15%;
    transform: translateX(-50%);
    transform-origin: 50% 0;
    animation: kb-swing 4.2s ease-in-out infinite;
}
.room-washline-toy[hidden] { display: none; }

/* Shared motion */
@keyframes kb-wiggle {
    0%, 100% { transform: translateX(0) rotate(0); }
    25% { transform: translateX(-4px) rotate(-3deg); }
    75% { transform: translateX(4px) rotate(3deg); }
}
@keyframes kb-swing {
    0%, 100% { rotate: -4deg; }
    50% { rotate: 4deg; }
}
@keyframes kb-scrub {
    0%, 100% { transform: translate(-50%, 0) scale(1); }
    30% { transform: translate(-54%, 0) scale(1.04, 0.96); }
    70% { transform: translate(-46%, 0) scale(0.97, 1.03); }
}
@keyframes kb-tap-turn {
    0%, 100% { transform: rotate(0); }
    15%, 80% { transform: rotate(-9deg); }
}
@keyframes kb-tap-pour {
    0% { clip-path: inset(0 0 42% 0); }
    22%, 80% { clip-path: inset(0 0 0 0); }
    100% { clip-path: inset(0 0 42% 0); }
}
@keyframes kb-suds-wash {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(45%) scale(0.5); opacity: 0; }
}
@keyframes kb-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(246, 196, 83, 0.0); }
    50% { box-shadow: 0 0 0 8px rgba(246, 196, 83, 0.45); }
}
@keyframes kb-sparkle {
    0% { opacity: 0; transform: translate(-50%, 0) scale(0.4); }
    30% { opacity: 1; transform: translate(-50%, -8px) scale(1.15); }
    100% { opacity: 0; transform: translate(-50%, -26px) scale(0.9); }
}
.kb-wiggle { animation: kb-wiggle 0.5s ease; }
.kb-swing { animation: kb-swing 0.9s ease-in-out 2; transform-origin: 50% 0; }
.kb-held { z-index: 20; cursor: grabbing; filter: drop-shadow(0 10px 10px rgba(30, 58, 49, 0.35)); transition: none; }
.kb-sparkle {
    position: absolute;
    left: 50%;
    top: 4%;
    z-index: 12;
    width: 34px;
    height: 34px;
    pointer-events: none;
    background: radial-gradient(circle, #fff7c2 0 30%, rgba(255, 224, 120, 0.9) 31% 55%, transparent 56%);
    clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
    animation: kb-sparkle 1s ease-out forwards;
}

/* ─── Bubble Bath scrub tools ───────────────────────────────── */
.bath-tool {
    pointer-events: auto;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: grab;
    touch-action: none;
    min-width: 64px;
    transition: transform 0.2s ease;
}
.bath-tool img { display: block; width: 100%; pointer-events: none; }
.bath-tool:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 3px; border-radius: 12px; }
.bath-rim--sponge, .bath-rim--soap { width: 14%; }
.bath-rim--sponge { left: 66%; }
.bath-rim--soap { left: 82%; }

/* ─── Tea party pour ────────────────────────────────────────── */
button.tea-pot {
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    width: 16%;
    aspect-ratio: 1;
    touch-action: none;
    transition: left 0.35s ease, top 0.35s ease, bottom 0.35s ease;
}
button.tea-pot img { display: block; width: 100%; pointer-events: none; }
button.tea-pot::before { content: ''; position: absolute; inset: -12px; }
button.tea-pot .tea-pot-pour { position: absolute; left: -22%; bottom: 0; width: 126%; max-width: none; }
button.tea-pot img[hidden] { display: none; }
button.tea-pot:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 3px; border-radius: 12px; }
.tea-pot--ready { animation: kb-glow 1.6s ease-in-out infinite; border-radius: 40%; }
.tea-pot--wiggle { animation: kb-wiggle 0.5s ease; }
.tea-pot--pouring { z-index: 6; }
.tea-pot--dragging { z-index: 7; cursor: grabbing; transition: none; filter: drop-shadow(0 8px 10px rgba(30, 58, 49, 0.3)); }
.tea-cup--target { animation: kb-glow 1s ease-in-out infinite; border-radius: 40%; }

/* ─── Cupcake tasting ───────────────────────────────────────── */
.bake-taste {
    position: absolute;
    left: 50%;
    bottom: 6%;
    z-index: 6;
    display: flex;
    gap: 0.5rem;
    transform: translateX(-50%);
    width: min(88%, 420px);
    justify-content: center;
}
.bake-taste[hidden] { display: none; }
.bake-taste-cake {
    flex: 1 1 0;
    min-width: 72px;
    max-width: 132px;
    aspect-ratio: 1;
    padding: 0.2rem;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-lg);
    background: var(--panel-soft);
    cursor: pointer;
    animation: kb-glow 2s ease-in-out infinite;
}
.bake-taste-cake img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.bake-taste-cake:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; }
.bake-taste-cake--eaten { animation: none; opacity: 0.25; transform: scale(0.8); transition: opacity 0.5s ease, transform 0.5s ease; }

/* ─── Pack the Picnic Basket ────────────────────────────────── */
.basket-overlay {
    background: radial-gradient(120% 90% at 50% 0%, rgba(60, 90, 50, 0.2), rgba(30, 58, 49, 0.55));
}
.basket-scene {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    border-radius: var(--radius-xl);
    background: linear-gradient(180deg, #d8efe0 0%, #c6e5cd 55%, #a9d3b0 100%);
}
.basket-blanket-img {
    position: absolute;
    left: 50%;
    bottom: -4%;
    width: 150%;
    height: 94%;
    object-fit: contain;
    transform: translateX(-50%);
    pointer-events: none;
}
.basket-blanket { position: absolute; left: 0; right: 0; bottom: 0; height: 60%; z-index: 2; padding: 0; border: 0; background: transparent; }
.basket-scene[data-stage="carry"] .basket-blanket { border: 3px dashed var(--gold); border-radius: var(--radius-xl); animation: kb-glow 1.6s ease-in-out infinite; }
.basket-guest {
    position: absolute;
    bottom: 25%;
    z-index: 3;
    width: 32%;
    height: 48%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}
.basket-guest-img { position: absolute; left: 14%; bottom: 20%; width: 72%; height: 80%; object-fit: contain; filter: drop-shadow(0 4px 6px rgba(30, 58, 49, 0.25)); pointer-events: none; }
.basket-plate { position: absolute; left: 18%; bottom: 3%; width: 64%; object-fit: contain; pointer-events: none; }
.basket-plate-food { position: absolute; left: 33%; bottom: 8%; width: 34%; height: 24%; object-fit: contain; pointer-events: none; }
.basket-plate-food[hidden] { display: none; }
.basket-napkin { position: absolute; left: 34%; bottom: -5%; width: 32%; object-fit: contain; pointer-events: none; }
.basket-like {
    position: absolute;
    right: 0;
    top: -2%;
    width: 30%;
    padding: 4%;
    border: 2px solid var(--glass-edge);
    border-radius: 50%;
    background: var(--panel-strong);
    object-fit: contain;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}
.basket-scene[data-stage="serve"] .basket-guest:not(.basket-guest--served) .basket-like { opacity: 1; transform: scale(1); }
.basket-guest--glow .basket-guest-img { animation: kb-swing 1s ease-in-out infinite; }
.basket-guest--glow::after { content: ''; position: absolute; inset: 0; border-radius: var(--radius-xl); animation: kb-glow 1.2s ease-in-out infinite; }
.basket-guest--served .basket-guest-img { animation: tea-nod 0.5s ease-out; }
.basket-guest:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; border-radius: var(--radius-lg); }
.basket-pack {
    position: absolute;
    left: 50%;
    top: 3%;
    z-index: 5;
    height: 32%;
    aspect-ratio: 1;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    transform: translateX(-50%);
    transition: top 0.6s ease, height 0.6s ease, left 0.6s ease;
}
.basket-pack img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 6px 8px rgba(30, 58, 49, 0.3)); pointer-events: none; }
.basket-pack--ready { animation: kb-glow 1.4s ease-in-out infinite; border-radius: 40%; }
.basket-pack--carry { animation: kb-wiggle 1.2s ease-in-out infinite; }
.basket-pack--carried { top: 74%; height: 26%; left: 50%; animation: none; }
.basket-pack:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 3px; border-radius: 12px; }
.basket-foods { display: flex; gap: 0.35rem; justify-content: center; }
.basket-foods[hidden] { display: none; }
.basket-food {
    display: grid;
    place-items: center;
    width: 60px;
    height: 60px;
    padding: 0.15rem;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-md);
    background: var(--panel-strong);
    box-shadow: var(--shadow-card);
    cursor: pointer;
}
.basket-food img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.basket-food--on { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(246, 196, 83, 0.3); }
.basket-food:disabled { opacity: 0.4; cursor: default; }
.basket-food:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; }
.basket-ghost {
    position: absolute;
    z-index: 30;
    pointer-events: none;
    transition: transform 0.55s cubic-bezier(0.3, 0.7, 0.4, 1), opacity 0.55s ease;
}

/* ─── Wash the Toys ─────────────────────────────────────────── */
.wash-overlay {
    background: radial-gradient(120% 90% at 50% 0%, rgba(80, 130, 150, 0.2), rgba(30, 58, 49, 0.55));
}
.wash-scene {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    border-radius: var(--radius-xl);
    background:
        linear-gradient(180deg, transparent 0 62%, rgba(255, 255, 255, 0.35) 62% 63%, transparent 63%),
        linear-gradient(180deg, #d8efe6 0%, #bfe3d6 62%, #a9d6c6 100%);
}
.wash-line {
    position: absolute;
    left: 6%;
    top: 1%;
    z-index: 3;
    width: 88%;
    height: 33%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}
.wash-line-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.wash-line--ready { animation: kb-glow 1.4s ease-in-out infinite; border-radius: var(--radius-lg); }
.wash-line:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; border-radius: var(--radius-lg); }
.wash-hang-row { position: absolute; inset: 0; pointer-events: none; }
.wash-hang-slot { position: absolute; top: 33%; width: 18%; height: 56%; transform: translateX(-50%); }
.wash-peg { position: absolute; left: 50%; top: -12%; width: 38%; transform: translateX(-50%); z-index: 2; opacity: 0; }
.wash-hung { position: absolute; left: 0; top: 0; width: 100%; height: 100%; object-fit: contain; transform-origin: 50% 0; }
.wash-hung[hidden] { display: none; }
.wash-hang-slot:has(.wash-hung:not([hidden])) .wash-peg { opacity: 1; }
.wash-basin {
    position: absolute;
    left: 20%;
    top: 42%;
    z-index: 2;
    width: 60%;
    height: 30%;
    border: 5px solid #f4efe3;
    border-radius: 18% 18% 42% 42% / 22% 22% 62% 62%;
    background: linear-gradient(180deg, #fffaf0, #e8dfcc);
    box-shadow: 0 8px 14px rgba(30, 58, 49, 0.25), inset 0 -6px 10px rgba(0, 0, 0, 0.08);
    overflow: visible;
}
.wash-water {
    position: absolute;
    left: 6%;
    right: 6%;
    top: 18%;
    bottom: 14%;
    border-radius: 14% 14% 40% 40% / 20% 20% 70% 70%;
    background: linear-gradient(180deg, #cfeaf7, #8fc9e6);
    opacity: 0.85;
}
.wash-basin--rinse .wash-water { animation: kb-glow 0.6s ease-in-out 2; }
.wash-basin-toy {
    position: absolute;
    left: 50%;
    top: -34%;
    z-index: 3;
    width: 44%;
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    transform: translateX(-50%);
}
.wash-basin-toy[hidden] { display: none; }
.wash-basin-toy img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; filter: drop-shadow(0 4px 6px rgba(30, 58, 49, 0.25)); }
.wash-basin-toy.kb-scrub { animation: kb-scrub 0.5s ease; }
.wash-basin-toy:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; border-radius: 12px; }
.wash-suds { position: absolute; z-index: 4; width: 34%; pointer-events: none; }
.wash-suds[hidden] { display: none; }
.wash-suds--1 { left: 4%; top: -38%; }
.wash-suds--2 { right: 4%; top: -30%; }
.wash-suds--3 { left: 33%; top: -12%; }
.wash-sparkle { position: absolute; left: 50%; top: -42%; z-index: 5; width: 44%; transform: translateX(-50%); pointer-events: none; }
.wash-sparkle[hidden] { display: none; }
.wash-tap {
    position: absolute;
    left: 55%;
    top: 26%;
    z-index: 4;
    width: 24%;
    aspect-ratio: 1;
    min-width: 64px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}
.wash-tap img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; clip-path: inset(0 0 42% 0); }
/* Rinse: the tap turns, the stream runs down onto the toy, then it stops. */
.wash-tap--running { animation: kb-tap-turn 1.7s ease-in-out forwards; }
.wash-tap--running img { animation: kb-tap-pour 1.7s ease-in-out forwards; }
.wash-suds--rinse { animation: kb-suds-wash 1.3s 0.3s ease-in forwards; }
.wash-tap--ready { animation: kb-glow 1.2s ease-in-out infinite; border-radius: 40%; }
.wash-tap:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; border-radius: 12px; }
.wash-sponge {
    position: absolute;
    left: 3%;
    top: 31%;
    z-index: 6;
    width: 17%;
    min-width: 64px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: grab;
    touch-action: none;
}
.wash-sponge img { display: block; width: 100%; pointer-events: none; }
.wash-sponge:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 3px; border-radius: 12px; }
.wash-scene[data-stage="scrub"] .wash-sponge { animation: kb-glow 1.4s ease-in-out infinite; border-radius: 30%; }
.wash-pile { position: absolute; left: 3%; right: 26%; bottom: 3%; z-index: 3; display: flex; gap: 0.4rem; justify-content: center; }
.wash-toy {
    flex: 1 1 0;
    max-width: 96px;
    min-width: 64px;
    aspect-ratio: 1;
    padding: 0.2rem;
    border: 2px solid var(--glass-edge);
    border-radius: var(--radius-lg);
    background: var(--panel-soft);
    cursor: pointer;
}
.wash-toy[hidden] { display: none; }
.wash-toy img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.wash-scene[data-stage="pick"] .wash-toy { animation: kb-glow 2s ease-in-out infinite; }
.wash-toy:focus-visible { outline: 3px solid var(--on-primary); outline-offset: 2px; }
.wash-towel { position: absolute; right: 3%; bottom: 3%; z-index: 2; width: 22%; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
    .room-washline-toy, .kb-wiggle, .kb-swing, .kb-sparkle, .tea-pot--ready, .tea-pot--wiggle,
    .bake-taste-cake, .basket-pack--ready, .basket-pack--carry, .basket-guest--glow .basket-guest-img,
    .basket-guest--glow::after, .basket-scene[data-stage="carry"] .basket-blanket,
    .wash-line--ready, .wash-basin--rinse .wash-water, .wash-basin-toy.kb-scrub, .wash-tap--ready,
    .wash-scene[data-stage="scrub"] .wash-sponge, .wash-scene[data-stage="pick"] .wash-toy,
    .wash-tap--running, .wash-tap--running img, .wash-suds--rinse {
        animation: none !important;
    }
    /* No motion: the stream just shows while the tap is on, and the suds are gone. */
    .wash-tap--running { transform: rotate(-9deg); }
    .wash-tap--running img { clip-path: none; }
    .wash-suds--rinse { opacity: 0.25; }
    .basket-pack, .basket-ghost, .bake-taste-cake--eaten, .basket-like { transition: none !important; }
}
