/* The org chart comes alive: the Owner card arrives, the connector lines draw, the nine roles arrive one by one,
   then the office keeps working quietly (a signal flows down from the Owner, status dots pulse, one role at a time
   lights up as if it has picked up a task). Hidden states only apply once org-motion.js adds .org-anim, so the
   chart is fully visible without JavaScript. Off for prefers-reduced-motion. */
@media (prefers-reduced-motion: no-preference) {
  .org.org-anim .owner { opacity: 0; transform: translateY(14px) scale(.96); transition: opacity .7s var(--ease), transform .7s var(--ease); }
  .org.org-anim .jarvis { opacity: 0; transform: translateY(10px); transition: opacity .5s var(--ease) .3s, transform .5s var(--ease) .3s; }
  .org.org-anim .roles::before { transform: scaleY(0); transform-origin: top; transition: transform .45s var(--ease) .6s; }
  .org.org-anim .roles::after { transform: scaleX(0); transform-origin: center; transition: transform .6s var(--ease) .8s; }
  .org.org-anim .role:nth-child(-n+3)::before { transform: scaleY(0); transform-origin: top; transition: transform .3s var(--ease) 1.25s; }
  .org.org-anim .role { opacity: 0; transform: translateY(18px);
    transition: opacity .6s var(--ease) calc(1.3s + var(--i, 0) * 70ms), transform .6s var(--ease) calc(1.3s + var(--i, 0) * 70ms), box-shadow .4s ease; }
  /* once everything has arrived, hover and the working glow respond straight away */
  .org.org-done .role { transition: box-shadow .4s ease, transform .3s var(--ease); }
  .org.org-anim .org-note { opacity: 0; transition: opacity .6s var(--ease) 2.1s; }

  .org.org-in .owner { opacity: 1; transform: none; animation: owner-glow 4.8s ease-in-out 1.2s infinite; }
  .org.org-in .jarvis { opacity: 1; transform: none; }
  .org.org-in .roles::before, .org.org-in .role:nth-child(-n+3)::before { transform: scaleY(1); }
  .org.org-in .roles::after { transform: scaleX(1); }
  .org.org-in .role { opacity: 1; transform: none; }
  .org.org-done .role:hover { transform: translateY(-3px); box-shadow: inset 0 0 0 1px rgba(140,200,255,.5), 0 14px 36px rgba(0,84,255,.2); }
  .org.org-in .org-note { opacity: 1; }

  /* a signal travelling down the line from the Owner to the team */
  .org-pulse { position: absolute; left: 50%; top: -64px; width: 7px; height: 7px; margin-left: -3px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 12px 3px rgba(140,200,255,.7); opacity: 0; pointer-events: none; }
  .org.org-in .org-pulse { animation: org-signal 2.8s cubic-bezier(.5,0,.5,1) 2.2s infinite; }

  /* each role is "online" */
  .role-dot { position: absolute; top: 18px; right: 18px; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(126,224,168,.55); opacity: .85; }
  .org.org-in .role-dot { animation: role-online 2.6s ease-out infinite; animation-delay: calc(2s + var(--i, 0) * 290ms); }

  /* one role at a time picks up a task */
  .role.is-working { box-shadow: inset 0 0 0 1px rgba(140,200,255,.55), 0 12px 34px rgba(0,84,255,.22); }
  .role.is-working .file { color: #fff; }
  .role.is-working .role-dot { background: var(--cyan); }
  .role .file, .role .role-dot { transition: color .4s, background .4s; }

  /* JARVIS is live: its dot pulses. On the phone under the chart each message pops up from below, the chat slides up
     to keep the newest one in view, and JARVIS's typing dots bounce (timing in org-motion.js) */
  .jarvis-dot { animation: role-online 2s ease-out infinite; }
  .wa-log { transition: transform .5s var(--ease), opacity .4s; }
  .wa-log.is-clearing { opacity: 0; transition: opacity .4s; }
  .jsays.is-live .wa-msg { transition: opacity .35s var(--ease), transform .35s var(--ease); }
  .jsays.is-live .wa-msg:not(.is-in) { transform: translateY(14px) scale(.97); }
  .jsays.is-live .wa-out { transform-origin: 100% 100%; }
  .jsays.is-live .wa-in { transform-origin: 0 100%; }
  .wa-typing i { animation: jsays-dot 1s ease-in-out infinite; }
  .wa-typing i:nth-child(2) { animation-delay: .15s; }
  .wa-typing i:nth-child(3) { animation-delay: .3s; }

  /* phones (the compact chart in aioffice.css): a smaller dot, and the signal runs the short line from the Owner to the CEO */
  @media (max-width: 720px) {
    .role-dot { top: 6px; right: 6px; width: 5px; height: 5px; }
    .org-pulse { top: -22px; }
    .org.org-in .org-pulse { animation-name: org-signal-sm; }
  }

  @keyframes owner-glow { 0%, 100% { box-shadow: 0 0 0 1px rgba(140,200,255,.25), 0 18px 60px rgba(0,84,255,.28); } 50% { box-shadow: 0 0 0 1px rgba(140,200,255,.45), 0 18px 80px rgba(0,84,255,.5); } }
  @keyframes org-signal { 0% { opacity: 0; transform: translateY(0); } 12% { opacity: 1; } 70% { opacity: 1; transform: translateY(44px); } 100% { opacity: 0; transform: translateY(46px); } }
  @keyframes org-signal-sm { 0% { opacity: 0; transform: translateY(0); } 15% { opacity: 1; } 70% { opacity: 1; transform: translateY(14px); } 100% { opacity: 0; transform: translateY(16px); } }
  @keyframes jsays-dot { 0%, 60%, 100% { opacity: .35; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
  @keyframes role-online { 0% { box-shadow: 0 0 0 0 rgba(126,224,168,.55); } 70%, 100% { box-shadow: 0 0 0 7px rgba(126,224,168,0); } }
}
@media (prefers-reduced-motion: reduce) { .org-pulse { display: none; } }
