/* The street through the day (street.js): milkman and newspaper boy at dawn, the sabzi wala at midday,
   gully cricket in the evening, a sleeping dog under the lamp post at night.
   Street geometry (from building.css): pavement 0-28px, kerb 28-34px, road 34-110px. */

:root,
html[data-scene="day"] {
  --sx-shadow: rgba(0, 0, 0, 0.2);
  --sx-tyre: #23252b;
  --sx-spoke: #c9ced6;
  --sx-frame: #2f6fa8;
  --sx-frame-red: #c23a2c;
  --sx-dark: #2a2026;
  --sx-steel: #cfd6de;
  --sx-steel2: #a3aebb;
  --sx-shine: rgba(255, 255, 255, 0.85);
  --sx-gamchha: #c9473b;
  --sx-topi: #fbf7ee;
  --sx-news: #e2dccd;
  --sx-print: #6f6858;
  --sx-band: #d0452f;
  --sx-bag: #7c6f3e;
  --sx-bag2: #93844c;
  --sx-basket: #c0904d;
  --sx-cap: #d0452f;
  --sx-tee-boy: #e8a33a;
  --sx-kurta: #4f86a8;
  --sx-turban: #e8911f;
  --sx-greens: #3f8a3a;
  --sx-greens2: #69b44a;
  --sx-tomato: #e0412d;
  --sx-onion: #b04a74;
  --sx-carrot: #f07e22;
  --sx-brinjal: #5d2c75;
  --sx-cauli: #f6f0dc;
  --sx-lemon: #f3d23a;
  --sx-chilli: #2e8b3a;
  --sx-stump: #ecd59f;
  --sx-ball: #d23a2c;
  --sx-tee-a: #3f7fd0;
  --sx-tee-b: #e05a8a;
  --sx-tee-c: #3ea36b;
  --sx-shorts-a: #2d3550;
  --sx-shorts-b: #6b4b8a;
  --sx-shorts-c: #8a6a3a;
  --sx-cap2: #f2c230;
  --sx-blade: #e6c58a;
  --sx-chalk: rgba(255, 255, 255, 0.7);
  --sx-dog: #cf9f68;
  --sx-dog2: #a9773f;
  --sx-dog3: #f4ead8;
  --sx-collar: #d63b3b;
  --sx-bubble: #fffaf0;
  --sx-bubble-ink: #2a2026;
  --sx-z: #6b5a50;
}
html[data-scene="night"] {
  --sx-shadow: rgba(0, 0, 0, 0.35);
  --sx-spoke: #8e939c;
  --sx-frame: #2a557e;
  --sx-frame-red: #94302a;
  --sx-steel: #a9b2bd;
  --sx-steel2: #7f8a98;
  --sx-shine: rgba(255, 255, 255, 0.5);
  --sx-topi: #e8e2d4;
  --sx-news: #ddd6c6;
  --sx-bag: #5d5430;
  --sx-bag2: #6e6438;
  --sx-basket: #957140;
  --sx-tee-boy: #c28a32;
  --sx-kurta: #3d6884;
  --sx-greens: #33703a;
  --sx-greens2: #4f8f3e;
  --sx-tomato: #b8392b;
  --sx-carrot: #c96a20;
  --sx-cauli: #ddd6c2;
  --sx-lemon: #d1b432;
  --sx-dog: #a98257;
  --sx-dog2: #876137;
  --sx-dog3: #d9cfbd;
  --sx-collar: #b8302f;
  --sx-bubble: #f6ecd6;
  --sx-z: #fff6d6;
}

