/* ─────────────────────────────────────────────────────────
   bottom-nav.css — MEA Hub Bottom Navigation
   Premium redesign: glass, aurora, safe-area, logo M button
   Architecture unchanged. Visual layer only.
   ───────────────────────────────────────────────────────── */

/* ── Nav Bar ────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  /* Safe area: lifts nav above Android gesture zone + breathing room */
  padding-bottom: calc(env(safe-area-inset-bottom) + 8px);
  background: rgba(8, 17, 32, 0.82);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  /* Hairline top border + aurora glow strip */
  border-top: 1px solid rgba(129, 212, 250, 0.08);
  z-index: 1150;
  display: flex;
  align-items: stretch;
  /* Aurora ambient strip — very subtle, low opacity */
  box-shadow:
    0 -1px 0 0 rgba(129, 212, 250, 0.06),
    0 -20px 60px -10px rgba(129, 212, 250, 0.04),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.03);
  /* Floating illusion — thin top gradient line */
  --nav-inner-height: 56px;
  height: calc(var(--nav-inner-height) + env(safe-area-inset-bottom) + 8px);
}

/* Aurora ambient pulse on nav bar — visible but tasteful */
.bottom-nav::before {
  content: '';
  position: absolute;
  top: -50px;
  left: 12%;
  right: 12%;
  height: 60px;
  background: radial-gradient(
    ellipse at 50% 100%,
    rgba(129, 212, 250, 0.16) 0%,
    rgba(100, 180, 255, 0.07) 50%,
    transparent 100%
  );
  pointer-events: none;
  border-radius: 50%;
  filter: blur(12px);
  animation: navAuroraAmbient 6s ease-in-out infinite;
  transition: opacity 0.4s ease;
}

/* When MEA Launcher is open, nav aurora syncs with the M button's open glow */
.bottom-nav.launcher-open::before {
  background: radial-gradient(
    ellipse at 50% 100%,
    rgba(129, 212, 250, 0.30) 0%,
    rgba(100, 180, 255, 0.14) 50%,
    transparent 100%
  );
  animation: navAuroraOpen 2.5s ease-in-out infinite;
}

.bottom-nav.launcher-open {
  border-top-color: rgba(129, 212, 250, 0.18);
}

/* ── Nav Inner ──────────────────────────────────────────── */
.bottom-nav-inner {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  /* Align items to top of inner so M button can float upward */
  padding-top: 0;
  height: var(--nav-inner-height);
}

/* ── Nav Items ──────────────────────────────────────────── */
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  text-decoration: none;
  border: none;
  background: none;
  padding: 0;
  height: var(--nav-inner-height);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  transition: color var(--transition-fast);
  outline: none;
}

/* ── Unread Badge ───────────────────────────────────────── */
.nav-item-badge {
  position: absolute;
  top: 2px;
  right: calc(50% - 18px);
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--red, #C41E3A);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  font-family: var(--font-mono, monospace);
}

.nav-item-badge[hidden] { display: none; }

.nav-item-label {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--text-3);
  transition: color var(--transition-fast), opacity var(--transition-fast);
  line-height: 1;
  /* Slightly muted by default — active state pops */
  opacity: 0.7;
}

/* Hover glow for text items */
.nav-item:not(.nav-item--m):hover .nav-item-label {
  color: rgba(129, 212, 250, 0.6);
  opacity: 1;
}

/* Active dot — refined */
.nav-item-active-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: 0 0 0 transparent;
}

/* Active state */
.nav-item.active .nav-item-label {
  color: var(--accent);
  font-weight: 600;
  opacity: 1;
}
.nav-item.active .nav-item-active-dot {
  opacity: 1;
  box-shadow: 0 0 6px rgba(129, 212, 250, 0.5);
}

/* ── M Button Container ─────────────────────────────────── */
.nav-item--m {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 10px;
  overflow: visible;
  height: var(--nav-inner-height);
}

/* ── M Button — Glass Logo Button ──────────────────────── */
.nav-m-button {
  position: absolute;
  /* Float above nav bar — M button center sits above the nav top edge */
  top: -22px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  /* Glass base */
  background: radial-gradient(
    circle at 38% 35%,
    rgba(129, 212, 250, 0.18) 0%,
    rgba(100, 180, 255, 0.10) 40%,
    rgba(8, 17, 32, 0.75) 100%
  );
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  /* Glass border — simulates light refraction */
  box-shadow:
    /* Outer aurora ring — breathing */
    0 0 0 1px rgba(129, 212, 250, 0.25),
    0 0 0 4px rgba(8, 17, 32, 0.9),
    0 0 0 5px rgba(129, 212, 250, 0.08),
    /* Depth shadow */
    0 8px 24px rgba(0, 0, 0, 0.45),
    0 2px 8px rgba(0, 0, 0, 0.3),
    /* Inner light catch */
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  transition:
    transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow var(--transition-base),
    background var(--transition-base);
  /* Aurora idle animation */
  animation: mAuroraIdle 4s ease-in-out infinite;
}

