/* Transformation board on the Halo landing (#prevrashchenie).
 *
 * THESIS: mess on the left, order on the right, and the visitor watches the
 *   material physically cross from one to the other. The left pile is loose
 *   (dashed, tilted) because it is unsorted; the engine is one aubergine slab
 *   that shows the recording being heard, read and cut into topics; the right
 *   column fills with the four things students get, as fragments of the app.
 * MOTION: one authored sequence. Sources fly into the engine, the timeline
 *   is cut, the topics fly out as modules, the lesson materials fill in.
 * OWN-WORLD: chrome is Halo (pearl canvas, iris, aubergine). The fragments
 *   inside the output cards are the app's world: Golos Text, ink, hairlines.
 * FORM: the markup rests in the finished state. halo_transform.js adds
 *   .is-live and replays the sequence while the board is on screen.
 */

.tf {
  --tf-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --tf-iris: #5D51B4;
  --tf-aub: #2B2644;
  --tf-lav: #C9C2E8;
  --tf-mid: #8F84C9;
  --tf-ink: #17151E;
  --tf-on-aub: #BDB5E0;
  max-width: 84rem;
  margin-inline: auto;
}
.tf-board {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 0.75fr) 3rem minmax(0, 1fr) 3rem minmax(0, 1.6fr);
  align-items: stretch;
}
.tf-col { display: flex; min-width: 0; flex-direction: column; }
.tf-label {
  margin-bottom: 0.9rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid rgba(23, 21, 30, 0.1);
  color: rgba(23, 21, 30, 0.64);
  font-size: 0.875rem;
  line-height: 1.2;
}
.tf-ico { display: grid; place-items: center; width: 1.35rem; color: var(--tf-iris); }
.tf-ico svg { width: 1.15rem; height: 1.15rem; }

