/* Qizil 0.4.0: effects layer, opt-in classes. Copied from src/effects.css by scripts/build.mjs; edit the source. */

/* Needs qizil.css (tokens, including the product accents). Load after components.css. Opt-in: nothing
   here applies until an element carries one of these classes.

   Rules of the layer (DESIGN.md E1 to E9):
   - One hero effect per screen: an aurora or a spotlight or a travelling light, not all three.
   - Every effect has a static fallback: without motion the turning rings stand still, without
     backdrop-filter glass is a solid surface, without JavaScript the spotlight rests at the top.
   - Glow follows the product glow (--q-product-glow) and hugs the element: a box-shadow on the box,
     or a layer that covers the box exactly (inset 0, the same radius). Focus stays the 2px crimson
     ring (K2); a glow is never a focus or a selection signal.
   - Animated effects move transform or opacity only, so nothing repaints per frame: the turning
     rings rotate a pre-painted conic layer. All stop with the motion layer (prefers-reduced-motion,
     data-motion="off"), and follow --q-motion-ambient.

   Pseudo-elements in use: .q-aurora, .q-spotlight, .q-card--lift (motion.css), .q-drift (motion.css)
   ::before; .q-grain, .q-card--glow, .q-glow-hover, .q-divider--sweep ::after; .q-grad-border--spin
   and .q-travel--spin both. Do not put two classes that share one on the same element. */

@keyframes q-turn {
  to {
    transform: translate(-50%, -50%) rotate(1turn);
  }
}

@keyframes q-aurora {
  to {
    transform: translate3d(4%, 3%, 0) scale(1.08);
  }
}

@keyframes q-line-sweep {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(340%);
  }
}

/* =========================================================================
   E1 Glow rings: a box-shadow that follows the element radius, in the product glow
   ========================================================================= */

.q-glow {
  box-shadow:
    0 0 0 var(--q-line-hairline) color-mix(in srgb, var(--q-product-glow) var(--q-glow-ring), transparent),
    0 8px var(--q-glow-blur) calc(var(--q-glow-blur) / -3) color-mix(in srgb, var(--q-product-glow) var(--q-glow-haze), transparent);
}

/* Hover glow (cards, tiles): the same ring and haze on a layer that covers the border box exactly;
   only its opacity changes. .q-card--glow also turns the hairline into the glow ring. */
.q-glow-hover,
.q-card--glow {
  position: relative;
  isolation: isolate;
}

.q-glow-hover::after,
.q-card--glow::after {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--q-line-hairline));
  z-index: -1;
  border-radius: inherit;
  box-shadow:
    inset 0 0 0 var(--q-line-hairline) color-mix(in srgb, var(--q-product-glow) calc(var(--q-glow-ring) * 2), var(--q-border)),
    0 10px var(--q-glow-blur) calc(var(--q-glow-blur) / -3) color-mix(in srgb, var(--q-product-glow) var(--q-glow-haze), transparent),
    var(--q-shadow-soft-1);
  opacity: 0;
  transition: opacity var(--q-duration-base) var(--q-ease-out);
  pointer-events: none;
}

.q-glow-hover:hover::after,
.q-glow-hover:focus-within::after,
.q-card--glow:hover::after,
.q-card--glow:focus-within::after {
  opacity: 1;
}

/* =========================================================================
   E2 Gradient border: the product gradient as a ring that hugs the radius (padding-box fill over a
   border-box gradient, no pseudo-element; --q-angle turns the still ring). --spin turns it slowly
   (see the turning rings below). Set --q-grad-border-fill when the element does not sit on --q-bg.
   ========================================================================= */

.q-grad-border {
  --q-grad-border-fill: var(--q-bg);
  border-style: solid;
  border-width: var(--q-grad-border-width, var(--q-line-hairline));
  border-color: transparent;
  background:
    linear-gradient(var(--q-grad-border-fill), var(--q-grad-border-fill)) padding-box,
    conic-gradient(from var(--q-angle, 0deg), var(--q-product-1), var(--q-product-mid), var(--q-product-end), var(--q-product-mid), var(--q-product-1)) border-box;
}

