/* Background patterns — the parts the app and the login screen share.
 *
 * The canvas positioning and the CSS-only patterns live here because
 * bgPatterns.js is loaded by both pages and its canvases need somewhere to
 * sit. login.html does not load style.css: it is standalone and carries no
 * session, which is the whole reason the pattern was invisible there.
 *
 * The #atlas-os-backdrop repaints came here too. They read as app-shell rules,
 * but login.html carries the same backdrop, so leaving them in style.css meant
 * dots and synapse painted on <body> there -- behind an opaque backdrop, and
 * so invisible -- while the app painted them on top of it.
 */

:root { --bg-effect-intensity: 1; }

/* Canvas-based effects — single source of truth for intensity. */
#synapse-canvas, #rain-canvas, #constellations-canvas,
#perlin-flow-canvas, #petals-canvas, #sparkles-canvas,
#embers-canvas {
  opacity: var(--bg-effect-intensity, 1);
}

.theme-bg-effect-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.theme-bg-effect-canvas--page {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* Dots reads Size as the canvas effects do -- the dot and its spacing -- so
   both sliders do something for it; they were hidden for it as if neither
   could, though Intensity always did. */
body.bg-pattern-dots {
  background-image: radial-gradient(color-mix(in srgb, var(--bg-effect-color, var(--fg)) calc(5% * var(--bg-effect-intensity, 1)), transparent) calc(1px * var(--bg-effect-size, 1)), transparent calc(1px * var(--bg-effect-size, 1)));
  background-size: calc(20px * var(--bg-effect-size, 1)) calc(20px * var(--bg-effect-size, 1)); background-attachment: fixed;
}
body.bg-pattern-synapse {
  /* CSS grid as base, canvas pulses overlay */
  background-image: linear-gradient(color-mix(in srgb, var(--bg-effect-color, var(--fg)) calc(3.5% * var(--bg-effect-intensity, 1)), transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--bg-effect-color, var(--fg)) calc(3.5% * var(--bg-effect-intensity, 1)), transparent) 1px, transparent 1px);
  background-size: 24px 24px; background-attachment: fixed;
}
body.bg-pattern-perlin-flow,
body.bg-pattern-petals,
body.bg-pattern-sparkles {
  /* canvas-only backgrounds */
}

/* Atlas Appearance supplies the base backdrop. Repaint the static patterns
   inside that backdrop so they overlay the selected design instead of sitting
   invisibly behind it on <body>. */
body.atlas-os.bg-pattern-dots,
body.atlas-os.bg-pattern-synapse {
  background-image: none;
}

body.atlas-os.bg-pattern-dots #atlas-os-backdrop::after,
body.atlas-os.bg-pattern-synapse #atlas-os-backdrop::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

body.atlas-os.bg-pattern-dots #atlas-os-backdrop::after {
  background-image: radial-gradient(color-mix(in srgb, var(--bg-effect-color, var(--fg)) calc(5% * var(--bg-effect-intensity, 1)), transparent) calc(1px * var(--bg-effect-size, 1)), transparent calc(1px * var(--bg-effect-size, 1)));
  background-size: calc(20px * var(--bg-effect-size, 1)) calc(20px * var(--bg-effect-size, 1));
}

body.atlas-os.bg-pattern-synapse #atlas-os-backdrop::after {
  background-image:
    linear-gradient(color-mix(in srgb, var(--bg-effect-color, var(--fg)) calc(3.5% * var(--bg-effect-intensity, 1)), transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--bg-effect-color, var(--fg)) calc(3.5% * var(--bg-effect-intensity, 1)), transparent) 1px, transparent 1px);
  background-size: 24px 24px;
}
