/* Four distinct stages in the knowledge-processing workflow. */
.architecture-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
  align-items: stretch;
}

.architecture-grid > .architecture-arrow {
  display: none;
}

.architecture-card {
  position: relative;
}

.architecture-card:not(:last-child)::after {
  position: absolute;
  top: 50%;
  right: -24px;
  z-index: 1;
  width: 24px;
  content: "→";
  color: #a6b0d0;
  font-size: 18px;
  line-height: 1;
  text-align: center;
  transform: translateY(-50%);
}

@media (max-width: 900px) {
  .architecture-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
  }

  .architecture-card::after {
    display: none;
  }
}

@media (max-width: 700px) {
  .architecture-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .architecture-card {
    min-height: 0;
  }
}

/* Document ingestion: connected workflow rather than a row of isolated cards. */
#ingestion .rich-flow {
  gap: 20px;
  margin-top: 36px;
  isolation: isolate;
}

#ingestion .rich-flow > div {
  min-height: 164px;
  padding: 19px 15px 17px;
  border: 1px solid #d8e3f4;
  border-radius: 14px;
  background: linear-gradient(145deg, #ffffff 0%, #f8fbff 100%);
  box-shadow: 0 10px 24px rgba(47, 87, 151, 0.055);
  transition: border-color 220ms ease, box-shadow 220ms ease, transform 220ms ease;
}

#ingestion .rich-flow > div:hover {
  z-index: 2;
  border-color: #9ab8fa;
  box-shadow: 0 14px 28px rgba(47, 87, 151, 0.12);
  transform: translateY(-4px);
}

#ingestion .rich-flow > div:not(:last-child)::after {
  top: 50%;
  right: -20px;
  z-index: 1;
  width: 20px;
  height: 2px;
  background: linear-gradient(90deg, #c1d1ee 0 36%, #4d7ff0 49%, #c1d1ee 62% 100%);
  background-size: 220% 100%;
  box-shadow: none;
}

#ingestion .rich-flow > div:not(:last-child)::before {
  position: absolute;
  top: calc(50% - 4px);
  right: -20px;
  z-index: 2;
  width: 0;
  height: 0;
  content: "";
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid #7fa4ed;
}

#ingestion .rich-flow b {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  color: #255fe8;
  background: #eaf1ff;
  font-size: 11px;
}

#ingestion .rich-flow strong {
  margin-top: 17px;
  color: #40516d;
  font-size: 15px;
  letter-spacing: -0.02em;
}

#ingestion .rich-flow span {
  margin-top: 7px;
  color: #71819a;
  font-size: 11px;
  line-height: 1.65;
}

.flow-motion-ready #ingestion .rich-flow > div {
  opacity: 0;
  transform: translateY(16px);
}

.flow-motion-ready #ingestion .rich-flow.is-flow-active > div {
  animation: flow-node-in 520ms cubic-bezier(0.22, 0.8, 0.25, 1) both;
}

.flow-motion-ready #ingestion .rich-flow.is-flow-active > div:nth-child(1) { animation-delay: 0ms; }
.flow-motion-ready #ingestion .rich-flow.is-flow-active > div:nth-child(2) { animation-delay: 80ms; }
.flow-motion-ready #ingestion .rich-flow.is-flow-active > div:nth-child(3) { animation-delay: 160ms; }
.flow-motion-ready #ingestion .rich-flow.is-flow-active > div:nth-child(4) { animation-delay: 240ms; }
.flow-motion-ready #ingestion .rich-flow.is-flow-active > div:nth-child(5) { animation-delay: 320ms; }
.flow-motion-ready #ingestion .rich-flow.is-flow-active > div:nth-child(6) { animation-delay: 400ms; }

.flow-motion-ready #ingestion .rich-flow.is-flow-active > div:not(:last-child)::after {
  animation: flow-link-travel 1.7s linear infinite;
}

@keyframes flow-node-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes flow-link-travel {
  from { background-position: 220% 0; }
  to { background-position: -20% 0; }
}

@media (max-width: 900px) {
  #ingestion .rich-flow { gap: 18px; }
  #ingestion .rich-flow > div:nth-child(3)::after,
  #ingestion .rich-flow > div:nth-child(3)::before { display: none; }
}

@media (max-width: 700px) {
  #ingestion .rich-flow { gap: 16px; }
  #ingestion .rich-flow > div { min-height: 150px; }
  #ingestion .rich-flow > div:nth-child(3)::after,
  #ingestion .rich-flow > div:nth-child(3)::before { display: block; }
  #ingestion .rich-flow > div:nth-child(2)::after,
  #ingestion .rich-flow > div:nth-child(2)::before,
  #ingestion .rich-flow > div:nth-child(4)::after,
  #ingestion .rich-flow > div:nth-child(4)::before { display: none; }
}

