/* ============================================================================
 * components/page-backgrounds.css - shared responsive page background layers
 * ============================================================================
 * Depends on: core/tokens.css
 * ========================================================================== */

.fx-page-bg-shell {
  isolation: isolate;
  position: relative;
}

.fx-page-bg-shell > :not(:where(.fx-page-bg, .fx-header, .fx-drawer, .fx-drawer-backdrop, [data-fx-feedback])) {
  position: relative;
  z-index: 1;
}

.fx-page-bg-shell > .fx-header {
  position: fixed;
  z-index: var(--z-header);
}

.fx-page-bg-shell > .fx-drawer-backdrop {
  position: fixed;
  z-index: 9000;
}

.fx-page-bg-shell > .fx-drawer {
  position: fixed;
  z-index: 9001;
}

.fx-page-bg {
  bottom: 0;
  left: 50%;
  opacity: 0.5;
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  width: 100vw;
  z-index: -2;
}

.fx-page-bg img {
  display: block;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  width: 100%;
}

.fx-page-bg--viewport {
  bottom: auto;
  height: calc(100vh - var(--header-height));
  inset: var(--header-height) 0 auto;
  left: 0;
  min-height: 640px;
  position: fixed;
  transform: none;
  width: 100vw;
  z-index: 0;
}

.fx-page-bg--viewport::after {
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: 1;
}

.fx-page-bg--viewport img {
  position: relative;
  z-index: 0;
}

.fx-page-bg-shell::after {
  bottom: 0;
  content: "";
  left: 50%;
  pointer-events: none;
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  width: 100vw;
  z-index: -1;
}

:root[data-theme="dark"] .fx-page-bg--light,
:root[data-theme="light"] .fx-page-bg--dark {
  display: none;
}

/* Panels on image-backed pages should keep operational readability while
 * allowing the page artwork to breathe through. Plain auth/test surfaces keep
 * the solid shared .panel treatment from components/panels.css.
 */
.fx-page-bg-shell .panel,
.fx-page-bg-shell .fx-dq-card {
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.06), transparent 42%),
    rgba(17, 24, 39, 0.82);
  box-shadow: 0 18px 44px rgba(3, 7, 18, 0.28);
  backdrop-filter: blur(8px);
}

.fx-page-bg-shell .panel {
  border-color: rgba(148, 163, 184, 0.18);
}

:root[data-theme="light"] .fx-page-bg-shell .panel,
:root[data-theme="light"] .fx-page-bg-shell .fx-dq-card {
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.05), transparent 44%),
    rgba(255, 255, 255, 0.88);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.1);
}

:root[data-theme="light"] .fx-page-bg-shell .panel {
  border-color: rgba(148, 163, 184, 0.28);
}

@supports not (backdrop-filter: blur(8px)) {
  .fx-page-bg-shell .panel,
  .fx-page-bg-shell .fx-dq-card {
    background:
      linear-gradient(135deg, rgba(37, 99, 235, 0.05), transparent 42%),
      rgba(17, 24, 39, 0.88);
  }

  :root[data-theme="light"] .fx-page-bg-shell .panel,
  :root[data-theme="light"] .fx-page-bg-shell .fx-dq-card {
    background:
      linear-gradient(135deg, rgba(37, 99, 235, 0.04), transparent 44%),
      rgba(255, 255, 255, 0.94);
  }
}

:root[data-theme="dark"] .fx-page-bg-shell::after {
  background:
    linear-gradient(90deg, rgba(3, 7, 18, 0.92) 0%, rgba(3, 7, 18, 0.62) 34%, rgba(3, 7, 18, 0.18) 72%, rgba(3, 7, 18, 0.4) 100%),
    linear-gradient(180deg, rgba(3, 7, 18, 0.22) 0%, rgba(3, 7, 18, 0) 44%, rgba(3, 7, 18, 0.66) 100%);
}

:root[data-theme="light"] .fx-page-bg-shell::after {
  background:
    linear-gradient(90deg, rgba(248, 250, 252, 0.92) 0%, rgba(248, 250, 252, 0.66) 34%, rgba(248, 250, 252, 0.22) 72%, rgba(248, 250, 252, 0.42) 100%),
    linear-gradient(180deg, rgba(248, 250, 252, 0.18) 0%, rgba(248, 250, 252, 0) 44%, rgba(248, 250, 252, 0.72) 100%);
}

:root[data-theme="dark"] .fx-page-bg--viewport::after {
  background:
    linear-gradient(90deg, rgba(3, 7, 18, 0.94) 0%, rgba(3, 7, 18, 0.66) 34%, rgba(3, 7, 18, 0.2) 72%, rgba(3, 7, 18, 0.44) 100%),
    linear-gradient(180deg, rgba(3, 7, 18, 0.14) 0%, rgba(3, 7, 18, 0.04) 48%, rgba(3, 7, 18, 0.82) 100%);
}

:root[data-theme="light"] .fx-page-bg--viewport::after {
  background:
    linear-gradient(90deg, rgba(248, 250, 252, 0.94) 0%, rgba(248, 250, 252, 0.68) 34%, rgba(248, 250, 252, 0.24) 72%, rgba(248, 250, 252, 0.46) 100%),
    linear-gradient(180deg, rgba(248, 250, 252, 0.12) 0%, rgba(248, 250, 252, 0.04) 48%, rgba(248, 250, 252, 0.84) 100%);
}

@media (max-width: 1180px) {
  .fx-page-bg img {
    object-position: 58% top;
  }

  .fx-page-bg--viewport {
    min-height: 760px;
  }

  :root[data-theme="dark"] .fx-page-bg-shell::after {
    background:
      linear-gradient(90deg, rgba(3, 7, 18, 0.88) 0%, rgba(3, 7, 18, 0.5) 58%, rgba(3, 7, 18, 0.28) 100%),
      linear-gradient(180deg, rgba(3, 7, 18, 0.18) 0%, rgba(3, 7, 18, 0) 42%, rgba(3, 7, 18, 0.7) 100%);
  }

  :root[data-theme="light"] .fx-page-bg-shell::after {
    background:
      linear-gradient(90deg, rgba(248, 250, 252, 0.9) 0%, rgba(248, 250, 252, 0.56) 58%, rgba(248, 250, 252, 0.32) 100%),
      linear-gradient(180deg, rgba(248, 250, 252, 0.16) 0%, rgba(248, 250, 252, 0) 42%, rgba(248, 250, 252, 0.74) 100%);
  }
}

@media (max-width: 640px) {
  .fx-page-bg img {
    object-position: 62% top;
  }

  .fx-page-bg--viewport {
    min-height: 720px;
  }

  :root[data-theme="dark"] .fx-page-bg-shell::after {
    background:
      linear-gradient(90deg, rgba(3, 7, 18, 0.9) 0%, rgba(3, 7, 18, 0.68) 100%),
      linear-gradient(180deg, rgba(3, 7, 18, 0.12) 0%, rgba(3, 7, 18, 0.12) 46%, rgba(3, 7, 18, 0.72) 100%);
  }

  :root[data-theme="light"] .fx-page-bg-shell::after {
    background:
      linear-gradient(90deg, rgba(248, 250, 252, 0.9) 0%, rgba(248, 250, 252, 0.7) 100%),
      linear-gradient(180deg, rgba(248, 250, 252, 0.1) 0%, rgba(248, 250, 252, 0.12) 46%, rgba(248, 250, 252, 0.76) 100%);
  }
}
