/* Painting internals. Panel size and position live in styles.css. */
.crate, [data-act] { cursor: pointer; }
.crate { transition: fill 0.25s ease; }
.crate:hover { filter: brightness(1.12); }

/* Paper grain: scene.js paints the painting's two noise layers once into this canvas and switches the
   copies inside the SVG off. No blend mode here: a blended layer over a moving picture is what stuttered. */
.scene { position: relative; }
.scene > canvas.grain { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; pointer-events: none; }

/* wind: hover the painting and the clouds drift while the plants lean into gusts */
@property --painting-wind { syntax: "<number>"; inherits: true; initial-value: 0; }
@property --painting-gust { syntax: "<number>"; inherits: false; initial-value: 0; }
.scene { transition: --painting-wind 1.6s ease-out; }
.scene:hover { --painting-wind: 1; transition: --painting-wind 0.6s ease-out; }
.home-painting-clouds { animation: 9s linear infinite alternate paused painting-drift; }
.home-painting-sway { transform-box: fill-box; transform-origin: 50% 100%; animation: 3.2s ease-in-out infinite paused painting-gust; }
.home-painting-bush, .home-painting-grass { transform: skewX(calc(var(--painting-gust) * var(--painting-wind) * -2.5deg)); }
.home-painting-wheat { transform: rotate(calc(var(--painting-gust) * var(--painting-wind) * 1.4deg)); }
.home-painting-leaf, .home-painting-flower { transform: rotate(calc(var(--painting-gust) * var(--painting-wind) * 1deg)); }
.scene:hover .home-painting-clouds, .scene:hover .home-painting-sway { animation-play-state: running; }
@keyframes painting-drift { to { transform: translate(5%); } }
@keyframes painting-gust { 0%, to { --painting-gust: 0.1; } 50% { --painting-gust: 1; } }

