/* Your own background (app/components/backdrop.js, app/views/background.js).
   Loaded last. While a background is on, <html data-bg="light|dark"> swaps the
   theme's solid surfaces for frosted glass in that tone; the accent comes in
   as inline custom properties read from the picture. */

/* ---- The layer ------------------------------------------------------------------------ */
.backdrop { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; background: #0b0d12; }
[data-bg="light"] .backdrop { background: #eef1f5; }
.backdrop-dim, .effects { position: absolute; inset: 0; width: 100%; height: 100%; }
/* One picture: "fill" covers the screen, "whole" shows all of it over a
   blurred copy of itself; zoom scales from the point kept in view. */
.bd-pic { position: absolute; inset: 0; overflow: hidden; }
.bd-pic img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; display: block; user-select: none; -webkit-user-drag: none; }
.bd-fill { object-fit: cover; filter: blur(28px) saturate(130%) brightness(.85); transform: scale(1.15); }
/* A new picture fades in over the last one (the slideshow's crossfade). */
.bd-pic.entering { animation: bgIn 1.2s ease both; }
.effects { display: block; }
@keyframes bgIn { from { opacity: 0; } to { opacity: 1; } }

/* ---- Frosted glass over the picture ----------------------------------------------------- */
/* --glass-a is how solid a panel is (0-1), from the "See-through panels"
   slider; everything that covers the picture is a fraction of it, the side
   rail and the veil the least, so the picture is the star. */
html[data-bg][data-theme] { --glass-a: .4; }
html[data-bg="dark"][data-theme] {
  --bg: transparent;
  --surface: rgba(14, 17, 25, var(--glass-a));
  --surface-2: rgba(28, 33, 45, calc(var(--glass-a) * .9));
  --surface-3: rgba(46, 53, 69, calc(var(--glass-a) + .1));
  --surface-solid: #161a23;
  --hover: rgba(255, 255, 255, .08);
  --press: rgba(255, 255, 255, .12);
  --border: rgba(255, 255, 255, .14);
  --border-strong: rgba(255, 255, 255, .22);
  --text: #f6f8fb;
  --text-2: #d3d9e3;
  --text-3: #aab3c1;
  --theirs: rgba(44, 51, 66, calc(var(--glass-a) + .2));
  --overlay: rgba(0, 0, 0, .5);
  --code-bg: #0d1016;
  --code-text: #e6e9ef;
  --hero-1: rgba(14, 17, 24, calc(var(--glass-a) * .8));
  --hero-2: rgba(14, 17, 24, calc(var(--glass-a) * .8));
  --rail-bg: rgba(8, 10, 15, calc(var(--glass-a) * .55)); --rail-brd: rgba(255, 255, 255, .08); --rail-fg: rgba(255, 255, 255, .78); --rail-fg-on: #fff;
  --rail-hover: rgba(255, 255, 255, .1); --rail-on: rgba(255, 255, 255, .18);
  --veil: rgba(8, 10, 15, calc(var(--glass-a) * .3));
  --legible: 0 1px 2px rgba(0, 0, 0, .45);
  color-scheme: dark;
}
html[data-bg="light"][data-theme] {
  --bg: transparent;
  --surface: rgba(255, 255, 255, calc(var(--glass-a) + .14));
  --surface-2: rgba(248, 249, 252, calc(var(--glass-a) + .08));
  --surface-3: rgba(230, 234, 241, calc(var(--glass-a) + .2));
  --surface-solid: #ffffff;
  --hover: rgba(10, 20, 40, .06);
  --press: rgba(10, 20, 40, .1);
  --border: rgba(10, 20, 40, .12);
  --border-strong: rgba(10, 20, 40, .2);
  --text: #0c1420;
  --text-2: #2f3a4a;
  --text-3: #4f5b6c;
  --theirs: rgba(236, 239, 245, calc(var(--glass-a) + .3));
  --overlay: rgba(15, 23, 36, .38);
  --code-bg: #141a26;
  --code-text: #e6e9ef;
  --hero-1: rgba(255, 255, 255, calc(var(--glass-a) * .9));
  --hero-2: rgba(255, 255, 255, calc(var(--glass-a) * .9));
  --rail-bg: rgba(255, 255, 255, calc(var(--glass-a) * .6)); --rail-brd: rgba(10, 20, 40, .08); --rail-fg: #364152; --rail-fg-on: #0c1420;
  --rail-hover: rgba(10, 20, 40, .07); --rail-on: rgba(255, 255, 255, .55); --rail-icon-on: var(--accent);
  --veil: rgba(255, 255, 255, calc(var(--glass-a) * .3));
  --legible: 0 1px 2px rgba(255, 255, 255, .6);
  color-scheme: light;
}
html[data-bg] body { background: #0b0d12; }
html[data-bg="light"] body { background: #eef1f5; }
html[data-bg] .app { background: transparent; }
html[data-bg] .snow { display: none; }

/* Everything that sits on the picture is glass. */
html[data-bg] :is(.rail, .tabbar, .pane-side, .notes-side, .settings-nav, .card, .quick button, .site, .suggest button, .nb-mini, .nb-class-card, .nb-rows, .nb-folder,
  .nb-head, .nb-pane-head, .pane-head, .nb-page, .composer-box, .month-grid, .month-dows, .week-head, .cal-surface, .table-wrap, .wx-stat, .chip, .segmented, .input, .select) {
  backdrop-filter: blur(22px) saturate(160%); -webkit-backdrop-filter: blur(22px) saturate(160%);
}
/* The rail and the tab bar float on the picture: thinner glass, softer blur,
   and a lift so their labels stay crisp over anything. */
html[data-bg] :is(.rail, .tabbar) { backdrop-filter: blur(14px) saturate(170%); -webkit-backdrop-filter: blur(14px) saturate(170%); }
html[data-bg] .rail-item, html[data-bg] .tabbar .rail-item { text-shadow: var(--legible); }
html[data-bg] .rail-item svg { filter: drop-shadow(var(--legible)); }
html[data-bg] .tabbar .rail-item { color: var(--rail-fg); }
/* Headings and labels that sit right on the picture get the same lift. */
html[data-bg] :is(.dash > .dash-inner > .row .btn-ghost, .nb-section-head, .pane-title, .h1, .eyebrow, .link-btn, .nb-section-head .link-btn) { text-shadow: var(--legible); }
html[data-bg="dark"] .nb-section-head .link-btn, html[data-bg="dark"] .dash .link-btn { color: #fff; }
html[data-bg] .home-hero { background: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
/* Working screens get a light veil so text never sits straight on a busy photo;
   Home stays open so the picture shows between the cards. */
html[data-bg] .main { background: var(--veil); }
html[data-bg] .main:has(> .dash) { background: transparent; }
/* Things that float stay nearly solid, so they always read. */
html[data-bg] :is(.popover, .dialog, .toast, .nb-qs) { background: var(--surface-solid); backdrop-filter: none; -webkit-backdrop-filter: none; }
html[data-bg] .nb-live, html[data-bg] .month-cell.out { background: var(--surface-2); }
html[data-bg] .btn:not(.btn-primary):not(.btn-ghost) { background: var(--surface); }
html[data-bg] .aria-user .bubble { background: var(--accent); color: var(--accent-text); }

@media (prefers-reduced-transparency: reduce) {
  html[data-bg][data-theme] { --glass-a: .92 !important; }
}
@media (prefers-reduced-motion: reduce) { .bd-pic.entering { animation-duration: .01ms; } }
@media print { .backdrop { display: none; } }

/* ---- Settings ------------------------------------------------------------------------------- */
.bg-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 10px; }
.bg-tile { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 6px; border-radius: 12px; border: 2px solid var(--border); background: var(--surface); color: var(--text); text-align: left; transition: border-color .15s ease, transform .16s var(--ease-out); min-width: 0; }
.bg-tile:active { transform: scale(.98); }
.bg-tile.on { border-color: var(--accent); }
.bg-tile.hot { border-style: dashed; border-color: var(--accent); }
.bg-tile-pick { display: flex; flex-direction: column; gap: 6px; border: none; background: none; padding: 0; color: inherit; text-align: left; min-width: 0; }
.bg-tile img, .bg-tile .skeleton, .bg-tile.upload > span { width: 100%; aspect-ratio: 16 / 10; border-radius: 8px; object-fit: cover; display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); }
.bg-tile b { font-size: 12.5px; font-weight: 600; padding: 0 2px 2px; display: block; }
.bg-tile.upload > span { border: 1.5px dashed var(--border-strong); background: none; }
.bg-tile-x { position: absolute; top: 10px; right: 10px; background: rgba(10, 12, 18, .62) !important; color: #fff !important; border-radius: 50%; width: 24px; height: 24px; opacity: .85; }
.bg-tile-x:hover { opacity: 1; background: var(--danger) !important; }
.bg-scenes { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(120px, 1fr); gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.bg-scene { display: flex; flex-direction: column; gap: 5px; padding: 0; border: none; background: none; color: var(--text-2); text-align: left; font-size: 12px; font-weight: 550; min-width: 0; }
.bg-scene img { width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); transition: transform .16s var(--ease-out), border-color .15s ease; }
.bg-scene:hover img { border-color: var(--accent); }
.bg-scene:active img { transform: scale(.97); }
.bg-scene span { display: inline-flex; align-items: center; gap: 4px; }
.bg-scene.have span { color: var(--text); }
.bg-scene.have svg { color: var(--success); }
.bg-slideshow { margin-top: 18px; padding: 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); }
.bg-editor { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
@media (max-width: 860px) { .bg-editor { grid-template-columns: 1fr; } }
.bg-preview { position: relative; aspect-ratio: 16 / 10; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: #0b0d12; cursor: crosshair; touch-action: none; }
.bg-preview:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.bg-preview-dim, .bg-preview .effects { position: absolute; inset: 0; width: 100%; height: 100%; }
.bg-focus { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 2px rgba(0, 0, 0, .35), 0 2px 8px rgba(0, 0, 0, .4); pointer-events: none; }
/* A tiny hub drawn over the preview, so you can see how the glass reads. */
.bg-mock { position: absolute; inset: 0; display: flex; gap: 6px; padding: 8px; pointer-events: none; }
.bg-mock i { display: block; border-radius: 6px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.bg-mock .rail { width: 9%; }
.bg-mock .cards { flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 4% 6%; }
.bg-mock .hero { height: 26%; }
.bg-mock .row2 { display: flex; gap: 6px; flex: 1; }
.bg-mock .row2 i { flex: 1; }
.bg-mock.dark i { background: rgba(14, 17, 25, var(--glass-a, .4)); border: 1px solid rgba(255, 255, 255, .12); }
.bg-mock.light i { background: rgba(255, 255, 255, calc(var(--glass-a, .4) + .14)); border: 1px solid rgba(10, 20, 40, .08); }
.bg-mock.dark .rail { background: rgba(8, 10, 15, calc(var(--glass-a, .4) * .55)) !important; }
.bg-mock.light .rail { background: rgba(255, 255, 255, calc(var(--glass-a, .4) * .6)) !important; }

.bg-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; align-content: start; }
.bg-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.bg-field.wide { grid-column: 1 / -1; }
.bg-field input[type="range"] { width: 100%; accent-color: var(--accent); }
.bg-swatch { position: relative; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--surface); background: var(--sw); box-shadow: 0 0 0 1px var(--border-strong); padding: 0; display: grid; place-items: center; color: var(--text-2); cursor: pointer; }
.bg-swatch.on { box-shadow: 0 0 0 2px var(--text); }
.bg-swatch.pick { background: var(--surface-2); overflow: hidden; }
.bg-swatch.pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.bg-field .segmented { display: flex; width: 100%; }
.bg-field .segmented button { flex: 1; justify-content: center; white-space: nowrap; }

/* ---- The front page, for someone signed in ------------------------------------------------ */
html[data-bg] .landing { background: transparent; z-index: 1; }
html[data-bg] .landing-art { display: none; }
html[data-bg] :is(.landing-nav, .home-panels, .home-feature, .home-stats > div, .shot-frame, .gallery-tabs) {
  background: var(--surface) !important; backdrop-filter: blur(22px) saturate(160%); -webkit-backdrop-filter: blur(22px) saturate(160%);
}
html[data-bg] .home-stats { background: transparent; }
html[data-bg] .landing .hero h1, html[data-bg] .landing .hero p, html[data-bg] .landing .hero-note { text-shadow: var(--pop); }

/* Full page sheets (a chat's Details) sit on top of the page: over a picture
   they're solid, like dialogs, not see-through to the chat underneath. */
html[data-bg] .sheet { background: var(--surface-solid); backdrop-filter: none; -webkit-backdrop-filter: none; }
