/*
 * Liquid glass — the shared interface material for every design.
 *
 * Depth comes from transparency, a refraction rim and a soft specular
 * highlight in the top-left corner,
 * not from heavy shadows or bevels.
 *
 * Tune per surface with:
 *   --lg-tint   RGB triplet the glass is tinted with
 *   --lg-alpha  tint strength
 *   --lg-blur   backdrop blur radius
 */
.lg {
  --lg-tint: 255 255 255;
  --lg-alpha: 0.07;
  --lg-blur: 22px;
  --lg-rim: 0.42;
  isolation: isolate;
  background: linear-gradient(
    180deg,
    rgb(var(--lg-tint) / calc(var(--lg-alpha) + 0.035)) 0%,
    rgb(var(--lg-tint) / var(--lg-alpha)) 100%
  );
  -webkit-backdrop-filter: blur(var(--lg-blur)) saturate(180%);
  backdrop-filter: blur(var(--lg-blur)) saturate(180%);
  box-shadow:
    inset 0 1px 0 0 rgb(255 255 255 / 0.22),
    inset 0 -1px 0 0 rgb(255 255 255 / 0.04),
    0 12px 32px -18px rgb(0 0 0 / 0.45);
}

/* Zero specificity so Tailwind's fixed/absolute/sticky utilities still win. */
:where(.lg) {
  position: relative;
}

/* Refraction rim: a 1px gradient edge, brightest where light "enters". */
.lg::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  padding: 1px;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    140deg,
    rgb(255 255 255 / var(--lg-rim)) 0%,
    rgb(255 255 255 / 0.06) 32%,
    rgb(255 255 255 / 0) 58%,
    rgb(255 255 255 / calc(var(--lg-rim) * 0.4)) 100%
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

/* Specular highlight, fixed in place. */
.lg::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(
    160px circle at 28% -20%,
    rgb(255 255 255 / 0.16),
    transparent 70%
  );
  transition: opacity 0.4s ease;
}

/* Variants */
.lg-light {
  --lg-tint: 255 255 255;
  --lg-alpha: 0.5;
  --lg-rim: 0.9;
  box-shadow:
    inset 0 1px 0 0 rgb(255 255 255 / 0.9),
    0 0 0 0.5px rgb(20 20 24 / 0.08),
    0 12px 32px -20px rgb(20 20 24 / 0.25);
}

.lg-dark {
  --lg-tint: 18 18 20;
  --lg-alpha: 0.38;
}

.lg-clear {
  --lg-alpha: 0.02;
  --lg-blur: 14px;
}

.lg-strong {
  --lg-alpha: 0.12;
  --lg-blur: 32px;
}

/* Small clear bubbles (badges, chips inside a liquid card). */
.lg-bubble {
  background: rgb(255 255 255 / 0.05);
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  backdrop-filter: blur(8px) saturate(140%);
  box-shadow:
    inset 0 0 0 1px rgb(255 255 255 / 0.22),
    inset 0 0 8px 0 rgb(255 255 255 / 0.08),
    inset 0 -4px 6px -4px rgb(255 255 255 / 0.3);
}


/* Interactive glass: gentle press, brighter highlight on hover. */
.lg-press {
  transition:
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    background-color 0.3s ease;
}
.lg-press:active {
  transform: scale(0.97);
}
.lg-press:not(:hover)::after {
  opacity: 0.55;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .lg {
    background: rgb(28 28 30 / 0.92);
  }
  .lg-light {
    background: rgb(250 250 250 / 0.94);
  }
}

@media (prefers-reduced-transparency: reduce) {
  .lg {
    background: rgb(28 28 30 / 0.96);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .lg-light {
    background: rgb(250 250 250 / 0.97);
  }
}

/* Film grain used over photography in the cinematic designs. */
.grain {
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
