/* Road traffic by the clock (traffic.js). Vehicles live inside .street (pavement 0-28px, kerb 28-34px,
   road 34-110px, centre line 70-74px). Near lane: wheels at the bottom, right to left. Far lane: above
   the centre line, left to right, drawn smaller and behind the near lane. */

:root,
html[data-scene="day"] {
  --tr-dark: #1f2128;
  --tr-glass: rgba(190, 225, 255, 0.6);
  --tr-person: #2a1f25;
  --tr-chrome: #c9ced6;
  --tr-seat: #2a2026;
  --tr-legs: #2f3a52;
  --tr-tail: #b83a30;
  --tr-tarp: #2f64b8;
  --tr-rope: #e8d9a8;
  --tr-plank: rgba(70, 40, 10, 0.35);
  --tr-band: #2f8f5b;
  --tr-text: #7a1f2b;
  --tr-board: #1f2128;
  --tr-board-lit: #f2a33a;
  --tr-honk-bg: #fffaf0;
  --tr-honk-ink: #3a2a1a;
}
html[data-scene="night"] {
  --tr-glass: rgba(255, 214, 140, 0.42);
  --tr-person: #14100f;
  --tr-tail: #ff3b2f;
  --tr-board-lit: #ffb547;
  --tr-honk-bg: #f3e9d2;
  --tr-honk-ink: #2a1f1a;
}

.tr-veh { position: absolute; left: 0; cursor: pointer; will-change: transform; }
.tr-veh.near { bottom: 4px; z-index: 3; }
.tr-veh.far { bottom: 40px; z-index: 2; }
.tr-veh.parked { cursor: default; }
.tr-veh svg { display: block; width: 100%; height: 100%; overflow: visible; }
.tr-veh.flip svg { transform: scaleX(-1); }
.tr-veh.flip .tr-unflip { transform-box: fill-box; transform-origin: center; transform: scaleX(-1); }

