/* ═══════════════════════════════════════════════════════════════════════════
   KrümelBot — Top Navigation v2 (.tnv)
   ═══════════════════════════════════════════════════════════════════════════ */

.topnav.tnv {
  --tnv-h: 56px;
  --tnv-border: rgba(255, 255, 255, 0.08);
  --tnv-accent: #3b82f6;
  display: block;
  height: var(--tnv-h);
  padding: 0;
  background: rgba(6, 6, 12, 0.88);
  border-bottom: 1px solid var(--tnv-border);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topnav.tnv::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.35), transparent);
  pointer-events: none;
}

.tnv-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  height: var(--tnv-h);
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 18px;
}

.tnv-left {
  display: flex;
  align-items: center;
  justify-self: start;
}

.tnv-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 8px 6px 6px;
  border-radius: 12px;
  border: none;
  background: transparent;
  color: #fff;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease;
}

.tnv-brand:hover {
  background: rgba(255, 255, 255, 0.06);
  opacity: 1;
}

.tnv-brand.is-active .tnv-brand-mark {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5), 0 4px 16px rgba(124, 58, 237, 0.4);
}

.tnv-brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 0.88rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(145deg, #2563eb 0%, #4f46e5 55%, #312e81 100%);
  box-shadow: 0 2px 12px rgba(124, 58, 237, 0.35);
  flex-shrink: 0;
}

.tnv-brand-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: 0;
}

.tnv-brand-text .topnav-name {
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.tnv-beta {
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #93c5fd;
}

/* Center nav */
.tnv-center {
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
}

.tnv-pills {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--tnv-border);
}

.tnv-pills.hidden {
  display: none !important;
}

.tnv-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.tnv-pill svg {
  opacity: 0.75;
  flex-shrink: 0;
}

.tnv-pill:hover {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.06);
}

.tnv-pill.is-active {
  color: #fff;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.45), rgba(109, 40, 217, 0.25));
  border-color: rgba(96, 165, 250, 0.35);
  box-shadow: 0 2px 10px rgba(109, 40, 217, 0.25);
}

.tnv-pill.is-active svg {
  opacity: 1;
  color: #bfdbfe;
}

.tnv-context {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(280px, 40vw);
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(52, 211, 153, 0.25);
  background: rgba(52, 211, 153, 0.08);
}

.tnv-context.hidden {
  display: none !important;
}

.tnv-context-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.25);
  flex-shrink: 0;
  animation: tnv-pulse 2s ease-in-out infinite;
}

@keyframes tnv-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.tnv-context-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.88);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Right actions */
.tnv-right {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-self: end;
}

.tnv-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}

.tnv-action--vote {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(96, 165, 250, 0.28);
  color: #93c5fd;
}

.tnv-action--vote:hover {
  background: rgba(59, 130, 246, 0.22);
  border-color: rgba(96, 165, 250, 0.45);
  color: #bfdbfe;
  transform: translateY(-1px);
}

/* User menu */
.tnv-user {
  position: relative;
}

.tnv-user-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 4px 10px 4px 4px;
  border-radius: 12px;
  border: 1px solid var(--tnv-border);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.tnv-user-btn:hover,
.tnv-user-btn[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.tnv-user-av-wrap {
  position: relative;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.tnv-user-av-wrap::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  opacity: 0.65;
  z-index: 0;
}

.tnv-user-av {
  position: relative;
  z-index: 1;
  width: 32px !important;
  height: 32px !important;
  border-radius: 50%;
  border: 2px solid rgba(8, 8, 14, 0.9);
  object-fit: cover;
}

.tnv-user-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  min-width: 0;
  max-width: 120px;
}

.tnv-user-name {
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.tnv-user-sub {
  font-size: 0.65rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.4);
  line-height: 1.2;
}

.tnv-user-chev {
  color: rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}

.tnv-user-btn[aria-expanded="true"] .tnv-user-chev {
  transform: rotate(180deg);
}

