/*
 * SPDX-FileCopyrightText: 2026 CodeNib Contributors
 * SPDX-License-Identifier: Apache-2.0
 */

/*
 * The step-through walkthrough in the thread context article. One surface:
 * the columns are divided by a hairline and the rows are lines of a list,
 * so nothing is boxed inside a box. It uses the vocabulary of the article's
 * diagrams: teal is what the document keeps, blue is what an agent is sent,
 * and an agent is a round badge with its letter.
 */
.walk {
  --walk-teal: #5fd4c4;
  --walk-ease: cubic-bezier(0.16, 1, 0.3, 1);
  width: min(100%, 1240px);
  margin: 0 auto 48px;
  padding-inline: 32px;
}

.walk-frame {
  border: 1px solid var(--line);
  border-radius: var(--r-box);
  background: var(--surface);
}

.walk-fallback {
  padding: 22px 28px;
  color: var(--ink-2);
  font-size: 15px;
}

.walk-head {
  padding: 20px 28px 0;
}

.walk-bar {
  display: flex;
  align-items: center;
  gap: 14px;
}

.walk-play,
.walk-nav {
  min-height: 34px;
  border-radius: var(--r-ui);
  font: inherit;
  font-size: 14px;
  font-weight: 560;
  cursor: pointer;
}

.walk-play {
  min-width: 76px;
  padding: 0 14px;
  border: 1px solid var(--button);
  background: var(--button);
  color: var(--button-ink);
}

.walk-nav {
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--ink-2);
}

.walk-nav:hover:not(:disabled) {
  color: var(--ink);
}

.walk-nav:disabled {
  color: var(--ink-3);
  opacity: 0.5;
  cursor: default;
}

.walk :is(button, a):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* One bar per step: where you are, and a way to jump. */
.walk-steps {
  display: flex;
  flex: 1;
  gap: 4px;
  list-style: none;
}

.walk-steps li {
  flex: 1;
}

.walk-tick {
  display: block;
  width: 100%;
  height: 26px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.walk-tick::before {
  content: "";
  display: block;
  height: 3px;
  border-radius: 2px;
  background: var(--line-strong);
  transition: background-color 0.3s var(--walk-ease);
}

.walk-tick.is-done::before {
  background: var(--ink-2);
}

.walk-tick[aria-current]::before {
  background: var(--ink);
}

.walk-tick:hover::before {
  background: var(--ink-3);
}

.walk-say {
  max-width: 78ch;
  min-height: 4.6em;
  margin: 14px 0 18px;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.6;
}

.walk-why {
  display: block;
  width: fit-content;
  margin-top: 2px;
  color: var(--ink-3);
  font-size: 14.5px;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
}

.walk-why:hover {
  color: var(--ink);
}

.walk-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  border-top: 1px solid var(--line);
}

.walk-col {
  min-width: 0;
  padding: 20px 28px 26px;
}

.walk-col + .walk-col {
  border-left: 1px solid var(--line);
}

.walk-title {
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
}

.walk-file {
  color: var(--walk-teal);
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 14px;
  font-weight: 500;
}

.walk-note {
  margin: 2px 0 16px;
  color: var(--ink-3);
  font-size: 14px;
  line-height: 1.5;
}

.walk-body {
  min-height: 330px;
}

.walk-empty {
  color: var(--ink-3);
  font-size: 14.5px;
}

.walk code {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 13px;
}

/* The records: a numbered list, one line each. */
.walk-records {
  list-style: none;
}

.walk-record {
  display: grid;
  grid-template-columns: 2ch minmax(0, auto) minmax(0, 1fr);
  align-items: baseline;
  gap: 12px;
  margin-inline: -10px;
  padding: 7px 10px;
  border-radius: var(--r-ui);
  transition: background-color 0.5s var(--walk-ease);
}

.walk-record + .walk-record {
  box-shadow: 0 -1px 0 var(--line);
}

.walk-record code {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.walk-pos {
  color: var(--ink-3);
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.walk-what {
  color: var(--ink-3);
  font-size: 13.5px;
  text-align: right;
}

.walk-record.is-fresh {
  animation: walk-arrive 0.5s var(--walk-ease);
}

.walk-record.is-fresh .walk-what {
  color: var(--ink);
}

.walk-record.is-sent {
  background: var(--accent-soft);
  box-shadow: none;
}

.walk-record.is-sent + .walk-record {
  box-shadow: none;
}

/* Rows sent together read as one block. */
.walk-record.is-sent:has(+ .walk-record.is-sent) {
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}

.walk-record.is-sent + .walk-record.is-sent {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.walk-record.is-sent .walk-pos {
  color: var(--accent);
}

@keyframes walk-arrive {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

.walk-agent {
  display: inline-grid;
  flex: none;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  background: #44484f;
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 700;
}

.walk-mark {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 0 5px calc(2ch + 12px);
  color: var(--ink-3);
  font-size: 13px;
}

.walk-sent {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 3px 10px;
  margin-top: 16px;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.5;
}

.walk-sent code {
  align-self: center;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.walk-sent > span:last-child {
  grid-column: 2;
}

.walk-sent.is-sent > span:last-child {
  color: var(--accent-dark);
}

/* The document, set as the file it is. */
.walk-ln {
  display: block;
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.7;
  margin-inline: -8px;
  padding-inline: 8px;
  border-radius: 4px;
  color: var(--body);
  overflow-wrap: anywhere;
  transition: background-color 0.5s var(--walk-ease), color 0.5s var(--walk-ease);
}

.walk-ln.is-head {
  color: var(--ink-3);
}

.walk-ln.is-head:not(:first-child) {
  margin-top: 0.85em;
}

.walk-ln.is-kept {
  background: rgba(95, 212, 196, 0.1);
  color: var(--walk-teal);
}

.walk-ln.is-sent {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.walk-caption {
  max-width: 820px;
  margin: 14px auto 0;
  color: var(--ink-2);
  font-size: 13px;
  text-align: center;
}

@media (max-width: 820px) {
  .walk {
    padding-inline: 20px;
  }

  /* The columns stack on a phone; keep the controls and the sentence for the
     current step in view while they scroll past. */
  .walk-head {
    position: sticky;
    top: 65px;
    z-index: 2;
    padding: 12px 16px 0;
    border-bottom: 1px solid var(--line);
    border-radius: var(--r-box) var(--r-box) 0 0;
    background: var(--surface);
  }

  .walk-bar {
    gap: 10px;
  }

  .walk-say {
    min-height: 8em;
    margin: 8px 0 10px;
    font-size: 15.5px;
  }

  .walk-grid {
    grid-template-columns: minmax(0, 1fr);
    border-top: 0;
  }

  .walk-col {
    padding: 18px 16px 22px;
  }

  .walk-col + .walk-col {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .walk-body {
    min-height: 0;
  }

  .walk-record {
    grid-template-columns: 2ch minmax(0, 1fr);
  }

  .walk-what {
    grid-column: 2;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .walk-record.is-fresh {
    animation: none;
  }

  .walk-record,
  .walk-ln,
  .walk-tick::before {
    transition: none;
  }
}
