:root {
  --bg: #0e1116;
  --panel: #161b22;
  --ink: #e8edf3;
  --muted: #8b97a8;
  --accent: #ffd166;
  --working: #4ade80;
  --completed: #60a5fa;
  --idle: #6b7280;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  height: 100%;
}
header {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid #222;
}
header h1 { margin: 0; font-size: 20px; letter-spacing: .5px; }
header .sub { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 8px; }
#meta { font-size: 13px; color: var(--muted); display: flex; gap: 16px; }
#source-badge {
  padding: 2px 8px; border-radius: 10px; background: #222a35;
  color: var(--accent); font-weight: 600;
}

main#office {
  position: relative;
  width: min(98vw, 1600px);
  aspect-ratio: 1400 / 900;
  margin: 16px auto;
  border: 1px solid #222;
  border-radius: 12px;
  overflow: hidden;
  background: #0b0f17;
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
}
#office-svg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}

/* Room labels (clean typography, replaces hand-lettered whiteboard) */
.roomLabel {
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 22px;
  font-weight: 700;
  fill: #1a1a1a;
  text-anchor: middle;
  letter-spacing: .5px;
  pointer-events: none;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 5px;
  stroke-linejoin: round;
}
.walkLabel {
  font-size: 16px;
  font-weight: 500;
  fill: #6a5a30;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.zoneLabel {
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  font-weight: 700;
  fill: #ffd166;
  letter-spacing: 1.5px;
}

#agents {
  position: absolute; inset: 0;
  pointer-events: none;
}

/* Agent sprite container — placed in % coords so it scales with the office */
.agent {
  position: absolute;
  width: 2.8%;          /* was 4.4% — another ~35% smaller */
  transform: translate(-50%, -50%);
  pointer-events: auto;
  transition: left .8s ease-in-out, top .8s ease-in-out;
}
.agent .body {
  width: 100%;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.5));
}
.agent .label {
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translate(-50%, 4px);
  background: rgba(14,17,22,.85);
  color: var(--ink);
  font-size: 9px;
  padding: 2px 5px;
  border-radius: 5px;
  white-space: nowrap;
  border: 1px solid #2a3340;
}
.agent .bubble {
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translate(-50%, -10px) scale(.7);
  transform-origin: bottom center;
  background: #fffbe8;
  color: #1a1a1a;
  font-size: 11px;
  line-height: 1.25;
  padding: 6px 10px;
  border-radius: 10px;
  max-width: 180px;
  min-width: 80px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  opacity: 0;
  transition: opacity .35s ease, transform .35s cubic-bezier(.2,1.4,.4,1);
  pointer-events: none;
}
.agent .bubble::after {
  /* tail centred on the agent's head (sprite head ~ y=26 of viewBox 110, ~24%) */
  content: "";
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: #fffbe8;
}
.agent.working .bubble,
.agent.completed .bubble {
  opacity: 1;
  transform: translate(-50%, -10px) scale(1);
}

/* States */
.agent.idle .body  { animation: idleBob 2s ease-in-out infinite; opacity: .85; }
.agent.working .body { animation: workBob 0.55s ease-in-out infinite; }
.agent.completed .body { animation: pulse-glow 2s ease-in-out; }

/* idle yawn-stretch every ~10s, applied to body group */
.agent.idle .body { animation: idleBob 2s ease-in-out infinite, idleStretch 10s ease-in-out infinite; }

.agent.working::before {
  content: "";
  position: absolute; inset: -8%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(74,222,128,.18), transparent 60%);
  animation: halo 1.4s ease-in-out infinite;
  pointer-events: none;
}
.agent.completed::before {
  content: "";
  position: absolute; inset: -8%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(96,165,250,.35), transparent 65%);
  animation: halo 1.4s ease-in-out;
  pointer-events: none;
}