@media (max-width: 390px) {
  #ingestion .rich-flow { gap: 22px; }
  #ingestion .rich-flow > div:not(:last-child)::after {
    top: auto;
    right: auto;
    bottom: -22px;
    left: 50%;
    width: 2px;
    height: 22px;
    transform: translateX(-50%);
    background: linear-gradient(180deg, #c1d1ee 0 36%, #4d7ff0 49%, #c1d1ee 62% 100%);
    background-size: 100% 220%;
  }
  #ingestion .rich-flow > div:not(:last-child)::before {
    top: auto;
    right: auto;
    bottom: -22px;
    left: calc(50% - 4px);
    border-top: 5px solid #7fa4ed;
    border-right: 4px solid transparent;
    border-bottom: 0;
    border-left: 4px solid transparent;
  }
  #ingestion .rich-flow > div:nth-child(n)::after,
  #ingestion .rich-flow > div:nth-child(n)::before { display: block !important; }
  #ingestion .rich-flow > div:last-child::after,
  #ingestion .rich-flow > div:last-child::before { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .flow-motion-ready #ingestion .rich-flow > div {
    opacity: 1;
    transform: none;
    animation: none !important;
  }
  .flow-motion-ready #ingestion .rich-flow.is-flow-active > div:not(:last-child)::after {
    animation: none;
  }
  #ingestion .rich-flow > div { transition: none; }
}

/* Refined ingestion pipeline: a single visual system with a travelling signal. */
#ingestion .rich-flow.flow-pipeline {
  position: relative;
  gap: 22px;
  margin-top: 40px;
  padding: 28px 20px 24px;
  border: 1px solid #dce7f7;
  border-radius: 22px;
  background:
    radial-gradient(circle at 12% 18%, rgba(66, 121, 255, 0.12), transparent 24%),
    radial-gradient(circle at 88% 82%, rgba(65, 193, 179, 0.08), transparent 26%),
    linear-gradient(135deg, #f9fbff 0%, #f3f7ff 49%, #f9fcff 100%);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.86), 0 18px 42px rgba(50, 88, 151, 0.055);
}

#ingestion .flow-pipeline::before {
  position: absolute;
  inset: 15px;
  z-index: -1;
  content: "";
  border-radius: 14px;
  opacity: 0.42;
  background-image: linear-gradient(rgba(115, 147, 205, 0.09) 1px, transparent 1px), linear-gradient(90deg, rgba(115, 147, 205, 0.09) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}

#ingestion .rich-flow.flow-pipeline > .flow-stage {
  min-height: 190px;
  padding: 18px 16px 16px;
  overflow: visible;
  border: 1px solid rgba(202, 218, 242, 0.9);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 28px rgba(41, 73, 125, 0.065);
  backdrop-filter: blur(5px);
}

#ingestion .rich-flow.flow-pipeline > .flow-stage:hover {
  border-color: #9bb9f7;
  box-shadow: 0 18px 36px rgba(41, 86, 159, 0.13);
  transform: translateY(-5px);
}

#ingestion .rich-flow.flow-pipeline > .flow-stage::after {
  right: -22px;
  width: 22px;
  height: 2px;
  border-radius: 4px;
  background: linear-gradient(90deg, #c5d5f0 0%, #6f9cf4 50%, #c5d5f0 100%);
  background-size: 180% 100%;
}

#ingestion .rich-flow.flow-pipeline > .flow-stage::before {
  top: calc(50% - 4px);
  right: -21px;
  width: 7px;
  height: 7px;
  border: 0;
  border-right: 2px solid #537fdc;
  border-bottom: 2px solid #537fdc;
  background: transparent;
  transform: rotate(-45deg);
}

#ingestion .rich-flow.flow-pipeline b {
  position: relative;
  width: 38px;
  height: 38px;
  overflow: visible;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(145deg, #447dff, #2862e8);
  box-shadow: 0 7px 16px rgba(40, 98, 232, 0.22);
  font-size: 11px;
  letter-spacing: 0.03em;
  transition: background 220ms ease, box-shadow 220ms ease, transform 220ms ease;
}

#ingestion .rich-flow b::after {
  position: absolute;
  inset: -5px;
  content: "";
  border: 1px solid rgba(61, 112, 240, 0.2);
  border-radius: 15px;
  opacity: 0;
  transform: scale(0.82);
}

#ingestion .rich-flow strong {
  position: relative;
  margin-top: 20px;
  color: #344a6e;
  font-size: 16px;
  font-weight: 750;
  line-height: 1.35;
}