/* one-shot click reactions */
.react { transform-box: view-box; }
.home-painting-sway.pulse, .pulse { animation: pulse 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
.sail { animation: sail 12s linear; }
.wobble { animation: wobble 0.9s ease-in-out; }
.spin-once { animation: turn 0.9s cubic-bezier(0.34, 1.3, 0.64, 1); }
@keyframes pulse { 40% { transform: scale(1.12); } }
/* out to sea past the right edge, then back to the berth; each leg eases on its own */
@keyframes sail {
    0%, 6% { transform: none; animation-timing-function: cubic-bezier(0.5, 0, 0.9, 0.6); }
    46%, 54% { transform: translateX(430px); animation-timing-function: cubic-bezier(0.1, 0.4, 0.4, 1); }
    100% { transform: none; }
}
@keyframes wobble { 25% { transform: rotate(-9deg); } 60% { transform: rotate(7deg); } 85% { transform: rotate(-2deg); } }

/* a puff of steam from the funnel, the engine or the chimneys when they sound */
.steam { opacity: 0; transform-box: fill-box; transform-origin: center; }
.sail .steam, .huff .steam { animation: steam 1.8s ease-out; }
@keyframes steam { 0% { opacity: 0; transform: scale(0.3); } 15% { opacity: 0.95; } 100% { opacity: 0; transform: translate(-16px, -34px) scale(1.7); } }

/* night: tap the sun */
.veil, .stars, .lights, .moonface { opacity: 0; transition: opacity 1.2s ease; }
/* the sun gives way to the moon in place: rays draw in and fade, one face dissolves into the other */
.sunface, .moonface, .rayset { transform-box: view-box; transform-origin: 0 0; }
.sunface { transition: opacity 1.2s ease; }
.rayset { transition: opacity 0.7s ease, transform 1.2s cubic-bezier(0.4, 0, 0.2, 1); }
.rays { animation: turn 40s linear infinite; }
.night .veil { opacity: 0.74; }
.night .stars, .night .lights, .night .moonface { opacity: 1; }
.night .sunface { opacity: 0; }
.night .rayset { opacity: 0; transform: scale(0.6) rotate(-45deg); }
.tw { animation: twinkle 3.5s ease-in-out infinite; }
.route { animation: march 1.6s linear infinite; }
@keyframes twinkle { 50% { opacity: 0.3; } }
@keyframes turn { to { transform: rotate(360deg); } }
@keyframes march { to { stroke-dashoffset: -11; } }

/* always moving */
.plane { animation: fly 52s linear -20s infinite; }
/* the crane's 16 s cycle: lift a container out at the left, carry it over, lower it behind the
   stack, come back empty. Trolley, hoist and cable share the same keyframe times so they stay joined;
   the cable is 21 units long and pays out by exactly what the hoist drops (90 left, 54 right). */
.trolley, .hoist, .cable { animation: 16s ease-in-out infinite; }
.trolley { animation-name: trolley; }
.hoist { animation-name: hoist; }
.cable { animation-name: cable; transform-box: fill-box; transform-origin: 50% 0; }
.load { animation: load 16s step-end infinite; }
.spin { transform-box: view-box; animation: turn 14s linear infinite; }
.bob { animation: bob 3.6s ease-in-out infinite alternate; }
.ripple { animation: ripple 4s ease-in-out infinite alternate; }
.smoke { animation: smoke 6s linear infinite; transform-box: fill-box; transform-origin: center; }
/* climbs left to right, passing just under the sun */
@keyframes fly { from { transform: translate(-140px, 300px) rotate(-6.5deg); } 70%, to { transform: translate(960px, 174px) rotate(-6.5deg); } }
@keyframes trolley { 0%, 14% { transform: translateX(0); } 40%, 66% { transform: translateX(67px); } 86%, 100% { transform: translateX(0); } }
@keyframes hoist { 0% { transform: translateY(90px); } 14%, 40% { transform: translateY(0); } 52%, 56% { transform: translateY(54px); } 66%, 86% { transform: translateY(0); } 98%, 100% { transform: translateY(90px); } }
@keyframes cable { 0% { transform: scaleY(5.2857); } 14%, 40% { transform: scaleY(1); } 52%, 56% { transform: scaleY(3.5714); } 66%, 86% { transform: scaleY(1); } 98%, 100% { transform: scaleY(5.2857); } }
/* the load is let go while hidden behind the stack and a new one is hooked on while hidden at the left */
@keyframes load { 0% { opacity: 1; } 54% { opacity: 0; } 99% { opacity: 1; } }
@keyframes bob { from { transform: translateY(-1px) rotate(-0.5deg); } to { transform: translateY(1.2px) rotate(0.5deg); } }
@keyframes ripple { from { transform: translateX(-5px); opacity: 0.4; } to { transform: translateX(6px); opacity: 1; } }
@keyframes smoke { from { transform: scale(0.35); opacity: 0; } 12% { opacity: 0.9; } to { transform: translate(30px, -46px) scale(1.5); opacity: 0; } }

/* sound toggle: sits in the page margin under the painting, clear of it and of the text */
.sound-toggle {
    position: fixed;
    right: 14px;
    bottom: 4px;
    z-index: 20;
    width: 26px;
    height: 26px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--color-text-tertiary);
    cursor: pointer;
    transition: var(--transition-smooth);
}
.sound-toggle:hover { color: #fff; border-color: rgba(168, 85, 247, 0.5); }
.sound-toggle svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sound-toggle[aria-pressed="false"] .on, .sound-toggle[aria-pressed="true"] .off { display: none; }
/* stacked layout: the painting fills the top, so the toggle goes to the end of the page */
@media (max-width: 999px) {
    .sound-toggle { position: static; margin: 0 20px 20px auto; }
}

/* petal burst */
.petal-bit {
    position: fixed;
    z-index: 30;
    width: 9px;
    height: 14px;
    margin: -7px 0 0 -4.5px;
    border-radius: 60% 60% 60% 60% / 80% 80% 30% 30%;
    pointer-events: none;
}

/* hold a still frame of the scene rather than strip it bare */
@media (prefers-reduced-motion: reduce) {
    .scene svg * { animation-play-state: paused !important; }
}

/* cursor: over the painting the drafting crosshair becomes a brush (tip is the hotspot); anything that reacts keeps the hand */
.scene { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' stroke-linejoin='round' stroke-linecap='round'%3E%3Cpath d='M13 19L28 4' stroke='%23141b33' stroke-width='5.6'/%3E%3Cpath d='M13 19L28 4' stroke='%23f3c14b' stroke-width='3.2'/%3E%3Cpath d='M8.5 20L12 23.5L15 20.5L11.5 17Z' fill='%23dfe5ee' stroke='%23141b33' stroke-width='1.3'/%3E%3Cpath d='M12 23.5L8.5 20C6 22 4.5 25 2.5 29.5C7 27.5 10 26 12 23.5Z' fill='%23e23b3b' stroke='%23141b33' stroke-width='1.3'/%3E%3C/svg%3E") 2 30, crosshair; }

/* the smudge brush's bitmap (tools.js) */
.smear { pointer-events: none; }
.smear canvas { display: block; }
