/* ---------- Wallpaper layers ---------- */

.scenery-root {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background-color: var(--background-primary);
}

.scenery-stage,
.scenery-dim {
  position: absolute;
  inset: 0;
}

.scenery-dim {
  background-color: var(--background-primary);
  opacity: var(--scenery-dim, 0.55);
}

.scenery-layer {
  position: absolute;
  inset: calc(-1 * var(--scenery-bleed, 0px));
  opacity: 0;
  transition: opacity 1.2s ease;
  filter: blur(var(--scenery-blur, 0px)) brightness(var(--scenery-brightness, 1))
    saturate(var(--scenery-saturation, 1));
  transform: translate3d(var(--scenery-px, 0px), var(--scenery-py, 0px), 0);
}

.scenery-layer.is-visible {
  opacity: 1;
}

/* Matching the frame's colour scheme to the page default keeps pages without a background see-through. */
iframe.scenery-media {
  color-scheme: light;
}

.scenery-media {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: var(--scenery-fit, cover);
}

/* ---------- Let the wallpaper show through the workspace ---------- */

/*
 * Obsidian copies body classes to its other windows (settings, pop-outs), which
 * have no wallpaper layer. Going transparent there would expose the bare window,
 * so every rule also requires the layer to be present in this document.
 *
 * The class is repeated on purpose: it raises specificity so these rules beat the
 * app's and themes' own background rules without resorting to !important.
 */

body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) {
  background-color: transparent;
}

body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .app-container,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .horizontal-main-container,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .workspace,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .workspace-split,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .workspace-tabs,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .workspace-tab-container,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .workspace-tab-header-container,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .workspace-leaf,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .workspace-leaf-content,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .view-header,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .view-content,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .nav-header,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .nav-files-container,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .workspace-sidedock-vault-profile,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .markdown-source-view,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .markdown-reading-view,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .cm-editor,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .cm-scroller,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .cm-gutters,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .sidebar-toggle-button,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .titlebar,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .titlebar-inner,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .status-bar {
  background-color: transparent;
}

body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .workspace-ribbon.mod-left::before {
  background-color: transparent;
}

/* Sidebars and ribbon get their own adjustable tint. */
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .workspace-ribbon,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .workspace-split.mod-left-split,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .workspace-split.mod-right-split {
  background-color: color-mix(in srgb, var(--background-secondary) var(--scenery-panel, 25%), transparent);
}

/* Active tab: keep it distinguishable without an opaque slab. */
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .workspace-tab-header.is-active,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .mod-root .workspace-tab-header.is-active {
  background-color: color-mix(in srgb, var(--background-primary) 45%, transparent);
  box-shadow: none;
}

body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .workspace-tab-header.is-active::before,
body.scenery-active.scenery-active.scenery-active:has(> .scenery-root) .workspace-tab-header.is-active::after {
  display: none;
}

/* ---------- Settings ---------- */

.scenery-item.is-active .setting-item-name {
  color: var(--text-accent);
}

.scenery-item .setting-item-description {
  word-break: break-all;
}

/* ---------- Scenes (layered wallpapers) ---------- */

.scenery-scene {
  position: absolute;
  inset: 0;
  isolation: isolate;
}

.scenery-sl,
.scenery-sl-parallax,
.scenery-sl-motion {
  position: absolute;
  inset: 0;
}

.scenery-sl-parallax {
  transform: translate3d(
    calc(var(--scenery-px, 0px) * var(--scenery-depth, 0)),
    calc(var(--scenery-py, 0px) * var(--scenery-depth, 0)),
    0
  );
}

.scenery-sl .scenery-media.is-broken {
  visibility: hidden;
}

.scenery-sl-motion {
  animation: 20s ease-in-out infinite alternate both;
}

.scenery-root.is-paused .scenery-sl-motion {
  animation-play-state: paused;
}

