/* "HOW THE AGENT WORKS" — annotated walkthrough section
   The centerpiece. Shows the AI's reasoning step-by-step, exposed
   like a living document with marginalia and footnotes.
   Lives inside the .dossier scope.
*/

.walkthrough {
  margin-top: 24px;
  padding: 56px 0 0;
  border-top: 1px solid var(--line-2);
}

.walkthrough-grid {
  display: grid;
  grid-template-columns: 96px 1fr 280px;
  gap: 32px;
  align-items: start;
  min-width: 0;
}

.wt-rail {
  position: sticky; top: 100px;
  display: flex; flex-direction: column; gap: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.16em;
  color: var(--dim); text-transform: uppercase;
}
.wt-rail-item {
  padding: 10px 0 10px 20px;
  border-left: 1px solid var(--line-2);
  position: relative;
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease;
}
.wt-rail-item::before {
  content: ""; position: absolute; left: -4px; top: 14px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--line-2);
  transition: all .3s ease;
}
.wt-rail-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
}
.wt-rail-item.active::before {
  background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.wt-rail-item .num {
  display: block; color: var(--accent);
  font-size: 9px; margin-bottom: 2px;
}

/* Main flow column */
.wt-flow {
  display: flex; flex-direction: column;
  gap: 0;
  min-width: 0;
}

.wt-step {
  position: relative;
  padding: 36px 0 36px;
  border-bottom: 1px dashed var(--line-2);
  min-width: 0;
}
.wt-step:last-child { border-bottom: none; }

.wt-step .meta {
  display: flex; align-items: baseline; gap: 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px; letter-spacing: 0.18em;
  color: var(--dim); text-transform: uppercase;
  margin-bottom: 14px;
}
.wt-step .meta .step-no { color: var(--accent); font-weight: 600; }
.wt-step .meta .ts { margin-left: auto; color: var(--dim); }

.wt-step h3 {
  font-family: 'Instrument Serif', serif;
  font-weight: 400;
  font-size: 30px; line-height: 1.15; letter-spacing: -0.02em;
  margin: 0 0 12px;
  color: var(--text);
}
.wt-step h3 em { font-style: italic; color: var(--accent); }

.wt-step .what {
  font-family: 'Instrument Serif', serif;
  font-size: 19px; line-height: 1.5; color: var(--text-2);
  margin: 0 0 18px;
}

/* The "card" — actual conversation / tool call render */
.wt-card {
  background: var(--panel);
  border: 1px solid var(--line-2);
  padding: 18px 22px;
  position: relative;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-2);
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
}
.wt-card.message {
  font-family: 'Instrument Serif', serif;
  font-size: 17px;
  color: var(--text);
  line-height: 1.5;
}
.wt-card.message .who {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px; letter-spacing: 0.18em; color: var(--accent);
  text-transform: uppercase; display: block; margin-bottom: 6px;
}
.wt-card.message.user .who { color: var(--muted); }

.wt-card .pill {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px; letter-spacing: 0.16em; color: var(--accent);
  text-transform: uppercase;
  background: var(--accent-soft);
  padding: 3px 8px; border-radius: 2px;
  margin-bottom: 10px;
}

.wt-card .kv {
  display: grid; grid-template-columns: 130px 1fr;
  gap: 4px 14px;
  font-family: 'JetBrains Mono', monospace; font-size: 11.5px;
  min-width: 0;
}
.wt-card .kv .k { color: var(--dim); letter-spacing: 0.06em; }
.wt-card .kv .k,
.wt-card .kv .v {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: normal;
}
.wt-card .kv .v { color: var(--text); }
.wt-card .kv .v.found { color: var(--good); }
.wt-card .kv .v.warn { color: var(--warn); }
.wt-card .kv .v em { color: var(--accent); font-style: normal; }

.wt-card .lookup-head {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 10px; margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 10.5px; letter-spacing: 0.16em; color: var(--dim);
  text-transform: uppercase;
  min-width: 0;
}
.wt-card .lookup-head .src { color: var(--accent); min-width: 0; overflow-wrap: anywhere; }
.wt-card .lookup-head .ms { margin-left: auto; color: var(--good); }

.wt-card.success::after {
  content: "✓ COMMITTED";
  position: absolute; top: 14px; right: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px; letter-spacing: 0.18em; color: var(--good);
}

