/* ============================================================
   TERMINAL MODULES · reusable design system
   A small set of primitives that carry the "live agent terminal"
   aesthetic from the hero down into other sections.

   Tokens (consumed, not defined here):
     --mono, --sans, --serif
     --ink / --ink-2 / --ink-3 / --ink-4
     --line / --surface / --surface-2 / --bg
     --magenta / --magenta-soft
     --plumink / --plumink-soft
     --amber / --amber-soft

   Primitives:
     .tm-card         → the parchment card that frames a terminal module
     .tm-head         → top bar (dot + title + right meta)
     .tm-dot          → live-state dot · variants: .muted .live .ok
     .tm-line         → one monospace row in an analysis stream
     .tm-line.accent  → highlights a found field
     .tm-line.done    → final "complete" line (slight top border)
     .tm-caret        → blinking magenta caret
     .tm-ref          → inline citation pill, e.g. [3]
     .tm-check        → rounded state-glyph (pending / active pulse / done ✓)
     .tm-pill         → small status pill (Clear / Verified / Low / Match)
     .tm-chip         → document/source chip
     .tm-row          → kv row with muted label + ink value
     .tm-divider      → dashed separator line
     .tm-summary      → summary line that reads like a log row
     .tm-note         → boxed annotation, monospace
   ============================================================ */

/* ---------- Card ---------- */
/* ---------- Card ----------
   Warm liquid-glass plate (same recipe as .hero-terminal-wrap, scaled down).
   The cream veil + backdrop-filter makes these cards pick up the parchment
   background and feel like they belong to the same family as the hero.
*/
.tm-card {
  position: relative;
  isolation: isolate;
  background: transparent;
  border: 0;
  border-radius: 14px;
  padding: 11px 14px;
}
.tm-card > * { position: relative; z-index: 2; }

/* Liquid-glass plate — EXACT match to .hero-terminal-wrap::before */
.tm-card::before {
  content: '';
  position: absolute; inset: 0; z-index: 0;
  border-radius: inherit;
  background: linear-gradient(135deg,
    rgba(255, 255, 255, 0.88) 0%,
    rgba(255, 255, 255, 0.74) 100%);
  backdrop-filter: blur(40px) saturate(125%) brightness(2.02);
  -webkit-backdrop-filter: blur(40px) saturate(125%) brightness(2.02);
  box-shadow:
    inset 0 1.5px 0 rgba(255,255,255,0.95),
    inset 0 -1px 0 rgba(230, 220, 200, 0.35),
    0 1px 2px rgba(21, 19, 31, 0.04),
    0 8px 16px -8px rgba(21, 19, 31, 0.10),
    0 40px 70px -28px rgba(21, 19, 31, 0.22),
    0 24px 48px -24px rgba(120, 90, 70, 0.10);
}

/* Refraction rim — EXACT match to .hero-terminal-wrap::after */
.tm-card::after {
  content: '';
  position: absolute; inset: 0; z-index: 1;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  background: linear-gradient(135deg,
    rgba(255, 255, 255, 0.95) 0%,
    rgba(255, 255, 255, 0.70) 22%,
    rgba(255, 255, 255, 0.25) 48%,
    rgba(180, 160, 135, 0.28) 72%,
    rgba(140, 115, 90, 0.38) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
}

.tm-card + .tm-card { margin-top: 9px; }

.tm-card-head {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-3);
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 7px;
}
.tm-card-head .tm-spacer { flex: 1; }
.tm-card-head .tm-timer {
  font-size: 10px; color: var(--ink-4); text-transform: none; letter-spacing: 0.02em;
}

/* ---------- State dot ---------- */
.tm-dot {
  width: 7px; height: 7px; border-radius: 999px;
  background: var(--ink-4);
  flex-shrink: 0;
}
.tm-dot.muted { background: var(--ink-4); }
.tm-dot.live {
  background: var(--magenta);
  box-shadow: 0 0 0 0 rgba(90, 58, 74, 0.35);
  animation: tmPulse 1.3s ease-out infinite;
}
.tm-dot.ok { background: var(--plumink); }
@keyframes tmPulse {
  0%   { box-shadow: 0 0 0 0 rgba(90, 58, 74, 0.45); }
  70%  { box-shadow: 0 0 0 6px rgba(90, 58, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(90, 58, 74, 0); }
}

/* ---------- Stream / log ---------- */
.tm-stream {
  display: flex; flex-direction: column; gap: 3px;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--ink-3);
}
.tm-line {
  position: relative;
  padding-left: 14px;
  opacity: 0; transform: translateY(3px);
  transition: opacity 360ms ease, transform 360ms ease;
}
.tm-line.on { opacity: 1; transform: none; }
.tm-line::before {
  content: '';
  position: absolute; left: 0; top: 0.52em;
  width: 5px; height: 5px; border-radius: 999px;
  background: var(--ink-4);
  transition: background 200ms ease;
}
.tm-line b { color: var(--ink); font-weight: 600; }
.tm-line.accent::before { background: var(--magenta); }
.tm-line.accent b { color: var(--magenta-ink); }
.tm-line.accent.current::before {
  animation: tmPulse 1.1s ease-out infinite;
}
.tm-line.accent.settled::before { background: var(--plumink); }
.tm-line.accent.settled::after {
  content: '✓';
  display: inline-block;
  margin-left: 6px;
  color: var(--plumink);
  font-size: 10px;
  font-weight: 700;
  opacity: 0;
  animation: tmCheckIn 220ms ease-out forwards;
}
@keyframes tmCheckIn {
  from { opacity: 0; transform: scale(0.6); }
  to   { opacity: 1; transform: none; }
}
.tm-line.done {
  color: var(--plumink);
  font-weight: 600;
  padding-top: 6px;
  margin-top: 4px;
  border-top: 1px dashed rgba(85, 69, 102, 0.2);
}
.tm-line.done::before {
  background: var(--plumink);
  width: 6px; height: 6px;
  top: 0.75em;
}
.tm-line.typing::after {
  content: ''; display: inline-block;
  width: 6px; height: 1em;
  background: var(--magenta);
  margin-left: 3px; vertical-align: -2px;
  animation: tmCaret 0.85s steps(2, start) infinite;
}

