/* ============================================================================
 * liquid-glass-effects.css — Composable CSS effect layer
 * ----------------------------------------------------------------------------
 * Ported from liquidglassui.org (Apple-inspired "Liquid Glass UI"). A pure-CSS,
 * GPU-only, zero-JS-runtime set of glass intensities + decorative animations
 * that COMPOSE on top of any element — including any LiquidGlass engine host.
 *
 *   • Intensities  .lg-glass / .lg-glass-light / .lg-glass-intense / .lg-glass-ultra
 *   • Effects      .lg-fx-specular / -shimmer / -float / -pulse / -morph
 *                  .lg-fx-liquid  / -particles / -hover  / -interactive
 *
 * Use directly in HTML, or via the JS API:
 *   LiquidGlass.create('#x', { intensity:'ultra', effects:['float','shimmer'] })
 *   LiquidGlass.applyEffects('#x', { intensity:'intense', effects:'specular' })
 *
 * Theme: light by default; dark via `.dark` / `[data-theme="dark"]`, or
 * automatically via prefers-color-scheme unless `.light`/[data-theme="light"].
 * Animation tempo: set --lg-fx-speed (1 = default; 0.5 = 2× faster).
 * ==========================================================================*/

/* ---- Theme tokens -------------------------------------------------------- */
:root {
  --lg-glass-bg:          rgba(255, 255, 255, 0.70);
  --lg-glass-bg-hover:    rgba(255, 255, 255, 0.60);
  --lg-glass-border:      rgba(0, 0, 0, 0.05);
  --lg-glass-shadow:      rgba(0, 0, 0, 0.08);
  --lg-glass-highlight:   rgba(255, 255, 255, 0.90);
  --lg-glass-light-bg:    rgba(255, 255, 255, 0.40);
  --lg-glass-intense-bg:  rgba(255, 255, 255, 0.80);
  --lg-glass-ultra-bg:    rgba(255, 255, 255, 0.90);
  --lg-fx-speed: 1; /* animation tempo multiplier */

  /* progressive blur (kube.io depth blur) */
  --lg-pblur: 14px;          /* max backdrop blur at the far edge */
  --lg-pblur-dir: to bottom; /* gradient direction (clear → blurred) */
  /* angular glare band (liquid-glass-studio glare) */
  --lg-glare-angle: 45deg;   /* direction of the glare streak */
  --lg-glare-width: 14%;     /* half-width of the streak */
  --lg-glare-strength: 0.45; /* peak brightness 0–1 */
}

.dark,
[data-theme="dark"] {
  --lg-glass-bg:          rgba(36, 41, 47, 0.50);
  --lg-glass-bg-hover:    rgba(56, 63, 71, 0.60);
  --lg-glass-border:      rgba(139, 148, 158, 0.20);
  --lg-glass-shadow:      rgba(0, 0, 0, 0.30);
  --lg-glass-highlight:   rgba(255, 255, 255, 0.10);
  --lg-glass-light-bg:    rgba(0, 0, 0, 0.20);
  --lg-glass-intense-bg:  rgba(36, 41, 47, 0.70);
  --lg-glass-ultra-bg:    rgba(40, 48, 56, 0.80);
}

@media (prefers-color-scheme: dark) {
  :root:not(.light):not([data-theme="light"]) {
    --lg-glass-bg:          rgba(36, 41, 47, 0.50);
    --lg-glass-bg-hover:    rgba(56, 63, 71, 0.60);
    --lg-glass-border:      rgba(139, 148, 158, 0.20);
    --lg-glass-shadow:      rgba(0, 0, 0, 0.30);
    --lg-glass-highlight:   rgba(255, 255, 255, 0.10);
    --lg-glass-light-bg:    rgba(0, 0, 0, 0.20);
    --lg-glass-intense-bg:  rgba(36, 41, 47, 0.70);
    --lg-glass-ultra-bg:    rgba(40, 48, 56, 0.80);
  }
}

/* ---- Glass intensities --------------------------------------------------- */
.lg-glass {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--lg-glass-border);
  background: var(--lg-glass-bg);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 4px 12px var(--lg-glass-shadow),
              inset 0 1px 0 var(--lg-glass-highlight);
  transition: 0.3s;
}

.lg-glass-light {
  background: var(--lg-glass-light-bg);
  -webkit-backdrop-filter: blur(10px) saturate(160%);
  backdrop-filter: blur(10px) saturate(160%);
  box-shadow: 0 2px 8px var(--lg-glass-shadow),
              inset 0 1px 0 var(--lg-glass-highlight);
}

