/*
 * Motion. Everything here is gated on html.motion, which the inline head script sets only when the
 * visitor has not asked for reduced motion, so the page is complete and still without it.
 * One orchestrated moment (the hero coming up); everything else answers something the visitor did
 * or something the demo's agents did.
 */

:root {
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  interpolate-size: allow-keywords;
}

/* ---------- Hero live counter ---------- */

.hero-live {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 28px;
  padding: 7px 14px 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-3);
  color: var(--muted);
  font-size: 14px;
}

.hero-live strong {
  color: var(--ink);
  font-weight: 500;
}

.hero-copy h1 .line {
  display: block;
}

/* ---------- The one orchestrated moment: the hero comes up ---------- */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(22px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes console-in {
  from {
    opacity: 0;
    transform: perspective(1800px) rotateX(10deg) translateY(56px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes tile-in {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.motion .hero-live,
.motion .hero-copy h1 .line,
.motion .hero-copy .lede,
.motion .hero-copy .hero-actions {
  animation: rise 0.9s var(--ease-out) backwards;
}

.motion .hero-copy h1 .line:nth-child(1) {
  animation-delay: 0.08s;
}

.motion .hero-copy h1 .line:nth-child(2) {
  animation-delay: 0.2s;
}

.motion .hero-copy .lede {
  animation-delay: 0.34s;
}

.motion .hero-copy .hero-actions {
  animation-delay: 0.44s;
}

.motion .console {
  transform-origin: 50% 0;
  animation: console-in 1.2s var(--ease-out) 0.5s backwards;
}

.motion .dock-tile {
  animation: tile-in 0.5s var(--ease-spring) backwards;
}

.motion .dock-tile:nth-child(1) {
  animation-delay: 1s;
}
.motion .dock-tile:nth-child(2) {
  animation-delay: 1.06s;
}
.motion .dock-tile:nth-child(3) {
  animation-delay: 1.12s;
}
.motion .dock-tile:nth-child(4) {
  animation-delay: 1.18s;
}
.motion .dock-tile:nth-child(5) {
  animation-delay: 1.24s;
}
.motion .dock-tile:nth-child(6) {
  animation-delay: 1.3s;
}
.motion .dock-tile:nth-child(7) {
  animation-delay: 1.36s;
}

.motion .loop-tile {
  animation: rise 0.6s var(--ease-out) backwards;
}

.motion .loop-tile:nth-child(1) {
  animation-delay: 1.1s;
}
.motion .loop-tile:nth-child(2) {
  animation-delay: 1.16s;
}
.motion .loop-tile:nth-child(3) {
  animation-delay: 1.22s;
}
.motion .loop-tile:nth-child(4) {
  animation-delay: 1.28s;
}
.motion .loop-tile:nth-child(5) {
  animation-delay: 1.34s;
}
.motion .loop-tile:nth-child(6) {
  animation-delay: 1.4s;
}

.motion .approval {
  animation: rise 0.7s var(--ease-out) backwards;
}

.motion .approval:nth-child(1) {
  animation-delay: 1.3s;
}
.motion .approval:nth-child(2) {
  animation-delay: 1.42s;
}
.motion .approval:nth-child(3) {
  animation-delay: 1.54s;
}

/* ---------- Things the agents do ---------- */

@keyframes bump {
  40% {
    transform: scale(1.22);
  }
}

@keyframes tick-flash {
  from {
    color: var(--accent);
  }
}

.motion .is-bumped {
  animation: bump 0.45s var(--ease-spring);
}

.motion .loop-count.is-bumped,
.motion .kpi-value.is-bumped,
.motion .brief-text .is-bumped,
.motion .hero-live strong.is-bumped {
  display: inline-block;
  animation: tick-flash 1.2s ease-out;
}

.motion .loop-tile {
  transition:
    border-color 0.3s ease,
    transform 0.3s var(--ease-out);
}

.motion .loop-tile.is-active {
  transform: translateY(-2px);
  border-color: var(--c);
}

/* A decision lands: the card settles and a check draws itself. */
.motion .is-arriving {
  animation: settle 0.35s var(--ease-out);
}

@keyframes settle {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

@keyframes draw {
  from {
    stroke-dashoffset: 18;
  }
}

.approval-done {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.approval-done svg {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 18;
}

.motion .approval-done {
  animation: settle 0.35s var(--ease-out);
}

.motion .approval-done svg {
  animation: draw 0.5s 0.1s var(--ease-out) both;
}

.approval {
  transition:
    border-color 0.3s ease,
    opacity 0.3s ease;
}

.approval.is-done h4,
.approval.is-done .approval-why {
  opacity: 0.55;
  transition: opacity 0.4s ease;
}

/* ---------- Presses ---------- */

.btn {
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    transform 0.12s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
}

.btn:disabled {
  cursor: default;
  opacity: 0.7;
}

.switch:active .switch-knob {
  width: 31px;
}

.switch[aria-checked='true']:active .switch-knob {
  transform: translateX(19px);
}

.switch-knob {
  transition:
    transform 0.25s var(--ease-spring),
    width 0.15s ease;
}

/* ---------- Nav: where you are ---------- */

.nav-links a {
  position: relative;
  transition: color 0.15s ease;
}

.nav-links a::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 1.5px;
  border-radius: 1px;
  background: var(--ink);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s var(--ease-out);
}

.nav-links a[aria-current='true'] {
  color: var(--ink);
}

.nav-links a[aria-current='true']::after {
  transform: scaleX(1);
}

@media (max-width: 900px) {
  .nav-links a::after {
    display: none;
  }
}

/* ---------- Overnight: the night's timeline draws as you read it ---------- */

.night-log {
  position: relative;
}

.night-log::before,
.night-log::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 28px;
  bottom: 28px;
  width: 1px;
  background: var(--night-line);
}

.night-log > li::before {
  z-index: 1;
  box-shadow: 0 0 0 4px var(--night);
}

.night-log::after {
  display: none;
}

@keyframes line-draw {
  from {
    transform: scaleY(0);
  }
  to {
    transform: scaleY(1);
  }
}

@supports (animation-timeline: view()) {
  .motion .night-log::after {
    display: block;
    width: 1.5px;
    background: linear-gradient(
      var(--panel-growth),
      var(--panel-customers),
      var(--panel-operations),
      var(--panel-mission)
    );
    transform-origin: top;
    animation: line-draw linear both;
    animation-timeline: view();
    animation-range: entry 30% cover 75%;
  }
}

/* "Why did it do that?" opens smoothly where the browser can size to auto. */
.why::details-content {
  block-size: 0;
  overflow: hidden;
  transition:
    block-size 0.4s var(--ease-out),
    content-visibility 0.4s allow-discrete;
}

.why[open]::details-content {
  block-size: auto;
}

/* ---------- Panels: switching departments ---------- */

@keyframes swap-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

.motion .panel-view.is-swapping > * {
  animation: swap-in 0.45s var(--ease-out) both;
}

.motion .panel-view.is-swapping > :nth-child(2) {
  animation-delay: 0.05s;
}
.motion .panel-view.is-swapping > :nth-child(3) {
  animation-delay: 0.1s;
}
.motion .panel-view.is-swapping > :nth-child(4) {
  animation-delay: 0.15s;
}

.panel-view {
  transition: border-top-color 0.35s ease;
}

.panel-glyph {
  transition:
    background-color 0.25s ease,
    color 0.25s ease,
    transform 0.25s var(--ease-spring);
}

.panel-tab:hover .panel-glyph {
  transform: scale(1.08);
}

/* ---------- Ask: answers arrive ---------- */

@keyframes bar-grow {
  from {
    background-size:
      0% 100%,
      auto;
  }
}

@keyframes bubble-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

.motion .intent-panel .ask-q {
  transform-origin: right bottom;
  animation: bubble-in 0.4s var(--ease-out) both;
}

.motion .intent-panel .ask-a {
  animation: bubble-in 0.5s var(--ease-out) 0.15s both;
}

.motion .intent-panel .bar {
  animation: bar-grow 0.9s var(--ease-out) 0.35s both;
}

.motion .intent-panel .answer-bars li:nth-child(2) .bar {
  animation-delay: 0.42s;
}
.motion .intent-panel .answer-bars li:nth-child(3) .bar {
  animation-delay: 0.49s;
}
.motion .intent-panel .answer-bars li:nth-child(4) .bar {
  animation-delay: 0.56s;
}
.motion .intent-panel .answer-bars li:nth-child(5) .bar {
  animation-delay: 0.63s;
}
.motion .intent-panel .answer-bars li:nth-child(6) .bar {
  animation-delay: 0.7s;
}

.intent-tab {
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}

/* ---------- How it works ---------- */

.flow-steps li {
  position: relative;
}

.motion .flow.is-running .flow-steps li.is-lit .flow-t {
  color: var(--accent);
}

.motion .flow.is-running .flow-steps li.is-lit:not(.is-done)::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 21px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-out infinite;
}

.email {
  transition:
    border-color 0.3s ease,
    box-shadow 0.3s ease;
}

.motion .flow.is-running .email {
  border-color: var(--success-line);
  box-shadow: 0 0 0 4px var(--success-bg);
}

.cascade-bar span {
  transform-origin: left;
}

.motion .cascade-bar:not(.is-in) span {
  transform: scaleX(0);
}

.motion .cascade-bar.is-in span {
  transition: transform 0.9s var(--ease-out);
}

.motion .cascade-bar.is-in span:nth-child(2) {
  transition-delay: 0.15s;
}
.motion .cascade-bar.is-in span:nth-child(3) {
  transition-delay: 0.3s;
}
.motion .cascade-bar.is-in span:nth-child(4) {
  transition-delay: 0.45s;
}

.ladder li {
  transition:
    background-color 0.4s ease,
    border-color 0.4s ease,
    transform 0.4s var(--ease-spring);
}

.ladder.is-promoted li:nth-child(2) {
  background: var(--paper-2);
  border-color: var(--line);
}

.ladder.is-promoted li:last-child {
  transform: translateY(-3px);
  border-color: var(--accent);
}

/* ---------- Pause ---------- */

.console {
  transition: filter 0.5s ease;
}

.console.is-paused .console-main,
.console.is-paused .console-dock {
  filter: saturate(0.25);
  transition: filter 0.5s ease;
}

/* ---------- Phone: notifications arrive ---------- */

.phone-screen {
  position: relative;
  overflow: hidden;
}

.phone-toast {
  position: absolute;
  z-index: 2;
  top: 10px;
  left: 10px;
  right: 10px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.35);
  transform: translateY(-130%);
  opacity: 0;
  transition:
    transform 0.55s var(--ease-spring),
    opacity 0.3s ease;
}

.phone-toast.is-shown {
  transform: none;
  opacity: 1;
}

.phone-toast img {
  border-radius: 6px;
}

.phone-toast p {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
}

.toast-title {
  font-weight: 600;
}

.toast-body {
  color: var(--muted);
}

.toast-time {
  color: var(--faintest);
  font-size: 11px;
}

/* ---------- Call to action ---------- */

@keyframes square-breathe {
  50% {
    transform: translateY(-3px);
  }
}

.motion .cta-panels span {
  animation: square-breathe 3.2s ease-in-out infinite;
}

.motion .cta-panels span:nth-child(2) {
  animation-delay: 0.2s;
}
.motion .cta-panels span:nth-child(3) {
  animation-delay: 0.4s;
}
.motion .cta-panels span:nth-child(4) {
  animation-delay: 0.6s;
}
.motion .cta-panels span:nth-child(5) {
  animation-delay: 0.8s;
}
.motion .cta-panels span:nth-child(6) {
  animation-delay: 1s;
}

@media (max-width: 480px) {
  .hero-live {
    border-radius: 14px;
    align-items: flex-start;
    font-size: 13.5px;
  }

  .hero-live .live-dot {
    margin-top: 6px;
  }
}
