/* Paperful AI - RAG architecture whiteboard.
   The content of support/rag-flow.html, brought into the landing page as real
   markup. Fonts are self-hosted because the site CSP allows only same-origin
   styles, fonts and images. */

@font-face {
  font-family: "Architects Daughter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/architects-daughter-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Patrick Hand";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/patrick-hand-latin.woff2") format("woff2");
}

.container--wide { max-width: 1440px; }

/* ---------- Architecture section ---------- */
.section--architecture {
  position: relative;
  background-color: var(--bg);
  background-image: radial-gradient(rgba(23, 21, 18, .05) 1px, transparent 1px);
  background-size: 22px 22px;
}
.architecture__lede {
  max-width: 760px;
  margin: -16px 0 clamp(26px, 3vw, 38px);
  color: var(--muted);
  font-size: clamp(16px, 1.4vw, 17.5px);
  line-height: 1.6;
}

/* ---------- Whiteboard card ---------- */
.whiteboard {
  --ink: #1e1e1e;
  --blue-fill: #a5d8ff;
  --blue-text: #1971c2;
  --green-fill: #b2f2bb;
  --green-text: #2f9e44;
  --yellow-fill: #ffec99;
  --coral-fill: #ffc9c9;
  --coral-text: #e03131;
  --purple-fill: #d0bfff;
  --teal-fill: #99e9f2;
  --gray-fill: #e9ecef;
  --orange-fill: #ffd8a8;
  --orange-text: #d9480f;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(18px, 2.2vw, 28px);
  margin: 0;
  padding: clamp(18px, 2.6vw, 36px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #fff;
  color: var(--ink);
  font-family: "Architects Daughter", "Patrick Hand", "Bradley Hand", "Chalkboard SE", cursive, sans-serif;
  box-shadow:
    inset 0 1px 0 #fff,
    0 1px 2px rgba(23, 21, 18, .05),
    0 26px 60px rgba(23, 21, 18, .10);
  overflow: hidden;
}
.whiteboard__title {
  margin: 0;
  font-size: clamp(1.35rem, 2.2vw, 1.85rem);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: .01em;
  text-align: center;
}

/* ---------- Dotted pipeline containers ---------- */
.pipeline {
  width: 100%;
  padding: clamp(16px, 2vw, 26px);
  border: 2.2px dotted #495057;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.pipeline__title {
  margin: 0 0 clamp(14px, 2vw, 24px);
  font-size: clamp(1.05rem, 1.5vw, 1.3rem);
  line-height: 1.25;
  font-weight: 700;
  text-align: center;
}

/* ---------- Flow row and stages ---------- */
.flow-row {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 8px;
  flex-wrap: nowrap;
}
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}
.top-label {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 2rem;
  margin: 0 0 .4rem;
  font-size: .85rem;
  line-height: 1.15;
  font-weight: 700;
  text-align: center;
}
.bottom-label {
  margin: .45rem 0 0;
  font-size: .85rem;
  line-height: 1.2;
  font-weight: 700;
  text-align: center;
}