.lg-glass-intense {
  background: var(--lg-glass-intense-bg);
  -webkit-backdrop-filter: blur(24px) saturate(200%);
  backdrop-filter: blur(24px) saturate(200%);
  box-shadow: 0 8px 24px var(--lg-glass-shadow),
              inset 0 1px 1px var(--lg-glass-highlight);
}

.lg-glass-ultra {
  background: var(--lg-glass-ultra-bg);
  border-width: 1.5px;
  -webkit-backdrop-filter: blur(32px) saturate(220%);
  backdrop-filter: blur(32px) saturate(220%);
  box-shadow: 0 16px 48px var(--lg-glass-shadow),
              inset 0 2px 1px var(--lg-glass-highlight);
}

/* The intensity modifiers are meant to layer onto .lg-glass, but also work
   standalone (border/radius from the base, or supply your own). */
.lg-glass-light,
.lg-glass-intense,
.lg-glass-ultra {
  position: relative;
}

/* ---- Specular highlight sweep (on hover) -------------------------------- */
.lg-fx-specular {
  position: relative;
  overflow: hidden;
}
.lg-fx-specular::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -150%;
  width: 200%;
  height: 200%;
  pointer-events: none;
  opacity: 0;
  transform: rotate(30deg);
  background: radial-gradient(circle,
              rgba(255, 255, 255, 0.20) 0,
              rgba(255, 255, 255, 0) 70%);
  transition: left 0.8s cubic-bezier(0.23, 1, 0.32, 1);
}
.lg-fx-specular:hover::after {
  opacity: 1;
  left: 50%;
  transition: left 0.8s cubic-bezier(0.23, 1, 0.32, 1),
              opacity 0.3s ease-in;
}

/* ---- Shimmer streak (continuous) ---------------------------------------- */
.lg-fx-shimmer {
  position: relative;
  overflow: hidden;
}
.lg-fx-shimmer::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  pointer-events: none;
  background: linear-gradient(110deg,
              rgba(0, 0, 0, 0),
              rgba(255, 255, 255, 0.10) 40%,
              rgba(255, 255, 255, 0.10) 60%,
              rgba(0, 0, 0, 0));
  animation: lg-shimmer calc(4s * var(--lg-fx-speed, 1)) ease-in-out infinite;
}

/* ---- Float (weightless bob) --------------------------------------------- */
.lg-fx-float {
  animation: lg-float calc(5s * var(--lg-fx-speed, 1)) ease-in-out infinite;
}

/* ---- Pulse glow (breathing shadow) -------------------------------------- */
.lg-fx-pulse {
  animation: lg-pulse-glow calc(4s * var(--lg-fx-speed, 1)) ease-in-out infinite;
}

/* ---- Morph (scale + rotate + deeper blur on hover) ---------------------- */
.lg-fx-morph {
  transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.lg-fx-morph:hover {
  border-radius: 24px;
  transform: scale(1.03) rotate(-0.5deg);
  -webkit-backdrop-filter: blur(24px) saturate(200%);
  backdrop-filter: blur(24px) saturate(200%);
}

/* ---- Liquid surface (organic light flow) -------------------------------- */
.lg-fx-liquid {
  position: relative;
  overflow: hidden;
}
.lg-fx-liquid::before {
  content: "";
  position: absolute;
  inset: -20px;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0.7;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.08) 0, rgba(0, 0, 0, 0) 30%),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.07) 0, rgba(0, 0, 0, 0) 30%),
    radial-gradient(circle at 60% 20%, rgba(255, 255, 255, 0.06) 0, rgba(0, 0, 0, 0) 25%);
  animation: lg-liquid-flow calc(12s * var(--lg-fx-speed, 1)) ease-in-out infinite;
}

/* ---- Particles (floating light dust, on hover) -------------------------- */
.lg-fx-particles {
  position: relative;
}
.lg-fx-particles::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.30) 1px, rgba(0, 0, 0, 0) 0),
    radial-gradient(circle, rgba(255, 255, 255, 0.20) 1px, rgba(0, 0, 0, 0) 0);
  background-size: 40px 40px, 80px 80px;
  transition: opacity 0.5s;
  animation: lg-particle-float calc(20s * var(--lg-fx-speed, 1)) linear infinite;
}
.lg-fx-particles:hover::after {
  opacity: 1;
}

