/* =========================================================
   Demand Engine — motion test page (/test/demand-engine-motion/)
   Builds on the tokens in styles.css. Loaded only by that page.
   ========================================================= */

/* ---------- Hero + industry switch ---------- */
.em-hero { position: relative; overflow: hidden; }
.em-hero::before { content: ""; position: absolute; inset: -20% -10% auto; height: 70%; background: radial-gradient(ellipse at 50% 0%, rgba(162, 36, 58, .28), transparent 60%); pointer-events: none; }
.em-head { position: relative; max-width: 920px; }
.em-switch { display: inline-flex; gap: 4px; padding: 5px; border-radius: 999px; background: var(--navy-2); border: 1px solid var(--navy-line); margin-top: 8px; flex-wrap: wrap; justify-content: center; }
.em-switch button { font: 600 15px/1 var(--font-body); color: var(--on-navy); background: transparent; border: 0; border-radius: 999px; padding: 12px 20px; cursor: pointer; transition: background-color .2s, color .2s; }
.em-switch button:hover { color: var(--white); }
.em-switch button[aria-selected="true"] { background: var(--white); color: var(--navy); }

/* ---------- Component wrapper (hero visual on /demand-engine/ and industry pages) ---------- */
.em-wrap { position: relative; text-align: left; }
.em-switch-row { display: flex; justify-content: center; margin-top: clamp(36px, 4vw, 56px); }
.hero--center .em-wrap .em-board, .hero .em-wrap .em-board { margin-top: clamp(40px, 5vw, 64px); }

