/* The app's background (public/js/background.js): a layer under the whole page (the tab buttons and the music player too) that holds a colour, a picture or the weather scene,
   with a tint on top. While it shows, the page's own plain colour steps aside (html[data-bg]); islands and cards are transparent (html[data-glass]) unless the person switched that off.
   The layer sits at z-index -1: above the page's colour, below everything drawn in the page. */
.app-bg { position: fixed; inset: 0; z-index: -1; display: none; overflow: hidden; pointer-events: none; }
html[data-bg] .app-bg { display: block; }
.app-bg > * { position: absolute; inset: 0; width: 100%; height: 100%; }
.bg-fill { transition: background-color 0.4s; }
.bg-image { background-repeat: no-repeat; transition: opacity 0.4s; }
.bg-scene { transition: opacity 0.4s; }
.bg-tint { transition: background-color 0.3s; }
html[data-bg], html[data-bg] body { background: transparent; }
html[data-bg] .app { background: none; }

/* a soft black (dark theme) or white (light theme) fade behind the tab buttons, so they can always be read */
html[data-bg] { --bg-scrim: rgba(0, 0, 0, 0.78); }
html[data-bg][data-theme="light"] { --bg-scrim: rgba(255, 255, 255, 0.86); }
html[data-bg] .layout-v .nav { background: linear-gradient(to top, var(--bg-scrim) 0%, color-mix(in srgb, var(--bg-scrim) 55%, transparent) 55%, transparent 100%); }
html[data-bg] .layout-h .nav { background: linear-gradient(to right, var(--bg-scrim) 0%, color-mix(in srgb, var(--bg-scrim) 45%, transparent) 70%, transparent 100%); }

/* glass: the panels let the background show faintly through (the dialogs and menus stay solid) */
html[data-glass] .app { --island-body: rgba(58, 58, 58, 0.6); --input: rgba(35, 35, 35, 0.58); --surface: rgba(26, 26, 26, 0.6); --surface-2: rgba(38, 38, 38, 0.6); }
html[data-glass][data-theme="light"] .app { --island-body: rgba(255, 255, 255, 0.6); --input: rgba(255, 255, 255, 0.55); --surface: rgba(255, 255, 255, 0.6); --surface-2: rgba(255, 255, 255, 0.6); }
html[data-glass] .app .island, html[data-glass] .app .ai-pane, html[data-glass] .app .queue-wrap { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }

/* the background settings window (public/js/backgroundWindow.js) */
.bgw-preview { position: relative; align-self: center; width: 100%; max-width: 280px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); }
.bgw-preview > * { position: absolute; inset: 0; width: 100%; height: 100%; }
.bgw-preview .bg-image { background-repeat: no-repeat; }
.bgw-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.bgw-swatch { width: 30px; height: 30px; padding: 0; border: 2px solid var(--line); border-radius: 50%; cursor: pointer; }
.bgw-swatch.on { border-color: var(--orange); box-shadow: 0 0 0 2px color-mix(in srgb, var(--orange) 45%, transparent); }
.bgw-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bgw-row input[type="color"] { width: 46px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: none; }
.bgw-row input[type="range"] { flex: 1; min-width: 120px; }
.bgw-files { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; max-height: calc(50vh / var(--ui-scale, 1)); overflow: auto; }
.bgw-file { position: relative; aspect-ratio: 1; padding: 0; overflow: hidden; border: 2px solid transparent; border-radius: 12px; background: var(--surface-2); cursor: pointer; }
.bgw-file img { width: 100%; height: 100%; object-fit: cover; }
.bgw-file:hover, .bgw-file.on { border-color: var(--orange); }
.bgw-crop { position: relative; align-self: center; overflow: hidden; border-radius: 12px; background: #000; touch-action: none; user-select: none; -webkit-user-select: none; }
.bgw-crop img { position: absolute; max-width: none; -webkit-user-drag: none; }
.bgw-crop .shade { position: absolute; background: rgba(0, 0, 0, 0.55); pointer-events: none; }
.bgw-crop .frame { position: absolute; border: 2px solid var(--orange); border-radius: 4px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); cursor: grab; }
.bgw-crop .frame:active { cursor: grabbing; }