/* Logo image inside M button */
.nav-m-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  /* Glow matching logo-glow.css spec */
  filter:
    drop-shadow(0 0 6px rgba(129, 212, 250, 0.6))
    drop-shadow(0 0 16px rgba(129, 212, 250, 0.3));
  transition: filter var(--transition-base), transform var(--transition-base);
  display: block;
}

/* Hover */
.nav-m-button:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow:
    0 0 0 1px rgba(129, 212, 250, 0.45),
    0 0 0 4px rgba(8, 17, 32, 0.9),
    0 0 0 5px rgba(129, 212, 250, 0.15),
    0 12px 32px rgba(0, 0, 0, 0.5),
    0 4px 12px rgba(0, 0, 0, 0.3),
    0 0 28px rgba(129, 212, 250, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}
.nav-m-button:hover .nav-m-logo {
  filter:
    drop-shadow(0 0 8px rgba(129, 212, 250, 0.85))
    drop-shadow(0 0 24px rgba(129, 212, 250, 0.45));
  transform: scale(1.05);
}

/* Active / pressed */
.nav-m-button:active {
  transform: scale(0.95) translateY(0);
  animation: none;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  box-shadow:
    0 0 0 1px rgba(129, 212, 250, 0.3),
    0 0 0 4px rgba(8, 17, 32, 0.9),
    0 0 0 5px rgba(129, 212, 250, 0.06),
    0 4px 12px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

/* Open state — launcher is open */
.nav-m-button.is-open {
  background: radial-gradient(
    circle at 38% 35%,
    rgba(129, 212, 250, 0.28) 0%,
    rgba(100, 180, 255, 0.18) 40%,
    rgba(8, 17, 32, 0.70) 100%
  );
  animation: mAuroraOpen 2.5s ease-in-out infinite;
  box-shadow:
    0 0 0 1px rgba(129, 212, 250, 0.5),
    0 0 0 4px rgba(8, 17, 32, 0.9),
    0 0 0 5px rgba(129, 212, 250, 0.14),
    0 8px 24px rgba(0, 0, 0, 0.4),
    0 0 32px rgba(129, 212, 250, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}
.nav-m-button.is-open .nav-m-logo {
  filter:
    drop-shadow(0 0 10px rgba(129, 212, 250, 0.9))
    drop-shadow(0 0 28px rgba(129, 212, 250, 0.5));
}

/* M label below button */
.nav-item--m .nav-item-label {
  font-size: 0.60rem;
  color: var(--text-3);
  letter-spacing: 0.06em;
  opacity: 0.55;
  transition: opacity var(--transition-fast);
}
.nav-m-button.is-open ~ .nav-item-label {
  opacity: 0.8;
  color: rgba(129, 212, 250, 0.5);
}

/* ── Aurora Animations ──────────────────────────────────── */

/* Nav bar ambient — visible breathing glow */
@keyframes navAuroraAmbient {
  0%, 100% { opacity: 0.55; transform: scaleX(0.85) scaleY(1); }
  50%       { opacity: 1;    transform: scaleX(1.2) scaleY(1.35); }
}

/* Nav bar — synced with M button's open aurora */
@keyframes navAuroraOpen {
  0%, 100% { opacity: 0.75; transform: scaleX(1) scaleY(1.1); }
  50%       { opacity: 1;    transform: scaleX(1.3) scaleY(1.6); }
}

/* M button idle — slow, large radius, low opacity */
@keyframes mAuroraIdle {
  0%, 100% {
    box-shadow:
      0 0 0 1px rgba(129, 212, 250, 0.20),
      0 0 0 4px rgba(8, 17, 32, 0.9),
      0 0 0 5px rgba(129, 212, 250, 0.06),
      0 8px 24px rgba(0, 0, 0, 0.45),
      0 2px 8px rgba(0, 0, 0, 0.3),
      0 0 16px rgba(129, 212, 250, 0.06),
      inset 0 1px 0 rgba(255, 255, 255, 0.15),
      inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(129, 212, 250, 0.32),
      0 0 0 4px rgba(8, 17, 32, 0.9),
      0 0 0 5px rgba(129, 212, 250, 0.10),
      0 8px 24px rgba(0, 0, 0, 0.45),
      0 2px 8px rgba(0, 0, 0, 0.3),
      0 0 36px rgba(129, 212, 250, 0.16),
      inset 0 1px 0 rgba(255, 255, 255, 0.15),
      inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  }
}

/* M button open — slightly faster, more intense */
@keyframes mAuroraOpen {
  0%, 100% {
    box-shadow:
      0 0 0 1px rgba(129, 212, 250, 0.42),
      0 0 0 4px rgba(8, 17, 32, 0.9),
      0 0 0 5px rgba(129, 212, 250, 0.12),
      0 8px 24px rgba(0, 0, 0, 0.4),
      0 0 24px rgba(129, 212, 250, 0.14),
      inset 0 1px 0 rgba(255, 255, 255, 0.22),
      inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(129, 212, 250, 0.60),
      0 0 0 4px rgba(8, 17, 32, 0.9),
      0 0 0 5px rgba(129, 212, 250, 0.18),
      0 8px 24px rgba(0, 0, 0, 0.4),
      0 0 48px rgba(129, 212, 250, 0.26),
      inset 0 1px 0 rgba(255, 255, 255, 0.22),
      inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  }
}

/* ── MEA Launcher Bottom Sheet — UNCHANGED BEHAVIOR ────── */
/* Only visual polish on existing elements — no structural change */

.launcher-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 17, 32, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 190;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-slow);
}

