/* ==========================================================================
   anim-cockpit.css
   Modul: simuliertes Live-Cockpit fuer chatCOS.
   Alle Farben ausschliesslich ueber die globalen Theme-Variablen
   (--bg, --surface, --surface-2, --text, --text-muted, --accent,
    --accent-2, --accent-soft, --on-accent, --border). Keine festen
   Farbwerte, damit beide Farbwelten (Business hell, Technik dunkel) tragen.
   ========================================================================== */

.ckpit {
  --ck-radius: 14px;
  --ck-gap: clamp(14px, 2.4vw, 22px);
  --ck-ease: cubic-bezier(.22, .61, .36, 1);

  max-width: 940px;
  margin: 0 auto;
  color: var(--text);
  font-family: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--ck-radius);
  overflow: hidden;
  box-shadow: 0 24px 60px -34px color-mix(in srgb, var(--accent) 34%, transparent);
  -webkit-font-smoothing: antialiased;
}

.ckpit *,
.ckpit *::before,
.ckpit *::after { box-sizing: border-box; }

/* --- Chrome-Leiste ------------------------------------------------------- */
.ckpit__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px clamp(16px, 2.4vw, 22px);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.ckpit__barL { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }

.ckpit__live {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
  box-shadow: 0 0 0 0 var(--accent-soft);
}
.ckpit.is-running .ckpit__live { animation: ck-pulse 1.8s var(--ck-ease) infinite; }

.ckpit__barTitle {
  font-size: .82rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.ckpit__elapsed {
  display: inline-flex; align-items: center; gap: 7px;
  padding: .3rem .66rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  flex: 0 0 auto;
}
.ckpit__elapsedDot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); }
.ckpit.is-running .ckpit__elapsedDot { background: var(--accent); }
.ckpit.is-done .ckpit__elapsedDot { background: var(--accent); }
.ckpit__elapsedVal {
  font-size: .78rem; font-weight: 600; color: var(--text);
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
}

/* --- Body ---------------------------------------------------------------- */
.ckpit__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.14fr);
  gap: var(--ck-gap);
  padding: clamp(16px, 2.6vw, 24px);
}

.ckpit__panelHead {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .72rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 12px;
}

.ckpit__feedTag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .64rem; font-weight: 700; letter-spacing: .1em;
  color: var(--accent);
  padding: .2rem .5rem; border-radius: 999px;
  background: var(--accent-soft);
}
.ckpit__feedTag::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
}
.ckpit.is-running .ckpit__feedTag::before { animation: ck-pulse 1.8s var(--ck-ease) infinite; }

/* --- Team-Panel ---------------------------------------------------------- */
.ckpit__team { min-width: 0; }

.ckpit__role {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.ckpit__role:last-child { border-bottom: 0; }

.ckpit__roleId { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }

.ckpit__avatar {
  flex: 0 0 auto;
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  font-size: .64rem; font-weight: 700; letter-spacing: .02em;
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border);
  transition: color .3s var(--ck-ease), border-color .3s var(--ck-ease),
              box-shadow .3s var(--ck-ease), background-color .3s var(--ck-ease);
}
.ckpit__role.is-active .ckpit__avatar {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 46%, var(--border));
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.ckpit.is-running .ckpit__role.is-active .ckpit__avatar { animation: ck-ring 1.9s var(--ck-ease) infinite; }

.ckpit__roleName {
  font-size: .9rem; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Status-Chip */
.ckpit__status {
  display: inline-flex; align-items: center; gap: 5px;
  padding: .24rem .6rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600; letter-spacing: .01em;
  white-space: nowrap;
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border);
  transition: background-color .3s var(--ck-ease), color .3s var(--ck-ease),
              border-color .3s var(--ck-ease);
}
.ckpit__status--denkt,
.ckpit__status--arbeitet {
  background: var(--accent-soft); color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}
.ckpit__status--prueft {
  background: color-mix(in srgb, var(--accent-2) 14%, transparent);
  color: var(--accent-2);
  border-color: color-mix(in srgb, var(--accent-2) 34%, var(--border));
}
.ckpit__status--fertig {
  background: var(--accent); color: var(--on-accent);
  border-color: transparent;
}
.ckpit__status--fertig::before {
  content: "✓"; font-size: .74rem; line-height: 1; margin-right: 1px;
}

/* "denkt ..." Punkte, nur im denkt-Status sichtbar */
.ckpit__dots { display: none; align-items: center; gap: 3px; margin-left: 1px; }
.ckpit__status--denkt .ckpit__dots { display: inline-flex; }
.ckpit__dots i {
  width: 3px; height: 3px; border-radius: 50%; background: currentColor;
  opacity: .35;
}
.ckpit.is-running .ckpit__status--denkt .ckpit__dots i { animation: ck-dot 1.2s var(--ck-ease) infinite; }
.ckpit__status--denkt .ckpit__dots i:nth-child(2) { animation-delay: .18s; }
.ckpit__status--denkt .ckpit__dots i:nth-child(3) { animation-delay: .36s; }

