/* ── Page backdrop: battlemap grid with soft light ──────────────────────
   Shared by the landing page (.login-root), the dashboard (.cp-root), the
   account hub (.acc-root: Account settings and My Content), the
   reset-password page and the loading screen (components/AppLoadingScreen,
   including the static copy in index.html, which links this file directly
   so the grid is there before the app's styles load). The guide pages copy
   the same values in public/seo/seo.css.
   Two layers drawn behind the page content that scroll WITH the page (not
   fixed), so panels read as glass lying on the map: ::after is the base
   colour with soft indigo, violet and blue light; ::before is the map grid,
   fading out to the sides and further down the page. Static CSS, no
   animation. The element's own background must be transparent, or it needs
   `isolation: isolate` (or its own stacking context), so the layers show. */
.ui-grid-backdrop {
  --ui-grid-cell: 56px;
  position: relative;
}

.ui-grid-backdrop::before,
.ui-grid-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ui-grid-backdrop::before {
  z-index: -1;
  /* Each axis is one continuous repeating gradient, not repeated tiles:
     browsers round every background tile to whole device pixels, so a
     fitted fractional square (useGridSnap) drifted up to ~5px across a row
     and the grid missed the content's right edge. The gradient is one square
     larger than the box and starts one square early, so the offset never
     leaves a seam. Offsets are where a line falls inside the first square:
     useGridSnap sets them (landing page, dashboard); without it the grid is
     centred across the page and starts at the top. */
  --ui-grid-x: var(--ui-grid-offset-x, rem(calc(50vw - var(--ui-grid-cell) / 2), var(--ui-grid-cell)));
  --ui-grid-y: var(--ui-grid-offset-y, 0px);
  background-image:
    repeating-linear-gradient(to bottom, rgba(122, 162, 255, 0.08) 0 1px, transparent 1px var(--ui-grid-cell)),
    repeating-linear-gradient(to right, rgba(122, 162, 255, 0.08) 0 1px, transparent 1px var(--ui-grid-cell));
  background-repeat: no-repeat;
  background-size: calc(100% + var(--ui-grid-cell)) calc(100% + var(--ui-grid-cell));
  background-position: calc(var(--ui-grid-x) - var(--ui-grid-cell)) calc(var(--ui-grid-y) - var(--ui-grid-cell));
  -webkit-mask-image:
    linear-gradient(90deg, transparent 0%, #000 18%, #000 82%, transparent 100%),
    linear-gradient(180deg, #000 0, rgba(0, 0, 0, 0.75) 900px, rgba(0, 0, 0, 0.55) 100%);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(90deg, transparent 0%, #000 18%, #000 82%, transparent 100%),
    linear-gradient(180deg, #000 0, rgba(0, 0, 0, 0.75) 900px, rgba(0, 0, 0, 0.55) 100%);
  mask-composite: intersect;
}

.ui-grid-backdrop::after {
  z-index: -2;
  background:
    radial-gradient(900px 620px at 88% -80px, rgba(99, 102, 241, 0.18), transparent 70%),
    radial-gradient(760px 560px at 8% 760px, rgba(139, 92, 246, 0.1), transparent 70%),
    radial-gradient(820px 520px at 50% 420px, rgba(59, 91, 219, 0.1), transparent 72%),
    radial-gradient(1000px 700px at 50% 1500px, rgba(79, 70, 229, 0.1), transparent 72%),
    #0b0d12;
}
/* The grid and light are the shared page backdrop (.ui-grid-backdrop,
   styles/grid-backdrop.css), so the loading screen looks like the landing
   page, dashboard and guides it sits between. The grid is centred both ways
   so the card's faint inner grid lines up with it. */
.app-loading-screen {
  /* Centred vertically too (the grid is centred across by default). */
  --ui-grid-offset-y: rem(calc(50vh - var(--ui-grid-cell) / 2), var(--ui-grid-cell));
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #0b0d12;
  color: var(--color-text, #f8fafc);
  font-family: var(--font-ui, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
  overflow: hidden;
}

/* .ui-grid-backdrop sets position: relative; keep the loading screen a fixed
   overlay whichever stylesheet loads last. */
.app-loading-screen.ui-grid-backdrop {
  position: fixed;
}

.app-loading-card {
  --ui-panel-bg: rgba(15, 18, 25, 0.12);
  --ui-panel-border: transparent;
  --ui-panel-blur: 5px;
  --ui-panel-shadow:
    0 22px 54px -22px rgba(0, 0, 0, 0.82),
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 rgba(255, 255, 255, 0.045),
    inset 8px 0 18px rgba(255, 255, 255, 0.018),
    inset -8px 0 18px rgba(122, 162, 255, 0.025);
  position: relative;
  z-index: 1;
  min-width: 210px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 17px;
  border: 0;
  border-radius: var(--ui-panel-radius, 12px);
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.035) 38%, rgba(255, 255, 255, 0.055)),
    var(--ui-panel-bg);
  backdrop-filter: blur(var(--ui-panel-blur)) saturate(1.45);
  -webkit-backdrop-filter: blur(var(--ui-panel-blur)) saturate(1.45);
}

.app-loading-card::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: calc(var(--ui-panel-radius, 12px) - 1px);
  pointer-events: none;
  background:
    linear-gradient(rgba(122, 162, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(122, 162, 255, 0.06) 1px, transparent 1px);
  background-size: var(--ui-grid-cell, 56px) var(--ui-grid-cell, 56px);
  background-position: center;
  opacity: 0.34;
  mask-image: linear-gradient(90deg, transparent, black 18%, black 82%, transparent);
}

.app-loading-mark {
  position: relative;
  z-index: 1;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  animation: app-loading-breathe 2.2s ease-in-out infinite;
  color: #7aa2ff;
  filter:
    drop-shadow(0 0 5px rgba(122, 162, 255, 0.36))
    drop-shadow(0 0 12px rgba(73, 139, 255, 0.18));
}

.app-loading-mark svg {
  position: relative;
  z-index: 1;
  width: 34px;
  height: 34px;
  overflow: visible;
  fill: currentColor;
}

.app-loading-copy {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.app-loading-label {
  color: var(--color-text, #f8fafc);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.app-loading-detail {
  margin-top: 3px;
  color: var(--color-text-muted, #94a3b8);
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.35;
}

@keyframes app-loading-breathe {
  0%,
  100% {
    transform: scale(0.96);
  }

  50% {
    transform: scale(1.08);
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-loading-mark {
    animation: none;
  }
}

/* Full page loads from the guide pages (Demo, Exchange, sign up) cross-fade
   into this loading screen instead of cutting to it. Only cross-document
   navigations are affected; in-app route changes are untouched. */
@view-transition {
  navigation: auto;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}
