/*
 * The recorded terminal.
 *
 * Loaded only by the landing page, which is the only page that shows it.
 *
 * The component is a `<pre>` with the full transcript, and everything here is
 * an enhancement on top of that. The player hides the `<pre>` only once its
 * JSON has parsed, so with JavaScript off, a blocked fetch, or a `file://`
 * origin, the reader still gets every line — styled, selectable and indexable.
 */

.term {
  margin: 2.5rem 0 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-code);
  overflow: hidden;
}

/* ── The title strip ───────────────────────────────────────────────────────── */

.term__bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
}

.term__dots {
  display: inline-flex;
  gap: 0.35rem;
  flex: none;
}
.term__dots::before,
.term__dots::after {
  content: "";
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--line);
}
.term__dots::before {
  box-shadow: 0.95rem 0 0 var(--line);
}

.term__title {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--fg-soft);
  margin-left: 0.6rem;
}

.term__controls {
  margin-left: auto;
  display: flex;
  gap: 0.4rem;
}

/* Same visual language as the copy button on a code block. */
.term__btn {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--fg-soft);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.72rem;
  padding: 0.18rem 0.5rem;
}
.term__btn:hover {
  color: var(--fg);
  border-color: var(--fg-faint);
}
.term__btn[hidden] {
  display: none;
}

/* ── The screen ────────────────────────────────────────────────────────────── */

/*
 * A fixed height, not a minimum. The page must not reflow as lines arrive, and
 * the transcript below is clipped rather than removed so it contributes nothing
 * to flow either.
 */
.term__screen {
  height: 26rem;
  overflow-y: auto;
  padding: 0.9rem 1rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.6;
  /* `docs.css` sets `scroll-behavior: smooth` on `html`, which would make the
   * auto-scroll trail a full second behind the typing. */
  scroll-behavior: auto;
}

.term--static .term__screen,
.term--static .term__caption {
  display: none;
}

.term__step {
  margin-bottom: 0.9rem;
}

.term__prompt {
  color: var(--fg-faint);
  user-select: none;
}

.term__cmd {
  color: var(--fg);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.term__caret {
  display: inline-block;
  width: 0.55ch;
  height: 1.05em;
  vertical-align: -0.18em;
  background: var(--accent);
  animation: term-blink 1s steps(1) infinite;
}

@keyframes term-blink {
  50% {
    opacity: 0;
  }
}

.term__line {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--fg);
}
.term__line--ok {
  color: var(--green);
}
.term__line--err {
  color: var(--red);
}
.term__line--warn {
  color: var(--amber);
}
.term__line--info {
  color: var(--accent);
}
.term__line--dim {
  color: var(--fg-faint);
}

/* Rendered from the recording's `omitted` count, never from a captured line,
 * so it can not be mistaken for something the CLI printed. */
.term__more {
  color: var(--fg-faint);
  font-style: italic;
}

.term__exit {
  color: var(--fg-faint);
  font-size: 0.72rem;
}
.term__exit--fail {
  color: var(--red);
}

/* ── The caption under the screen ──────────────────────────────────────────── */

.term__caption {
  margin: 0;
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  font-size: 0.82rem;
  color: var(--fg-soft);
  min-height: 2.9rem;
}

/* ── The no-JavaScript transcript ──────────────────────────────────────────── */

.term__transcript {
  margin: 0;
  padding: 0.9rem 1rem;
  max-height: 26rem;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--fg);
  white-space: pre;
}

/*
 * Clipped, not `[hidden]`. A screen reader gets one calm, complete transcript
 * instead of a live region announcing ninety lines over forty seconds — which
 * is also why `.term__screen` carries `aria-hidden`.
 */
.term--playing .term__transcript,
.term--done .term__transcript {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.term__meta {
  margin: 0 0 2rem;
  font-size: 0.82rem;
  color: var(--fg-faint);
}

@media (max-width: 640px) {
  .term__screen,
  .term__transcript {
    height: 20rem;
    max-height: 20rem;
    font-size: 0.72rem;
  }
  .term__title {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .term__caret {
    animation: none;
  }
}
