/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 * Copyright © 2026 Marcel Rymenhout and IniqDash contributors */
/* ==========================================================================
   Theme look + dashboard background (components/theme/theme.js writes the values; this file only USES them).
   Every rule is scoped to a data attribute the theme sets on its root, so with no theme (IniqDash Original) nothing here applies.
   Nothing here changes a size or a position: backgrounds are painted behind the content (absolute pseudo-elements, no layout),
   blur is a backdrop filter, glow is a shadow.
   ========================================================================== */

/* a theme change happens in ONE frame (components/theme/theme.js suspendTransitions): no element fades through in-between colours */
[data-theme-switching], [data-theme-switching] *, [data-theme-switching] *::before, [data-theme-switching] *::after { transition: none !important; }

/* headings follow the theme's heading colour only when the theme sets one (otherwise they keep inheriting, as always) */
:where([data-theme-heading]) :where(.ed-dash-title, .mc__title, .tsg-th__title) { color: var(--text-heading); }

/* widget compatibility: the Sensor card draws its own dark gradient; under a theme it uses the shared card surface like the other
   device cards (without a theme — IniqDash Original — it keeps its own look) */
:where([data-theme]) .sw { background: var(--device-surface); box-shadow: var(--device-shadow); }

/* frosted cards: the device card family and panels (their own radius clips the blur) */
:where([data-theme-blur]) :where(.lw, .cw, .sw, .iq-room, .pr, .iq-act, .ap, .wx, .ca, .mc--primary, .bw__b, .mtabs[data-style="panel"]) {
  -webkit-backdrop-filter: blur(var(--theme-blur)) saturate(1.15);
  backdrop-filter: blur(var(--theme-blur)) saturate(1.15);
}

/* glow: the selected page and pressed primary controls */
:where([data-theme-glow]) .mnav__b[aria-current="page"] { box-shadow: inset 0 0 0 1px var(--accent-line), var(--theme-glow); }
:where([data-theme-glow]) .iqc-btn[data-on="true"]:not([data-style="bare"]) { box-shadow: var(--theme-glow); }

/* ---- the DASHBOARD BACKGROUND (the canvas — and the Theme Studio's preview / thumbnails, which draw it the same way):
   colour or gradient, then the image (fit, position, opacity, blur), then the overlay */
[data-theme-bg] :is(.ed-canvas, .ed-mcanvas, .tst-canvas, .tsg-th__canvas) { isolation: isolate; }
[data-theme-bg] :is(.ed-canvas:not([data-design="popup"]), .ed-mcanvas, .tst-canvas, .tsg-th__canvas) { background-image: var(--theme-bg, none); }
[data-theme-bg-image] :is(.ed-canvas, .ed-mcanvas, .tst-canvas, .tsg-th__canvas)::before,
[data-theme-bg-overlay] :is(.ed-canvas, .ed-mcanvas, .tst-canvas, .tsg-th__canvas)::after {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
}
[data-theme-bg-image] :is(.ed-canvas, .ed-mcanvas, .tst-canvas, .tsg-th__canvas)::before {
  background-image: var(--theme-bg-image);
  background-size: var(--theme-bg-size, cover);
  background-position: var(--theme-bg-position, center);
  background-repeat: no-repeat;
  background-attachment: var(--theme-bg-attach, scroll);
  opacity: var(--theme-bg-opacity, 1);
  filter: var(--theme-bg-blur, none);
  clip-path: inset(0 round 20px);          /* a blurred image never bleeds past the canvas corners */
}
[data-theme-bg-overlay] :is(.ed-canvas, .ed-mcanvas, .tst-canvas, .tsg-th__canvas)::after { background: var(--theme-bg-overlay); }
