/* ============================================================
   Liquid glass — js/liquid-glass.js (engine) + js/liquid-glass-ui.js
   ------------------------------------------------------------
   Inert unless html[data-lg] is set by the engine (kill switch
   ?noliquidglass=true). html[data-lg="refract"] = Chromium: the
   backdrop is bent through an SVG displacement map, set inline on
   each glass element. html[data-lg="frost"] = Safari / Firefox:
   same layers, a frosted blur instead of the bend.

   The rule for every surface: the white stroke, the colours (the mic
   stays red / green) and the icons stay exactly as they were. Only the
   fill gets clearer, and the old flat blur layers make way for the
   glass — they would blur the refraction away (some adopted widgets
   stacked three of them).

   Loaded last in <head> on both pages, after css/glass-ui.css.
   ============================================================ */

/* ---------- 1. engine layers ---------- */
html[data-lg] .lg-host {
    isolation: isolate;
}

html[data-lg] .lg-lens,
html[data-lg] .lg-rim,
html[data-lg] .lg-glow {
    position: absolute;
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
    pointer-events: none;
}

/* lens (hosts with a dropdown inside): under the stroke + tint layer */
html[data-lg] .lg-lens {
    inset: 0;
    border-radius: inherit;
    z-index: -2;
}

/* the rim plane: specular light on the top and bottom of the rim + a soft
   side shade — sized by the engine 2px beyond the border box */
html[data-lg] .lg-rim {
    z-index: -1;
    background-size: 100% 100%;
    background-repeat: no-repeat;
}

/* pointer-tracked glow (hover 0.35, press 1) */
html[data-lg] .lg-glow {
    inset: 0;
    border-radius: inherit;
    z-index: -1;
    --lg-glow-color: rgb(255 255 255 / 0.24);
    background-image: radial-gradient(
        var(--lg-glow-size, 64px) circle at var(--lg-glow-x, 50%) var(--lg-glow-y, 50%),
        color-mix(in srgb, var(--lg-glow-color) calc(var(--lg-glow, 0) * 100%), transparent),
        transparent 65%);
}
html[data-lg][data-theme="light"] .lg-glow {
    --lg-glow-color: rgb(255 255 255 / 0.5);
}

