/* ============================================================
   Secret Systems App — global liquid-glass design-system layer
   (2026-10-27)

   Scoped entirely to `.cp-shell` (the authenticated dashboard shell).
   Does not touch the public marketing/login surfaces, which keep the
   existing brand look. Works by re-pointing the EXISTING design tokens
   from client-portal.css (--cp-surface, --cp-bg-raised, --cp-line, ...)
   to translucent values and adding backdrop-filter to the handful of
   selectors that already build every card/table/drawer/input/nav
   surface in the app — no new per-page markup or classes required.
   ============================================================ */

.cp-shell {
  /* Cosmic ribbon waves background (v3 — truly fixed via a dedicated layer):
     background-attachment:fixed is unreliable on mobile (historically
     disabled on iOS Safari, and inconsistent on Android Chrome once the
     address bar collapses/expands and resizes the viewport mid-scroll), so
     the image is no longer painted as .cp-shell's own CSS background.
     Instead .cp-shell::before (below) is a position:fixed, inset:0 layer
     with z-index behind all real content -- that technique is well
     supported on desktop AND mobile because it's just a normal element
     positioned relative to the viewport, not a background-attachment mode.
     .cp-shell itself stays transparent so the fixed layer shows through. */
  background: transparent;

  /* Re-point the shared tokens to glass values for every descendant. */
  --cp-bg-raised: rgba(10, 16, 27, .5);
  --cp-surface: rgba(255, 255, 255, .045);
  --cp-surface-2: rgba(255, 255, 255, .07);
  --cp-surface-3: rgba(255, 255, 255, .1);
  --cp-line: rgba(255, 255, 255, .11);
  --cp-line-strong: rgba(255, 255, 255, .22);
  --cp-shadow-1: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 16px 40px -24px rgba(0, 0, 0, .75);
  --cp-shadow-2: 0 1px 0 rgba(255, 255, 255, .08) inset, 0 32px 80px -30px rgba(0, 0, 0, .85);
  --glass-blur: 20px;
}

/* The parallax background layer: a plain, non-scrolling-with-the-document
   box behind .cp-shell's content, moved via a GPU-friendly transform (never
   background-position, which is main-thread/layout-bound) driven by
   assets/glass-parallax.js. position:fixed + an overscanned box (18vh
   beyond the viewport top/bottom) means the element never needs to resize
   or reflow as the user scrolls -- only its transform changes, which the
   compositor can animate independent of layout/paint. The 18vh overscan is
   the hard bound on how far the parallax can travel before the image edge
   would show; the JS clamps to the same figure. z-index:0 (not negative)
   keeps it behind the sidebar/main/cards -- a negative z-index risks some
   mobile browsers painting it behind the root canvas entirely.
   pointer-events:none so it never intercepts touch/scroll/clicks. */
.cp-shell::before {
  content: "";
  position: fixed;
  top: -18vh;
  bottom: -18vh;
  left: 0;
  right: 0;
  z-index: 0;
  pointer-events: none;
  transform: translate3d(0, var(--cp-parallax-y, 0px), 0);
  will-change: transform;
  background-color: #05080d;
  background-image:
    radial-gradient(ellipse 120% 90% at 15% 0%, rgba(0, 200, 255, .05), transparent 55%),
    radial-gradient(ellipse 100% 80% at 100% 100%, rgba(140, 90, 255, .05), transparent 55%),
    linear-gradient(180deg, rgba(4, 7, 12, .5) 0%, rgba(4, 7, 12, .68) 100%),
    url("/assets/bg/cosmic-ribbon-waves.jpg");
  background-image:
    radial-gradient(ellipse 120% 90% at 15% 0%, rgba(0, 200, 255, .05), transparent 55%),
    radial-gradient(ellipse 100% 80% at 100% 100%, rgba(140, 90, 255, .05), transparent 55%),
    linear-gradient(180deg, rgba(4, 7, 12, .5) 0%, rgba(4, 7, 12, .68) 100%),
    image-set(url("/assets/bg/cosmic-ribbon-waves.webp") type("image/webp") 1x,
              url("/assets/bg/cosmic-ribbon-waves.jpg") type("image/jpeg") 1x);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
}

/* prefers-reduced-motion: the JS itself refuses to start when this matches
   (see glass-parallax.js), but pin the transform here too as a CSS-only
   guarantee -- a stable, fully static background either way. */
@media (prefers-reduced-motion: reduce) {
  .cp-shell::before { transform: none; }
}

/* .cp-main needs an explicit stacking order so it reliably paints above the
   z-index:0 fixed background layer (the sidebar/tabbar already establish
   their own stacking context via position:sticky/fixed). */
.cp-shell > .cp-main { position: relative; z-index: 1; }