/* ---------- Engine board ---------- */
.em-board { position: relative; margin-top: clamp(40px, 5vw, 64px); background: linear-gradient(180deg, var(--navy-2), #0C1D31); border: 1px solid var(--navy-line); border-radius: var(--radius-lg); overflow: hidden; }
.em-stage { position: relative; padding: clamp(40px, 5vw, 64px) clamp(20px, 3vw, 40px) 110px; }
.em-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
.em-flow { position: relative; z-index: 1; display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: clamp(20px, 3vw, 40px); align-items: start; }
.em-sources { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.em-sources li { min-height: 31px; min-width: 96px; font-size: 13px; font-weight: 600; line-height: 1.2; color: var(--on-navy); background: var(--navy-3); border: 1px solid var(--navy-line-2); border-radius: 999px; padding: 7px 12px; white-space: nowrap; transition: border-color .2s, color .2s; }
.em-sources li.is-emit { color: var(--white); border-color: var(--on-navy); }
.em-legend { position: relative; z-index: 3; min-height: 1.7em; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 4px; margin: 0 0 64px; font-size: 13px; color: var(--on-navy-2); }
.em-li { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; margin-right: 14px; }
.em-li:last-child { margin-right: 0; }
.em-li--note { font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.em-g { display: inline-block; flex: none; }
.em-g--dot { width: 7px; height: 7px; border-radius: 50%; background: #fff; }
.em-g--win { width: 9px; height: 9px; border-radius: 50%; background: var(--rose); box-shadow: 0 0 0 3px rgba(242, 120, 140, .25); }
.em-g--partner { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #E8B65C; background: radial-gradient(circle, #E8B65C 0 2px, transparent 2.5px); }
.em-g--park { width: 7px; height: 7px; border-radius: 50%; background: rgba(159, 176, 200, .5); }
.em-g--cluster { width: 18px; height: 14px; background: radial-gradient(circle at 4px 4px, #fff 0 2.2px, transparent 2.7px), radial-gradient(circle at 14px 4px, #fff 0 2.2px, transparent 2.7px), radial-gradient(circle at 9px 11px, #fff 0 2.2px, transparent 2.7px); }
.em-hubs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; position: relative; z-index: 1; }
.em-hub { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; }
.em-hub__dot { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; background: var(--navy-3); border: 1.5px solid var(--navy-line-2); color: var(--rose); margin-bottom: 14px; position: relative; transition: transform .25s; }
.em-hub__dot::before { content: ""; position: absolute; inset: -1.5px; border-radius: 50%; border: 1.5px solid var(--rose); box-shadow: 0 0 0 6px rgba(242, 120, 140, .12), 0 0 32px rgba(242, 120, 140, .35); opacity: 0; transition: opacity .25s; will-change: opacity; pointer-events: none; }
.em-hub__dot svg { width: 34px; height: 34px; }
.em-hub.is-hit .em-hub__dot { transform: scale(1.06); }
.em-hub.is-hit .em-hub__dot::before { opacity: 1; }
.em-hub--win .em-hub__dot { background: var(--crimson); border-color: var(--rose); color: var(--white); }
.em-hub__num { font-family: var(--font-mono); font-size: 12px; letter-spacing: .1em; color: var(--rose); }
.em-hub strong { font-family: var(--font-display); font-size: clamp(19px, 1.7vw, 23px); line-height: 1.15; letter-spacing: -0.02em; color: var(--white); }
.em-hub__sub { font-size: 14px; line-height: 1.45; color: var(--on-navy-2); max-width: 22ch; min-height: 2.9em; }
.em-hub__stat { margin-top: 10px; font-size: 13px; color: var(--on-navy); }
.em-hub__stat b { display: block; font-family: var(--font-display); font-size: clamp(24px, 2.3vw, 32px); font-weight: 700; color: var(--white); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.em-loop-label { position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 3; font-family: var(--font-mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--on-navy-2); background: var(--navy-2); padding: 4px 12px; border-radius: 999px; border: 1px solid var(--navy-line); white-space: nowrap; transition: color .3s, border-color .3s; }
.em-loop-label.is-on { color: var(--white); border-color: var(--rose); }

/* floating "+$6,000" */
.em-pop { position: absolute; z-index: 4; font: 700 15px/1 var(--font-display); color: var(--rose); pointer-events: none; animation: em-pop 1.4s ease-out forwards; white-space: nowrap; }
.em-pop--big { font-size: 20px; }
@keyframes em-pop { 0% { opacity: 0; transform: translate(-50%, 0) scale(.8); } 15% { opacity: 1; transform: translate(-50%, -10px) scale(1); } 100% { opacity: 0; transform: translate(-50%, -54px); } }

/* ---------- Results strip ---------- */
.em-results { display: grid; grid-template-columns: 1.1fr 1.6fr 1fr; gap: clamp(20px, 3vw, 40px); align-items: end; padding: 28px clamp(20px, 3vw, 40px) 32px; border-top: 1px solid var(--navy-line); background: rgba(9, 23, 40, .55); }
.em-label { font-family: var(--font-mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--on-navy-2); }
.em-rev { display: flex; flex-direction: column; gap: 6px; }
.em-rev__num { display: inline-block; font-family: var(--font-display); font-weight: 800; font-size: clamp(36px, 4.4vw, 60px); line-height: 1; letter-spacing: -0.03em; color: var(--white); transform-origin: left center; }
.em-rev__num span { color: var(--rose); }
.em-rev__note { max-width: 32ch; line-height: 1.45; }
.em-rev__note { font-size: 13px; color: var(--on-navy-2); }
.em-chart { display: flex; flex-direction: column; gap: 10px; }
.em-chart__bars { display: grid; grid-template-columns: repeat(12, 1fr); grid-template-rows: 100%; gap: 6px; align-items: end; height: 110px; }
.em-chart__bars i { display: block; height: 2%; min-height: 3px; border-radius: 5px 5px 2px 2px; background: var(--navy-line-2); transition: height .35s ease-out, background-color .3s; }
.em-chart__bars i.is-done { background: linear-gradient(180deg, var(--rose), var(--crimson)); }
.em-chart__bars i.is-now { background: var(--white); }
.em-chart__axis { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em; color: var(--on-navy-2); }
.em-side { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.em-toast { font-size: 14px; line-height: 1.45; color: var(--on-navy); min-height: 4.4em; border-left: 2px solid var(--rose); padding-left: 12px; transition: opacity .35s; }
.em-toast b { display: block; font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--rose); margin-bottom: 2px; }
.em-toast.is-fading { opacity: 0; }
.em-side__row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.em-play { font: 600 13px/1 var(--font-body); color: var(--white); background: transparent; border: 1px solid var(--navy-line-2); border-radius: 999px; padding: 9px 14px; cursor: pointer; }
.em-play:hover { border-color: var(--white); }
.em-speed { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--navy-line-2); border-radius: 999px; }
.em-speed button { font: 600 12px/1 var(--font-body); color: var(--on-navy-2); background: transparent; border: 0; border-radius: 999px; padding: 7px 10px; cursor: pointer; }
.em-speed button:hover { color: var(--white); }
.em-speed button[aria-pressed="true"] { background: var(--navy-3); color: var(--white); }

/* ---------- Stage stories ---------- */
.em-steps { display: flex; flex-direction: column; gap: clamp(64px, 8vw, 112px); }
.em-step { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(32px, 5vw, 80px); align-items: center; }
.em-step:nth-child(even) .em-vis { order: -1; }
.em-step__num { font-family: var(--font-mono); font-size: 13px; letter-spacing: .1em; color: var(--crimson); }
.em-step .lede { color: var(--muted); }
.em-step .em-outcome { font-weight: 600; color: var(--ink); }
.em-vis { position: relative; min-height: 340px; border-radius: var(--radius-lg); background: var(--navy); color: var(--white); overflow: hidden; display: grid; place-items: center; padding: 60px 32px 32px; }
.em-vis *, .em-vis *::before, .em-vis *::after { animation-play-state: paused !important; }
.em-vis.is-in *, .em-vis.is-in *::before, .em-vis.is-in *::after { animation-play-state: running !important; }
.em-vis .tag { position: absolute; top: 16px; right: 16px; z-index: 3; }
.em-vis-set:not([hidden]) { display: contents; }

/* 01 Generate: channels flow into the business */
.em-v-gen__core { position: relative; z-index: 2; width: 120px; height: 120px; border-radius: 50%; background: var(--crimson); display: grid; place-items: center; text-align: center; font: 700 15px/1.2 var(--font-display); box-shadow: 0 0 0 10px rgba(162, 36, 58, .25), 0 0 0 22px rgba(162, 36, 58, .1); animation: em-breathe 2.4s ease-in-out infinite; }
@keyframes em-breathe { 50% { transform: scale(1.05); } }
.em-v-gen__chip { position: absolute; left: 50%; top: 50%; font-size: 13px; font-weight: 600; white-space: nowrap; padding: 8px 14px; border-radius: 999px; background: var(--navy-3); border: 1px solid var(--navy-line-2); color: var(--white); animation: em-converge 4.8s cubic-bezier(.55, 0, .45, 1) infinite; opacity: 0; }
@keyframes em-converge {
  0% { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(.9); }
  12% { opacity: 1; }
  55% { opacity: 1; transform: translate(calc(-50% + var(--x) * .55), calc(-50% + var(--y) * .55)) scale(1); }
  85%, 100% { opacity: 0; transform: translate(-50%, -50%) scale(.4); }
}
.em-v-gen__ring { position: absolute; left: 50%; top: 50%; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 1px solid rgba(242, 120, 140, .5); animation: em-ring 3s ease-out infinite; }
.em-v-gen__ring:nth-child(2) { animation-delay: 1s; }
.em-v-gen__ring:nth-child(3) { animation-delay: 2s; }
@keyframes em-ring { from { transform: scale(1); opacity: .9; } to { transform: scale(3.2); opacity: 0; } }

/* 02 Capture: leads land and get an instant reply */
.em-v-cap { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; }
.em-lead { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; background: var(--navy-2); border: 1px solid var(--navy-line); border-radius: 16px; padding: 14px; opacity: 0; transform: translateX(40px); animation: em-lead 6s ease-out infinite; }
.em-lead:nth-child(2) { animation-delay: .9s; }
.em-lead:nth-child(3) { animation-delay: 1.8s; }
.em-lead__ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--navy-3); color: var(--rose); }
.em-lead__ico svg { width: 20px; height: 20px; }
.em-lead__txt { font-size: 14px; line-height: 1.35; }
.em-lead__txt span { display: block; font-size: 12px; color: var(--on-navy-2); }
.em-lead__ok { font: 600 11px/1 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: #7FE0A8; background: rgba(29, 107, 69, .3); border-radius: 999px; padding: 6px 9px; opacity: 0; animation: em-ok 6s ease-out infinite; }
.em-lead:nth-child(1) .em-lead__ok { animation-delay: .5s; }
.em-lead:nth-child(2) .em-lead__ok { animation-delay: 1.4s; }
.em-lead:nth-child(3) .em-lead__ok { animation-delay: 2.3s; }
@keyframes em-lead { 0% { opacity: 0; transform: translateX(40px); } 8%, 82% { opacity: 1; transform: none; } 92%, 100% { opacity: 0; transform: translateY(-8px); } }
@keyframes em-ok { 0%, 8% { opacity: 0; transform: scale(.6); } 14%, 80% { opacity: 1; transform: none; } 90%, 100% { opacity: 0; } }

/* 03 Nurture: touches light up until the win */
.em-v-nur { width: 100%; max-width: 360px; list-style: none; margin: 0; padding: 0; position: relative; }
.em-v-nur::before { content: ""; position: absolute; left: 11px; top: 14px; bottom: 14px; width: 2px; background: var(--navy-line-2); }
.em-touch { position: relative; display: flex; align-items: center; gap: 16px; padding: 9px 0; font-size: 15px; color: var(--on-navy-2); animation: em-touch-txt 7s linear infinite; }
.em-touch::before { content: ""; position: relative; z-index: 1; flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--navy); border: 2px solid var(--navy-line-2); animation: em-touch-dot 7s linear infinite; }
.em-touch span { font: 500 11px/1 var(--font-mono); letter-spacing: .06em; color: var(--on-navy-2); min-width: 48px; }
.em-touch--win { color: var(--white); font-weight: 700; }
.em-touch--win::before { animation-name: em-touch-win; }
.em-touch:nth-child(1), .em-touch:nth-child(1)::before { animation-delay: 0s; }
.em-touch:nth-child(2), .em-touch:nth-child(2)::before { animation-delay: .9s; }
.em-touch:nth-child(3), .em-touch:nth-child(3)::before { animation-delay: 1.8s; }
.em-touch:nth-child(4), .em-touch:nth-child(4)::before { animation-delay: 2.7s; }
.em-touch:nth-child(5), .em-touch:nth-child(5)::before { animation-delay: 3.6s; }
@keyframes em-touch-dot { 0% { background: var(--navy); border-color: var(--navy-line-2); } 4%, 80% { background: var(--rose); border-color: var(--rose); } 90%, 100% { background: var(--navy); border-color: var(--navy-line-2); } }
@keyframes em-touch-win { 0% { background: var(--navy); border-color: var(--navy-line-2); transform: scale(1); } 4% { transform: scale(1.4); } 8%, 80% { background: #2FA56B; border-color: #7FE0A8; transform: scale(1); } 90%, 100% { background: var(--navy); border-color: var(--navy-line-2); } }
@keyframes em-touch-txt { 0% { color: var(--on-navy-2); } 4%, 80% { color: var(--white); } 90%, 100% { color: var(--on-navy-2); } }

/* 04 Measure: bars grow, budget follows what converts */
.em-v-mea { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 18px; }
.em-v-mea__bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: end; height: 170px; border-bottom: 1px solid var(--navy-line-2); }
.em-v-mea__bar { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 8px; height: 100%; }
.em-v-mea__bar i { display: block; width: 100%; border-radius: 8px 8px 2px 2px; background: var(--navy-line-2); height: var(--h); transform: scaleY(var(--sa)); transform-origin: bottom; animation: em-bar 6s ease-in-out infinite; }
.em-v-mea__bar--best i { background: linear-gradient(180deg, var(--rose), var(--crimson)); }
@keyframes em-bar { 0%, 15% { transform: scaleY(var(--sa)); } 45%, 85% { transform: scaleY(var(--sb)); } 100% { transform: scaleY(var(--sa)); } }
.em-v-mea__lbl { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; font-size: 12px; text-align: center; color: var(--on-navy-2); margin-top: -8px; }
.em-v-mea__note { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--on-navy); }
.em-v-mea__note b { font: 600 11px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--rose); border: 1px solid rgba(242, 120, 140, .4); border-radius: 999px; padding: 6px 10px; animation: em-blink 6s ease-in-out infinite; }
@keyframes em-blink { 0%, 30% { background: transparent; } 45%, 85% { background: rgba(242, 120, 140, .16); } 100% { background: transparent; } }

/* ---------- Responsive ---------- */
@media (max-width: 1060px) {
  .em-flow { grid-template-columns: 1fr; gap: 28px; }
  .em-sources { flex-direction: row; flex-wrap: wrap; justify-content: center; }
}
@media (max-width: 900px) {
  .em-results { grid-template-columns: 1fr 1fr; }
  .em-chart { grid-column: 1 / -1; order: 3; }
}
@media (max-width: 760px) {
  .em-stage { padding: 32px 20px 36px; }
  .em-switch { flex-wrap: nowrap; }
  .em-switch button { padding: 11px 13px; font-size: 14px; }
  .em-hubs { grid-template-columns: 1fr; gap: 34px; }
  .em-sources { justify-content: flex-start; }
  .em-legend { justify-content: flex-start; margin-bottom: 20px; }
  .em-hub { display: grid; grid-template-columns: 64px 1fr; column-gap: 18px; row-gap: 2px; text-align: left; align-items: center; }
  .em-hub__dot { width: 64px; height: 64px; margin: 0; grid-row: 1 / span 4; align-self: start; }
  .em-hub__dot svg { width: 26px; height: 26px; }
  .em-hub__sub { max-width: none; min-height: 0; }
  .em-hub__stat { margin-top: 4px; }
  .em-hub__stat b { display: inline; font-size: 22px; margin-right: 6px; }
  .em-loop-label { display: none; }
  .em-results { grid-template-columns: 1fr; }
  .em-step { grid-template-columns: 1fr; }
  .em-step:nth-child(even) .em-vis { order: 0; }
  .em-vis { min-height: 300px; padding: 28px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .em-vis *, .em-vis.is-in * { animation: none !important; opacity: 1 !important; transform: none !important; }
  /* still picture: channels sit around the business instead of flying in */
  .em-vis .em-v-gen__chip, .em-vis.is-in .em-v-gen__chip { opacity: 1 !important; transform: translate(calc(-50% + var(--x) * .72), calc(-50% + var(--y) * .72)) !important; }
  .em-vis .em-v-gen__ring { display: none; }
}