/* the glass is the only backdrop now */
html[data-lg] .lg-host::before,
html[data-lg] .lg-host[data-lg-layer="lens"] {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* ---------- 2. galaxy: hive bubbles + #gd-corner row ---------- */
html.dock-ui[data-lg] :is(#galaxy-dock, #gd-corner) {
    --gd-bubble-bg: rgba(255, 255, 255, 0.055);
    --gd-bubble-bg-hover: rgba(255, 255, 255, 0.12);
}
/* frost (Safari / iPhone / Firefox): there is no bend to show what's
   behind, and a blurred glow under a 5% tint reads as a flat colour —
   a little more white keeps it reading as glass */
html.dock-ui[data-lg="frost"] :is(#galaxy-dock, #gd-corner, .gd-edge-nav) {
    --gd-bubble-bg: rgba(255, 255, 255, 0.1);
    --gd-bubble-bg-hover: rgba(255, 255, 255, 0.17);
}
/* light theme wins over both (arrows included — same id-level weight) */
html.dock-ui[data-lg][data-theme="light"] :is(#galaxy-dock, #gd-corner, .gd-edge-nav) {
    --gd-bubble-bg: rgba(255, 255, 255, 0.34);
    --gd-bubble-bg-hover: rgba(255, 255, 255, 0.5);
}

/* mic: still red when muted, green when live — tinted glass, not paint */
html.dock-ui[data-lg] :is(#galaxy-dock, #gd-corner) #mic-toggle-button::before {
    background: linear-gradient(160deg, rgba(255, 82, 82, 0.66), rgba(196, 32, 46, 0.6)) !important;
}
html.dock-ui[data-lg] :is(#galaxy-dock, #gd-corner) #mic-toggle-button.active::before {
    background: linear-gradient(160deg, rgba(64, 220, 120, 0.68), rgba(24, 160, 78, 0.62)) !important;
}

/* the + carries a second, legacy glass circle inside the adopted
   container — the container's stroke is the one that stays */
html.dock-ui[data-lg] :is(#galaxy-dock, #gd-corner) #add-star-button,
html.dock-ui[data-lg] :is(#galaxy-dock, #gd-corner) #add-star-button::before {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
html.dock-ui[data-lg] :is(#galaxy-dock, #gd-corner) #add-star-button::before {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

/* mobile resting state dimmed the whole cluster with opacity, which
   makes the cluster the bubbles' backdrop root (no glass at all) —
   dim the orb, the icons and the stroke instead */
@media (max-width: 768px) {
    html.dock-ui[data-lg] #galaxy-dock.gd-mini #gd-cluster {
        opacity: 1;
    }
    html.dock-ui[data-lg] #galaxy-dock.gd-mini .gd-orb-item,
    html.dock-ui[data-lg] #galaxy-dock.gd-mini .lg-host > svg,
    html.dock-ui[data-lg] #galaxy-dock.gd-mini .lg-host::before {
        opacity: 0.82;
    }
}

/* ---------- 3. galaxy: prev / next arrows ---------- */
html.dock-ui[data-lg] .gd-edge-nav {
    --gd-bubble-bg: rgba(255, 255, 255, 0.055);
    --gd-bubble-bg-hover: rgba(255, 255, 255, 0.12);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.08),
        inset 1.8px 3px 0 -2px rgba(255, 255, 255, 0.85),
        inset -2px -2px 0 -2px rgba(255, 255, 255, 0.55),
        var(--gd-bubble-glow);
}
html.dock-ui[data-lg] .gd-edge-nav > svg {
    position: relative;
    z-index: 1;
}

/* ---------- 4. galaxy: minimap ---------- */
html.dock-ui[data-lg] #galaxy-minimap {
    background: rgba(10, 14, 26, 0.24);
    border-color: rgba(255, 255, 255, 0.22);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.05),
        inset 1.8px 3px 0 -2px rgba(255, 255, 255, 0.6),
        0 6px 22px rgba(0, 0, 0, 0.3);
}
html.dock-ui[data-lg] #galaxy-minimap:hover {
    background: rgba(14, 20, 34, 0.32);
    border-color: rgba(255, 255, 255, 0.3);
}
/* the full map carries labels — a deeper tint keeps them readable */
html.dock-ui[data-lg] #galaxy-minimap.expanded {
    background: rgba(8, 12, 22, 0.5);
}
html.dock-ui[data-lg][data-theme="light"] #galaxy-minimap:not(.expanded) {
    background: rgba(255, 255, 255, 0.22);
}

/* ---------- 5. galaxy chat panel ---------- */
html.dock-ui[data-lg] #galaxy-chat-panel {
    background: linear-gradient(180deg, rgba(20, 24, 42, 0.34), rgba(10, 13, 26, 0.46));
    border-color: rgba(255, 255, 255, 0.2);
}
html.dock-ui[data-lg][data-theme="light"] #galaxy-chat-panel {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(244, 247, 255, 0.62));
    border-color: rgba(255, 255, 255, 0.7);
}
/* the panel already frosts the page — the bubbles skip their own blur pass */
html.dock-ui[data-lg] #galaxy-chat-panel :is(.chat-message, .gc-chip, #gc-input-row) {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

/* ---------- 6. world: the top-left row ---------- */
html[data-lg] .top-nav-buttons {
    --world-glass-bg: rgba(255, 255, 255, 0.05);
    --world-glass-bg-hover: rgba(255, 255, 255, 0.11);
}
html[data-lg="frost"] .top-nav-buttons {
    --world-glass-bg: rgba(255, 255, 255, 0.09);
    --world-glass-bg-hover: rgba(255, 255, 255, 0.15);
}
html[data-lg][data-theme="light"] .top-nav-buttons {
    --world-glass-bg: rgba(255, 255, 255, 0.34);
    --world-glass-bg-hover: rgba(255, 255, 255, 0.5);
}
/* the legacy .glass-circle-btn base (blur(20px) on the button itself)
   is replaced inline by the glass; its hover lift and :active shrink
   give way to the press spring */
