/* The word. Still at rest; ::before / ::after are displaced slices that only appear during a burst. */
@layer title {
  .title {
    position: relative;
    margin: 0;
    padding-inline-end: .055em; /* trailing negative tracking would pull the word off-centre */
    font-size: clamp(3.5rem, 16vw, 15rem);
    font-weight: 500;
    line-height: 1;
    letter-spacing: -.055em;
    white-space: nowrap;
    color: transparent; /* reserves the final width so scrambling never shifts the layout */
    animation: title-in 3s cubic-bezier(.16, .8, .2, 1) .6s both;
  }

  /* --redact-x / --redact-w are published by js/effects/redactions.js; the bar wipes in from the left. */
  .word {
    position: absolute;
    inset: 0;
    color: var(--c-signal);
    text-shadow: 0 0 .6em rgb(237 237 237 / .1);
    background: linear-gradient(var(--c-signal) 0 0) no-repeat;
    background-position: calc(var(--redact-x, 0em) - .03em) 58%;
    background-size: 0 .74em;
    transition: background-size .45s cubic-bezier(.7, 0, .2, 1);
  }

  .word.is-redacted {
    background-size: calc(var(--redact-w, 0em) + .06em) .74em;
  }

  .word::before,
  .word::after {
    content: attr(data-text);
    position: absolute;
    inset: 0;
    background: var(--c-void);
    clip-path: inset(0 0 100% 0);
  }

  /* ── Burst ── */
  .is-glitching .word {
    text-shadow: -.03em 0 var(--c-channel-r), .03em 0 var(--c-channel-b);
    animation: word-jolt .16s steps(1) infinite;
  }

  .is-glitching .word::before { animation: slice-shift .2s steps(1) infinite; }
  .is-glitching .word::after  { animation: slice-invert .26s steps(1) infinite; }

  /* A film title, not a boot screen: out of focus and widely tracked, settling into place. */
  @keyframes title-in {
    from {
      letter-spacing: .6em;
      opacity: 0;
      filter: blur(.12em);
    }
  }

  @keyframes word-jolt {
    0%  { transform: none; }
    33% { transform: translateX(-.015em); }
    66% { transform: translateX(.02em) skewX(-4deg); }
  }

  @keyframes slice-shift {
    0%  { clip-path: inset(10% 0 72% 0); transform: translateX(-.06em); }
    25% { clip-path: inset(48% 0 38% 0); transform: translateX(.09em); }
    50% { clip-path: inset(0 0 100% 0);  transform: none; }
    75% { clip-path: inset(70% 0 12% 0); transform: translateX(-.04em); }
  }

  /* Every property is set on every step so nothing lingers between keyframes. */
  @keyframes slice-invert {
    0%  { clip-path: inset(0 0 100% 0);  transform: none;               background: var(--c-void);   color: var(--c-signal); }
    30% { clip-path: inset(34% 0 52% 0); transform: translateX(.05em);  background: var(--c-signal); color: var(--c-void); }
    55% { clip-path: inset(62% 0 22% 0); transform: translateX(-.08em); background: var(--c-void);   color: var(--c-signal); }
    80% { clip-path: inset(0 0 100% 0);  transform: none;               background: var(--c-void);   color: var(--c-signal); }
  }
}
