.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  /* Subtle fade-in on load + a soft shadow that eases in once scrolled. */
  animation: nav-fade-in 0.4s var(--ease) both;
  transition: box-shadow 0.3s var(--ease), border-color 0.3s var(--ease);
}
.nav.is-scrolled {
  box-shadow: var(--shadow-sm);
  border-bottom-color: transparent;
}
@keyframes nav-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.nav-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 24px;
}

.nav-logo {
  display: inline-flex;
  align-items: center;
  color: var(--text);
  flex: 0 0 auto;
}
.nav-logo-img {
  height: 40px;
  width: auto;
  max-width: 100%;
  /* object-fit guards the aspect ratio so the wordmark never stretches even
     if a flex parent tries to size it. */
  object-fit: contain;
  display: block;
  letter-spacing: -0.01em;
}
@media (prefers-color-scheme: dark) {
  /* The dark-variant artwork is dark-on-light; lift it to stay legible on the
     dark nav background. */
  .nav-logo-img { filter: invert(1) hue-rotate(180deg); }
}

/* Order: Logo, Search, Menu (.nav-links), User actions (.nav-cta).
   The search takes the left-of-centre space; the menu + actions are pushed
   to the right as a group (margin-left:auto on .nav-links). */
.nav-search {
  flex: 1 1 auto;   /* fill all the room between the logo and the menu */
  min-width: 0;
}

/* Home/feed: hidden until the user scrolls past the hero search. Fades in/out
   smoothly; nav.js toggles .is-visible. Space is reserved either way so the
   menu/actions don't shift when it appears. */
.nav-search--reveal {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}
.nav-search--reveal.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
@media (prefers-reduced-motion: reduce) {
  .nav { animation: none; }
  .nav-search--reveal { transition: none; }
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.nav-link {
  position: relative;
  padding: 8px 12px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  opacity: 0.9;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  transition: color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.nav-link:hover { color: var(--text); background-color: var(--surface)}
.nav-link.is-active {
  color: var(--unique);
}

/* ---- Hover dropdowns (Explore / Platform) ------------------------------- */
.nav-group { position: relative; display: flex; align-items: center; }

/* The trigger reuses .nav-link; reset button chrome + add the caret gap. */
.nav-group-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}
.nav-group-caret {
  font-size: 10px;
  opacity: 0.55;
  transition: transform 0.15s var(--ease);
}
.nav-group:hover .nav-group-caret,
.nav-group:focus-within .nav-group-caret { transform: rotate(180deg); }

.nav-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  padding-top: 8px;            /* invisible bridge so hover survives the gap */
  min-width: 200px;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.16s var(--ease), transform 0.16s var(--ease), visibility 0.16s var(--ease);
}
.nav-group:hover .nav-dropdown,
.nav-group:focus-within .nav-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.nav-dropdown-panel {
  display: flex;
  flex-direction: column;
  padding: 6px;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.nav-dropdown-item {
  display: block;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  text-decoration: none;
  transition: color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.nav-dropdown-item:hover { background: var(--surface); color: var(--unique); }
.nav-dropdown-item.is-active { color: var(--unique); }

@media (prefers-reduced-motion: reduce) {
  .nav-dropdown { transition: opacity 0.16s linear, visibility 0.16s linear; transform: none; }
  .nav-group:hover .nav-dropdown,
  .nav-group:focus-within .nav-dropdown { transform: none; }
  .nav-group-caret { transition: none; }
}

.nav-cta {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ---- Nav search bar (same control as the home hero search) -------------- */
.hero-search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 7px 7px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.hero-search:focus-within {
  border-color: var(--unique);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--unique) 18%, transparent);
}

.hero-search-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  padding: 0 6px;
}
.hero-search-input:focus { outline: none; }
.hero-search-input::placeholder { color: var(--text-muted); }

.hero-search-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--text);
  color: var(--background);
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.12s var(--ease), opacity 0.15s var(--ease);
}
.hero-search-btn:hover { opacity: 0.9; }
.hero-search-btn:active { transform: scale(0.94); }

