/* ==========================================================================
   Liquid glass material (.lg). Refraction comes from glass.js (Chromium); everything
   here (tint, rim light, thickness, interaction) also styles the Safari/Firefox fallback.
   Opt in: class="lg" (+ data-lg="panel" for text-heavy panels, "button" for small round ones).
   Elements may override any --lg-* token.
   ========================================================================== */

@property --lg-glow { syntax: "<number>"; inherits: false; initial-value: 0; }

.lg {
  /* light tone (default: over the pale watercolour map) */
  --lg-tint: rgba(255, 255, 255, .32);
  --lg-tint-top: rgba(255, 255, 255, .26);
  --lg-ink: #141b2b;
  --lg-ink-muted: rgba(20, 27, 43, .72);
  --lg-hairline: rgba(255, 255, 255, .42);
  --lg-hi: rgba(255, 255, 255, .95);     /* specular, top-left */
  --lg-lo: rgba(255, 255, 255, .55);     /* counter-reflection, bottom-right */
  --lg-inner: rgba(255, 255, 255, .55);  /* inner glow just under the top rim */
  --lg-shade: rgba(20, 26, 44, .20);     /* thickness: darker inside the lower rim */
  --lg-drop: 0 10px 28px -6px rgba(18, 24, 40, .30), 0 2px 6px -1px rgba(18, 24, 40, .16);
  --lg-text-shadow: 0 .5px 0 rgba(255, 255, 255, .45);
  --lg-bright: 1.1;
  --lg-press: .965;
  --lg-hover-glow: .28;

  color: var(--lg-ink);
  text-shadow: var(--lg-text-shadow);
  background:
    radial-gradient(circle 64px at var(--lg-mx, 30%) var(--lg-my, 0%), rgb(255 255 255 / calc(var(--lg-glow) * 1)), transparent 100%),
    linear-gradient(180deg, var(--lg-tint-top), transparent 58%),
    var(--lg-tint);
  border: 0;
  box-shadow:
    inset 0 0 0 .5px var(--lg-hairline),
    inset 1.6px 1.8px .6px -.6px var(--lg-hi),
    inset -1.2px -1.4px .6px -.6px var(--lg-lo),
    inset 0 10px 16px -12px var(--lg-inner),
    inset 0 -12px 18px -14px var(--lg-shade),
    var(--lg-drop);
  /* fallback material; replaced by the refracting filter once glass.js has baked a map */
  -webkit-backdrop-filter: blur(calc(var(--lg-blur, 2px) + 9px)) saturate(1.8) brightness(var(--lg-bright));
  backdrop-filter: blur(calc(var(--lg-blur, 2px) + 9px)) saturate(1.8) brightness(var(--lg-bright));
  transition: scale .55s cubic-bezier(.3, 1.6, .45, 1), --lg-glow .35s ease,
    color .6s ease, background-color .6s ease, box-shadow .6s ease;
}
/* no url() refraction here: a bit more veil so text stays legible through heavier frost */
.lg-fallback .lg { --lg-tint: rgba(255, 255, 255, .24); }

/* the real thing */
.lg-refraction .lg.lg-on {
  -webkit-backdrop-filter: none;
  backdrop-filter: var(--lg-filter) blur(var(--lg-blur, 1.5px)) saturate(var(--lg-sat, 1.6)) brightness(var(--lg-bright));
}
.lg-refraction.lg-moving .lg.lg-on {
  backdrop-filter: var(--lg-filter-lite) blur(var(--lg-blur, 1.5px)) saturate(var(--lg-sat, 1.6)) brightness(var(--lg-bright));
}