/* ── Left: the unsorted pile ── */
.tf-pile { display: flex; flex: 1; flex-direction: column; gap: 0.55rem; padding-top: 0.2rem; }
.tf-src {
  display: grid;
  flex: 1;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.8rem;
  align-items: center;
  min-height: 3.9rem;
  padding: 0.7rem 0.9rem;
  border: 1px dashed rgba(93, 81, 180, 0.4);
  border-radius: 1rem;
  transform: translateX(var(--x, 0)) rotate(var(--r, 0deg));
  transition: transform 520ms var(--tf-ease), background-color 260ms ease, border-color 260ms ease;
}
.tf-src.is-picked { transform: none; border-color: var(--tf-iris); background: #fff; }
.tf-src-text { min-width: 0; }
.tf-src-text b { display: block; color: var(--tf-ink); font-size: 0.9375rem; font-weight: 500; line-height: 1.3; }
.tf-src-text small {
  display: block;
  margin-top: 0.1rem;
  overflow: hidden;
  color: rgba(23, 21, 30, 0.62);
  font-size: 0.8125rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Gutters ── */
.tf-arrow { display: grid; place-items: center; color: rgba(93, 81, 180, 0.5); transition: color 320ms ease; }
.tf-arrow svg { width: 1.5rem; height: 1.5rem; transition: transform 420ms var(--tf-ease); }
.tf-arrow.is-hot { color: var(--tf-iris); }
.tf-arrow.is-hot svg { transform: translateX(0.2rem); }

/* ── Centre: the engine ── */
.tf-core {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1.15rem;
  padding: 1.5rem;
  border-radius: 1.25rem;
  background: var(--tf-aub);
  color: #fff;
}
.tf-core-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.tf-core-name { font-size: 1.25rem; font-weight: 500; letter-spacing: -0.03em; }
.tf-count {
  display: inline-block;
  color: var(--tf-on-aub);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: color 300ms ease;
}
.tf-count.is-bump { color: #fff; animation: tf-bump 420ms var(--tf-ease); }
@keyframes tf-bump { 35% { transform: scale(1.12); } }

.tf-view {
  display: grid;
  gap: 0.6rem;
  padding: 0.95rem 0 1.05rem;
  border-block: 1px solid rgba(255, 255, 255, 0.1);
  font-family: "Golos Text", system-ui, sans-serif;
  font-size: 0.78125rem;
  line-height: 1.45;
}
.tf-view * { font-family: inherit; }
.tf-file { display: flex; align-items: center; gap: 0.45rem; min-width: 0; }
.tf-file svg { flex-shrink: 0; width: 0.8rem; height: 0.8rem; color: var(--tf-lav); }
.tf-file b { min-width: 0; overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.tf-file small { flex-shrink: 0; margin-left: auto; color: var(--tf-on-aub); font-size: inherit; font-variant-numeric: tabular-nums; }

.tf-wave { display: flex; gap: 5px; height: 2.5rem; }
.tf-seg { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 2px; min-width: 0; }
.tf-seg i {
  flex: 1;
  min-width: 1px;
  max-width: 4px;
  height: calc(var(--h) * 100%);
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.42);
  transition: background-color 420ms ease, transform 420ms var(--tf-ease) var(--d, 0ms);
}
.tf-view.is-cut .tf-seg:nth-child(odd) i { background: var(--tf-lav); }
.tf-view.is-cut .tf-seg:nth-child(even) i { background: var(--tf-mid); }
/* The cut itself: a hairline dropped between two topics. */
.tf-seg + .tf-seg::before {
  content: "";
  position: absolute;
  top: -0.25rem;
  bottom: -0.25rem;
  left: -3px;
  width: 1px;
  background: rgba(255, 255, 255, 0.6);
  transform-origin: top center;
}
.tf-marks {
  display: flex;
  gap: 5px;
  margin-top: -0.3rem;
  color: var(--tf-on-aub);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}
.tf-marks span { min-width: 0; white-space: nowrap; }

.tf-lines { display: grid; gap: 0.3rem; margin: 0.15rem 0 0; padding: 0; list-style: none; }
.tf-lines li { display: grid; grid-template-columns: 3.1rem minmax(0, 1fr); gap: 0.5rem; align-items: baseline; }
.tf-lines time { color: var(--tf-on-aub); font-variant-numeric: tabular-nums; }
.tf-lines li > span { overflow: hidden; color: rgba(255, 255, 255, 0.88); text-overflow: ellipsis; white-space: nowrap; }
.tf-lines mark {
  padding: 0.05rem 0.25rem;
  border-radius: 0.25rem;
  background: linear-gradient(rgba(143, 132, 201, 0.5), rgba(143, 132, 201, 0.5)) no-repeat 0 0 / 100% 100%;
  color: #fff;
}

.tf-steps { display: grid; flex: 1; grid-auto-rows: 1fr; margin: 0; padding: 0; list-style: none; }
.tf-step {
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr);
  gap: 0.7rem;
  align-items: center;
  padding: 0.6rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.9375rem;
  line-height: 1.4;
  transition: color 300ms ease;
}
.tf-step:first-child { padding-top: 0; border-top: 0; }
.tf-step:last-child { padding-bottom: 0; }
.tf-step-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  box-shadow: inset 0 0 0 1px rgba(201, 194, 232, 0.45);
  color: var(--tf-lav);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  transition: background-color 300ms ease, color 300ms ease, box-shadow 300ms ease;
}
.tf-step-mark i { font-style: normal; transition: opacity 200ms ease; }
.tf-step-mark svg {
  position: absolute;
  width: 0.8rem;
  height: 0.8rem;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 240ms ease, transform 420ms var(--tf-ease);
}
.tf-step.is-done .tf-step-mark { background: rgba(201, 194, 232, 0.16); box-shadow: none; }
.tf-step.is-done .tf-step-mark i { opacity: 0; }
.tf-step.is-done .tf-step-mark svg { opacity: 1; transform: none; }
.tf-step.is-now .tf-step-mark {
  background: var(--tf-lav);
  color: var(--tf-aub);
  box-shadow: 0 0 0 0 rgba(201, 194, 232, 0.5);
  animation: tf-pulse 1400ms ease-out infinite;
}
@keyframes tf-pulse { to { box-shadow: 0 0 0 0.6rem rgba(201, 194, 232, 0); } }

/* ── Right: what students get ── */
.tf-outs { display: grid; flex: 1; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
.tf-out {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 1rem 1rem 1.1rem;
  border: 1px solid rgba(23, 21, 30, 0.07);
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 14px 26px -24px rgba(43, 38, 68, 0.7);
  transition: background-color 360ms ease, box-shadow 360ms ease;
}
.tf-out-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.7rem; align-items: start; }
.tf-out-text b { display: block; color: var(--tf-ink); font-size: 0.9375rem; font-weight: 500; line-height: 1.3; }
.tf-out-text small { display: block; margin-top: 0.1rem; color: rgba(23, 21, 30, 0.62); font-size: 0.8125rem; line-height: 1.35; }
.tf-check {
  display: grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 9999px;
  background: rgba(93, 81, 180, 0.1);
  color: var(--tf-iris);
  transition: opacity 240ms ease, transform 460ms var(--tf-ease);
}
.tf-check svg { width: 0.7rem; height: 0.7rem; }

/* Fragments of the app: no inner box, a hairline and the content itself. */
.tf-frag {
  display: grid;
  flex: 1;
  align-content: start;
  gap: 0.4rem;
  margin: 0.85rem 0 0;
  padding: 0.8rem 0 0;
  border-top: 1px solid rgba(23, 21, 30, 0.08);
  color: #1a1a2e;
  font-family: "Golos Text", system-ui, sans-serif;
  font-size: 0.8125rem;
  line-height: 1.4;
  list-style: none;
}
.tf-frag * { font-family: inherit; }
.tf-frag i { font-style: normal; }

.tf-prog li { display: grid; grid-template-columns: 1.25rem minmax(0, 1fr) auto; gap: 0.5rem; align-items: baseline; }
.tf-num {
  display: grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 9999px;
  background: #f4f5f7;
  font-size: 0.6875rem;
  font-weight: 600;
}
.tf-prog b { font-weight: 500; }
.tf-prog small { color: #6b7080; font-size: 0.75rem; white-space: nowrap; }

.tf-note b { font-weight: 600; }
.tf-note p { position: relative; padding-left: 0.85rem; color: #525866; }
.tf-note p::before {
  content: "";
  position: absolute;
  top: 0.55em;
  left: 0.15rem;
  width: 0.25rem;
  height: 0.25rem;
  border-radius: 9999px;
  background: #a3a8b4;
}

.tf-chap { gap: 0.1rem; }
.tf-chap li {
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr);
  gap: 0.4rem;
  margin-inline: -0.45rem;
  padding: 0.2rem 0.45rem;
  overflow: hidden;
  border-radius: 0.4rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tf-chap time { color: #6b7080; font-variant-numeric: tabular-nums; }
.tf-chap .is-now { background: #eef2ff; }
.tf-chap .is-now time { color: #4f46e5; }

.tf-quiz b { font-weight: 600; }
.tf-opt {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.28rem 0.5rem;
  border: 1px solid #e1e4e8;
  border-radius: 0.5rem;
}
.tf-opt i {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 1.1rem;
  height: 1.1rem;
  border: 1px solid #e1e4e8;
  border-radius: 0.3rem;
  color: #525866;
  font-size: 0.6875rem;
}
.tf-opt.is-right { border-color: #a7f3d0; background: #ecfdf5; }
.tf-opt.is-right i { border-color: #a7f3d0; color: #047857; }
.tf-task { display: flex; align-items: center; gap: 0.4rem; min-width: 0; color: #525866; font-size: 0.75rem; }
.tf-task svg { flex-shrink: 0; width: 0.85rem; height: 0.85rem; }

/* ── Tokens that carry material across the board ── */
.tf-fly {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(93, 81, 180, 0.22), 0 10px 18px -10px rgba(43, 38, 68, 0.55);
  color: var(--tf-iris);
  opacity: 0;
  pointer-events: none;
}
.tf-fly svg { width: 1.05rem; height: 1.05rem; }
.tf-fly--mod {
  width: 1.6rem;
  height: 1.6rem;
  background: var(--tf-lav);
  box-shadow: 0 8px 16px -8px rgba(43, 38, 68, 0.6);
  color: var(--tf-aub);
  font-family: "Golos Text", system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
}

.tf-foot { display: flex; justify-content: center; min-height: 2rem; margin-top: 1.25rem; }

/* ── While the script plays: staged pieces start hidden ── */
/* Before the recording is heard the track is a flat, silent line. */
.tf.is-live .tf-view:not(.is-heard) .tf-seg i { transform: scaleY(0.08); }
.tf.is-live .tf-seg + .tf-seg::before,
.tf.is-live .tf-marks span {
  opacity: 0;
  transition: opacity 260ms ease, transform 420ms var(--tf-ease);
  transition-delay: calc(var(--n, 0) * 150ms);
}
.tf.is-live .tf-seg + .tf-seg::before { transform: scaleY(0); }
.tf.is-live .tf-seg:nth-child(2), .tf.is-live .tf-marks span:nth-child(2) { --n: 1; }
.tf.is-live .tf-seg:nth-child(3), .tf.is-live .tf-marks span:nth-child(3) { --n: 2; }
.tf.is-live .tf-seg:nth-child(4), .tf.is-live .tf-marks span:nth-child(4) { --n: 3; }
.tf.is-live .tf-view.is-cut .tf-seg + .tf-seg::before { opacity: 1; transform: none; }
.tf.is-live .tf-view.is-cut .tf-marks span { opacity: 1; }

.tf.is-live .tf-lines time { opacity: 0; transition: opacity 240ms ease; }
.tf.is-live .tf-lines li > span { clip-path: inset(0 100% 0 0); transition: clip-path 520ms linear; }
.tf.is-live .tf-lines li.is-in time { opacity: 1; }
.tf.is-live .tf-lines li.is-in > span { clip-path: inset(0 0 0 0); }
.tf.is-live .tf-lines mark { background-size: 0% 100%; transition: background-size 460ms var(--tf-ease); }
.tf.is-live .tf-lines mark.is-on { background-size: 100% 100%; }

.tf.is-live .tf-step:not(.is-done):not(.is-now) { color: rgba(255, 255, 255, 0.55); }

/* An empty slot speaks the same dashed language as the unsorted pile. */
.tf.is-live .tf-out:not(.is-on) { border: 1px dashed rgba(93, 81, 180, 0.4); background: transparent; box-shadow: none; }
.tf.is-live .tf-out:not(.is-on) .tf-frag { border-top-color: transparent; }
.tf.is-live .tf-out:not(.is-done) .tf-check { opacity: 0; transform: scale(0.4); }
.tf.is-live [data-tf-item] { opacity: 0; transform: translateY(0.4rem); transition: opacity 380ms var(--tf-ease), transform 520ms var(--tf-ease); }
.tf.is-live [data-tf-item].is-in { opacity: 1; transform: none; }

/* Rewinding the loop must not replay every transition backwards. */
.tf.is-resetting *, .tf.is-resetting *::before { transition: none !important; }

/* Side by side, the two-line notes keep the fragment hairlines level. */
@media (min-width: 1280px) {
  .tf-out-text small { min-height: 2.7em; }
}

/* ── Narrower than a wide desktop: the same flow, top to bottom ── */
@media (max-width: 1279px) {
  .tf { max-width: 42rem; }
  .tf-board { grid-template-columns: minmax(0, 1fr); }
  .tf-arrow { padding: 0.9rem 0; }
  .tf-arrow svg { transform: rotate(90deg); }
  .tf-arrow.is-hot svg { transform: rotate(90deg) translateX(0.2rem); }
  .tf-pile { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tf-src:last-child { grid-column: 1 / -1; }
  .tf-core { padding: 1.35rem; }
}
@media (max-width: 560px) {
  .tf-pile, .tf-outs { grid-template-columns: minmax(0, 1fr); }
  .tf-src { min-height: 3.5rem; transform: translateX(calc(var(--x, 0) * 0.5)) rotate(calc(var(--r, 0deg) * 0.6)); }
  .tf-src:last-child { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .tf-src, .tf-arrow, .tf-arrow svg, .tf-out, .tf-check, .tf-step, .tf-step-mark, .tf-step-mark svg { transition: none; }
  .tf-step.is-now .tf-step-mark, .tf-count.is-bump { animation: none; }
}
