/* 05 / Train it: three knowledge sources drop into a zone and are indexed, then the website
   chat answers a question from the new document. Every rule is scoped under #train. */

/* ---------- Layout: drop zone (left) and chat (right), Replay on its own row below ---------- */

#train .sup-train-in {
  --sup-train-h: 300px; /* desktop: the drop zone and the chat widget share this height */
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  align-items: start;
  column-gap: 28px;
  row-gap: 16px;
  padding: 28px;
}

#train .sup-drop,
#train .sup-train-chat {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

#train .sup-drop-head,
#train .sup-train-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
  min-height: 28px;
}

#train .sup-drop-r {
  margin-left: auto;
  text-align: right;
}

/* ---------- Drop zone ---------- */

#train .sup-drop-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
  padding: 16px;
  border: 1.5px dashed var(--line);
  border-radius: var(--r-lg);
  transition: border-color 0.4s var(--ease-std), background-color 0.4s var(--ease-std);
}

#train .sup-drop-zone.is-over {
  border-color: var(--accent);
  background-color: rgb(255 255 255 / 0.04);
}

#train .sup-drop-hint {
  position: absolute;
  inset: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  pointer-events: none;
  transition: opacity 0.4s var(--ease-std);
}

#train .sup-drop-hint.is-gone {
  opacity: 0;
}

#train .sup-drop-hint > svg {
  width: 28px;
  height: 28px;
  color: var(--ash);
}

#train .sup-drop-hint-t {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.4;
  color: var(--ash);
}

#train .sup-drop-hint-m {
  font-size: 12px;
}

#train .sup-src-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- Source row ---------- */

#train .sup-src {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  grid-template-areas: "ic main st";
  align-items: center;
  gap: 4px 14px;
  padding: 12px 14px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1), transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Entrance: starts offset and transparent, then the JS removes .is-enter and the transition runs */
#train .sup-src.is-enter {
  opacity: 0;
  transform: translate(-28px, -18px) scale(0.96);
}

#train .sup-src-ic {
  grid-area: ic;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--elev);
  color: var(--accent);
  transition: color 0.4s var(--ease-std);
}

#train .sup-src-ic svg {
  display: block;
  width: 18px;
  height: 18px;
}

#train .sup-src-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1;
  letter-spacing: 0.02em;
}

#train .sup-src.is-done .sup-src-ic {
  color: var(--bone);
}

#train .sup-src-main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

#train .sup-src-name {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.005em;
  color: var(--bone);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#train .sup-src-meta {
  font-size: 12px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#train .sup-src-st {
  grid-area: st;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.4;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ash);
  white-space: nowrap;
}

#train .sup-src.is-done .sup-src-st {
  color: var(--ok);
}

#train .sup-src-check {
  flex: none;
  width: 14px;
  height: 14px;
}

/* 2px progress bar along the foot of the row, filled in gold while indexing */
#train .sup-src-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  pointer-events: none;
  transition: opacity 0.4s var(--ease-std);
}

#train .sup-src-bar i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
}

#train .sup-src.is-done .sup-src-bar {
  opacity: 0;
}

/* Narrow rows: the status text drops under the name */
@media (max-width: 520px) {
  #train .sup-src {
    grid-template-columns: 36px minmax(0, 1fr);
    grid-template-areas:
      "ic main"
      "ic st";
    gap: 4px 12px;
  }

  #train .sup-src-st {
    justify-self: start;
    min-width: 0;
    white-space: normal;
    letter-spacing: 0.08em;
  }

  #train .sup-train-foot-l {
    letter-spacing: 0.1em;
  }
}

/* ---------- Footer, once all sources are indexed ---------- */

#train .sup-train-foot {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.5s var(--ease-soft), transform 0.5s var(--ease-soft);
}

#train .sup-train-foot.is-on {
  opacity: 1;
  transform: none;
}

#train .sup-train-foot-l {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--bone);
}

#train .sup-train-foot-r {
  white-space: nowrap;
}

/* ---------- Chat ---------- */

#train .sup-train-wg {
  --wg-fs: 13.5px;
  height: var(--sup-train-h);
}

/* ---------- Replay: bottom right of the stage, hidden (but keeps its row) until the sequence ends ---------- */

#train .sup-train-replay {
  grid-column: 1 / -1;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--bone);
  transition: border-color 0.2s, color 0.2s;
}

#train .sup-train-replay[hidden] {
  display: inline-flex;
  visibility: hidden;
  pointer-events: none;
}

#train .sup-train-replay:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#train .sup-train-replay svg {
  width: 14px;
  height: 14px;
}

/* Static and reduced motion: no Replay at all, so its row goes too */
#train .sup-train-in.is-final .sup-train-replay {
  display: none;
}

/* Under the stage, left-aligned like the other captions */

#train .sup-train-line {
  max-width: 44rem;
  margin: 24px 0 0;
  text-align: left;
}

/* ---------- Desktop: the drop zone is exactly as tall as the chat widget (no empty band) ---------- */

@media (min-width: 1024px) {
  #train .sup-drop-zone {
    min-height: var(--sup-train-h);
  }
}

/* ---------- One column below 1024px: drop zone, then chat ---------- */

@media (max-width: 1023px) {
  #train .sup-train-in {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 24px;
    padding: 18px;
  }
}

/* Phones: the widget gets its smaller size (matches the widget's mobile type) */
@media (max-width: 600px) {
  #train .sup-train-wg {
    --wg-fs: 12.5px;
    height: 340px;
  }
}

/* The gold phrase of the heading moves to its own line as a whole */
#train .sec-title .gold-i {
  display: inline-block;
}