/* Profile dropdown v2 */
.topnav.tnv .tnv-drop {
  width: 268px;
  padding: 8px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 10, 18, 0.98);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 24px 56px rgba(0, 0, 0, 0.6);
  animation: tnv-drop-in 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes tnv-drop-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.tnv-drop-header {
  margin-bottom: 4px;
}

.tnv-drop-head {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(255, 255, 255, 0.03));
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.tnv-drop-head:hover {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.22), rgba(255, 255, 255, 0.06));
}

.tnv-drop-av {
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}

.tnv-drop-head-info {
  flex: 1;
  min-width: 0;
}

.tnv-drop-name {
  font-size: 0.92rem;
  font-weight: 800;
  color: #fff;
}

.tnv-drop-sub {
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 2px;
}

.tnv-drop-head-arrow {
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.35);
}

.tnv-drop-body {
  padding: 2px 0 4px;
}

.tnv-drop-group-label {
  margin: 10px 10px 4px;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.32);
}

.topnav.tnv .profile-drop-item {
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 0.84rem;
}

.topnav.tnv .profile-drop-item svg {
  width: 16px;
  height: 16px;
  padding: 7px;
  box-sizing: content-box;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  opacity: 0.9;
}

.topnav.tnv .profile-drop-item:hover svg {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.25);
}

.topnav.tnv .tnv-drop-logout {
  margin-top: 6px;
}

.topnav.tnv .tnv-drop-logout svg {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.2);
}

/* Light theme */
body.is-light .topnav.tnv {
  background: rgba(255, 255, 255, 0.92);
  --tnv-border: rgba(26, 16, 51, 0.1);
}

body.is-light .tnv-brand:hover {
  background: rgba(109, 40, 217, 0.06);
}

body.is-light .tnv-brand-text .topnav-name {
  color: #1a1033;
}

body.is-light .tnv-pills {
  background: rgba(109, 40, 217, 0.06);
  border-color: rgba(26, 16, 51, 0.08);
}

body.is-light .tnv-pill {
  color: rgba(26, 16, 51, 0.55);
}

body.is-light .tnv-pill.is-active {
  color: #1e3a8a;
  background: rgba(109, 40, 217, 0.15);
}

body.is-light .tnv-context {
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(16, 185, 129, 0.25);
}

body.is-light .tnv-context-label {
  color: #1a1033;
}

body.is-light .tnv-user-btn {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(26, 16, 51, 0.1);
}

body.is-light .tnv-user-name {
  color: #1a1033;
}

body.is-light .topnav.tnv .tnv-drop {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(26, 16, 51, 0.1);
  box-shadow: 0 20px 48px rgba(109, 40, 217, 0.12);
}

body.is-light .tnv-drop-name {
  color: #1a1033;
}

/* Mobile */
@media (max-width: 900px) {
  .tnv-inner {
    grid-template-columns: auto 1fr auto;
    padding: 0 12px;
    gap: 10px;
  }

  .tnv-center {
    justify-self: stretch;
    min-width: 0;
  }

  .tnv-pills {
    width: 100%;
    justify-content: center;
  }

  .tnv-pill {
    flex: 1;
    justify-content: center;
    padding: 7px 10px;
    font-size: 0.78rem;
  }

  .tnv-pill svg {
    display: none;
  }

  .tnv-action--vote {
    width: 36px;
    padding: 0;
    justify-content: center;
  }

  .tnv-user-meta,
  .tnv-user-chev {
    display: none;
  }

  .tnv-user-btn {
    padding: 4px;
    width: 40px;
    justify-content: center;
  }

  .tnv-brand-text .topnav-name {
    display: none;
  }

  .tnv-beta {
    display: none;
  }
}

@media (max-width: 480px) {
  .tnv-context {
    max-width: 140px;
    padding: 6px 10px;
  }

  .tnv-context-label {
    font-size: 0.75rem;
  }
}
