/*
 * Glass material foundation — OPT-IN stylesheet.
 *
 * Consumers that inherit the Tailwind preset (`@aisquare/ui/tailwind.preset`)
 * already get all of this via `glassMaterialPlugin` and do NOT need to import
 * this file. Import it only if you consume the library WITHOUT the preset
 * (parallel to `tokens.template.css`):
 *
 *     import "@aisquare/ui/onyx-hex.css";
 *
 * This file MIRRORS `glassMaterialPlugin` in `tailwind.preset.ts` (the
 * canonical source; the frost/sheen recipe lives in `src/lib/onyx-material.ts`).
 * Keep the two in sync.
 *
 * The filename is legacy: this stylesheet used to also ship the Onyx Hex
 * notch/keycap/hexagon material (`.nx-*`, `.hex`, `.raise`/`.key`, `.elev-*`).
 * That system is retired now that every consumer has migrated to plain
 * `rounded-*` + a real `border`/`box-shadow` — only the glass rules (which
 * never used `clip-path`) remain.
 *
 * Theme-agnostic geometry; only the glass token VALUES flip under `.dark`.
 * Colour/surface/accent tokens (`--ac`, `--cardBd`, `--acSoft`) are owned by
 * theme-engine/Steel and referenced by NAME.
 */

/* ---- per-theme glass tokens (light default) ---- */
:root {
  /* Frosted-glass family for floating panels/composer (GlassSurface). The
     float drop-shadow is the deepest shadow in the system (floating surfaces
     sit above everything else). --glass + --glassSheen are verbatim from the
     design file; the other 5 light values are DERIVED (navy-tinted float +
     bright white frost rim) and FLAGGED for sign-off. */
  --dropFloat: drop-shadow(0 3px 8px rgba(10, 37, 64, 0.1)) drop-shadow(0 28px 54px rgba(10, 37, 64, 0.16));
  --glass: rgba(255, 255, 255, 0.55);
  /* FAINT shadow-caster fill (issue #159): lowered from 0.4 so the glass layer's
     backdrop-filter samples the PAGE behind the panel, not this fill. Nonzero so
     --dropFloat still has an alpha source to cast from. */
  --glassBack: rgba(255, 255, 255, 0.12);
  --glassBd: rgba(255, 255, 255, 0.85);
  --glassHi: rgba(255, 255, 255, 0.92);
  --glassSheen: rgba(30, 111, 224, 0.14);
  --acLine: rgba(30, 111, 224, 0.42);
}

/* Dark theme — same geometry, stronger/darker values. */
.dark {
  /* Dark frosted-glass family — verbatim from the design file's `.onyx` block.
     Same geometry as light; only the values flip. */
  --dropFloat: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.45)) drop-shadow(0 28px 54px rgba(0, 0, 0, 0.58));
  --glass: rgba(20, 26, 40, 0.36);
  /* FAINT shadow-caster fill (issue #159): lowered from 0.42 — see the light
     note above. Nonzero so the float drop-shadow casts, low enough that the
     frost samples the page, not this backstop. */
  --glassBack: rgba(9, 12, 20, 0.14);
  --glassBd: rgba(255, 255, 255, 0.22);
  --glassHi: rgba(255, 255, 255, 0.3);
  --glassSheen: rgba(90, 160, 255, 0.24);
  --acLine: rgba(70, 144, 255, 0.42);
}

/* ---- frosted-glass material for FLOATING surfaces (GlassSurface) ---- */
/* Two stacked layers — backdrop-filter and filter CANCEL on one DOM node, so
   they are split across `.glass-back` (backing) and `.glass-panel`/
   `.glass-composer` (the frost layer on top). */

/* Backing layer: ONLY filter (the float drop-shadow) over a FAINT --glassBack
   fill. The fill is intentionally low-alpha (issue #159) so it gives
   drop-shadow an alpha source to cast from WITHOUT becoming the surface the
   frost blurs. Empty + aria-hidden. NO backdrop-filter here. */
.glass-back {
  background: var(--glassBack);
  filter: var(--dropFloat);
}

/* Glass layer (on top): ONLY backdrop-filter (the 22px frost) over the --glass
   translucent fill + the --glassSheen blue lumen + a --glassHi top highlight.
   The rim keyline is a real `border` on the GlassSurface host itself
   (--glassBd for the panel / --acLine for the composer) — the
   `inset 0 1px 0 --glassHi` top sheen here is the extra highlight on top of
   that border. --glassBd rim = floating panel; --acLine rim = composer. */
.glass-panel,
.glass-composer {
  background: radial-gradient(circle at 82% -8%, var(--glassSheen), transparent 58%), var(--glass);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  box-shadow: inset 0 1px 0 var(--glassHi);
  /* Containment + GPU hints (issue #9): when a parent animates WIDTH the glass
     relayouts every frame and the backdrop-filter blur re-rasterizes. `contain:
     paint` bounds the blur repaint to this box, and `translateZ(0)` promotes it
     to its own GPU compositor layer so the frost is rasterized once and the
     resize is cheaper. NOT `will-change: transform` — we are not transforming
     this layer; width is the animated property (hinted on the wrapper). */
  contain: paint;
  transform: translateZ(0);
}
