/* ==========================================================================
   Home page: the hero background

   The background draws the headline. Lines arrive from the left tangled and
   irregular, pass behind the wordmark, and leave on the right as evenly
   spaced lanes: probabilistic in, deterministic out. A pulse travels along
   each line, and a soft teal light sits behind the wordmark.

   The hero's own content (wordmark, headline, sub-line, scroll cue) is
   untouched; it is only lifted above this layer.
   ========================================================================== */

body:has(.xh) .md-typeset .xr-hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

body:has(.xh) .md-typeset .xr-hero > :not(.xr-hero__bg) {
  position: relative;
  z-index: 1;
}

.xr-hero__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* A light behind the wordmark, and calm behind the words: the lines stay
   strong at the sides and recede where there is text to read. */
.xr-hero__bg::before,
.xr-hero__bg::after {
  content: "";
  position: absolute;
  inset: 0;
}

.xr-hero__bg::before {
  z-index: 1;
  background: radial-gradient(ellipse 50% 64% at 50% 54%,
              var(--md-default-bg-color) 0,
              color-mix(in srgb, var(--md-default-bg-color) 92%, transparent) 58%,
              color-mix(in srgb, var(--md-default-bg-color) 55%, transparent) 78%,
              transparent 100%);
}

.xr-hero__bg::after {
  z-index: 2;
  background:
    radial-gradient(ellipse 34% 38% at 50% 36%,
      color-mix(in srgb, var(--xr-teal) 17%, transparent) 0, transparent 100%),
    radial-gradient(ellipse 120% 90% at 50% 45%,
      transparent 55%, var(--xr-hero-shade, transparent) 100%);
}

[data-md-color-scheme="slate"] .xr-hero__bg {
  --xr-hero-shade: rgba(0, 0, 0, 0.28);
}

.md-typeset .xr-hero__flow {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
}

/* Colours of the two halves: what arrives, and what leaves. */
.xr-flow-a { stop-color: var(--md-default-fg-color--lighter); }
.xr-flow-b { stop-color: var(--xr-teal); }
.xr-flow-c { stop-color: var(--md-default-fg-color--light); stop-opacity: 0.7; }
.xr-flow-d { stop-color: var(--xr-teal-bright); }

/* On the dark scheme the ordered side carries the brighter teal, so order
   reads as clearly as the tangle it came from. */
[data-md-color-scheme="slate"] .xr-flow-b { stop-color: var(--xr-teal-bright); }

.xr-hero__lines path {
  fill: none;
  stroke: url(#xr-flow-line);
  stroke-width: 1.15;
  opacity: calc(var(--o, 1) * 0.6);
}

.xr-hero__pulses path {
  fill: none;
  stroke: url(#xr-flow-pulse);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 0.024 1;
  stroke-dashoffset: 0.03;
  animation: xr-flow var(--t, 12s) linear infinite;
  animation-delay: var(--d, 0s);
}

@keyframes xr-flow {
  from { stroke-dashoffset: 0.03; }
  to   { stroke-dashoffset: -1; }
}

/* The lines are drawn in the label grey; on the light slate they keep their
   full strength so the hero's pattern reads. */
[data-md-color-scheme="default"] .xr-hero__lines path {
  opacity: var(--o, 1);
}

/* The scroll cue keeps to the width of the words above it. At full width it
   cut across the lines behind and read as one more of them, most of all in
   the tangle on the left. */
body:has(.xh) .md-typeset .xr-hero__cue {
  max-width: 800px;
}

@media (prefers-reduced-motion: reduce) {
  .xr-hero__pulses {
    display: none;
  }
}

@media print {
  .xr-hero__bg {
    display: none;
  }
}