/* Travelling light: the same ring in the border colour with one bright arc, for the one thing on a
   screen that is waiting for the person (a plan to pick, a live connection). Still by default; add
   .q-travel--spin to let the light run around. */
.q-travel {
  --q-travel-fill: var(--q-bg);
  border-style: solid;
  border-width: var(--q-line-hairline);
  border-color: transparent;
  background:
    linear-gradient(var(--q-travel-fill), var(--q-travel-fill)) padding-box,
    conic-gradient(
      from var(--q-angle, 0deg),
      var(--q-border) 0% 72%,
      color-mix(in srgb, var(--q-product-glow) 90%, var(--q-border)) 86%,
      var(--q-border) 100%
    ) border-box;
}

/* Turning rings (.q-grad-border--spin, .q-travel--spin) without repainting: ::before is a square
   conic layer, at least 150% of the larger side so it covers the box at every angle, turned by
   transform on the compositor. overflow: clip with a clip margin of the border width cuts it to the
   border box and its radius (and keeps it out of the page's scrollable area); ::after is the fill,
   drawn over the padding box by the browser's own inner radius (a transparent border of the same
   width over the same border box), so the ring stays exact at every radius and zoom. Where the
   clip margin is not supported the clip is the padding box: the layer is hidden under the fill and
   the still ring of the element itself shows. Both pseudo-elements and the clip are taken: no
   .q-card--glow, .q-card--lift, .q-glow or outer shadow on a turning ring. */
.q-grad-border--spin,
.q-travel--spin {
  position: relative;
  isolation: isolate;
  overflow: clip;
  overflow-clip-margin: var(--q-grad-border-width, var(--q-line-hairline));
}

.q-travel--spin {
  overflow-clip-margin: var(--q-line-hairline);
}

.q-grad-border--spin::before,
.q-travel--spin::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: -1;
  aspect-ratio: 1;
  min-width: 150%;
  min-height: 150%;
  background: conic-gradient(var(--q-product-1), var(--q-product-mid), var(--q-product-end), var(--q-product-mid), var(--q-product-1));
  transform: translate(-50%, -50%);
  animation: q-turn var(--q-loop-drift) linear infinite;
  animation-play-state: var(--q-motion-ambient, running);
  pointer-events: none;
}

.q-travel--spin::before {
  background: conic-gradient(
    var(--q-border) 0% 72%,
    color-mix(in srgb, var(--q-product-glow) 90%, var(--q-border)) 86%,
    var(--q-border) 100%
  );
  animation-duration: var(--q-loop-travel);
}

.q-grad-border--spin::after,
.q-travel--spin::after {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--q-grad-border-width, var(--q-line-hairline)));
  z-index: -1;
  border: var(--q-grad-border-width, var(--q-line-hairline)) solid transparent;
  border-radius: inherit;
  background: var(--q-grad-border-fill, var(--q-bg)) padding-box;
  pointer-events: none;
}

.q-travel--spin::after {
  inset: calc(-1 * var(--q-line-hairline));
  border-width: var(--q-line-hairline);
  background: var(--q-travel-fill, var(--q-bg)) padding-box;
}

/* =========================================================================
   E3 Glass and frosted surfaces (nav bars, floating panels over the aurora or an illustration)
   ========================================================================= */

.q-glass,
.q-frost {
  border: var(--q-line-hairline) solid var(--q-glass-line);
  background: var(--q-glass-solid);
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .q-glass {
    background: var(--q-glass);
    -webkit-backdrop-filter: blur(var(--q-glass-blur)) saturate(var(--q-glass-saturate));
    backdrop-filter: blur(var(--q-glass-blur)) saturate(var(--q-glass-saturate));
  }

  .q-frost {
    background: color-mix(in srgb, var(--q-glass-solid) 86%, transparent);
    -webkit-backdrop-filter: blur(calc(var(--q-glass-blur) * 2)) saturate(var(--q-glass-saturate));
    backdrop-filter: blur(calc(var(--q-glass-blur) * 2)) saturate(var(--q-glass-saturate));
  }
}