.scenery-sl-motion[data-motion="sway-x"] {
  animation-name: scenery-sway-x;
}
.scenery-sl-motion[data-motion="sway-y"] {
  animation-name: scenery-sway-y;
}
.scenery-sl-motion[data-motion="zoom"] {
  animation-name: scenery-zoom;
}
.scenery-sl-motion[data-motion="pulse"] {
  animation-name: scenery-pulse;
}
.scenery-sl-motion[data-motion="drift"] {
  animation-name: scenery-drift;
  animation-direction: normal;
}
.scenery-sl-motion[data-motion="rotate"] {
  animation-name: scenery-rotate;
  animation-direction: normal;
  animation-timing-function: linear;
}

@keyframes scenery-sway-x {
  from { transform: translateX(calc(var(--scenery-amt) * -15%)); }
  to { transform: translateX(calc(var(--scenery-amt) * 15%)); }
}
@keyframes scenery-sway-y {
  from { transform: translateY(calc(var(--scenery-amt) * -15%)); }
  to { transform: translateY(calc(var(--scenery-amt) * 15%)); }
}
@keyframes scenery-zoom {
  from { transform: scale(1); }
  to { transform: scale(calc(1 + var(--scenery-amt) * 0.6)); }
}
@keyframes scenery-pulse {
  from { opacity: 1; }
  to { opacity: calc(1 - var(--scenery-amt)); }
}
@keyframes scenery-rotate {
  to { transform: rotate(360deg); }
}
@keyframes scenery-drift {
  0%, 100% { transform: translate(calc(var(--scenery-amt) * -10%), 0); }
  25% { transform: translate(0, calc(var(--scenery-amt) * -8%)); }
  50% { transform: translate(calc(var(--scenery-amt) * 10%), 0); }
  75% { transform: translate(0, calc(var(--scenery-amt) * 8%)); }
}

/* Editor: temporarily lift the readability dimming to judge the scene itself. */
.scenery-root.is-preview .scenery-dim {
  opacity: 0;
}

/* ---------- Scene editor ---------- */

.scenery-editor {
  padding: var(--size-4-3);
}

.scenery-editor .setting-item {
  padding: var(--size-4-2) 0;
}

.scenery-editor-hint {
  color: var(--text-muted);
  font-size: var(--font-ui-small);
  margin: var(--size-4-2) 0;
}

.scenery-layer-row {
  display: flex;
  align-items: center;
  gap: var(--size-2-1);
  padding: var(--size-2-2) var(--size-4-1);
  border-radius: var(--radius-s);
  cursor: pointer;
}

.scenery-layer-row:hover {
  background-color: var(--background-modifier-hover);
}

.scenery-layer-row.is-selected {
  background-color: var(--background-modifier-active-hover);
}

.scenery-layer-row.is-hidden .scenery-layer-name {
  opacity: 0.45;
}

.scenery-layer-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scenery-layer-kind {
  color: var(--text-faint);
  font-size: var(--font-ui-smaller);
}

.scenery-layer-props {
  margin: var(--size-4-2) 0 var(--size-4-4);
  padding-left: var(--size-4-2);
  border-left: 2px solid var(--interactive-accent);
}

.scenery-layer-props input[type="text"] {
  width: 100%;
}

/* The "add wallpaper" row holds more buttons than fit on one line. */
.scenery-add.setting-item {
  flex-direction: column;
  align-items: stretch;
  gap: var(--size-4-2);
}

.scenery-add .setting-item-info {
  margin-right: 0;
}

.scenery-add .setting-item-control {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.scenery-wide-input {
  width: 100%;
}

/* Long file paths and URLs must not widen the settings pane. */
.scenery-item .setting-item-info {
  min-width: 0;
}

/* ---------- Library thumbnails and drag-to-reorder ---------- */

.scenery-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 80px;
  height: 48px;
  margin-right: var(--size-4-3);
  overflow: hidden;
  border-radius: var(--radius-s);
  background-color: var(--background-modifier-border);
}

.scenery-thumb.is-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

/* Thumbnails are stills. */
.scenery-thumb .scenery-sl-motion {
  animation-play-state: paused;
}

.scenery-item[draggable="true"],
.scenery-layer-row[draggable="true"] {
  cursor: grab;
}

.scenery-item.is-dragging,
.scenery-layer-row.is-dragging {
  opacity: 0.4;
}

.scenery-item.is-drop-target,
.scenery-layer-row.is-drop-target {
  box-shadow: inset 0 2px 0 var(--interactive-accent);
}
