/**
 * Homepage: missed-call → SMS → dashboard → owner SMS (premium motion)
 */

.qn-pipeline-root {
  --qn-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --qn-ease-soft: cubic-bezier(0.33, 1, 0.68, 1);
  --qn-duration: 0.55s;
}

.qn-pipeline-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

@media (min-width: 1024px) {
  .qn-pipeline-layout {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.25rem 0.75rem;
  }
}

.qn-pipeline-phone-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

/* —— Realistic phone chassis (procedural; not Apple artwork) —— */
.qn-pipeline-device {
  position: relative;
  width: min(228px, 78vw);
  aspect-ratio: 393 / 852;
  max-height: 485px;
  border-radius: 42px;
  padding: 9px;
  background:
    linear-gradient(168deg, rgba(255, 255, 255, 0.14) 0%, transparent 42%),
    linear-gradient(145deg, #4a4a4f 0%, #2e2e32 38%, #1a1a1d 52%, #353539 100%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.1) inset,
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 32px 64px -16px rgba(15, 23, 42, 0.45),
    0 16px 32px -12px rgba(37, 99, 235, 0.14);
}

.qn-pipeline-device-reflection {
  pointer-events: none;
  position: absolute;
  inset: 11px;
  border-radius: 34px;
  background: linear-gradient(
    125deg,
    rgba(255, 255, 255, 0.07) 0%,
    transparent 35%,
    transparent 65%,
    rgba(255, 255, 255, 0.03) 100%
  );
  z-index: 3;
}

.qn-pipeline-device-side {
  position: absolute;
  border-radius: 2px;
  background: linear-gradient(180deg, #3f3f43, #2a2a2d);
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.4);
  padding: 0;
  border: none;
  pointer-events: none;
}

.qn-pipeline-device-side--mute {
  left: -2px;
  top: 82px;
  width: 3px;
  height: 18px;
}

.qn-pipeline-device-side--vol-up {
  left: -2px;
  top: 116px;
  width: 3px;
  height: 36px;
}

.qn-pipeline-device-side--vol-down {
  left: -2px;
  top: 158px;
  width: 3px;
  height: 36px;
}

.qn-pipeline-device-side--power {
  right: -2px;
  top: 136px;
  width: 3px;
  height: 58px;
}

.qn-pipeline-screen {
  position: relative;
  z-index: 1;
  height: 100%;
  border-radius: 34px;
  overflow: hidden;
  background: #000;
  display: flex;
  flex-direction: column;
}

.qn-pipeline-island {
  position: absolute;
  top: 9px;
  left: 50%;
  z-index: 5;
  width: 90px;
  height: 26px;
  margin-left: -45px;
  border-radius: 16px;
  background: #0a0a0a;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 4px 12px rgba(0, 0, 0, 0.45);
}

.qn-pipeline-island-lens {
  position: absolute;
  right: 14px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #1e3a5f, #0d1118 70%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* Messages UI */
.qn-pipeline-msg-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 44px 10px 8px;
  background: rgba(248, 248, 248, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.qn-pipeline-msg-back {
  font-size: 18px;
  font-weight: 300;
  color: #007aff;
  line-height: 1;
  width: 16px;
}

.qn-pipeline-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(145deg, #2563eb, #4f46e5);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qn-pipeline-msg-title {
  min-width: 0;
  flex: 1;
}

.qn-pipeline-msg-name {
  font-size: 11px;
  font-weight: 700;
  color: #000;
  letter-spacing: 0.04em;
}

.qn-pipeline-msg-sub {
  font-size: 9px;
  color: rgba(60, 60, 67, 0.55);
  margin-top: 2px;
  line-height: 1.2;
}

.qn-pipeline-msg-brand {
  font-weight: 600;
  color: rgba(60, 60, 67, 0.45);
  font-size: 8px;
  letter-spacing: 0.02em;
}

.qn-pipeline-msg-thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 8px 8px;
  background: linear-gradient(180deg, #e5e5ea 0%, #d8d8dd 100%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-content: flex-end;
}

.qn-pipeline-msg-input {
  flex-shrink: 0;
  padding: 6px 10px 10px;
  background: rgba(248, 248, 248, 0.98);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.qn-pipeline-msg-input-placeholder {
  display: block;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 6px 12px;
  font-size: 11px;
  color: rgba(60, 60, 67, 0.45);
}

.qn-pipeline-bubble {
  max-width: 88%;
  padding: 7px 10px 8px;
  font-size: 11px;
  line-height: 1.35;
  letter-spacing: -0.01em;
  opacity: 0;
  transform: translateY(14px) scale(0.97);
  transition:
    opacity var(--qn-duration) var(--qn-ease),
    transform var(--qn-duration) var(--qn-ease);
  will-change: opacity, transform;
}

.qn-pipeline-bubble p {
  margin: 0;
}

.qn-pipeline-bubble--in {
  align-self: flex-start;
  border-radius: 15px 15px 15px 4px;
  background: #e9e9eb;
  color: #000;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.qn-pipeline-bubble--out {
  align-self: flex-end;
  border-radius: 15px 15px 4px 15px;
  background: #34c759;
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.qn-pipeline-bubble.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.qn-pipeline-bubble--dense {
  font-size: 10px;
  line-height: 1.32;
  padding: 7px 9px 8px;
}

.qn-pipeline-typing {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  border-radius: 18px;
  background: #e9e9eb;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.35s var(--qn-ease), transform 0.35s var(--qn-ease);
}

.qn-pipeline-typing--hidden {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  padding: 0;
  margin: 0;
}

.qn-pipeline-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(60, 60, 67, 0.45);
  animation: qn-pipeline-dot 1.2s var(--qn-ease-soft) infinite;
}

.qn-pipeline-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.qn-pipeline-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes qn-pipeline-dot {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* Connector */
.qn-pipeline-connector-wrap {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-self: center;
  width: 160px;
  flex-shrink: 0;
  padding: 0 2px;
}

@media (min-width: 1024px) {
  .qn-pipeline-connector-wrap {
    display: flex;
  }
}

.qn-pipeline-connector-svg {
  width: 160px;
  height: 48px;
}

.qn-pipeline-connector-svg .qn-pipeline-flow-node,
.qn-pipeline-connector-svg-mobile .qn-pipeline-flow-node {
  transform-box: fill-box;
  transform-origin: center;
}

.qn-pipeline-flow-node-halo {
  pointer-events: none;
}

.qn-pipeline-connector-label {
  margin-top: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #2563eb;
  opacity: 1;
}

.qn-pipeline-connector-label--mobile {
  margin-top: 2px;
}

.qn-pipeline-flow-path {
  stroke-dashoffset: 0;
  stroke-dasharray: 1.2 8.4;
  stroke-linecap: round;
  stroke-width: 3;
  opacity: 0.98;
  animation: qn-pipeline-dash 1.1s linear infinite;
}

@keyframes qn-pipeline-dash {
  from {
    stroke-dashoffset: 0;
  }
  to {
    stroke-dashoffset: -36;
  }
}

.qn-pipeline-flow-node {
  opacity: 0.92;
  animation: qn-pipeline-node-flash-a 0.5s ease-in-out infinite;
  will-change: opacity, filter;
}

.qn-pipeline-flow-node--b,
.qn-pipeline-flow-node--m-b {
  animation-name: qn-pipeline-node-flash-b;
  animation-delay: 0.25s;
}

@keyframes qn-pipeline-node-flash-a {
  0%,
  100% {
    opacity: 0.88;
    filter: drop-shadow(0 0 6px rgba(37, 99, 235, 0.75));
  }
  50% {
    opacity: 1;
    filter: drop-shadow(0 0 16px rgba(37, 99, 235, 1)) drop-shadow(0 0 8px rgba(59, 130, 246, 0.9))
      drop-shadow(0 0 3px rgba(255, 255, 255, 0.95));
  }
}

@keyframes qn-pipeline-node-flash-b {
  0%,
  100% {
    opacity: 0.88;
    filter: drop-shadow(0 0 6px rgba(79, 70, 229, 0.75));
  }
  50% {
    opacity: 1;
    filter: drop-shadow(0 0 16px rgba(79, 70, 229, 1)) drop-shadow(0 0 8px rgba(129, 140, 248, 0.9))
      drop-shadow(0 0 3px rgba(255, 255, 255, 0.95));
  }
}

.qn-pipeline-connector-mobile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: min(320px, 100%);
  padding: 0.35rem 0 0.5rem;
}

@media (min-width: 1024px) {
  .qn-pipeline-connector-mobile {
    display: none;
  }
}

.qn-pipeline-connector-svg-mobile {
  width: 56px;
  height: 92px;
}

.qn-pipeline-flow-path-mobile {
  stroke-dashoffset: 0;
  stroke-dasharray: 1.1 7;
  stroke-linecap: round;
  stroke-width: 3.1;
  opacity: 0.98;
  animation: qn-pipeline-dash-m 1s linear infinite;
}

@keyframes qn-pipeline-dash-m {
  from {
    stroke-dashoffset: 0;
  }
  to {
    stroke-dashoffset: -28;
  }
}

/* Outcomes column */
.qn-pipeline-outcomes {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 1024px) {
  .qn-pipeline-outcomes {
    padding-top: 0;
  }
}

/* Dashboard shell + hanging SMS tag (top-right) */
.qn-pipeline-dash-wrap {
  position: relative;
  z-index: 0;
}

.qn-pipeline-sms-tag {
  position: absolute;
  top: -4px;
  right: 12px;
  z-index: 6;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  max-width: calc(100% - 24px);
  pointer-events: none;
  filter: drop-shadow(0 14px 32px rgba(15, 23, 42, 0.2));
  opacity: 0;
  transform: translateY(-10px) rotate(5deg) scale(0.94);
  transition:
    opacity 0.55s var(--qn-ease),
    transform 0.55s var(--qn-ease);
  transform-origin: 100% 0%;
}

.qn-pipeline-sms-tag.is-visible {
  opacity: 1;
  transform: translateY(0) rotate(2.5deg) scale(1);
}

.qn-pipeline-sms-tag-hole {
  flex-shrink: 0;
  width: 11px;
  align-self: flex-start;
  margin-top: 14px;
  margin-right: -1px;
  height: 11px;
  border-radius: 50%;
  background: #f1f5f9;
  border: 2px solid #334155;
  box-shadow:
    0 0 0 2px #fff,
    inset 0 1px 2px rgba(255, 255, 255, 0.9);
}

.qn-pipeline-sms-tag-body {
  min-width: 0;
  padding: 8px 12px 9px;
  border-radius: 10px 10px 10px 4px;
  background: linear-gradient(155deg, #1e293b 0%, #0f172a 55%, #020617 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
}

.qn-pipeline-sms-tag-kicker {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.95);
}

.qn-pipeline-sms-tag-name {
  margin-top: 3px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #f8fafc;
  line-height: 1.2;
}

.qn-pipeline-sms-tag-need {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.35;
  color: rgba(226, 232, 240, 0.92);
}

.qn-pipeline-dash-row {
  position: relative;
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.45s var(--qn-ease),
    transform 0.45s var(--qn-ease),
    background-color 0.5s var(--qn-ease),
    box-shadow 0.5s var(--qn-ease);
}

.qn-pipeline-dash-row.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.qn-pipeline-dash-row.is-highlight {
  background: linear-gradient(90deg, rgba(239, 246, 255, 0.95), rgba(255, 255, 255, 0));
  box-shadow: inset 3px 0 0 #2563eb;
  animation: qn-pipeline-row-glow 1.4s var(--qn-ease-soft) ease-out;
}

@keyframes qn-pipeline-row-glow {
  0% {
    background-color: rgba(219, 234, 254, 0.9);
  }
  100% {
    background-color: transparent;
  }
}

/* Mobile / touch: WebKit often fails to animate SVG filters on circles; keep dash + dot motion readable */
@media (max-width: 1023.98px) {
  .qn-pipeline-phone-column {
    position: relative;
    z-index: 2;
  }

  .qn-pipeline-connector-mobile {
    position: relative;
    z-index: 1;
    margin-top: 0.25rem;
    margin-bottom: 0.15rem;
  }

  .qn-pipeline-outcomes {
    position: relative;
    z-index: 0;
    margin-top: 0.35rem;
  }

  /* Slightly narrower chassis so thread / input proportions feel balanced on small screens */
  .qn-pipeline-device {
    width: min(210px, 72vw);
  }

  .qn-pipeline-msg-header {
    padding: 40px 10px 6px;
  }

  .qn-pipeline-msg-input {
    padding: 5px 10px 8px;
  }

  .qn-pipeline-msg-thread {
    min-height: 132px;
  }

  .qn-pipeline-connector-svg-mobile {
    transform: translateZ(0);
  }

  /* Make the "lead synced" dash look more like dot-loading on mobile */
  .qn-pipeline-flow-path-mobile {
    opacity: 1;
    stroke-width: 3;
  }

  .qn-pipeline-connector-svg-mobile .qn-pipeline-flow-node {
    animation: qn-pipeline-node-pulse-m 0.65s ease-in-out infinite;
    /* Static glow + high-contrast opacity/scale animation */
    filter: drop-shadow(0 0 12px rgba(37, 99, 235, 0.55));
    will-change: transform, opacity;
    opacity: 1;
  }

  .qn-pipeline-connector-svg-mobile .qn-pipeline-flow-node-halo {
    opacity: 1;
    /* Halo stays visible even while the dash moves */
    filter: drop-shadow(0 0 14px rgba(147, 197, 253, 0.55));
  }

  .qn-pipeline-connector-svg-mobile .qn-pipeline-flow-node--m-b {
    animation-name: qn-pipeline-node-pulse-m;
    animation-delay: 0.32s;
  }
}

@keyframes qn-pipeline-node-pulse-m {
  0%,
  100% {
    opacity: 0.82;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.3);
  }
}

@media (prefers-reduced-motion: reduce) {
  .qn-pipeline-bubble,
  .qn-pipeline-sms-tag,
  .qn-pipeline-typing,
  .qn-pipeline-dash-row {
    transition: none !important;
    animation: none !important;
  }

  .qn-pipeline-bubble {
    opacity: 1;
    transform: none;
  }

  .qn-pipeline-dash-row {
    opacity: 1 !important;
    transform: none !important;
  }

  .qn-pipeline-typing {
    display: none !important;
  }

  .qn-pipeline-flow-path,
  .qn-pipeline-flow-path-mobile,
  .qn-pipeline-flow-node {
    animation: none !important;
  }

  .qn-pipeline-flow-node {
    opacity: 1 !important;
    filter: none !important;
  }

  .qn-pipeline-sms-tag {
    opacity: 1;
    transform: none;
  }

  .qn-pipeline-connector-label,
  .qn-pipeline-connector-label--mobile {
    color: #64748b;
  }
}