/* Token-Zaehler */
.ckpit__tok { display: inline-flex; align-items: baseline; gap: 4px; justify-self: end; }
.ckpit__tokVal {
  font-size: .84rem; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; letter-spacing: .01em;
  min-width: 44px; text-align: right;
}
.ckpit__tokUnit { font-size: .66rem; font-weight: 500; color: var(--text-muted); }

/* --- Feed-Panel ---------------------------------------------------------- */
.ckpit__feedWrap { min-width: 0; display: flex; flex-direction: column; }

.ckpit__feed {
  position: relative;
  flex: 1 1 auto;
  min-height: 218px;
  height: 218px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
/* dezenter Fade oben, damit alte Zeilen sauber ausblenden */
.ckpit__feed::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 30px;
  background: linear-gradient(180deg, var(--surface-2), transparent);
  pointer-events: none; z-index: 1;
}

.ckpit__line {
  display: flex; align-items: baseline; gap: 8px;
  font-size: .8rem; line-height: 1.4;
}
.ckpit__line.is-in { animation: ck-line-in .42s var(--ck-ease) both; }

.ckpit__lineActor {
  flex: 0 0 auto;
  position: relative;
  padding-left: 12px;
  font-weight: 700; color: var(--accent);
  white-space: nowrap;
}
.ckpit__lineActor::before {
  content: ""; position: absolute; left: 0; top: .5em;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
}
.ckpit__lineText { color: var(--text-muted); min-width: 0; }

/* --- Fertig-Banner ------------------------------------------------------- */
.ckpit__done {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px clamp(16px, 2.4vw, 24px);
  border-top: 1px solid var(--border);
  background: linear-gradient(90deg, var(--accent-soft), transparent 70%);
}
.ckpit.is-done .ckpit__done { display: flex; animation: ck-done-in .5s var(--ck-ease) both; }

.ckpit__doneL { display: inline-flex; align-items: center; gap: 12px; min-width: 0; }
.ckpit__doneCheck {
  flex: 0 0 auto;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
  box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--accent) 70%, transparent);
}
.ckpit__ico { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

.ckpit__doneTxt { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.ckpit__doneTxt strong { font-size: .95rem; font-weight: 700; color: var(--text); }
.ckpit__doneTxt span { font-size: .76rem; color: var(--text-muted); }

.ckpit__url {
  display: inline-flex; align-items: center; gap: 8px;
  padding: .4rem .78rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  max-width: 100%; min-width: 0;
}
.ckpit__urlDot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  flex: 0 0 auto; box-shadow: 0 0 0 3px var(--accent-soft);
}
.ckpit__urlTxt {
  font-size: .76rem; font-weight: 600; color: var(--text);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}

/* --- Keyframes ----------------------------------------------------------- */
@keyframes ck-pulse {
  0%   { box-shadow: 0 0 0 0 var(--accent-soft); }
  70%  { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes ck-ring {
  0%   { box-shadow: 0 0 0 0 var(--accent-soft); }
  70%  { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes ck-dot {
  0%, 100% { opacity: .3; transform: translateY(0); }
  40%      { opacity: 1;  transform: translateY(-1.5px); }
}
@keyframes ck-line-in {
  from { opacity: 0; transform: translateY(9px); }
  to   { opacity: 1; transform: none; }
}
@keyframes ck-done-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* --- Responsive ---------------------------------------------------------- */
@media (max-width: 720px) {
  .ckpit__body { grid-template-columns: 1fr; }
  .ckpit__feed { min-height: 190px; height: 190px; }
}

@media (max-width: 460px) {
  .ckpit__role { gap: 8px; }
  .ckpit__avatar { width: 27px; height: 27px; }
  .ckpit__roleName { font-size: .84rem; }
  .ckpit__status { padding: .22rem .5rem; font-size: .68rem; }
  .ckpit__tokUnit { display: none; }
  .ckpit__tokVal { min-width: 38px; font-size: .8rem; }
  .ckpit__done { flex-direction: column; align-items: flex-start; gap: 12px; }
  .ckpit__url { align-self: stretch; }
  .ckpit__line { font-size: .76rem; }
}

/* --- Reduced Motion: statischer Endzustand, keine Bewegung --------------- */
@media (prefers-reduced-motion: reduce) {
  .ckpit *,
  .ckpit *::before,
  .ckpit *::after {
    animation: none !important;
    transition: none !important;
  }
}
