/* ============================================================
   STEP 2 — BASE STYLE, CSS VARIABLES & MOBILE-ONLY RESTRICTION
   ============================================================ */

:root {
  /* Layout */
  --nav-bar-h: 68px;
  --nav-pad-bottom: env(safe-area-inset-bottom, 0px);
  --indicator-size: 52px;
  --bubble-size: 46px;

  /* Colors */
  --nav-bg: #101322;
  --indicator-bg: #6366f1;
  --bubble-bg: #6366f1;
  --bubble-color: #ffffff;
  --icon-color: #8b93a7;
  --icon-active: #ffffff;

  /* Typography */
  --label-size: 10px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, sans-serif;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: #eef2f9;
  color: #0f172a;
  -webkit-tap-highlight-color: transparent;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 20px;
  font-family: var(--font);
  line-height: 1.55;
}

/* --- Mobile-only: the navigation is HIDDEN by default --- */
.liquid-nav {
  display: none;
}

.liquid-nav__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* --- Sub-menu bubbles are hidden by default --- */
.liquid-nav__bubbles {
  opacity: 0;
  pointer-events: none;
}

/* ============================================================
   MOBILE ACTIVATION — only appear on screens <= 768px
   ============================================================ */

@media (max-width: 768px) {
  .page {
    padding-bottom: calc(var(--nav-bar-h) + var(--nav-pad-bottom) + 24px);
  }

  .liquid-nav {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--nav-bar-h);
    padding-bottom: var(--nav-pad-bottom);
    background: var(--nav-bg);
    z-index: 1000;
  }

  .liquid-nav__list {
    display: flex;
    align-items: center;
    justify-content: space-around;
    width: 100%;
    max-width: 420px;
    height: 100%;
    position: relative;
  }

  .liquid-nav__item {
    position: relative;
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
  }

  .liquid-nav__link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px 12px;
    text-decoration: none;
    color: var(--icon-color);
    z-index: 2;
    transition: color 0.3s ease;
  }

  .liquid-nav__link:focus-visible,
  .liquid-nav__bubble:focus-visible {
    outline: 2px solid #a5b4fc;
    outline-offset: 3px;
  }

  .liquid-nav__icon {
    transition: transform 0.45s var(--ease-out);
  }

  .liquid-nav__label {
    font-size: var(--label-size);
    font-family: var(--font);
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
  }
}

/* ============================================================
   STEP 3 — LIQUID EFFECT & FLOATING BUBBLE ANIMATION
   ============================================================ */

/* Dynamic liquid indicator: slides to the active item (position set by JS) */
.liquid-nav__indicator {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--indicator-size);
  height: var(--indicator-size);
  background: var(--indicator-bg);
  box-shadow: 0 10px 24px rgba(99, 102, 241, 0.45);
  transform: translate(-50%, -50%);
  border-radius: 42% 58% 55% 45% / 45% 40% 60% 55%;
  transition:
    left 0.55s var(--ease-out),
    transform 0.5s var(--ease-out),
    border-radius 0.6s ease;
  z-index: 1;
  will-change: left, transform;
  animation: liquidFloat 7s ease-in-out infinite;
}

/* Gooey bumps: two small circles that pop in on the blob's upper sides
   when the sub-menu opens -> "curved cutout / liquid" look. */
.liquid-nav__indicator::before,
.liquid-nav__indicator::after {
  content: "";
  position: absolute;
  top: -7px;
  width: 16px;
  height: 16px;
  background: inherit;
  border-radius: 50%;
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.35s ease, transform 0.45s var(--ease-out);
}

.liquid-nav__indicator::before {
  left: -6px;
}

.liquid-nav__indicator::after {
  right: -6px;
}

/* Sub-menu open -> blob stretches upward toward the bubbles */
.liquid-nav.is-open .liquid-nav__indicator {
  transform: translate(-50%, calc(-50% - 7px)) scale(1.08);
}

.liquid-nav.is-open .liquid-nav__indicator::before,
.liquid-nav.is-open .liquid-nav__indicator::after {
  opacity: 1;
  transform: scale(1);
}

/* Active item: icon glides upward, label turns bright */
.liquid-nav__item.is-active .liquid-nav__link {
  color: var(--icon-active);
}

.liquid-nav__item.is-active .liquid-nav__icon {
  transform: translateY(-5px);
}

/* --- Floating bubble sub-menu --- */
.liquid-nav__bubbles {
  position: absolute;
  left: 50%;
  bottom: calc(100% - 14px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  transform: translateX(-50%) translateY(8px);
  transition: opacity 0.35s ease, transform 0.45s var(--ease-out);
  z-index: 10;
}

.liquid-nav__item.is-open .liquid-nav__bubbles {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.liquid-nav__bubble {
  width: var(--bubble-size);
  height: var(--bubble-size);
  border: none;
  border-radius: 50%;
  background: var(--bubble-bg);
  color: var(--bubble-color);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translateY(14px) scale(0);
  transition: transform 0.25s var(--ease-out), filter 0.2s ease;
}

.liquid-nav__item.is-open .liquid-nav__bubble {
  opacity: 1;
  transform: translateY(0) scale(1);
  animation: bubblePop 0.5s var(--ease-out) backwards;
  animation-delay: calc(var(--bubble-i, 0) * 70ms);
}

.liquid-nav__bubble:nth-child(1) { --bubble-i: 0; }
.liquid-nav__bubble:nth-child(2) { --bubble-i: 1; }
.liquid-nav__bubble:nth-child(3) { --bubble-i: 2; }

.liquid-nav__item.is-open .liquid-nav__bubble:hover {
  transform: translateY(-3px) scale(1.08);
  filter: brightness(1.12);
}

.liquid-nav__item.is-open .liquid-nav__bubble:active {
  transform: translateY(0) scale(0.94);
}

/* Toast feedback injected by app.ts */
.liquid-nav__toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 999px;
  font: 13px var(--font);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 2000;
}

.liquid-nav__toast.is-visible {
  opacity: 1;
}

/* --- Keyframes --- */
@keyframes liquidFloat {
  0%, 100% { border-radius: 42% 58% 55% 45% / 45% 40% 60% 55%; }
  33%      { border-radius: 58% 42% 45% 55% / 55% 60% 40% 45%; }
  66%      { border-radius: 48% 52% 60% 40% / 52% 45% 55% 48%; }
}

@keyframes bubblePop {
  0%   { transform: translateY(26px) scale(0); opacity: 0; }
  60%  { transform: translateY(-4px) scale(1.12); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .liquid-nav__indicator,
  .liquid-nav__bubble {
    animation: none;
    transition: none;
  }
}