/* ---- Hover lift ---------------------------------------------------------- */
.lg-fx-hover {
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.lg-fx-hover:hover {
  background: var(--lg-glass-bg-hover);
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 32px var(--lg-glass-shadow),
              inset 0 1px 1px var(--lg-glass-highlight);
}

/* ---- Interactive press --------------------------------------------------- */
.lg-fx-interactive {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.lg-fx-interactive:active {
  transform: scale(0.97);
  transition: transform 0.1s;
  box-shadow: 0 2px 8px var(--lg-glass-shadow),
              inset 0 1px 0 var(--lg-glass-highlight);
}

/* ---- Progressive blur (depth-of-field backdrop blur) -------------------- */
/* kube.io "Progressive Blur Strength": a masked backdrop-filter layer whose
   blur ramps along --lg-pblur-dir (clear → blurred). Tune with --lg-pblur. */
.lg-fx-progressive-blur {
  position: relative;
}
.lg-fx-progressive-blur::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  -webkit-backdrop-filter: blur(var(--lg-pblur, 14px));
  backdrop-filter: blur(var(--lg-pblur, 14px));
  -webkit-mask-image: linear-gradient(var(--lg-pblur-dir, to bottom),
              transparent 0%, rgba(0, 0, 0, 0.45) 38%, #000 72%);
  mask-image: linear-gradient(var(--lg-pblur-dir, to bottom),
              transparent 0%, rgba(0, 0, 0, 0.45) 38%, #000 72%);
}

/* ---- Glare band (directional, angle-configurable) ----------------------- */
/* Approximates liquid-glass-studio's angular glare: a bright streak crossing
   the surface at --lg-glare-angle. Static highlight, screen-blended. */
.lg-fx-glare {
  position: relative;
  overflow: hidden;
}
.lg-fx-glare::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  border-radius: inherit;
  background: linear-gradient(var(--lg-glare-angle, 45deg),
              transparent calc(50% - var(--lg-glare-width, 14%) - 8%),
              rgba(255, 255, 255, 0) calc(50% - var(--lg-glare-width, 14%)),
              rgba(255, 255, 255, var(--lg-glare-strength, 0.45)) 50%,
              rgba(255, 255, 255, 0) calc(50% + var(--lg-glare-width, 14%)),
              transparent calc(50% + var(--lg-glare-width, 14%) + 8%));
}

/* ---- Blob / shape-merge (gooey metaball container) ---------------------- */
/* Generalises the slider's #lg-goo: apply to a CONTAINER and its glass
   children merge with surface-tension necks. Needs the #lg-fx-goo SVG filter
   (auto-injected by the JS API when effects include 'blob', or inline it). */
.lg-fx-blob {
  filter: url(#lg-fx-goo);
}
.lg-fx-blob > * {
  /* children read as the merged "liquid" — keep them solid-ish for the goo */
  will-change: transform;
}

/* ---- Keyframes ----------------------------------------------------------- */
@keyframes lg-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

@keyframes lg-pulse-glow {
  0%, 100% {
    box-shadow: 0 4px 12px var(--lg-glass-shadow),
                inset 0 1px 0 var(--lg-glass-highlight);
  }
  50% {
    box-shadow: 0 8px 24px var(--lg-glass-shadow),
                inset 0 1px 1px var(--lg-glass-highlight),
                0 0 15px rgba(139, 148, 158, 0.10);
  }
}

@keyframes lg-shimmer {
  0%   { opacity: 0.1; transform: translateX(-100%) skew(-20deg); }
  20%  { opacity: 1; }
  100% { opacity: 0.1; transform: translateX(100%) skew(-20deg); }
}

@keyframes lg-liquid-flow {
  0%, 100% { transform: translate(0, 0); }
  25%      { transform: translate(10px, 5px); }
  50%      { transform: translate(-5px, -10px); }
  75%      { transform: translate(5px, 10px); }
}

@keyframes lg-particle-float {
  0%   { background-position: 0 0, 0 0; }
  100% { background-position: -40px 0, 0 -80px; }
}

/* ---- Reduced-motion: honour user preference ----------------------------- */
@media (prefers-reduced-motion: reduce) {
  .lg-fx-float,
  .lg-fx-pulse,
  .lg-fx-shimmer::before,
  .lg-fx-liquid::before,
  .lg-fx-particles::after,
  .lg-fx-specular::after,
  .lg-fx-morph,
  .lg-fx-hover,
  .lg-fx-interactive {
    animation: none !important;
    transition: none !important;
  }
  .lg-fx-hover:hover,
  .lg-fx-interactive:active,
  .lg-fx-morph:hover {
    transform: none !important;
  }
}
