/* Region swaps: the one stylesheet in this directory that is not a port.
 *
 * The other seventeen files here are byte for byte the React application's own
 * (src/client/styles), and they stay that way: an SPA had no need for this
 * mechanism, so its styles could not have described it. Everything below is
 * four rules, and every value that could be a token is one.
 *
 * See core/regions.py and docs/regions.md. */

/* A REGION IS INVISIBLE TO THE LAYOUT. `.content` is a column with
 * `gap: var(--space-6)` between its children (components.css), so wrapping
 * three of them in a plain div would quietly collapse the space between them.
 * This restores the same column and the same gap from the same token, which is
 * why a page looks identical before and after its data area becomes a region. */
.region { display: flex; flex-direction: column; gap: var(--space-6); }

/* WHILE A SWAP IS IN THE AIR, NOTHING HAPPENS FOR 150ms. A fragment from a
 * database on the same network arrives in tens of milliseconds, and a dim that
 * showed for 20ms would read as a flicker rather than as progress. So the
 * transition is delayed past the length of a normal swap: a fast answer is
 * invisible, a slow one fades the stale rows down and says why. The rows stay
 * readable at 0.55 rather than being replaced by a skeleton, because they are
 * still true until the new ones land. aria-busy carries the same fact to a
 * screen reader, which is the half that does not depend on seeing it. */
.region { transition: opacity 120ms linear; }
.region[aria-busy="true"] { opacity: 0.55; transition-delay: 150ms; }

/* Somebody who asked for less motion gets none of it: no fade in either
 * direction, and no dim at all rather than an abrupt one. */
@media (prefers-reduced-motion: reduce) {
  .region, .region[aria-busy="true"] { opacity: 1; transition: none; }
}

/* The Apply button and anything else that only exists because a server rendered
 * form needs something to submit it. The script sets data-regions on <html>
 * once it is running, so these are visible exactly when they are the only way
 * to apply a filter. */
[data-regions="on"] [data-region-fallback] { display: none; }
