*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --bg: #111111;
    --surface: #f7f7f7;
    --text: #222222;
    --caption: rgba(255, 255, 255, 0.78);

    --h: 56px;
    --radius: 28px;

    --x0: 0px;
    --x1: 0px;
    --x2: 0px;
    --x3: 0px;
    --x4: 0px;

    --scale-main: 1;
    --scale-item: 0.72;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    background: var(--bg);
    font-family: Inter, Arial, sans-serif;
}

.scene {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 40px 20px;
}

.liquid-menu {
    position: relative;
    width: 520px;
    max-width: calc(100vw - 32px);
    height: 92px;
}

.goo-layer,
.ui-layer {
    position: absolute;
    inset: 0;
}

.goo-layer {
    pointer-events: none;
    z-index: 1;
}

.goo-svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.goo-pill {
    fill: var(--surface);
    transform-box: fill-box;
    transform-origin: center center;
    transition:
            transform 420ms cubic-bezier(0.22, 0.8, 0.2, 1),
            opacity 280ms ease;
    will-change: transform, opacity;
}

.goo-pill-main {
    transform:
            translateX(var(--x0))
            scale(var(--scale-main), 1);
    opacity: 1;
}

.goo-pill-1 {
    transform:
            translateX(var(--x1))
            scale(var(--scale-item), 1);
    opacity: 0;
}

.goo-pill-2 {
    transform:
            translateX(var(--x2))
            scale(var(--scale-item), 1);
    opacity: 0;
}

.goo-pill-3 {
    transform:
            translateX(var(--x3))
            scale(var(--scale-item), 1);
    opacity: 0;
}

.goo-pill-4 {
    transform:
            translateX(var(--x4))
            scale(var(--scale-item), 1);
    opacity: 0;
}

.liquid-menu.is-open .goo-pill-1,
.liquid-menu.is-open .goo-pill-2,
.liquid-menu.is-open .goo-pill-3,
.liquid-menu.is-open .goo-pill-4 {
    opacity: 1;
    transform:
            translateX(var(--target-x))
            scale(1, 1);
}

.liquid-menu.is-open .goo-pill-1 {
    --target-x: 66px;
}

.liquid-menu.is-open .goo-pill-2 {
    --target-x: 164px;
}

.liquid-menu.is-open .goo-pill-3 {
    --target-x: 262px;
}

.liquid-menu.is-open .goo-pill-4 {
    --target-x: 372px;
}

.liquid-menu.is-open .goo-pill-main {
    transform: translateX(0) scale(1, 1);
}

.ui-layer {
    z-index: 2;
}

.menu-toggle,
.menu-item {
    position: absolute;
    top: 18px;
    height: var(--h);
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    will-change: transform, opacity;
}

.menu-toggle {
    left: 0;
    width: 56px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.menu-item {
    padding: 0 18px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-18px) scale(0.92) translateZ(0);
    transition:
            transform 420ms cubic-bezier(0.22, 0.8, 0.2, 1),
            opacity 240ms ease;
}

.item-1 { left: 66px; width: 88px; }
.item-2 { left: 164px; width: 88px; }
.item-3 { left: 262px; width: 100px; }
.item-4 { left: 372px; width: 96px; }

.liquid-menu.is-open .menu-item {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0) scale(1) translateZ(0);
}

.liquid-menu.is-open .item-1 { transition-delay: 30ms; }
.liquid-menu.is-open .item-2 { transition-delay: 70ms; }
.liquid-menu.is-open .item-3 { transition-delay: 110ms; }
.liquid-menu.is-open .item-4 { transition-delay: 150ms; }

.icon {
    position: absolute;
    inset: 0;
    display: block;
    transition:
            opacity 240ms ease,
            transform 340ms cubic-bezier(0.22, 0.8, 0.2, 1);
}

.icon-burger {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.icon-burger span {
    position: absolute;
    left: 19px;
    width: 18px;
    height: 2px;
    background: var(--text);
    border-radius: 999px;
}

.icon-burger span:first-child {
    top: 22px;
}

.icon-burger span:last-child {
    top: 32px;
}

.icon-close {
    opacity: 0;
    transform: scale(0.72) rotate(-20deg);
}

.icon-close::before,
.icon-close::after {
    content: "";
    position: absolute;
    left: 19px;
    top: 27px;
    width: 18px;
    height: 2px;
    background: var(--text);
    border-radius: 999px;
}

.icon-close::before {
    transform: rotate(45deg);
}

.icon-close::after {
    transform: rotate(-45deg);
}

.liquid-menu.is-open .icon-burger {
    opacity: 0;
    transform: scale(0.72) rotate(20deg);
}

.liquid-menu.is-open .icon-close {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.menu-caption {
    position: absolute;
    left: 28px;
    bottom: -6px;
    transform: translateX(-50%);
    font-size: 12px;
    line-height: 1;
    color: var(--caption);
    user-select: none;
    pointer-events: none;
}

@media (hover: hover) {
    .menu-toggle:hover,
    .menu-item:hover {
        transform: translateZ(0) scale(1.03);
    }

    .liquid-menu.is-open .menu-item:hover {
        transform: translateX(0) scale(1.03) translateZ(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .goo-pill,
    .menu-item,
    .icon {
        transition: none;
    }
}