/* The scroll-aware nav (motion.css) with a frosted backdrop. */
.q-nav-bar--glass::before {
  border-bottom-color: var(--q-glass-line);
  background: var(--q-glass-solid);
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .q-nav-bar--glass::before {
    background: var(--q-glass);
    -webkit-backdrop-filter: blur(var(--q-glass-blur)) saturate(var(--q-glass-saturate));
    backdrop-filter: blur(var(--q-glass-blur)) saturate(var(--q-glass-saturate));
  }
}

@media (prefers-reduced-transparency: reduce) {
  .q-glass,
  .q-frost,
  .q-nav-bar--glass::before {
    background: var(--q-glass-solid);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* =========================================================================
   E4 Aurora and mesh backgrounds, in the product colours over --q-bg
   ========================================================================= */

/* Aurora: soft light from the top corners and the bottom edge. --live drifts it (transform only). */
.q-aurora {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background-color: var(--q-bg);
}

.q-aurora::before {
  content: "";
  position: absolute;
  inset: -12%;
  z-index: -1;
  background: var(--q-product-aurora);
  pointer-events: none;
}

.q-aurora--live::before {
  animation: q-aurora var(--q-loop-aurora) var(--q-ease-in-out) infinite alternate;
  animation-play-state: var(--q-motion-ambient, running);
}

/* Mesh: four still corner glows for a card or a section band. */
.q-mesh {
  background:
    radial-gradient(70% 80% at 0% 0%, color-mix(in srgb, var(--q-product-glow-2) var(--q-aurora-1), transparent), transparent 70%),
    radial-gradient(70% 80% at 100% 0%, color-mix(in srgb, var(--q-product-glow) var(--q-aurora-2), transparent), transparent 70%),
    radial-gradient(80% 70% at 100% 100%, color-mix(in srgb, var(--q-product-2) var(--q-aurora-3), transparent), transparent 70%),
    var(--q-bg);
}

/* =========================================================================
   E5 Grain: a fine noise over a surface (dist/patterns/grain.svg, no data URI)
   ========================================================================= */

.q-grain {
  position: relative;
  isolation: isolate;
}

.q-grain::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background-image: url("./patterns/grain.svg");
  background-size: var(--q-grain-size) var(--q-grain-size);
  opacity: var(--q-grain-opacity);
  pointer-events: none;
}

/* =========================================================================
   E6 Spotlight: a soft light that follows the pointer. motion.js moves it with --q-spot-dx and
   --q-spot-dy (transform only, one listener, once per frame). Without it the light rests at the top.
   ========================================================================= */

.q-spotlight {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.q-spotlight::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  z-index: -1;
  width: var(--q-spotlight-size);
  height: var(--q-spotlight-size);
  margin: calc(var(--q-spotlight-size) / -2) 0 0 calc(var(--q-spotlight-size) / -2);
  border-radius: var(--q-radius-full);
  background: radial-gradient(closest-side, color-mix(in srgb, var(--q-product-glow) var(--q-spot-alpha), transparent), transparent);
  transform: translate(var(--q-spot-dx, 0px), var(--q-spot-dy, 0px));
  opacity: 0;
  transition: opacity var(--q-duration-base) var(--q-ease-out);
  pointer-events: none;
}

.q-spotlight:hover::before,
.q-spotlight:focus-within::before {
  opacity: 1;
}

/* =========================================================================
   E7 Gradient text and soft shadows
   ========================================================================= */

/* A soft halo in the product glow around one gradient word (static: a filter, no motion). */
.q-grad-text--glow {
  filter: drop-shadow(0 0 18px color-mix(in srgb, var(--q-product-glow) var(--q-glow-haze), transparent));
}

.q-soft-1 {
  box-shadow: var(--q-shadow-soft-1);
}

.q-soft-2 {
  box-shadow: var(--q-shadow-soft-2);
}

.q-soft-3 {
  box-shadow: var(--q-shadow-soft-3);
}

/* =========================================================================
   E8 Divider with a light sweep. The line fades out at both ends; the light crosses it now and then.
   Use a <div class="q-divider q-divider--sweep" role="separator"> (an <hr> has no ::after).
   ========================================================================= */

.q-divider--sweep {
  position: relative;
  overflow: hidden;
  background: linear-gradient(90deg, transparent, var(--q-border) 16%, var(--q-border) 84%, transparent);
}

.q-divider--sweep::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 30%;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--q-product-glow) 80%, transparent), transparent);
  transform: translateX(-100%);
  animation: q-line-sweep var(--q-loop-travel) var(--q-ease-in-out) infinite;
  animation-play-state: var(--q-motion-ambient, running);
}