@media (max-width: 760px) {
  /* The desktop aurora is a wide landscape image; background-size:cover on a
     tall narrow viewport crops almost all of its colour out. Swap to a
     dedicated portrait crop (same source, cropped to the band with the most
     visible detail) positioned to show the top/center glow instead of
     stretching/cropping the landscape asset. Still a fixed, non-scrolling
     layer -- same .cp-shell::before element, just a different image. */
  .cp-shell { --glass-blur: 10px; }
  .cp-shell::before {
    background-image:
      radial-gradient(ellipse 120% 90% at 15% 0%, rgba(0, 200, 255, .05), transparent 55%),
      radial-gradient(ellipse 100% 80% at 100% 100%, rgba(140, 90, 255, .05), transparent 55%),
      linear-gradient(180deg, rgba(4, 7, 12, .42) 0%, rgba(4, 7, 12, .66) 100%),
      url("/assets/bg/cosmic-ribbon-waves-mobile.jpg");
    background-image:
      radial-gradient(ellipse 120% 90% at 15% 0%, rgba(0, 200, 255, .05), transparent 55%),
      radial-gradient(ellipse 100% 80% at 100% 100%, rgba(140, 90, 255, .05), transparent 55%),
      linear-gradient(180deg, rgba(4, 7, 12, .42) 0%, rgba(4, 7, 12, .66) 100%),
      image-set(url("/assets/bg/cosmic-ribbon-waves-mobile.webp") type("image/webp") 1x,
                url("/assets/bg/cosmic-ribbon-waves-mobile.jpg") type("image/jpeg") 1x);
    background-position: top center;
  }
}

/* Frosted surfaces: every existing card/table/nav/input selector, scoped
   under .cp-shell so the public landing / login pages are untouched. */
.cp-shell .cp-sidebar,
.cp-shell .cp-topbar,
.cp-shell .cp-tabbar,
.cp-shell .cp-card, .cp-shell .cp-tile, .cp-shell .cp-panel, .cp-shell .cp-section-card,
.cp-shell .cp-content-group, .cp-shell .cp-req-item,
.cp-shell .cp-table-wrap,
.cp-shell .cp-state,
.cp-shell .cp-drawer, .cp-shell .cp-drawer-backdrop,
.cp-shell .cp-chip,
.cp-shell .cp-adminbar,
.cp-shell .cp-field input, .cp-shell .cp-field select, .cp-shell .cp-field textarea, .cp-shell .cp-input,
.cp-shell .cp-adminbar-search, .cp-shell .cp-adminbar-results {
  backdrop-filter: blur(var(--glass-blur)) saturate(135%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(135%);
}

.cp-shell .cp-sidebar { background: rgba(8, 13, 22, .42); border-right-color: var(--cp-line); }
.cp-shell .cp-topbar { background: rgba(8, 13, 22, .62); }
.cp-shell .cp-tabbar { background: rgba(8, 13, 22, .72); }

/* Thin top highlight on primary panels — the classic glass "edge light". */
.cp-shell .cp-card, .cp-shell .cp-section-card, .cp-shell .cp-panel, .cp-shell .cp-tile {
  position: relative;
}
.cp-shell .cp-card::before, .cp-shell .cp-section-card::before,
.cp-shell .cp-panel::before, .cp-shell .cp-tile::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  border-radius: var(--cp-radius) var(--cp-radius) 0 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .22), transparent);
  pointer-events: none;
}

/* Buttons keep full opacity/contrast — glass is for passive surfaces, not
   primary actions or anything carrying critical information. */
.cp-shell .btn-cyan, .cp-shell .cp-btn-primary { backdrop-filter: none; -webkit-backdrop-filter: none; }

/* Reduced motion: no added motion here beyond what client-portal.css already
   guards; keep the glow gradients static (they already are) and skip the
   edge-light pseudo-element's implicit layout recalculation cost. */
@media (prefers-reduced-motion: reduce) {
  .cp-shell .cp-card::before, .cp-shell .cp-section-card::before,
  .cp-shell .cp-panel::before, .cp-shell .cp-tile::before { display: none; }
}

/* Browsers without backdrop-filter support: fall back to solid panels so
   text stays fully readable against the busy background. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .cp-shell .cp-sidebar, .cp-shell .cp-topbar, .cp-shell .cp-tabbar,
  .cp-shell .cp-card, .cp-shell .cp-tile, .cp-shell .cp-panel, .cp-shell .cp-section-card,
  .cp-shell .cp-content-group, .cp-shell .cp-req-item, .cp-shell .cp-table-wrap,
  .cp-shell .cp-state, .cp-shell .cp-drawer {
    background: #0b121c;
  }
}