/* ---------- Fills and strokes ---------- */
.sx-shadow { fill: var(--sx-shadow); }
.sx-tyre { fill: none; stroke: var(--sx-tyre); stroke-width: 2.6; }
.sx-spoke, .sx-frame, .sx-rack, .sx-crank, .sx-seat, .sx-bar, .sx-leg, .sx-shin, .sx-shorts, .sx-shoe, .sx-arm, .sx-strap,
.sx-stache, .sx-smile, .sx-fold, .sx-can-band, .sx-shine, .sx-print, .sx-band, .sx-weave, .sx-handle, .sx-pole, .sx-cord, .sx-axle,
.sx-leg-bare, .sx-chappal, .sx-stem, .sx-leafy, .sx-chilli, .sx-check, .sx-stump, .sx-bail, .sx-bat-handle, .sx-tee-num,
.sx-tail, .sx-collar, .sx-eye-shut, .sx-mouth-line, .sx-fur {
  fill: none; stroke-linecap: round; stroke-linejoin: round;
}
.sx-spoke { stroke: var(--sx-spoke); stroke-width: 1; }
.sx-frame { stroke: var(--sx-frame); stroke-width: 2.6; }
.sx-frame.red { stroke: var(--sx-frame-red); }
.sx-rack, .sx-crank { stroke: var(--sx-dark); stroke-width: 1.6; }
.sx-ring { fill: none; stroke: var(--sx-dark); stroke-width: 1.4; }
.sx-seat { stroke: var(--sx-dark); stroke-width: 3; }
.sx-bar { stroke: var(--sx-dark); stroke-width: 2; }
.sx-leg { stroke: var(--pants); stroke-width: 4.4; }
.sx-leg.far, .sx-shin.far, .sx-leg-bare.far { filter: brightness(0.75); }
.sx-shin, .sx-leg-bare { stroke: var(--skin); stroke-width: 3.2; }
.sx-leg-bare { stroke-width: 3.6; }
.sx-shorts { stroke: var(--pants); stroke-width: 5; }
.sx-shoe { stroke: var(--sx-dark); stroke-width: 2.6; }
.sx-chappal { stroke: #6b4a2c; stroke-width: 2; }
.sx-arm { stroke: var(--skin); stroke-width: 3.4; }
.sx-arm.thin { stroke-width: 2.8; }
.sx-strap { stroke: #5b4a2a; stroke-width: 1.4; }
.sx-stache { stroke: var(--hair); stroke-width: 1.2; }
.sx-smile { stroke: #6b2f2a; stroke-width: 0.9; }
.sx-mouth { fill: #6b2f2a; }
.sx-fold { stroke: rgba(0, 0, 0, 0.15); stroke-width: 1; }
.sx-gamchha { fill: var(--sx-gamchha); }
.sx-check { stroke: rgba(255, 255, 255, 0.55); stroke-width: 1; }
.sx-topi { fill: var(--sx-topi); }
.sx-steel > * { fill: var(--sx-steel); }
.sx-steel2 > * { fill: var(--sx-steel2); }
.sx-shine { stroke: var(--sx-shine); stroke-width: 1.4; }
.sx-can-band { stroke: rgba(0, 0, 0, 0.18); stroke-width: 1; }
.sx-news { fill: var(--sx-news); stroke: rgba(40, 30, 20, 0.55); stroke-width: 0.8; }
.sx-news-end { fill: #bdb5a2; }
.sx-print { stroke: var(--sx-print); stroke-width: 0.7; }
.sx-band { stroke: var(--sx-band); stroke-width: 1.2; }
.sx-bag { fill: var(--sx-bag); }
.sx-bag-flap { fill: var(--sx-bag2); }
.sx-basket { fill: var(--sx-basket); }
.sx-weave { stroke: rgba(0, 0, 0, 0.22); stroke-width: 0.8; }
.sx-cap { fill: var(--sx-cap); }
.sx-tee-boy { fill: var(--sx-tee-boy); }
.sx-kurta { fill: var(--sx-kurta); }
.sx-turban { fill: var(--sx-turban); }
.sx-handle { stroke: var(--wood2); stroke-width: 3; }
.sx-axle { stroke: var(--sx-dark); stroke-width: 2; }
.sx-pole { stroke: #6b5a44; stroke-width: 1.6; }
.sx-cord { stroke: #8d8678; stroke-width: 0.6; }
.sx-pan { fill: #c9a24d; }
.sx-greens { fill: var(--sx-greens); }
.sx-greens2 { fill: var(--sx-greens2); }
.sx-tomato > * { fill: var(--sx-tomato); }
.sx-stem { stroke: var(--sx-greens); stroke-width: 1.2; }
.sx-onion > * { fill: var(--sx-onion); }
.sx-carrot { fill: var(--sx-carrot); }
.sx-leafy { stroke: var(--sx-greens2); stroke-width: 1.2; }
.sx-brinjal > * { fill: var(--sx-brinjal); }
.sx-chilli { stroke: var(--sx-chilli); stroke-width: 1.6; }
.sx-cauli > * { fill: var(--sx-cauli); }
.sx-lemon > * { fill: var(--sx-lemon); }
.sx-stump { stroke: var(--sx-stump); stroke-width: 2.2; }
.sx-bail { stroke: var(--sx-stump); stroke-width: 1.4; }
.sx-ball-art { fill: var(--sx-ball); }
.sx-tee-a { fill: var(--sx-tee-a); }
.sx-tee-b { fill: var(--sx-tee-b); }
.sx-tee-c { fill: var(--sx-tee-c); }
.sx-tee-num { stroke: rgba(255, 255, 255, 0.8); stroke-width: 1.2; }
.sx-shorts-a { fill: var(--sx-shorts-a); }
.sx-shorts-b { fill: var(--sx-shorts-b); }
.sx-shorts-c { fill: var(--sx-shorts-c); }
.sx-cap2 { fill: var(--sx-cap2); }
.sx-bat-handle { stroke: #3a2a1a; stroke-width: 1.8; }
.sx-blade { fill: var(--sx-blade); stroke: rgba(0, 0, 0, 0.25); stroke-width: 0.5; }
.sx-dog { fill: var(--sx-dog); }
.sx-dog2 { fill: var(--sx-dog2); }
.sx-dog3 { fill: var(--sx-dog3); }
.sx-fur { stroke: rgba(0, 0, 0, 0.14); stroke-width: 0.8; }
.sx-tail { stroke: var(--sx-dog2); stroke-width: 4; }
.sx-collar { stroke: var(--sx-collar); stroke-width: 2.2; }
.sx-tag { fill: #e2b04e; }
.sx-nose { fill: #2a1a14; }
.sx-mouth-line { stroke: rgba(42, 26, 20, 0.6); stroke-width: 0.7; }
.sx-eye-shut { stroke: #2a1a14; stroke-width: 1; }
.sx-eye-open { fill: #2a1a14; display: none; }
.sx-tail-up { display: none; }

/* ---------- Layout ---------- */
.sx-layer { position: absolute; top: 100%; left: 0; height: 110px; z-index: 5; pointer-events: none; overflow-x: clip; overflow-y: visible; }
.sx-char {
  position: absolute; left: 0; display: block; padding: 0; margin: 0; border: 0; background: none;
  cursor: pointer; pointer-events: auto; -webkit-tap-highlight-color: transparent;
}
.sx-char svg { display: block; width: 100%; height: 100%; overflow: visible; }
.sx-flip svg { transform: scaleX(-1); }
.sx-char:focus-visible, .sx-dog-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sx-moving { will-change: transform; }

.sx-milk { bottom: 42px; z-index: 1; width: 92px; height: 58px; }
.sx-paperboy { bottom: 6px; z-index: 3; width: 84px; height: 54px; }
.sx-paperboy.thrown .sx-held { display: none; }

.sx-thela { position: absolute; left: 0; bottom: 5px; z-index: 2; width: 128px; height: 63px; }
.sx-thela .sx-char { inset: 0; width: 100%; height: 100%; }
.sx-bubble {
  position: absolute; left: 50%; bottom: calc(100% - 2px); z-index: 1; white-space: nowrap;
  padding: 3px 9px 4px; border-radius: 12px; background: var(--sx-bubble); color: var(--sx-bubble-ink);
  font: 600 12px/1.3 var(--font-body); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
  transform: translateX(-50%); opacity: 0; visibility: hidden;
}
.sx-bubble::after {
  content: ""; position: absolute; left: 30%; top: 100%; border: 5px solid transparent; border-top-color: var(--sx-bubble); border-bottom: 0;
}
.sx-flip .sx-bubble::after { left: auto; right: 30%; }
.sx-bubble.show { opacity: 1; visibility: visible; }
.sx-veg { font-size: 12px; letter-spacing: 1px; }
.sx-thela.filmi .sx-call { font-style: italic; letter-spacing: 0.02em; } /* the big debut line */

.sx-stumps { position: absolute; bottom: 9px; z-index: 2; width: 18px; height: 30px; }
.sx-stumps svg { display: block; width: 100%; height: 100%; }
.sx-crease { position: absolute; bottom: 8px; z-index: 1; width: 3px; height: 30px; background: var(--sx-chalk); border-radius: 2px; transform: skewX(-30deg); opacity: 0.55; }
.sx-kid { bottom: 6px; z-index: 3; width: 45px; height: 58px; }
.sx-fielder { bottom: 41px; z-index: 1; width: 36px; height: 47px; }
.sx-ball { position: absolute; left: 0; top: 0; z-index: 25; width: 6px; height: 6px; border-radius: 50%; background: var(--sx-ball); box-shadow: inset -1px -1px 0 rgba(0, 0, 0, 0.25); pointer-events: none; }

.sx-fly-paper { position: absolute; left: 0; top: 0; z-index: 25; width: 22px; height: 8px; pointer-events: none; }
.sx-fly-paper svg, .sx-sill-paper svg { display: block; width: 100%; height: 100%; }
.sx-sill-paper { position: absolute; z-index: 4; width: 24px; height: 9px; pointer-events: none; transition: opacity 1.2s; filter: drop-shadow(0 1.5px 0 rgba(0, 0, 0, 0.3)); }
.sx-sill-paper.gone { opacity: 0; }

/* The dog lives inside .street, on the pavement (y 0-33, paws on the kerb), under both traffic lanes
   (vehicles are z-index 2-3). His Zzz live in the building, just above the street's top edge. */
.sx-dog-btn {
  position: absolute; bottom: 77px; z-index: 1; width: 58px; height: 33px; padding: 0; margin: 0; border: 0; background: none;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.sx-dog-btn svg { display: block; width: 100%; height: 100%; overflow: visible; }
.sx-zs { position: absolute; bottom: 0; z-index: 6; width: 22px; height: 30px; pointer-events: none; }
.sx-z { position: absolute; left: 4px; bottom: -4px; font: italic 700 10px var(--font-display); color: var(--sx-z); opacity: 0.75; }
.sx-z:nth-child(2) { left: 8px; bottom: 6px; font-size: 11px; }
.sx-z:nth-child(3) { left: 13px; bottom: 16px; font-size: 13px; }
.sx-zs.awake { display: none; }
.sx-dog-btn.awake .sx-eye-open, .sx-dog-btn.awake .sx-tail-up { display: inline; }
.sx-dog-btn.awake .sx-eye-shut, .sx-dog-btn.awake .sx-tail-curl { display: none; }
.sx-dog-head { transform-box: view-box; }
.sx-dog-btn.awake .sx-dog-head { transform: rotate(-18deg) translateY(-2px); }

/* ---------- Motion ---------- */
.sx-layer.idle *, .sx-dog-btn.idle *, .sx-zs.idle * { animation-play-state: paused !important; }
@media (prefers-reduced-motion: no-preference) {
  .sx-spin { transform-box: fill-box; transform-origin: center; }
  .sx-moving .sx-spin, .sx-thela.walking .sx-spin { animation: sx-turn 0.55s linear infinite; }
  @keyframes sx-turn { to { transform: rotate(360deg); } }
  .sx-pedal-a, .sx-pedal-b, .sx-walk-a, .sx-walk-b, .sx-throw, .sx-bat, .sx-bowl, .sx-ear, .sx-tail-up, .sx-breathe { transform-box: view-box; }
  .sx-moving .sx-pedal-a { animation: sx-pedal 0.55s ease-in-out infinite alternate; }
  .sx-moving .sx-pedal-b { animation: sx-pedal 0.55s ease-in-out infinite alternate-reverse; }
  @keyframes sx-pedal { from { transform: rotate(-13deg); } to { transform: rotate(9deg); } }
  .sx-moving .sx-rider { animation: sx-bob 0.55s ease-in-out infinite alternate; }
  @keyframes sx-bob { to { transform: translateY(-0.8px); } }
  .sx-thela.walking .sx-walk-a { animation: sx-stride 0.9s ease-in-out infinite alternate; }
  .sx-thela.walking .sx-walk-b { animation: sx-stride 0.9s ease-in-out infinite alternate-reverse; }
  @keyframes sx-stride { from { transform: rotate(-13deg); } to { transform: rotate(13deg); } }
  .sx-thela.walking .sx-char { animation: sx-bob 0.45s ease-in-out infinite alternate; }
  .sx-paperboy.throwing .sx-throw { animation: sx-throw 0.6s ease-in-out 1; }
  @keyframes sx-throw { 0% { transform: none; } 40% { transform: rotate(-60deg); } 72% { transform: rotate(75deg); } 100% { transform: none; } }

  .sx-bubble { transition: opacity 0.25s, transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1), visibility 0.25s; transform: translateX(-50%) scale(0.6); transform-origin: 50% 100%; }
  .sx-bubble.show { transform: translateX(-50%) scale(1); }
  .sx-call { display: inline-block; }

  .sx-kid > svg { animation: sx-bob 1.6s ease-in-out infinite alternate; } /* kids are never flipped */
  .sx-bat { animation: sx-tap 1.4s ease-in-out infinite; }
  @keyframes sx-tap { 0%, 60%, 100% { transform: none; } 70% { transform: rotate(10deg); } 80% { transform: rotate(-2deg); } 90% { transform: rotate(8deg); } }
  .sx-batter.swing .sx-bat { animation: sx-swing 0.6s cubic-bezier(0.3, 0.6, 0.4, 1) 1; }
  @keyframes sx-swing { 0% { transform: none; } 30% { transform: rotate(95deg); } 60% { transform: rotate(-120deg); } 100% { transform: none; } }
  .sx-bowler.bowling .sx-bowl { animation: sx-windmill 0.65s ease-in 1; }
  @keyframes sx-windmill { to { transform: rotate(-360deg); } }
  .sx-bowler.bowling .sx-ball-art { animation: sx-release 0.65s steps(1) 1; }
  @keyframes sx-release { 0% { opacity: 1; } 66% { opacity: 0; } 100% { opacity: 0; } }
  .sx-fielder.hop { animation: sx-hop 0.52s ease-out 1; }
  @keyframes sx-hop { 40% { transform: translateY(-8px); } 100% { transform: none; } }

  .sx-sill-paper.land { animation: sx-land 0.45s ease-out 1; }
  @keyframes sx-land { 0% { transform: translateY(-4px) rotate(-14deg); } 55% { transform: translateY(0) rotate(4deg); } 100% { transform: none; } }

  .sx-breathe { transform-origin: 30px 34px; animation: sx-breathe 3.8s ease-in-out infinite; }
  @keyframes sx-breathe { 50% { transform: scale(1.015, 1.07); } }
  .sx-ear { animation: sx-twitch 7s ease-in-out infinite; }
  @keyframes sx-twitch { 0%, 84%, 100% { transform: none; } 87% { transform: rotate(-20deg); } 90% { transform: none; } 93% { transform: rotate(-12deg); } 96% { transform: none; } }
  .sx-dog-head { transition: transform 0.35s cubic-bezier(0.3, 1.4, 0.5, 1); }
  .sx-dog-btn.awake .sx-tail-up { animation: sx-wag 0.18s ease-in-out infinite alternate; }
  @keyframes sx-wag { from { transform: rotate(-22deg); } to { transform: rotate(18deg); } }
  .sx-z { opacity: 0; animation: sx-z 4.2s linear infinite; }
  .sx-z:nth-child(1) { left: 4px; bottom: -4px; }
  .sx-z:nth-child(2) { left: 4px; bottom: -4px; animation-delay: -1.4s; }
  .sx-z:nth-child(3) { left: 4px; bottom: -4px; animation-delay: -2.8s; }
  @keyframes sx-z { 0% { opacity: 0; transform: translate(0, 0) scale(0.7); } 20% { opacity: 0.85; } 100% { opacity: 0; transform: translate(10px, -28px) scale(1.25); } }
}
@media (prefers-reduced-motion: reduce) {
  .sx-z:not(:first-child) { display: none; }
}
