i've been experimenting with building an animated focus ring using CSS anchor positioning https://codepen.io/hi_mayank/pen/MWNrBpQ

i'm adding a pseudo-element on the body itself, so it requires no extra HTML. and unlike a regular outline, it won't get clipped by adjacent elements or overflow.

issues:
- it does not work for elements focused inside a popover or dialog.
- i'm also trying to animate it but it's not performant bc you cannot use anchored values in transforms.

Anchored focus ring

...

one day i'd love to be able to access the top layer using CSS only.

just let me do this:

```
body::after {
/* elevates this pseudo-element to the top layer */
overlay: manual;
}
```

i should not have to write any HTML or JS for this.

in my quest for anchored focus rings, i had somewhat of an epiphany today. i can add an `::after` pseudo-element on a top-layer element. works ok if you can ensure the pseudo is unused.

i was also trying to use proximity scoping (with lower boundary) to avoid creating multiple pseudos, but couldn't figure that one out.

my border-radius :(
@mayank can you use anchor position to ensure all edges of the focus rings are appropriately placed around the edges of the target?
@scrwd yes, that's what i did in the first post in the thread (unless i'm misunderstanding your question)
@mayank ah sorry, I didn't see the thread when I saw that toot - I took it as an isolated thing. Thanks for pointing me in the right direction!

@mayank Yep. Not related, but I'd be a bit wary of an unbounded `:has()` like that, haha. Maybe there could be a way to optimize it by doing something like

:has(:focus-visible):scope:focus-within::after {}

I remember that switching the places of selectors by moving :has() to the left helped in a few cases. Plus, we could try to help browsers by telling them to first check if the scope in question has any focus inside at all, and only then try to use `:has()`.

@kizu in this case, i might be able to completely replace `:has(:focus-visible)` with `:focus-within`.

the `*:focus-visible` rule that sets the anchor-name should automatically take care of the rest.