/* =========================================================================
   E9 Product motifs: a pattern layer behind content, in --q-product-motif, fading out from the top.
   <div class="q-motif" aria-hidden="true"></div> as the first child of a positioned, isolated
   container (.q-hero, .q-aurora, a card with .q-glow-hover). Products pick the pattern; a modifier
   (--dots, --grid, --constellation, --asanoha, --rays) forces one.
   ========================================================================= */

.q-motif {
  --q-motif-fade: radial-gradient(110% 85% at 50% 0%, black 10%, transparent 72%);
  position: absolute;
  inset: 0;
  z-index: -1;
  background-color: var(--q-product-motif);
  -webkit-mask-image: url("./patterns/dots.svg"), var(--q-motif-fade);
  mask-image: url("./patterns/dots.svg"), var(--q-motif-fade);
  -webkit-mask-size: 20px 20px, 100% 100%;
  mask-size: 20px 20px, 100% 100%;
  -webkit-mask-repeat: repeat, no-repeat;
  mask-repeat: repeat, no-repeat;
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
  opacity: 0.75;
  pointer-events: none;
}

.q-motif--fade-bottom {
  --q-motif-fade: radial-gradient(110% 85% at 50% 100%, black 10%, transparent 72%);
}

.q-motif--full {
  --q-motif-fade: linear-gradient(black, black);
}

/* The product picks the pattern (default, admin and profile keep the dots) ... */
[data-product="infracanvas"] .q-motif {
  -webkit-mask-image: url("./patterns/grid.svg"), var(--q-motif-fade);
  mask-image: url("./patterns/grid.svg"), var(--q-motif-fade);
  -webkit-mask-size: 96px 96px, 100% 100%;
  mask-size: 96px 96px, 100% 100%;
  -webkit-mask-repeat: repeat, no-repeat;
  mask-repeat: repeat, no-repeat;
}

[data-product="account"] .q-motif {
  -webkit-mask-image: url("./patterns/constellation.svg"), var(--q-motif-fade);
  mask-image: url("./patterns/constellation.svg"), var(--q-motif-fade);
  -webkit-mask-size: 160px 160px, 100% 100%;
  mask-size: 160px 160px, 100% 100%;
  -webkit-mask-repeat: repeat, no-repeat;
  mask-repeat: repeat, no-repeat;
}

[data-product="manabi"] .q-motif {
  -webkit-mask-image: url("./patterns/asanoha.svg"), var(--q-motif-fade);
  mask-image: url("./patterns/asanoha.svg"), var(--q-motif-fade);
  -webkit-mask-size: 36px 62.354px, 100% 100%;
  mask-size: 36px 62.354px, 100% 100%;
  -webkit-mask-repeat: repeat, no-repeat;
  mask-repeat: repeat, no-repeat;
}

[data-product="site"] .q-motif {
  -webkit-mask-image: repeating-conic-gradient(from -90deg at 50% 115%, black 0deg 0.6deg, transparent 0.6deg 7.5deg), var(--q-motif-fade);
  mask-image: repeating-conic-gradient(from -90deg at 50% 115%, black 0deg 0.6deg, transparent 0.6deg 7.5deg), var(--q-motif-fade);
  -webkit-mask-size: 100% 100%, 100% 100%;
  mask-size: 100% 100%, 100% 100%;
  -webkit-mask-repeat: no-repeat, no-repeat;
  mask-repeat: no-repeat, no-repeat;
}

