/* TypeVerse — typing.css
   The typing box, character states, caret, current-word highlight,
   syntax-highlight token colors, code indentation. */

.typing-box {
  position: relative;
  border-radius: var(--radius-m);
  border: 1px solid var(--line);
  padding: 1.4rem;
  cursor: text;
}

.typing-scroll {
  position: relative;
  height: calc(3 * var(--type-line, 2.4rem)); /* show ~3 lines */
  overflow: hidden;
}

.text-display {
  position: relative;
  font-family: var(--type-font);
  font-size: clamp(1.15rem, 2.6vw, 1.45rem);
  line-height: var(--type-line, 2.4rem);
  letter-spacing: .01em;
  white-space: pre-wrap;
  word-break: break-word;
  transition: transform 180ms var(--ease);
  color: var(--ink-soft);
}
body[data-theme="dark"] .text-display {
  font-size: clamp(.95rem, 2.2vw, 1.15rem);
  letter-spacing: 0;
}

/* ---------- character states ---------- */
.text-display .ch { position: relative; }
.text-display .ch--correct { color: var(--ink); }
.text-display .ch--wrong {
  color: var(--error);
  background: var(--error-tint);
  border-radius: 3px;
}
/* mistyped space/newline still needs to be visible */
.text-display .ch--wrong.ch--ws { box-shadow: inset 0 -2px 0 var(--error); }

/* current word highlight */
.text-display .ch--word { background: var(--accent-tint); border-radius: 3px; }
.text-display .ch--wrong.ch--word { background: var(--error-tint); }

/* real indentation, slightly dimmed */
.text-display .ch--indent { opacity: .38; }

/* visible newline marker in code mode */
.text-display .ch--nl::before {
  content: "\21B5";           /* ↵ */
  font-size: .7em;
  opacity: .45;
  margin-left: .1em;
}

/* ---------- syntax token colors (dev mode display only) ---------- */
body[data-theme="dark"] .text-display .kw  { color: #C792EA; }
body[data-theme="dark"] .text-display .str { color: #C3E88D; }
body[data-theme="dark"] .text-display .cmt { color: #5C6B8A; font-style: italic; }
body[data-theme="dark"] .text-display .num { color: #F78C6C; }
body[data-theme="dark"] .text-display .fn  { color: #82AAFF; }
/* correctness classes on the inner .ch spans win over token colors */
body[data-theme="dark"] .text-display .ch--correct { color: var(--ink); }
body[data-theme="dark"] .text-display .ch--wrong   { color: var(--error); }
/* token tint retained for untyped (pending) chars via inherit */
body[data-theme="dark"] .text-display .kw .ch--pending,
body[data-theme="dark"] .text-display .str .ch--pending,
body[data-theme="dark"] .text-display .cmt .ch--pending,
body[data-theme="dark"] .text-display .num .ch--pending,
body[data-theme="dark"] .text-display .fn .ch--pending { color: inherit; }

/* ---------- caret ---------- */
.caret {
  position: absolute;
  top: 0; left: 0;
  width: 2px;
  height: calc(var(--type-line, 2.4rem) * .72);
  background: var(--accent);
  border-radius: 2px;
  transition: transform 90ms var(--ease), width 160ms var(--ease);
  animation: caret-pulse 1.2s ease-in-out infinite;
  will-change: transform;
}
/* thicker while a test is live — toggled by engine.js */
.caret--active {
  width: 4px;
  animation: none;
  opacity: 1;
}

/* ---------- focus overlay ---------- */
.focus-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  z-index: 3;
}