/* Per-role working sub-animations on inner sprite parts */
.agent.working .leftArm  { animation: typeArm 0.4s ease-in-out infinite; transform-origin: 60% 0%; }
.agent.working .rightArm { animation: typeArm 0.4s ease-in-out infinite reverse; transform-origin: 40% 0%; }
.agent[data-role="phone"].working .rightArm { animation: phoneArm 2s ease-in-out infinite; }
.agent[data-role="phone"].working .head     { animation: headNod 2.5s ease-in-out infinite; transform-origin: 50% 80%; }
.agent[data-role="paper"].working .leftArm  { animation: shuffleArm 1.2s ease-in-out infinite; }
.agent[data-role="paper"].working .rightArm { animation: shuffleArm 1.2s ease-in-out infinite reverse; }

/* Walking helper — applied during scripted walks */
.agent.walking { transition: left 1.4s ease-in-out, top 1.4s ease-in-out; }
.agent.walking .body { animation: walkBob .35s ease-in-out infinite; }

@keyframes idleBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-1.5px); }
}
@keyframes idleStretch {
  0%, 92%, 100% { transform: scaleY(1); }
  95%           { transform: scaleY(1.06) translateY(-2px); }
}
@keyframes workBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}
@keyframes walkBob {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50%      { transform: translateY(-2px) rotate(1deg); }
}
@keyframes typeArm {
  0%, 100% { transform: rotate(-4deg); }
  50%      { transform: rotate(8deg); }
}
@keyframes phoneArm {
  0%, 100% { transform: rotate(-40deg) translateY(-4px); }
  50%      { transform: rotate(-44deg) translateY(-5px); }
}
@keyframes headNod {
  0%, 100% { transform: rotate(-3deg); }
  50%      { transform: rotate(3deg); }
}
@keyframes shuffleArm {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50%      { transform: translateY(-2px) rotate(10deg); }
}
@keyframes halo {
  0%, 100% { opacity: .4; transform: scale(.95); }
  50%      { opacity: .9; transform: scale(1.1); }
}
@keyframes pulse-glow {
  0%   { filter: drop-shadow(0 0 0 #60a5fa); }
  50%  { filter: drop-shadow(0 0 12px #60a5fa); }
  100% { filter: drop-shadow(0 0 0 #60a5fa); }
}

/* ============ AMBIENT SVG ANIMATIONS ============ */
.plantSway {
  animation: plantSway 4s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: 50% 100%;
}
.plantSway2 { animation-delay: -2s; animation-duration: 5s; }
@keyframes plantSway {
  0%, 100% { transform: rotate(-3deg); }
  50%      { transform: rotate(3deg); }
}

.fanSpin {
  animation: spin 4s linear infinite;
  transform-box: fill-box;
  transform-origin: 50% 50%;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.steam circle { animation: steamRise 4s ease-in infinite; }
.steam circle:nth-child(2) { animation-delay: .6s; }
.steam circle:nth-child(3) { animation-delay: 1.2s; }
@keyframes steamRise {
  0%   { opacity: 0; transform: translateY(0)   scale(.6); }
  20%  { opacity: .9; }
  100% { opacity: 0; transform: translateY(-30px) scale(1.6); }
}

.printerBlink { animation: blinkGreen 3.4s ease-in-out infinite; }
@keyframes blinkGreen {
  0%, 90%, 100% { opacity: 1; }
  92%, 96%      { opacity: .15; }
}
.rackBlink1 { animation: blinkGreen 1.7s ease-in-out infinite; }
.rackBlink2 { animation: blinkGreen 2.3s ease-in-out infinite; }
.rackBlink3 { animation: blinkGreen 1.1s ease-in-out infinite; }

.paperDrift {
  animation: paperDrift 18s linear infinite;
  transform-box: fill-box;
}
@keyframes paperDrift {
  0%   { transform: translate(380px, 540px) rotate(0deg);  opacity: 0; }
  10%  { opacity: 1; }
  50%  { transform: translate(640px, 548px) rotate(180deg); }
  90%  { opacity: 1; }
  100% { transform: translate(880px, 540px) rotate(360deg); opacity: 0; }
}

footer {
  display: flex; gap: 24px; justify-content: center;
  padding: 10px; color: var(--muted); font-size: 12px;
  border-top: 1px solid #222;
}
footer code { color: var(--accent); }