html[data-lg] .top-nav-buttons .lg-host:hover,
html[data-lg] .top-nav-buttons .lg-host:active {
    transform: none !important;
}
html[data-lg] .top-nav-buttons #mic-toggle-button::before {
    background: linear-gradient(160deg, rgba(255, 82, 82, 0.66), rgba(196, 32, 46, 0.6));
}
html[data-lg] .top-nav-buttons #mic-toggle-button.active::before {
    background: linear-gradient(160deg, rgba(64, 220, 120, 0.68), rgba(24, 160, 78, 0.62));
}

/* ---------- 7. touch joystick (galaxy + world) + the world's jump button ---------- */
/* js/mobile-controls.js dims the whole joystick with an inline opacity
   (0.7 idle, 0.9 while dragged). Opacity below 1 makes the container the
   backdrop root of everything inside it, so the disc's glass (and the old
   flat blur before it) saw nothing at all after the first touch. Keep it
   opaque; the knob's .active state carries the touch feedback. */
html[data-lg] #mobile-joystick {
    opacity: 1 !important;
}
/* the disc: same 2px white stroke, a clearer fill */
html[data-lg] #mobile-joystick .joystick-base {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.32);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.06),
        inset 2px 3px 0 -2px rgba(255, 255, 255, 0.7),
        inset -2px -2px 0 -2px rgba(255, 255, 255, 0.4),
        0 6px 24px rgba(0, 0, 0, 0.22);
}
/* the knob: a thicker glass marble — white stroke kept */
html[data-lg] #mobile-joystick .joystick-handle {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.62);
    box-shadow:
        inset 1.5px 2.5px 0 -1.5px rgba(255, 255, 255, 0.9),
        inset -2px -2px 0 -2px rgba(255, 255, 255, 0.55),
        0 4px 14px rgba(0, 0, 0, 0.3);
}
html[data-lg] #mobile-joystick .joystick-handle.active {
    background: rgba(255, 255, 255, 0.26);
    box-shadow:
        inset 1.5px 2.5px 0 -1.5px rgba(255, 255, 255, 0.9),
        inset -2px -2px 0 -2px rgba(255, 255, 255, 0.55),
        0 0 22px rgba(255, 255, 255, 0.55);
}
html[data-lg] #mobile-joystick .joystick-arrows {
    z-index: 1;
}
html[data-lg] #mobile-jump-button {
    background: rgba(255, 255, 255, 0.06);
    box-shadow:
        inset 2px 3px 0 -2px rgba(255, 255, 255, 0.7),
        inset -2px -2px 0 -2px rgba(255, 255, 255, 0.4),
        0 6px 20px rgba(0, 0, 0, 0.22);
}
html[data-lg] #mobile-jump-button > svg {
    position: relative;
    z-index: 1;
}
html[data-lg="frost"] #mobile-joystick .joystick-base,
html[data-lg="frost"] #mobile-jump-button {
    background: rgba(255, 255, 255, 0.1);
}

/* ---------- 8. Imagine Social ---------- */
/* the panel holds a lot of small text: a deeper tint than the chat panel */
html[data-lg] .social-feed-panel {
    background: linear-gradient(180deg, rgba(16, 20, 38, 0.58), rgba(8, 11, 24, 0.68));
    border-color: rgba(255, 255, 255, 0.2);
}
html[data-lg][data-theme="light"] .social-feed-panel {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.66), rgba(244, 247, 255, 0.76));
    border-color: rgba(255, 255, 255, 0.8);
}
html[data-lg="frost"] .social-feed-panel {
    background: linear-gradient(180deg, rgba(18, 22, 40, 0.72), rgba(10, 13, 26, 0.8));
}
html[data-lg="frost"][data-theme="light"] .social-feed-panel {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(244, 247, 255, 0.86));
}