/* dark tone: night, or a dark patch of map behind the element */
.lg[data-lg-tone-now="dark"] {
  --lg-tint: rgba(14, 18, 34, .40);
  --lg-tint-top: rgba(255, 255, 255, .08);
  --lg-ink: #f4f6fc;
  --lg-ink-muted: rgba(240, 243, 252, .70);
  --lg-hairline: rgba(255, 255, 255, .20);
  --lg-hi: rgba(255, 255, 255, .62);
  --lg-lo: rgba(255, 255, 255, .26);
  --lg-inner: rgba(255, 255, 255, .16);
  --lg-shade: rgba(0, 0, 0, .30);
  --lg-drop: 0 10px 30px -6px rgba(0, 0, 0, .45), 0 2px 6px -1px rgba(0, 0, 0, .25);
  --lg-text-shadow: 0 1px 1px rgba(0, 0, 0, .3);
  --lg-bright: .96;
  --lg-hover-glow: .16;
}
.lg-fallback .lg[data-lg-tone-now="dark"] { --lg-tint: rgba(16, 20, 38, .46); }

/* text-heavy panels: same glass, more veil (iOS menus do this too) */
.lg[data-lg="panel"] { --lg-tint: rgba(255, 255, 255, .56); --lg-tint-top: rgba(255, 255, 255, .22); --lg-text-shadow: none; }
.lg[data-lg="panel"][data-lg-tone-now="dark"] { --lg-tint: rgba(16, 20, 38, .56); --lg-tint-top: rgba(255, 255, 255, .06); --lg-text-shadow: none; }
.lg-fallback .lg[data-lg="panel"] { --lg-tint: rgba(255, 255, 255, .55); }
.lg-fallback .lg[data-lg="panel"][data-lg-tone-now="dark"] { --lg-tint: rgba(16, 20, 38, .62); }

/* interaction: a soft light follows the pointer; press squishes with a springy release */
@media (hover: hover) {
  .lg:hover { --lg-glow: var(--lg-hover-glow); }
}
.lg.lg-pressed { scale: var(--lg-press); --lg-glow: calc(var(--lg-hover-glow) * 1.6); transition-duration: .18s, .2s, .6s, .6s, .6s; }

/* -------- glass bubble for buttons that sit on a glass surface (nested backdrop
   filters don't see the map, so these are lit like a lens instead of refracting) */
.lg-btn {
  position: relative;
  transition: scale .5s cubic-bezier(.3, 1.7, .45, 1), background-color .25s ease, box-shadow .25s ease;
}
@media (hover: hover) {
  .lg-btn:hover {
    background: radial-gradient(120% 100% at 30% 15%, rgba(255, 255, 255, .42), rgba(255, 255, 255, .10) 60%, rgba(255, 255, 255, .16));
    box-shadow: inset 0 0 0 .5px rgba(255, 255, 255, .5), inset 1px 1.4px .5px -.5px rgba(255, 255, 255, .95),
      inset -1px -1px .5px -.5px rgba(255, 255, 255, .5), 0 2px 8px -2px rgba(18, 24, 40, .25);
  }
  [data-lg-tone-now="dark"] .lg-btn:hover {
    background: radial-gradient(120% 100% at 30% 15%, rgba(255, 255, 255, .22), rgba(255, 255, 255, .05) 60%, rgba(255, 255, 255, .08));
    box-shadow: inset 0 0 0 .5px rgba(255, 255, 255, .22), inset 1px 1.4px .5px -.5px rgba(255, 255, 255, .5), 0 2px 8px -2px rgba(0, 0, 0, .4);
  }
}
.lg-btn:active { scale: .88; transition-duration: .15s, .15s, .15s; }

/* engines without any backdrop-filter: an honest, readable plate */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .lg, .lg[data-lg="panel"] { --lg-tint: rgba(250, 250, 252, .86); }
  .lg[data-lg-tone-now="dark"] { --lg-tint: rgba(22, 26, 40, .88); }
}
@media (prefers-reduced-motion: reduce) {
  .lg, .lg-btn { transition: none; }
  .lg.lg-pressed { scale: 1; }
}
@media (prefers-reduced-transparency: reduce) {
  .lg, .lg[data-lg="panel"] { --lg-tint: rgba(250, 250, 252, .9); }
  .lg[data-lg-tone-now="dark"] { --lg-tint: rgba(22, 26, 40, .92); }
}