.launcher-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.launcher-sheet {
  position: fixed;
  bottom: calc(var(--nav-inner-height) + env(safe-area-inset-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  width: calc(100% - 32px);
  max-width: 420px;
  /* Glass surface */
  background: rgba(13, 20, 35, 0.90);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid rgba(129, 212, 250, 0.10);
  border-radius: var(--radius-lg);
  z-index: 195;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity var(--transition-slow),
    transform var(--transition-slow);
  overflow: hidden;
  box-shadow:
    0 -2px 40px rgba(129, 212, 250, 0.06),
    0 20px 60px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

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

.launcher-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(129, 212, 250, 0.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.launcher-title {
  font-family: 'Bebas Neue', 'Impact', sans-serif;
  font-size: 1rem;
  letter-spacing: 0.12em;
  color: var(--text);
  opacity: 0.85;
}

.launcher-close {
  font-size: 0.70rem;
  color: var(--text-3);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  letter-spacing: 0.04em;
  transition: color var(--transition-fast), background var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}
.launcher-close:hover {
  color: var(--text-2);
  background: rgba(129, 212, 250, 0.06);
}

.launcher-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: rgba(129, 212, 250, 0.06);
}

.launcher-item {
  background: rgba(13, 20, 35, 0.95);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.launcher-item:hover {
  background: rgba(129, 212, 250, 0.05);
}
.launcher-item:active {
  background: rgba(129, 212, 250, 0.10);
}

.launcher-item-name {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-2);
  text-align: center;
  line-height: 1.2;
}
.launcher-item.is-active .launcher-item-name {
  color: var(--text);
}

.launcher-item-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--border-2);
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
}
.launcher-item.is-active .launcher-item-dot {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(129, 212, 250, 0.45);
}

.launcher-item-status {
  font-size: 0.60rem;
  color: var(--text-3);
  letter-spacing: 0.05em;
}
.launcher-item.is-active .launcher-item-status {
  color: var(--green);
}

/* ── Desktop refinements ────────────────────────────────── */
@media (min-width: 768px) {
  .bottom-nav {
    border-top: 1px solid rgba(129, 212, 250, 0.08);
  }

  .nav-item-label {
    font-size: 0.70rem;
  }

  .nav-m-button {
    width: 54px;
    height: 54px;
    top: -24px;
  }

  .nav-m-logo {
    width: 38px;
    height: 38px;
  }
}

/* ── Reduced motion ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .nav-m-button,
  .bottom-nav::before,
  .bottom-nav.launcher-open::before {
    animation: none;
  }
  .nav-m-button,
  .nav-item,
  .launcher-sheet,
  .launcher-backdrop {
    transition: none;
  }
}

/* ── Light theme overrides ────────────────────────────── */
[data-theme="light"] .bottom-nav {
  background: rgba(235, 243, 249, 0.95);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
}

[data-theme="light"] .nav-item-label {
  color: var(--text-3);
}

[data-theme="light"] .nav-item-label.active,
[data-theme="light"] .nav-item.active .nav-item-label {
  color: var(--accent);
}

[data-theme="light"] .launcher-orb-btn {
  background: radial-gradient(
    ellipse at center,
    rgba(2, 136, 209, 0.18) 0%,
    rgba(2, 136, 209, 0.08) 50%,
    rgba(235, 243, 249, 0.75) 100%
  );
  box-shadow:
    0 0 0 1px rgba(2, 136, 209, 0.25),
    0 0 0 4px rgba(235, 243, 249, 0.9),
    0 0 0 5px rgba(2, 136, 209, 0.10),
    0 8px 24px rgba(0, 0, 0, 0.12);
}
