/* data-flow.html — "Where your text goes".

   Page-only styles, kept out of style.css so the site's cached stylesheet is
   untouched. Three blocks, all inside one 880px column:

   - .ill       the illustration. Three tiles joined by one wire; a packet
                ("Your text", then "Answer") rides above the wire. data-flow.js
                walks .ill-stage[data-step] from 1 to 7 and every visual state
                below is keyed off that one attribute, so the whole animation
                is CSS transitions. The markup ships at step 7 (the finished
                picture), which is what no-JS visitors see.
   - .kept      what each place keeps, and for how long.
   - .qs        short questions and answers.

   Tile centres are fixed by the three equal grid columns: 16.667%, 50% and
   83.333% of the row. The wire, the locks and the packet all use those. */

.df-body {
  max-width: 880px;
  margin: 0 auto;
}

.df-body > * + * {
  margin-top: 4.5rem;
}

.df-body h2 {
  font-size: 1.35rem;
  color: var(--text-white);
  margin: 0 0 1.25rem;
}

/* ── Illustration ──────────────────────────────────────────────────────────── */
.ill {
  margin: 0;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 1.5rem 2rem 1.4rem;
}

.ill-stage {
  --tile: 64px;
  --lane: 3.25rem; /* room above the tiles for the packet */
  position: relative;
}

.ill-row {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding-top: var(--lane);
}

/* The wire, tile centre to tile centre, behind the tiles. */
.ill-row::before {
  content: "";
  position: absolute;
  left: 16.667%;
  right: 16.667%;
  top: calc(var(--lane) + var(--tile) / 2);
  height: 1px;
  background: rgba(255, 255, 255, 0.14);
}

.ill-lock {
  position: absolute;
  top: calc(var(--lane) + var(--tile) / 2);
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #1c1c1c;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  transition: color 0.3s ease, border-color 0.3s ease;
}

.ill-lock svg {
  width: 11px;
  height: 11px;
}

.ill-lock.is-left { left: 33.333%; }
.ill-lock.is-right { left: 66.667%; }

.ill-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 0;
  padding: 0 0.25rem;
}

.ill-tile {
  position: relative;
  z-index: 1;
  width: var(--tile);
  height: var(--tile);
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: #1f1f1f;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #c2c2ca;
  transition: border-color 0.35s ease, background-color 0.35s ease, transform 0.35s ease;
}

.ill-tile svg {
  width: 26px;
  height: 26px;
}

.ill-tile img {
  width: 34px;
  height: 34px;
}

.ill-tile .pv-brand {
  fill: currentColor;
}

.ill-node b {
  margin-top: 0.75rem;
  color: var(--text-white);
  font-size: 0.95rem;
  line-height: 1.3;
}

/* One slot under each name; the pills in it are stacked and cross-fade. */
.ill-status {
  display: grid;
  justify-items: center;
  margin-top: 0.55rem;
  min-height: 1.6rem;
}

.ill-pill {
  grid-area: 1 / 1;
  align-self: start;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.25;
  padding: 0.25rem 0.6rem;
  /* Not a full pill: on a phone "Kept until you clear it" wraps to two lines. */
  border-radius: 10px;
  max-width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text-secondary);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.ill-pill.is-live {
  color: var(--text-white);
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.22);
}

/* The packet. The runner spans the whole row, so translateX(50%) on it is
   50% of the row: exactly the middle tile's centre. */
.ill-rail {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: var(--lane);
  pointer-events: none;
}

.ill-runner {
  position: absolute;
  inset: 0;
  transform: translateX(var(--x, 16.667%));
  transition: transform 1s cubic-bezier(0.45, 0, 0.2, 1);
}

