/* WSPÓLNY SILNIK - proces jako rozmowa („teatr"). Znaczniki renderuje
   strona (IID: PHP, Entrada: React), animację uzbraja theater.js.
   Bez JS i przy ograniczonym ruchu wszystko jest widoczne od razu.
   Kolory: tokeny marki ustawione niżej na .th[data-brand]. */

.th[data-brand="entrada"] {
  --th-ink: rgb(var(--fg-rgb));
  --th-mute: rgba(var(--fg-rgb), .6);
  --th-line: rgba(var(--fg-rgb), .12);
  --th-accent: rgb(var(--accent-rgb));
  --th-you-bg: rgba(var(--fg-rgb), .05);
  --th-us-bg: rgba(var(--accent-rgb), .12);
  --th-font: var(--ff-sans);
  --th-mono: var(--ff-mono);
  --th-r: 4px;
  --th-plate: rgb(var(--bg-rgb));
}
.th[data-brand="iid"] {
  --th-ink: var(--tx);
  --th-mute: var(--tx-3);
  --th-line: var(--line);
  --th-accent: var(--cta);
  --th-you-bg: var(--panel);
  --th-us-bg: color-mix(in srgb, var(--cta) 9%, var(--panel));
  --th-font: var(--display);
  --th-mono: var(--mono);
  --th-r: 14px;
}

.th { color: var(--th-ink); font-family: var(--th-font); }
.th-acts { position: relative; list-style: none; margin: 0; padding: 0; }
/* Szyna łącząca numery etapów; wypełnienie idzie za przewijaniem. */
.th-acts::before, .th-acts::after {
  content: ''; position: absolute; left: 17px; top: 46px; bottom: 46px; width: 1px; background: var(--th-line);
}
.th-acts::after { background: var(--th-accent); transform-origin: 50% 0; transform: scaleY(var(--th-p, 1)); }

.th-act {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, .85fr) minmax(0, 1.25fr);
  column-gap: clamp(20px, 3vw, 44px);
  padding: clamp(26px, 3.4vw, 40px) 0;
  border-top: 1px solid var(--th-line);
}
.th-act:last-child { border-bottom: 1px solid var(--th-line); }
.th-n {
  position: relative; z-index: 1;
  width: 36px; height: 36px; display: grid; place-items: center;
  font: 500 12px/1 var(--th-mono); letter-spacing: .04em; color: var(--th-mute);
  border: 1px solid var(--th-line); border-radius: 50%;
  background: var(--th-plate, transparent);
  transition: color .3s ease, border-color .3s ease, background-color .3s ease;
}
.th-stage { padding-top: 4px; }
.th-t { margin: 0; font-size: clamp(18px, 1.7vw, 22px); font-weight: 600; letter-spacing: -.01em; line-height: 1.25; }
.th-out {
  margin: 14px 0 0; display: grid; gap: 6px; max-width: 34ch;
  font-size: 15px; line-height: 1.5; color: var(--th-mute);
}
.th-out span { font: 500 12px/1 var(--th-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--th-accent); }

.th-chat { display: flex; flex-direction: column; gap: 12px; }
.th-msg { max-width: min(88%, 56ch); }
.th-who {
  display: flex; align-items: center; gap: 7px; margin-bottom: 6px;
  font: 500 12px/1 var(--th-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--th-mute);
}
.th-who svg { width: 14px; height: 14px; color: var(--th-accent); }
.th-msg p { position: relative; margin: 0; padding: 12px 16px; font-size: 16px; line-height: 1.55; }
.th-you { align-self: flex-end; }
.th-you .th-who { justify-content: flex-end; }
.th-you p { background: var(--th-you-bg); border: 1px solid var(--th-line); border-radius: var(--th-r) var(--th-r) 3px var(--th-r); }
.th-us p { background: var(--th-us-bg); border-radius: var(--th-r) var(--th-r) var(--th-r) 3px; }
.th[data-brand="entrada"] .th-us p { border-left: 2px solid var(--th-accent); border-radius: 2px var(--th-r) var(--th-r) 2px; }

/* Kropki „pisze…" - tylko w trybie uzbrojonym. */
.th-dots { display: none; }

@media (max-width: 760px) {
  .th-act { grid-template-columns: 36px minmax(0, 1fr); row-gap: 18px; }
  .th-chat { grid-column: 2; }
  .th-msg { max-width: 94%; }
  .th-msg p { font-size: 15px; }
}

/* ─── tryb uzbrojony (theater.js) ─────────────────────────────────── */
.th.is-armed .th-acts::after { transform: scaleY(var(--th-p, 0)); }
.th.is-armed .th-you,
.th.is-armed .th-us,
.th.is-armed .th-out { opacity: 0; translate: 0 10px; }
.th.is-armed .th-txt { opacity: 0; }
.th.is-armed .th-dots {
  display: flex; gap: 5px; position: absolute; left: 16px; top: 50%; translate: 0 -50%; opacity: 0;
}
.th.is-armed .th-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--th-accent); }

.th.is-armed .is-on .th-you,
.th.is-armed .is-on .th-us,
.th.is-armed .is-on .th-out {
  opacity: 1; translate: 0 0;
  transition: opacity .45s ease, translate .6s cubic-bezier(.23, 1, .32, 1);
}
.th.is-armed .is-on .th-us { transition-delay: .35s; }
.th.is-armed .is-on .th-out { transition-delay: 1.45s; }
.th.is-armed .is-on .th-txt { opacity: 1; transition: opacity .4s ease 1.2s; }
.th.is-armed .is-on .th-dots { animation: th-dots 1.25s ease forwards; }
.th.is-armed .is-on .th-dots i { animation: th-bounce .9s ease-in-out infinite; }
.th.is-armed .is-on .th-dots i:nth-child(2) { animation-delay: .15s; }
.th.is-armed .is-on .th-dots i:nth-child(3) { animation-delay: .3s; }
.th.is-armed .is-on .th-n { color: var(--th-accent); border-color: var(--th-accent); }
.th.is-armed .is-instant *, .th.is-armed .is-instant { transition: none !important; animation: none !important; }
.th.is-armed .is-instant .th-dots { opacity: 0; }

@keyframes th-dots { 0%, 25% { opacity: 0; } 32%, 88% { opacity: 1; } 100% { opacity: 0; } }
@keyframes th-bounce { 0%, 100% { translate: 0 0; opacity: .45; } 40% { translate: 0 -4px; opacity: 1; } }

/* Entrada: przy prawej krawędzi stoi ozdobna helisa (Transitions.jsx) -
   dymki klienta nie mogą na nią wchodzić. */
@media (min-width: 1000px) { .th[data-brand="entrada"] { padding-right: clamp(32px, 4vw, 64px); } }
