/* ========================================
   VINSNAP COMMUNITY NAV — MODE TOGGLE & SOCIAL FEATURES
   ======================================== */

/* ========================================
   MODE TOGGLE SWITCH
   ======================================== */

.mode-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px 18px 16px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(34, 211, 166, 0.0441);
  position: relative;
}

.mode-toggle-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              text-shadow 0.3s ease;
  user-select: none;
  white-space: nowrap;
}

.mode-toggle-label.active {
  color: var(--text-primary);
  text-shadow: 0 0 12px rgba(34, 211, 166, 0.147);
}

/* Toggle track — garage state (default): cyan tint */
.mode-toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: rgba(14, 165, 233, 0.049);
  border: 1.5px solid rgba(14, 165, 233, 0.1078);
  border-radius: 12px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.35s ease,
              box-shadow 0.35s ease;
}

.mode-toggle-switch:hover {
  border-color: rgba(14, 165, 233, 0.196);
  box-shadow: 0 0 8px rgba(14, 165, 233, 0.0735);
}

/* Toggle knob — garage state (default): cyan */
.mode-toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: linear-gradient(135deg, #0EA5E9 0%, #22D3A6 100%);
  border-radius: 50%;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
              background 0.35s ease,
              box-shadow 0.35s ease;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4),
              0 0 0 2px rgba(14, 165, 233, 0.0882);
}

/* Community-active state — knob slides right, AMBER lights up */
.mode-toggle-switch.community-active {
  background: linear-gradient(135deg, rgba(251, 146, 60, 0.18) 0%, rgba(250, 204, 21, 0.22) 100%);
  border-color: rgba(251, 146, 60, 0.4);
  box-shadow: 0 0 14px rgba(251, 146, 60, 0.18),
              inset 0 1px 2px rgba(255, 255, 255, 0.06);
}

.mode-toggle-switch.community-active::after {
  transform: translateX(20px);
  background: var(--dash-amber-grad);
  box-shadow: 0 1px 8px rgba(251, 146, 60, 0.45),
              0 0 0 2px rgba(251, 146, 60, 0.18);
}

/* ========================================
   COMMUNITY NAV SECTION (sidebar)
   ======================================== */