.ill-packet {
  position: absolute;
  left: 0;
  top: 45%;
  display: grid;
  transform: translate(-50%, -50%) scale(var(--s, 0.6));
  opacity: var(--o, 0);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.ill-packet span {
  grid-area: 1 / 1;
  justify-self: center;
  padding: 0.3rem 0.7rem;
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  transition: opacity 0.3s ease;
}

/* "Your text" looks like a selection; "Answer" like something written. */
.ill-packet .is-q {
  background: var(--text-white);
  color: #1c1c1c;
}

.ill-packet .is-a {
  background: #2a2a2a;
  color: var(--text-white);
  border: 1px solid rgba(255, 255, 255, 0.35);
  opacity: 0;
}

/* ── Steps ─────────────────────────────────────────────────────────────────────
   1 selected on the PC      2 travelling to the server   3 at the server
   4 travelling to Google    5 Gemini writes the answer   6 answer travels home
   7 done: what each place keeps                                              */
.ill-stage[data-step="1"] .ill-packet,
.ill-stage[data-step="2"] .ill-packet,
.ill-stage[data-step="3"] .ill-packet,
.ill-stage[data-step="4"] .ill-packet,
.ill-stage[data-step="5"] .ill-packet,
.ill-stage[data-step="6"] .ill-packet {
  --o: 1;
  --s: 1;
}

.ill-stage[data-step="2"] .ill-runner,
.ill-stage[data-step="3"] .ill-runner {
  --x: 50%;
}

.ill-stage[data-step="4"] .ill-runner,
.ill-stage[data-step="5"] .ill-runner {
  --x: 83.333%;
}

/* The way home passes the server without stopping. */
.ill-stage[data-step="6"] .ill-runner {
  transition-duration: 1.6s;
}

.ill-stage[data-step="5"] .ill-packet .is-q,
.ill-stage[data-step="6"] .ill-packet .is-q,
.ill-stage[data-step="7"] .ill-packet .is-q {
  opacity: 0;
}

.ill-stage[data-step="5"] .ill-packet .is-a,
.ill-stage[data-step="6"] .ill-packet .is-a,
.ill-stage[data-step="7"] .ill-packet .is-a {
  opacity: 1;
}

.ill-stage[data-step="1"] [data-node="pc"] .ill-tile,
.ill-stage[data-step="7"] [data-node="pc"] .ill-tile,
.ill-stage[data-step="3"] [data-node="server"] .ill-tile,
.ill-stage[data-step="5"] [data-node="google"] .ill-tile {
  background: #282828;
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}

.ill-stage[data-step="2"] .ill-lock.is-left,
.ill-stage[data-step="4"] .ill-lock.is-right,
.ill-stage[data-step="6"] .ill-lock {
  color: var(--text-white);
  border-color: rgba(255, 255, 255, 0.4);
}

/* "In memory" while the server has it; "Nothing kept" once it's gone. */
.ill-stage[data-step="3"] .ill-pill.is-mem,
.ill-stage[data-step="4"] .ill-pill.is-mem,
.ill-stage[data-step="5"] .ill-pill.is-mem,
.ill-stage[data-step="6"] .ill-pill.is-mem {
  opacity: 1;
  transform: none;
}

.ill-stage[data-step="7"] .ill-pill.is-keep {
  opacity: 1;
  transform: none;
}

.ill-stage[data-step="7"] [data-node="server"] .ill-pill.is-keep { transition-delay: 0.15s; }
.ill-stage[data-step="7"] [data-node="google"] .ill-pill.is-keep { transition-delay: 0.3s; }

/* Replay jumps back to the start without animating the jump. */
.ill-stage.is-resetting *,
.ill-stage.is-resetting *::before {
  transition: none !important;
}

/* ── Caption and replay ────────────────────────────────────────────────────── */
.ill-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border-color);
}

.ill-say {
  margin: 0;
  min-height: 1.5em;
  color: var(--text-white);
  font-size: 0.95rem;
  line-height: 1.5;
}

.ill-replay {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: transparent;
  color: var(--text-white);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.ill-replay:hover,
.ill-replay:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.3);
}

.ill-replay svg {
  width: 14px;
  height: 14px;
}

/* Without JS there is nothing to replay. */
html:not(.js) .ill-replay {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .ill-stage *,
  .ill-stage *::before {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}

/* ── What's kept ───────────────────────────────────────────────────────────── */
.kept-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border-color);
}

.kept-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--border-color);
}

.kept-what b {
  display: block;
  color: var(--text-white);
  font-size: 1rem;
}

.kept-what span {
  display: block;
  margin-top: 0.2rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}

.kept-for {
  flex: none;
  max-width: 10rem;
  text-align: right;
  color: var(--text-white);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
}

.kept-for.is-none {
  color: var(--text-secondary);
}

/* ── Questions ─────────────────────────────────────────────────────────────── */
.qs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.q {
  scroll-margin-top: 100px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.35rem 1.4rem;
}

.q h3 {
  margin: 0 0 0.5rem;
  color: var(--text-white);
  font-size: 1rem;
  line-height: 1.4;
}

.q p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.6;
}

.q a,
.df-note a {
  color: var(--text-white);
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.3);
  text-underline-offset: 2px;
}

.df-note {
  margin-top: 2.5rem !important;
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.6;
  text-align: center;
}

@media (max-width: 760px) {
  .qs-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 600px) {
  .ill {
    padding: 1.1rem 0.75rem 1.1rem;
  }

  .ill-stage {
    --tile: 54px;
  }

  .ill-tile {
    border-radius: 14px;
  }

  .ill-tile svg {
    width: 22px;
    height: 22px;
  }

  .ill-tile img {
    width: 28px;
    height: 28px;
  }

  .ill-node b {
    font-size: 0.78rem;
  }

  .ill-pill {
    font-size: 0.68rem;
    padding: 0.22rem 0.5rem;
  }

  .ill-bar {
    padding-inline: 0.5rem;
  }

  .ill-say {
    min-height: 3em;
    font-size: 0.9rem;
  }

  .kept-list li {
    gap: 1rem;
  }

  .kept-for {
    max-width: 6.5rem;
    font-size: 0.95rem;
  }
}