/* Connecting marginalia / annotation column */
.wt-annot-panel {
  position: sticky;
  top: 100px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.wt-annot {
  font-family: 'Instrument Serif', serif;
  font-style: italic; font-size: 14.5px; line-height: 1.55;
  color: var(--muted);
  display: flex; flex-direction: column; gap: 8px;
  position: relative;
  padding-top: 4px;
}
.wt-annot .ref {
  font-family: 'JetBrains Mono', monospace;
  font-style: normal; font-size: 9.5px; letter-spacing: 0.18em;
  color: var(--accent); text-transform: uppercase;
}
.wt-annot-copy {
  display: block;
}
.wt-annot strong { color: var(--text-2); font-weight: 500; font-style: normal; }
.wt-annot-active {
  min-height: 150px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-2);
  animation: wtAnnotIn .28s ease both;
}
.wt-annot-progress {
  display: flex;
  gap: 7px;
  align-items: center;
}
.wt-annot-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--line-2);
  transition: background .2s ease, transform .2s ease;
}
.wt-annot-dot.active {
  background: var(--accent);
  transform: scale(1.45);
}
.wt-annot .arrow {
  position: absolute; left: -32px; top: 14px;
  width: 22px; height: 14px; opacity: 0.7;
}

@keyframes wtAnnotIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* Closing pull — the "next day" callback */
.wt-close {
  margin-top: 56px;
  padding: 36px;
  background:
    repeating-linear-gradient(0deg, var(--paper-tint) 0 26px, transparent 26px 27px),
    var(--panel);
  border: 1px solid var(--line-2);
  position: relative;
}
.wt-close::before {
  content: "EPILOGUE — 23 HOURS LATER, WHATSAPP";
  position: absolute; top: -10px; left: 24px;
  background: var(--bg); padding: 0 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px; letter-spacing: 0.2em; color: var(--accent);
}
.wt-close .pull-q {
  font-family: 'Instrument Serif', serif;
  font-size: clamp(24px, 2.6vw, 32px);
  line-height: 1.35; letter-spacing: -0.01em;
  color: var(--text);
  max-width: 44ch;
}
.wt-close .pull-q em { color: var(--accent); font-style: italic; }
.wt-close .epilogue {
  margin-top: 22px;
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.wt-close .epi-msg {
  font-family: 'Instrument Serif', serif;
  font-size: 16px; line-height: 1.5; color: var(--text-2);
  border-left: 2px solid var(--accent);
  padding: 4px 0 4px 14px;
}
.wt-close .epi-msg .who {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px; letter-spacing: 0.18em; color: var(--accent);
  text-transform: uppercase; display: block; margin-bottom: 4px;
}
.wt-close .epi-msg.user .who { color: var(--muted); }

@media (max-width: 980px) {
  .walkthrough-grid { grid-template-columns: 1fr; }
  .wt-rail { flex-direction: row; overflow-x: auto; position: relative; top: 0; gap: 16px; padding-bottom: 12px; }
  .wt-rail-item { border-left: none; border-top: 1px solid var(--line-2); padding: 10px 0 0; min-width: 120px; }
  .wt-rail-item::before { left: 0; top: -4px; }
  .wt-annot-panel { display: none; }
  .wt-close .epilogue { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .walkthrough {
    padding-top: 36px;
  }

  .wt-step {
    padding: 30px 0;
  }

  .wt-step .meta {
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    font-size: 10px;
    line-height: 1.35;
    letter-spacing: 0.12em;
  }

  .wt-step .meta .ts {
    margin-left: 0;
    flex-basis: 100%;
  }

  .wt-step h3 {
    font-size: 28px;
  }

  .wt-step .what {
    font-size: 18px;
  }

  .wt-card {
    padding: 16px;
    font-size: 12px;
    line-height: 1.6;
  }

  .wt-card .lookup-head {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 10px;
    align-items: baseline;
    font-size: 10px;
    line-height: 1.45;
    letter-spacing: 0.12em;
  }

  .wt-card .lookup-head .src {
    grid-column: 1 / -1;
    text-transform: none;
    letter-spacing: 0.04em;
  }

  .wt-card .lookup-head .ms {
    margin-left: 0;
    justify-self: end;
  }

  .wt-card .kv {
    grid-template-columns: minmax(84px, 0.42fr) minmax(0, 1fr);
    gap: 6px 12px;
    font-size: 11px;
    line-height: 1.55;
  }
}

@media (max-width: 480px) {
  .wt-rail {
    gap: 12px;
    margin-inline: -18px;
    padding-inline: 18px;
    scroll-padding-inline: 18px;
  }

  .wt-rail-item {
    min-width: 96px;
    font-size: 9.5px;
    letter-spacing: 0.11em;
  }

  .wt-step .meta {
    font-size: 9.5px;
    letter-spacing: 0.1em;
  }

  .wt-card {
    margin-inline: -2px;
    padding: 14px;
  }

  .wt-card.message {
    font-size: 16px;
  }

  .wt-card .kv {
    grid-template-columns: 1fr;
    gap: 2px;
    font-size: 10.75px;
  }

  .wt-card .kv .k {
    margin-top: 8px;
    font-size: 9.5px;
    line-height: 1.25;
    text-transform: uppercase;
  }

  .wt-card .kv .k:first-child {
    margin-top: 0;
  }

  .wt-card .kv .v {
    line-height: 1.55;
  }

  .wt-card.success::after {
    position: static;
    display: block;
    margin-top: 12px;
  }

  .wt-close {
    padding: 28px 20px;
  }
}
