/* Article-only dynamic visuals. The homepage header intentionally remains static. */

body.lunarveil-dynamic-article #wrap {
  background: transparent;
}

body.lunarveil-dynamic-article #wrap > #header,
body.lunarveil-dynamic-article #wrap > #content,
body.lunarveil-dynamic-article #wrap > footer {
  position: relative;
  z-index: 1;
}

#header.lunarveil-dynamic-header {
  isolation: isolate;
  overflow: hidden;
}

/* The theme's original cover is taller than the banner. Hide it after the
   dynamic layers have mounted so it cannot bleed into the article area. */
#header.lunarveil-dynamic-header > picture,
#header.lunarveil-dynamic-header > img {
  visibility: hidden;
}

.lunarveil-header-visuals,
.lunarveil-article-backdrop {
  pointer-events: none;
}

.lunarveil-header-visuals {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

#header.lunarveil-dynamic-header > #header-outer {
  z-index: 1;
}

#header.lunarveil-dynamic-header .lunarveil-header-visuals .lunarveil-visual-layer {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: 100%;
  height: 100%;
  z-index: 0;
  object-fit: cover;
  user-select: none;
  -webkit-mask: linear-gradient(to top, transparent, #fff 50%);
  mask: linear-gradient(to top, transparent, #fff 50%);
  opacity: 0;
  transition: opacity 650ms ease;
}

#header.lunarveil-dynamic-header .lunarveil-header-visuals .lunarveil-visual-layer.is-active {
  opacity: 1;
}

.lunarveil-article-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: var(--color-background);
}

.lunarveil-article-backdrop::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  content: '';
  background: rgba(255, 255, 255, 0.72);
}

.lunarveil-article-backdrop .lunarveil-visual-layer {
  position: absolute;
  inset: -2%;
  width: 104%;
  height: 104%;
  object-fit: cover;
  opacity: 0;
  filter: saturate(0.82) blur(1px);
  transition: opacity 650ms ease;
}

.lunarveil-article-backdrop .lunarveil-visual-layer.is-active {
  opacity: 0.16;
}

[data-theme="dark"] .lunarveil-article-backdrop::after {
  background: rgba(20, 24, 31, 0.76);
}

[data-theme="dark"] .lunarveil-article-backdrop .lunarveil-visual-layer.is-active {
  opacity: 0.13;
}

.lunarveil-dynamic-effects-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: calc(100% - 40px);
  margin: 16px 20px 4px;
  padding: 10px 12px;
  box-sizing: border-box;
  color: var(--color-default);
  background: var(--red-6);
  border: 1px solid var(--red-4);
  border-radius: 10px;
}

.lunarveil-dynamic-effects-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  line-height: 1.25;
}

.lunarveil-dynamic-effects-label small {
  color: var(--grey-7);
  font-size: 11px;
}

.lunarveil-dynamic-effects-switch {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--grey-4);
  transition: background 180ms ease;
}

.lunarveil-dynamic-effects-switch::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  content: '';
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 180ms ease;
}

.lunarveil-dynamic-effects-switch[aria-checked="true"] {
  background: var(--red-1);
}

.lunarveil-dynamic-effects-switch[aria-checked="true"]::after {
  transform: translateX(18px);
}

.lunarveil-dynamic-effects-switch:focus-visible {
  outline: 3px solid var(--red-3);
  outline-offset: 3px;
}

.lunarveil-dynamic-effects-switch:disabled {
  cursor: not-allowed !important;
  opacity: 0.55;
}

@media (max-width: 959px) {
  #header.lunarveil-dynamic-header .lunarveil-header-visuals .lunarveil-visual-layer {
    height: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lunarveil-header-visuals,
  .lunarveil-article-backdrop {
    display: none;
  }

  .lunarveil-visual-layer,
  .lunarveil-dynamic-effects-switch,
  .lunarveil-dynamic-effects-switch::after {
    transition: none;
  }
}