/* Dropdown menus */
.menu-host { position: relative; }
.menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 6px;
  display: none;
  z-index: 50;
}
.menu.is-open { display: block; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text);
}
.menu-item:hover { background: var(--surface); }
.menu-item .menu-icon {
  width: 18px;
  text-align: center;
  font-size: 15px;
  color: var(--text-muted);
}
.menu-item:hover .menu-icon { color: var(--unique); }
.menu-item .menu-sub {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Avatar button */
.avatar-btn {
  width: 50px; height: 50px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface);
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  font-weight: 600;
  color: var(--text);
}
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }

/* No-photo fallback: a padded plane emoji injected by nav.js when an avatar
   image fails to load. Fills whatever round/square avatar holder it lands in. */
.avatar-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  line-height: 1;
  background: var(--surface);
  user-select: none;
}

/* Notification bell */
.notif-bell {
  position: relative;
  width: 50px; height: 50px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  border-radius: 50%;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.notif-bell:hover {
  background: var(--surface);
  color: var(--text);
}
.notif-bell:active { transform: scale(0.92); }
.notif-bell.has-unread { color: var(--unique); }

.notif-bell i { font-size: 20px; line-height: 1; }
/* Subtle ring on unread - animates once when the page loads and pauses on hover. */
.notif-bell .ringing {
  transform-origin: top center;
  animation: bell-ring 2.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) 0.6s 1;
}
.notif-bell:hover .ringing { animation: none; }
@keyframes bell-ring {
  0%   { transform: rotate(0); }
  3%   { transform: rotate(14deg); }
  6%   { transform: rotate(-12deg); }
  9%   { transform: rotate(10deg); }
  12%  { transform: rotate(-8deg); }
  15%  { transform: rotate(6deg); }
  18%  { transform: rotate(-4deg); }
  21%  { transform: rotate(0); }
  100% { transform: rotate(0); }
}

/* Badge - pill with a faint pulse halo and a clean entry */
.notif-bell .badge {
  position: absolute;
  top: 4px; right: 4px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  border: 2px solid var(--background);
  box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.45);
  animation: badge-in 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28), badge-pulse 2.2s ease-out 1.5s infinite;
}
@keyframes badge-in {
  from { transform: scale(0.4); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
@keyframes badge-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(225, 29, 72, 0.45); }
  70%  { box-shadow: 0 0 0 8px rgba(225, 29, 72, 0); }
  100% { box-shadow: 0 0 0 0   rgba(225, 29, 72, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .notif-bell .ringing,
  .notif-bell .badge { animation: none; }
}

/* Hamburger button - hidden on desktop, revealed at the mobile breakpoint. */
.nav-burger {
  display: none;
  margin-left: auto;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: var(--radius-md);
  background: none;
  border: 0;
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.15s var(--ease);
}
.nav-burger:hover { background: var(--surface); }
.nav-burger i { font-size: 22px; line-height: 1; }

/* Mobile drawer - drops below the sticky header, holds every menu item. */
.nav-mobile {
  display: none;
  position: absolute;
  top: var(--nav-h);
  left: 0;
  right: 0;
  background: var(--background);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  padding: 8px;
  max-height: calc(100vh - var(--nav-h));
  overflow-y: auto;
}
.nav-mobile.is-open { display: block; }

.nav-mobile-links { display: block; }
.nav-mobile-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  font-size: 17px;
  font-weight: 500;
  color: var(--text);
  border-radius: var(--radius-sm);
}
.nav-mobile-link:hover { background: var(--surface); }
.nav-mobile-link.is-active { color: var(--unique); }
/* Group heading (Explore / Platform) in the mobile drawer */
.nav-mobile-group-label {
  padding: 12px 12px 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.nav-mobile-group-label:first-child { padding-top: 4px; }
.nav-mobile-link .menu-icon {
  width: 20px;
  text-align: center;
  color: var(--text-muted);
}
.nav-mobile-link--primary { color: var(--unique); }
.nav-mobile-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}
.nav-mobile-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 4px;
}

/* Mobile (desktop-first): swap the inline links/CTA for the hamburger drawer. */
@media (max-width: 768px) {
  .nav { height: 70px; }
  .nav-logo-img { height: 35px; }
  .nav-inner { gap: 12px; padding: 0px; }
  .nav-search { display: none; }
  .nav-links { display: none; }
  .nav-cta { display: none; }
  .nav-burger { display: inline-grid; }
}

/* Above the breakpoint the drawer can never show, even if left open on resize. */
@media (min-width: 769px) {
  .nav-mobile { display: none !important; }
}