.nav-section-community {
  display: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.nav-section-community.visible {
  display: block;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  animation: communityNavIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes communityNavIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================
   APP-LEVEL MODE SWITCHING
   Toggling #app class controls garage vs community nav visibility
   ======================================== */

/* When community mode is active, hide garage nav sections and show community section */
.app-mode-community .nav-section-garage,
.app-mode-community .nav-section-primary {
  display: none;
}

.app-mode-community .nav-section-community {
  display: block;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ========================================
   NOTIFICATION BADGE
   ======================================== */

.community-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 8px;
  letter-spacing: 0;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.5);
  animation: badgeEnter 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Position badge over the icon in mobile nav */
.mobile-nav-item .community-unread-badge {
  position: absolute;
  top: 2px;
  right: 8px;
  z-index: 2;
  border: 2px solid var(--primary-bg, #070c16);
}

/* Hide badge when count is 0 */
.community-unread-badge[data-count="0"],
.community-unread-badge:empty {
  display: none;
}

@keyframes badgeEnter {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Subtle pulse for non-zero badge counts */
.community-unread-badge:not(:empty) {
  animation: badgeEnter 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both,
             badgeBreath 3s ease-in-out 0.5s infinite;
}

@keyframes badgeBreath {
  0%, 100% {
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.45),
                0 0 0 2px rgba(239, 68, 68, 0.15);
  }
  50% {
    box-shadow: 0 2px 14px rgba(239, 68, 68, 0.65),
                0 0 0 3px rgba(239, 68, 68, 0.2);
  }
}

/* ========================================
   MOBILE BOTTOM NAV — COMMUNITY ITEMS
   ======================================== */

.mobile-nav-community {
  display: none;
  align-items: center;
  justify-content: space-around;
  width: 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.mobile-nav-community.visible {
  display: flex;
  opacity: 1;
  pointer-events: auto;
  animation: mobileNavFadeIn 0.25s ease forwards;
}

@keyframes mobileNavFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Hide garage mobile nav items when community mode active */
.mobile-nav-item.hidden {
  display: none !important;
}

/* Social switch button — subtle accent glow in garage mode */
.mobile-nav-switch-community .mobile-nav-icon {
  filter: hue-rotate(0deg);
}
.mobile-nav-switch-community .mobile-nav-label {
  color: #5eead4;
}

/* ========================================
   COMMUNITY CREATE POST FAB
   Floating action button — bottom-right, mobile only
   ======================================== */

.community-fab {
  display: none; /* hidden until community mode activates */
  position: fixed;
  bottom: calc(70px + env(safe-area-inset-bottom, 0px)); /* sits above mobile nav bar */
  right: 20px;
  z-index: 900;

  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;

  background: linear-gradient(135deg, #22D3A6 0%, #6366f1 50%, #0EA5E9 100%);
  color: #ffffff;
  font-size: 28px;
  font-weight: 300;
  line-height: 1;

  align-items: center;
  justify-content: center;

  box-shadow: 0 6px 20px rgba(34, 211, 166, 0.147),
              0 2px 8px rgba(0, 0, 0, 0.35),
              inset 0 1px 2px rgba(255, 255, 255, 0.2);

  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.25s ease,
              background 0.25s ease;

  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Show FAB in community mode */
.app-mode-community .community-fab {
  display: flex;
}

/* Hide FAB when post composer is open */
body:has(.post-composer-overlay.open) .community-fab {
  display: none !important;
}

@media (min-width: 769px) {
  .community-fab {
    bottom: 32px;
    right: 32px;
  }
}

/* Mobile: reposition FAB into center of bottom nav bar */
/* Spacer in mobile nav to make room for centered FAB */
.mobile-nav-fab-spacer {
  width: 64px;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .app-mode-community .community-fab {
    position: fixed;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%) translateY(-12px);
    right: auto;
    z-index: 1001;
    width: 52px;
    height: 52px;
    border: none;
  }

  .app-mode-community .community-fab:active {
    transform: translateX(-50%) translateY(-12px) scale(0.92);
  }
}

.community-fab:hover {
  transform: translateY(-3px) scale(1.06);
  box-shadow: 0 10px 28px rgba(34, 211, 166, 0.1911),
              0 4px 12px rgba(0, 0, 0, 0.4),
              inset 0 1px 2px rgba(255, 255, 255, 0.25);
  background: linear-gradient(135deg, #9d6ef8 0%, #7577f5 50%, #8b4ef0 100%);
}

.community-fab:active {
  transform: translateY(-1px) scale(0.97);
  box-shadow: 0 4px 14px rgba(34, 211, 166, 0.1323),
              0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

/* "+" icon inside FAB — can be a child span or rely on button text */
.community-fab::before {
  content: '+';
  display: block;
  font-size: 30px;
  font-weight: 200;
  line-height: 1;
  color: #ffffff;
  margin-top: -1px; /* optical centering */
}

/* If an inner element provides the icon, hide the pseudo-element */
.community-fab > * {
  position: relative;
  z-index: 1;
}

/* Ripple / press feedback */
.community-fab::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0);
  transition: background 0.2s ease;
}

.community-fab:active::after {
  background: rgba(255, 255, 255, 0.12);
}

/* ========================================
   REDUCED MOTION SUPPORT
   ======================================== */

@media (prefers-reduced-motion: reduce) {
  .mode-toggle-switch,
  .mode-toggle-switch::after,
  .mode-toggle-label,
  .nav-section-community,
  .mobile-nav-community,
  .community-fab,
  .community-unread-badge {
    transition: none;
    animation: none;
  }
}
