/* ============================================================================
   flow4.css — Learning loop
   Mount: #flow4-mount (the "Memory & context" card, right intelligence panel).
   Warm-dark system: tokens.css vars, JetBrains-Mono chrome, tabular numerals,
   motion easing var(--ease), prefers-reduced-motion respected.
   ==========================================================================*/

#flow4-mount {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

/* ---- header --------------------------------------------------------------- */
.mem-head {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.mem-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}
.mem-head-label {
  font-family: var(--font-mono);
  font-size: var(--fs-10);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--ink-dim);
  font-weight: 500;
}
.mem-count {
  font-family: var(--font-mono);
  font-size: var(--fs-11);
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  background: var(--gold-soft);
  border: 1px solid color-mix(in srgb, var(--gold) 32%, transparent);
  border-radius: var(--r-pill);
  min-width: 20px;
  padding: 1px 8px;
  text-align: center;
  line-height: 1.5;
}
.mem-head-sub {
  font-family: var(--font-sans);
  font-size: var(--fs-12);
  line-height: var(--lh-body);
  color: var(--ink-dim);
}

/* ---- "saved to context" confirmation ------------------------------------- */
.mem-confirm {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  background: var(--ok-soft);
  border: 1px solid color-mix(in srgb, var(--ok) 34%, transparent);
  color: var(--ok);
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  font-weight: 500;
  letter-spacing: 0.01em;
  overflow: hidden;
  transform-origin: top center;
}
.mem-confirm-text { color: var(--ok); }

.mem-confirm-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--ok) 22%, transparent);
  color: var(--ok);
}
.mem-confirm-check svg { width: 12px; height: 12px; }

/* entrance: gentle drop + fade, with a soft check pop */
.mem-confirm.is-in {
  animation: mem-confirm-in var(--dur-3) var(--ease) both;
}
.mem-confirm.is-in .mem-confirm-check {
  animation: mem-check-pop var(--dur-3) var(--ease) both;
}
.mem-confirm.is-out {
  animation: mem-confirm-out var(--dur-2) var(--ease-in) both;
}

@keyframes mem-confirm-in {
  0%   { opacity: 0; transform: translateY(-6px) scale(0.99); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes mem-confirm-out {
  0%   { opacity: 1; transform: translateY(0); max-height: 60px; }
  100% { opacity: 0; transform: translateY(-4px); max-height: 0; padding-top: 0; padding-bottom: 0; border-width: 0; }
}
@keyframes mem-check-pop {
  0%   { transform: scale(0.4); opacity: 0; }
  55%  { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); }
}

/* ---- memory list ---------------------------------------------------------- */
.mem-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.mem-item {
  position: relative;
  padding: var(--sp-3);
  padding-left: calc(var(--sp-3) + 3px);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-sunken);
}
/* warm accent spine */
.mem-item::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 2px;
  border-radius: var(--r-pill);
  background: linear-gradient(180deg, var(--gold), var(--ember));
  opacity: 0.7;
}

.mem-item-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.mem-item-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  flex: 0 0 auto;
}
.mem-item-mark svg { width: 13px; height: 13px; }

.mem-item-from {
  font-family: var(--font-mono);
  font-size: var(--fs-11);
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--ink-muted);
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mem-item-time {
  font-family: var(--font-mono);
  font-size: var(--fs-10);
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

.mem-item-rule {
  font-family: var(--font-sans);
  font-size: var(--fs-12);
  line-height: var(--lh-body);
  color: var(--ink-muted);
}

/* newly-learned entry: settle-in + a brief gold wash so the eye catches it */
.mem-item--new {
  animation: mem-item-in var(--dur-4) var(--ease) both,
             mem-item-flash 1600ms var(--ease) both;
}
@keyframes mem-item-in {
  0%   { opacity: 0; transform: translateY(-8px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes mem-item-flash {
  0%   { border-color: color-mix(in srgb, var(--gold) 60%, var(--border)); box-shadow: var(--glow-ember); background: var(--gold-soft); }
  100% { border-color: var(--border); box-shadow: none; background: var(--bg-sunken); }
}
.mem-item--new::before { animation: mem-spine-flash 1600ms var(--ease) both; }
@keyframes mem-spine-flash {
  0%   { opacity: 1; width: 3px; }
  100% { opacity: 0.7; width: 2px; }
}

/* ---- empty state ---------------------------------------------------------- */
.mem-empty {
  font-family: var(--font-sans);
  font-size: var(--fs-12);
  line-height: var(--lh-body);
  color: var(--ink-dim);
  padding: var(--sp-3);
  border: 1px dashed var(--border-lit);
  border-radius: var(--r-md);
  text-align: center;
}

/* ---- reduced motion: no transforms/flash, instant confirmation ----------- */
@media (prefers-reduced-motion: reduce) {
  .mem-confirm.is-in,
  .mem-confirm.is-in .mem-confirm-check,
  .mem-confirm.is-out,
  .mem-item--new,
  .mem-item--new::before {
    animation: none !important;
  }
  .mem-confirm.is-out { opacity: 0; }
}