#ingestion .rich-flow strong::after {
  display: block;
  width: 22px;
  height: 2px;
  margin-top: 9px;
  content: "";
  border-radius: 9px;
  background: linear-gradient(90deg, #2e6cf0, #82abff);
}

#ingestion .rich-flow span {
  margin-top: 10px;
  color: #71819a;
  font-size: 11px;
  line-height: 1.68;
}

#ingestion .rich-flow.is-flow-active > .flow-stage:not(:last-child)::after {
  animation: flow-link-travel 1.35s linear infinite;
}

#ingestion .rich-flow.is-flow-active > .flow-stage.is-stage-active {
  z-index: 3;
  border-color: #92b3f7;
  background: linear-gradient(145deg, #ffffff, #eef5ff);
  box-shadow: 0 18px 38px rgba(44, 94, 182, 0.17);
}

#ingestion .rich-flow.is-flow-active > .flow-stage.is-stage-active b {
  background: linear-gradient(145deg, #316df4, #3ea9d5);
  box-shadow: 0 9px 20px rgba(48, 109, 244, 0.34);
  transform: scale(1.08);
}

#ingestion .rich-flow.is-flow-active > .flow-stage.is-stage-active b::after {
  animation: flow-signal-pulse 900ms ease-out both;
}

@keyframes flow-signal-pulse {
  0% { opacity: 0.78; transform: scale(0.82); }
  80%, 100% { opacity: 0; transform: scale(1.62); }
}

#ingestion .rich-status {
  gap: 12px;
  margin-top: 20px;
  padding: 12px;
  border: 1px solid #e1e9f5;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

#ingestion .rich-status div {
  position: relative;
  min-height: 78px;
  padding: 14px 13px 13px 17px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 11px;
  background: linear-gradient(135deg, #f7faff, #fff);
  transition: border-color 180ms ease, background 180ms ease;
}

#ingestion .rich-status div::before {
  position: absolute;
  top: 13px;
  bottom: 13px;
  left: 0;
  width: 3px;
  content: "";
  border-radius: 0 5px 5px 0;
  background: #aab8cb;
}

#ingestion .rich-status div:not(.waiting):not(.failed)::before { background: #40b889; }
#ingestion .rich-status .failed::before { background: #df6b75; }
#ingestion .rich-status div:hover { border-color: #d5e1f3; background: #fff; }
#ingestion .rich-status b { margin-bottom: 4px; color: #3c5274; font-size: 13px; }
#ingestion .rich-status i { width: 8px; height: 8px; margin-right: 7px; box-shadow: 0 0 0 4px rgba(67, 185, 132, 0.11); }
#ingestion .rich-status .waiting i { box-shadow: 0 0 0 4px rgba(174, 185, 202, 0.15); }
#ingestion .rich-status .failed i { box-shadow: 0 0 0 4px rgba(220, 106, 115, 0.12); }

@media (max-width: 900px) {
  #ingestion .rich-flow.flow-pipeline { gap: 18px; padding: 20px 16px; }
  #ingestion .rich-flow.flow-pipeline > .flow-stage { min-height: 172px; }
}

@media (max-width: 700px) {
  #ingestion .rich-flow.flow-pipeline { gap: 16px; padding: 16px 13px; }
  #ingestion .rich-flow.flow-pipeline > .flow-stage { min-height: 154px; padding: 16px 14px; }
  #ingestion .rich-flow strong { margin-top: 16px; font-size: 15px; }
  #ingestion .rich-flow span { margin-top: 8px; }
  #ingestion .rich-status { grid-template-columns: 1fr 1fr; padding: 8px; }
}

@media (max-width: 390px) {
  #ingestion .rich-flow.flow-pipeline { gap: 22px; }
  #ingestion .rich-flow.flow-pipeline > .flow-stage:not(:last-child)::after {
    background: repeating-linear-gradient(180deg, #bdd0f2 0 7px, #618df0 7px 11px, #bdd0f2 11px 18px);
    background-size: 100% 140%;
  }
  #ingestion .rich-flow.flow-pipeline > .flow-stage:not(:last-child)::before {
    right: auto;
    bottom: -21px;
    left: calc(50% - 4px);
    width: 7px;
    height: 7px;
    border: 0;
    border-right: 2px solid #537fdc;
    border-bottom: 2px solid #537fdc;
    transform: rotate(45deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  #ingestion .rich-flow.is-flow-active > .flow-stage.is-stage-active b::after { animation: none; }
  #ingestion .rich-flow.flow-pipeline > .flow-stage,
  #ingestion .rich-status div,
  #ingestion .rich-flow b { transition: none; }
}