/* At night the paint goes dim; lights, glass and tail lights stay bright. */
html[data-scene="night"] .tr-paint { filter: brightness(0.62) saturate(0.85); }
html[data-scene="night"] .tr-veh .tr-glass { filter: none; }
html[data-scene="night"] .tr-tail { filter: drop-shadow(0 0 3px #ff3b2f); }
html[data-scene="night"] .tr-veh .lamp { filter: drop-shadow(0 0 3px #ffe7a3); }

.tr-body { fill: var(--tr-body, #ecebe6); }
.tr-shade { fill: rgba(0, 0, 0, 0.12); }
.tr-glass { fill: var(--tr-glass); }
.tr-person { fill: var(--tr-person); }
.tr-dark { fill: var(--tr-dark); }
.tr-line { fill: none; stroke: rgba(0, 0, 0, 0.28); stroke-width: 1.2; stroke-linecap: round; }
.tr-tail { fill: var(--tr-tail); }
.tr-chrome { fill: none; stroke: var(--tr-chrome); stroke-width: 3; stroke-linecap: round; }
.tr-fork { fill: none; stroke: var(--tr-dark); stroke-width: 2.6; stroke-linecap: round; }
.tr-guard { fill: none; stroke: var(--tr-body, #1f2128); stroke-width: 3; stroke-linecap: round; }
.tr-seat { fill: var(--tr-seat); }
.tr-legs { fill: none; stroke: var(--tr-legs); stroke-width: 4.2; stroke-linecap: round; stroke-linejoin: round; }
.tr-shoe { fill: none; stroke: #1c1215; stroke-width: 2.6; stroke-linecap: round; }
.tr-shirt { fill: var(--tr-shirt, #3f7fd0); }
.tr-kurta { fill: var(--tr-kurta, #e05a8a); }
.tr-dupatta { fill: var(--tr-dupatta, #f2c230); opacity: 0.92; }
.tr-arm { fill: none; stroke: var(--skin, #c68a63); stroke-width: 2.6; stroke-linecap: round; }
.tr-helmet { fill: var(--tr-helmet, #e8e4da); }
.tr-visor { fill: #1f2a3a; opacity: 0.85; }
.tr-bus { fill: var(--tr-bus, #c8372d); }
.tr-bus2 { fill: var(--tr-bus2, #efe3c4); }
.tr-board { fill: var(--tr-board); }
.tr-board-dots { fill: none; stroke: var(--tr-board-lit); stroke-width: 2; stroke-dasharray: 2 2.4; }
.tr-rail { fill: none; stroke: var(--tr-chrome); stroke-width: 1.4; }
.tr-tarp { fill: var(--tr-tarp); }
.tr-rope { fill: none; stroke: var(--tr-rope); stroke-width: 1.2; }
.tr-box { fill: var(--tr-box, #d9a33d); }
.tr-plank { fill: none; stroke: var(--tr-plank); stroke-width: 1.2; }
.tr-band { fill: var(--tr-band); }
.tr-dot0 { fill: #f2c230; } .tr-dot1 { fill: #e0412d; } .tr-dot2 { fill: #ffffff; }
.tr-text { fill: var(--tr-text); font: 700 8.4px var(--font-body, sans-serif); letter-spacing: 0.06em; }
.tr-cab { fill: var(--tr-cab, #e8761f); }
.tr-visorcab { fill: #e0412d; }

/* A honk: a little speech bubble that floats up from a stuck vehicle. */
.tr-honk {
  position: absolute; left: 50%; bottom: calc(100% + 2px); transform: translateX(-50%);
  padding: 1px 6px; border-radius: 8px; white-space: nowrap; pointer-events: none;
  font: 700 10px var(--font-body, sans-serif); color: var(--tr-honk-ink); background: var(--tr-honk-bg);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

/* Night incidents: brake lights, skid marks, the bonk, the argument. */
.tr-veh.braking .tr-tail { fill: #ff2a1f; filter: drop-shadow(0 0 4px #ff2a1f); }
.tr-honk.tr-screech { color: #c8372d; font-style: italic; letter-spacing: 0.04em; }
.tr-honk.tr-argue { font-weight: 600; }
.tr-skid { position: absolute; z-index: 1; height: 3px; border-radius: 2px; background: rgba(15, 15, 18, 0.55); pointer-events: none; transition: opacity 3.4s linear; }
.tr-skid.near { bottom: 3px; }
.tr-skid.far { bottom: 39px; }
.tr-skid.gone { opacity: 0; }
.tr-bang {
  position: absolute; z-index: 4; padding: 12px 13px; pointer-events: none;
  font: 800 11px var(--font-body, sans-serif); color: #c8372d; background: #ffd23a; letter-spacing: 0.03em;
  clip-path: polygon(50% 0, 61% 30%, 96% 18%, 72% 46%, 100% 64%, 66% 66%, 72% 100%, 50% 76%, 26% 100%, 32% 68%, 0 66%, 28% 47%, 4% 18%, 39% 30%);
}
.tr-bang.near { bottom: 22px; }
.tr-bang.far { bottom: 52px; }

@media (prefers-reduced-motion: no-preference) {
  .tr-bang { animation: tr-bang 1.1s ease-out forwards; }
  @keyframes tr-bang { 0% { transform: scale(0.3); opacity: 0; } 15% { transform: scale(1.15); opacity: 1; } 30% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(1.05); } }
  .tr-dupatta { transform-box: fill-box; transform-origin: 100% 30%; animation: tr-flutter 0.35s ease-in-out infinite alternate; }
  @keyframes tr-flutter { from { transform: skewY(-6deg) scaleX(0.94); } to { transform: skewY(5deg) scaleX(1.04); } }
  .tr-veh.near svg, .tr-veh.far svg { animation: tr-bump 0.6s ease-in-out infinite alternate; }
  .tr-veh.flip svg { animation-name: tr-bump-flip; }
  @keyframes tr-bump { from { transform: translateY(0); } to { transform: translateY(-0.8px); } }
  @keyframes tr-bump-flip { from { transform: scaleX(-1) translateY(0); } to { transform: scaleX(-1) translateY(-0.8px); } }
  .tr-honk { animation: tr-honk 1.5s ease-out forwards; }
  @keyframes tr-honk { 0% { opacity: 0; transform: translate(-50%, 4px) scale(0.7); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -10px); } }
}