/* ... and a modifier wins over the product (same specificity, later in the file). */
.q-motif.q-motif--grid {
  -webkit-mask-image: url("./patterns/grid.svg"), var(--q-motif-fade);
  mask-image: url("./patterns/grid.svg"), var(--q-motif-fade);
  -webkit-mask-size: 96px 96px, 100% 100%;
  mask-size: 96px 96px, 100% 100%;
  -webkit-mask-repeat: repeat, no-repeat;
  mask-repeat: repeat, no-repeat;
}

.q-motif.q-motif--constellation {
  -webkit-mask-image: url("./patterns/constellation.svg"), var(--q-motif-fade);
  mask-image: url("./patterns/constellation.svg"), var(--q-motif-fade);
  -webkit-mask-size: 160px 160px, 100% 100%;
  mask-size: 160px 160px, 100% 100%;
  -webkit-mask-repeat: repeat, no-repeat;
  mask-repeat: repeat, no-repeat;
}

.q-motif.q-motif--asanoha {
  -webkit-mask-image: url("./patterns/asanoha.svg"), var(--q-motif-fade);
  mask-image: url("./patterns/asanoha.svg"), var(--q-motif-fade);
  -webkit-mask-size: 36px 62.354px, 100% 100%;
  mask-size: 36px 62.354px, 100% 100%;
  -webkit-mask-repeat: repeat, no-repeat;
  mask-repeat: repeat, no-repeat;
}

.q-motif.q-motif--rays {
  -webkit-mask-image: repeating-conic-gradient(from -90deg at 50% 115%, black 0deg 0.6deg, transparent 0.6deg 7.5deg), var(--q-motif-fade);
  mask-image: repeating-conic-gradient(from -90deg at 50% 115%, black 0deg 0.6deg, transparent 0.6deg 7.5deg), var(--q-motif-fade);
  -webkit-mask-size: 100% 100%, 100% 100%;
  mask-size: 100% 100%, 100% 100%;
  -webkit-mask-repeat: no-repeat, no-repeat;
  mask-repeat: no-repeat, no-repeat;
}

.q-motif.q-motif--dots {
  -webkit-mask-image: url("./patterns/dots.svg"), var(--q-motif-fade);
  mask-image: url("./patterns/dots.svg"), var(--q-motif-fade);
  -webkit-mask-size: 20px 20px, 100% 100%;
  mask-size: 20px 20px, 100% 100%;
  -webkit-mask-repeat: repeat, no-repeat;
  mask-repeat: repeat, no-repeat;
}

/* =========================================================================
   Static fallbacks: forced colours, reduced motion, motion off
   ========================================================================= */

@media (forced-colors: active) {
  .q-glow,
  .q-soft-1,
  .q-soft-2,
  .q-soft-3 {
    box-shadow: none;
  }

  .q-glow-hover::after,
  .q-card--glow::after,
  .q-aurora::before,
  .q-grain::after,
  .q-spotlight::before,
  .q-divider--sweep::after,
  .q-grad-border--spin::before,
  .q-grad-border--spin::after,
  .q-travel--spin::before,
  .q-travel--spin::after,
  .q-motif {
    display: none;
  }

  .q-grad-border,
  .q-travel {
    border-color: CanvasText;
    background: Canvas;
  }

  .q-grad-text--glow {
    filter: none;
  }
}

:is([data-motion="off"], [data-motion="off"] *),
:is([data-motion="off"], [data-motion="off"] *)::before,
:is([data-motion="off"], [data-motion="off"] *)::after {
  animation: none !important;
  transition: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .q-grad-border--spin::before,
  .q-travel--spin::before,
  .q-aurora--live::before,
  .q-divider--sweep::after {
    animation: none !important;
  }

  .q-glow-hover::after,
  .q-card--glow::after,
  .q-spotlight::before {
    transition: none !important;
  }
}

/* With motion off the sweep has nowhere to rest, so it is not drawn. */
:is([data-motion="off"], [data-motion="off"] *).q-divider--sweep::after {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .q-divider--sweep::after {
    display: none;
  }
}