/* Label colours */
.t-blue { color: var(--blue-text); }
.t-green { color: var(--green-text); }
.t-coral { color: var(--coral-text); }
.t-orange { color: var(--orange-text); }
.t-purple { color: #6741d9; }
.t-teal { color: #0c8599; }

/* ---------- Hand-drawn boxes ---------- */
.sketch-box {
  border: 2.3px solid var(--ink);
  border-radius: 14px 12px 15px 11px / 11px 15px 12px 14px;
  box-shadow: 2px 3px 0 rgba(30, 30, 30, .12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-weight: 700;
  font-size: .85rem;
  line-height: 1.15;
  text-align: center;
  position: relative;
  transition: transform .2s ease;
}
.sketch-box:hover { transform: translateY(-3px) rotate(-.5deg); }

/* Stacked documents */
.doc-stack { position: relative; width: 128px; height: 104px; }
.doc-sheet {
  position: absolute;
  width: 99px;
  height: 78px;
  background: var(--gray-fill);
  border: 2.2px solid var(--ink);
  border-radius: 12px;
}
.doc-sheet:nth-child(1) { top: 0; left: 0; }
.doc-sheet:nth-child(2) { top: 9px; left: 10px; }
.doc-sheet:nth-child(3) { top: 18px; left: 20px; }
.doc-sheet:nth-child(4) {
  top: 27px;
  left: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-weight: 700;
  font-size: .8rem;
}

/* Horizontal bar stacks (chunks, embeddings, citations) */
.bar-stack { display: flex; flex-direction: column; gap: 6px; width: 118px; }
.bar-item {
  height: 19px;
  width: 100%;
  border: 2.1px solid var(--ink);
  border-radius: 6px 5px 6px 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: -.02em;
  white-space: nowrap;
  overflow: hidden;
}
.single-bar {
  width: 114px;
  height: 27px;
  border: 2.2px solid var(--ink);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
}

/* Square / rounded nodes */
.node-square {
  width: 106px;
  height: 92px;
  padding: .35rem;
}
.node-icon {
  width: 21px;
  height: 21px;
  stroke: var(--ink);
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Fills */
.bg-blue { background-color: var(--blue-fill); }
.bg-green { background-color: var(--green-fill); }
.bg-yellow { background-color: var(--yellow-fill); }
.bg-coral { background-color: var(--coral-fill); }
.bg-purple { background-color: var(--purple-fill); }
.bg-teal { background-color: var(--teal-fill); }
.bg-orange { background-color: var(--orange-fill); }

/* ---------- Animated hand-drawn arrows ---------- */
.arrow-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  flex: none;
}
.arrow-svg { width: 44px; height: 26px; overflow: visible; }
.sketch-track { stroke: #adb5bd; stroke-width: 2; fill: none; stroke-linecap: round; }
.sketch-flow {
  stroke: var(--ink);
  stroke-width: 2.4;
  stroke-dasharray: 6 6;
  fill: none;
  stroke-linecap: round;
  animation: handFlow .85s linear infinite;
}
.sketch-head {
  stroke: var(--ink);
  stroke-width: 2.3;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* OCR branch below the chat model */
.stage--branch { position: relative; }
.v-arrow { width: 28px; height: 36px; margin: 4px 0; }
.v-sketch-flow {
  stroke: var(--orange-text);
  stroke-width: 2.2;
  stroke-dasharray: 5 5;
  fill: none;
  stroke-linecap: round;
  animation: handFlowUp .9s linear infinite;
}
.ocr-box {
  width: 112px;
  height: 54px;
  border: 2.2px dashed var(--orange-text);
  border-radius: 12px;
  background-color: #fff4e6;
  color: var(--orange-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  gap: 2px;
}

/* Retrieval row keeps its staggered whiteboard look */
.flow-row--retrieval { align-items: flex-start; }
.stage--query { margin-top: 1.4rem; }
.flow-row--retrieval > .arrow-wrap { margin-top: 3.1rem; }

@keyframes handFlow {
  to { stroke-dashoffset: -24; }
}
@keyframes handFlowUp {
  to { stroke-dashoffset: 20; }
}

/* ---------- Responsive: keep the pipeline horizontal ---------- */
/* Below the board's natural width, do not collapse the flow into a vertical
   list. Keep the left-to-right pipeline and scroll the row sideways instead. */
@media (max-width: 1340px) {
  .flow-row {
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    justify-content: flex-start;
    justify-content: safe center;
    padding-bottom: 8px;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #c9c1b6 transparent;
    /* Fade the right edge only when the row actually overflows. At 1280px the
       content ends before this 12px strip, so the full diagram stays sharp. */
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 12px), transparent 100%);
    mask-image: linear-gradient(90deg, #000 calc(100% - 12px), transparent 100%);
  }
  .arrow-wrap { width: 41px; }
  .arrow-svg { width: 39px; height: 23px; }
  .stage { flex: none; }
  .flow-row::-webkit-scrollbar { height: 8px; }
  .flow-row::-webkit-scrollbar-track { background: transparent; }
  .flow-row::-webkit-scrollbar-thumb {
    background: #c9c1b6;
    border-radius: 999px;
  }
}
@media (max-width: 560px) {
  .whiteboard { border-radius: 18px; }
  .pipeline { border-radius: 16px; padding: 14px 10px; }
  .bar-stack { width: 110px; }
}
@media (prefers-reduced-motion: reduce) {
  .sketch-flow, .v-sketch-flow { animation: none; }
}