/* ---------- Caret ---------- */
.tm-caret {
  display: inline-block;
  width: 2px; height: 1.1em;
  background: var(--magenta);
  margin-left: 4px; vertical-align: -2px;
  animation: tmCaret 0.85s steps(2, start) infinite;
}
@keyframes tmCaret { 0%,49% { opacity: 1; } 50%,100% { opacity: 0; } }

/* ---------- Citation ref ---------- */
.tm-ref {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--magenta);
  letter-spacing: 0.02em;
  font-weight: 600;
}

/* ---------- State glyph (round check) ---------- */
.tm-check {
  position: relative;
  width: 14px; height: 14px; border-radius: 999px;
  border: 1.2px solid var(--ink-4);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: transparent;
  transition: all 200ms ease;
}
.tm-check svg { width: 9px; height: 9px; color: #fff; display: none; }
.tm-check.active { border-color: var(--magenta); }
.tm-check.active::before {
  content: ''; position: absolute; inset: 3px; border-radius: 999px;
  background: var(--magenta);
  animation: tmPulseDot 1.2s ease-in-out infinite;
}
.tm-check.done {
  background: var(--plumink);
  border-color: var(--plumink);
}
.tm-check.done svg { display: block; }
@keyframes tmPulseDot {
  0%,100% { transform: scale(0.85); opacity: 0.9; }
  50%     { transform: scale(1.1); opacity: 1; }
}

/* ---------- Status pill ---------- */
.tm-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--sans);
  font-size: 10px; font-weight: 500;
  padding: 2px 8px; border-radius: 4px;
  letter-spacing: -0.002em;
}
.tm-pill.clear,
.tm-pill.verified,
.tm-pill.low     { background: var(--plumink-soft); color: var(--plumink); }
.tm-pill.clear::before,
.tm-pill.verified::before { content: '✓'; font-size: 9px; }
.tm-pill.low::before { content: '•'; font-size: 11px; line-height: 1; }
.tm-pill.note    { background: var(--amber-soft); color: var(--amber-warm); }
.tm-pill.match   { background: rgba(217,100,70,0.12); color: #C8502E; }

/* ---------- Chip ---------- */
.tm-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-2);
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  letter-spacing: 0.01em;
}
.tm-chip .doc-icon {
  width: 8px; height: 10px; border-radius: 1px;
  background: var(--ink-4);
  opacity: 0.6; flex-shrink: 0;
}

/* ---------- KV row ---------- */
.tm-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px;
  padding: 3px 0;
  border-bottom: 1px dashed var(--line);
  font-family: var(--mono);
  font-size: 10.5px;
  opacity: 0; transform: translateY(3px);
  transition: opacity 320ms ease, transform 320ms ease;
}
.tm-row.on {
  opacity: 1; transform: none;
  animation: tmRowFlash 520ms ease-out;
}
.tm-row:last-child { border-bottom: 0; }
.tm-row .k {
  color: var(--ink-4);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 9px;
}
.tm-row .v {
  font-family: var(--sans);
  font-weight: 600; color: var(--magenta-ink);
  letter-spacing: -0.005em;
  display: inline-flex; align-items: center; gap: 5px;
}
.tm-row .v::before {
  content: '✓'; font-size: 8.5px; color: var(--plumink); font-weight: 700;
}
@keyframes tmRowFlash {
  0%   { background: rgba(90, 58, 74, 0.10); }
  100% { background: transparent; }
}

/* ---------- Divider ---------- */
.tm-divider {
  height: 0;
  border-top: 1px dashed var(--line);
  margin: 10px 0;
}

/* ---------- Summary ---------- */
.tm-summary {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
  line-height: 1.6;
}
.tm-summary b { color: var(--ink); font-weight: 600; }

/* ---------- Note box ---------- */
.tm-note {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px dashed rgba(90, 58, 74, 0.28);
  border-radius: 6px;
  background: rgba(90, 58, 74, 0.04);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  line-height: 1.55;
}
.tm-note b { color: var(--ink-2); font-weight: 600; }

@keyframes tmCaret { 0%,49% { opacity: 1; } 50%,100% { opacity: 0; } }
