/* Screen-wide atmosphere. `.is-glitching` on <html> is toggled by js/effects/glitch-bursts.js. */
@layer effects {
  /* ── Data field: quiet behind the word so it always reads first ── */
  .field {
    mask-image: radial-gradient(ellipse 46vw 24vh at 50% 50%, rgb(0 0 0 / .08) 30%, #000 100%);
    transition: opacity 3s ease-in;
  }

  @starting-style {
    .field { opacity: 0; }
  }

  /* ── Vignette, film grain (::before) and the inverted tear band used by bursts (::after) ── */
  .grain {
    background: radial-gradient(ellipse at center, transparent 40%, rgb(0 0 0 / .8) 100%);
  }

  .grain::before {
    content: "";
    position: absolute;
    inset: -50%;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    opacity: .06;
    animation: grain .6s steps(4) infinite;
  }

  .grain::after {
    content: "";
    position: absolute;
    inset-inline: 0;
    top: 50%;
    height: 0;
    backdrop-filter: invert(1);
  }

  @keyframes grain {
    0%  { transform: translate(0, 0); }
    25% { transform: translate(-6%, 4%); }
    50% { transform: translate(5%, -7%); }
    75% { transform: translate(-3%, 8%); }
  }

  /* ── Hidden terminal (js/effects/terminal.js): the word steps back, the field becomes the screen ── */
  .stage { transition: opacity .8s ease; }
  .is-terminal .stage { opacity: .18; }

  /* The camera image needs the centre of the field, so the mask behind the word opens up. */
  .is-mirroring .field {
    mask-image: radial-gradient(ellipse 46vw 24vh at 50% 50%, rgb(0 0 0 / .6) 30%, #000 100%);
  }

  /* ── Burst state ── */
  .is-glitching .field {
    filter: brightness(1.9);
    animation: field-jolt .18s steps(1) infinite;
  }

  .is-glitching .grain::after {
    animation: tear .22s steps(1) infinite;
  }

  @keyframes field-jolt {
    0%  { translate: 0 0; }
    33% { translate: -10px 0; }
    66% { translate: 6px 0; }
  }

  @keyframes tear {
    0%  { top: 47%; height: 14px; }
    30% { top: 53%; height: 3px; }
    55% { top: 21%; height: 1px; }
    80% { top: 49.5%; height: 26px; }
  }
}
