/* ===== TOP NAV ===== */
.topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  height: 64px;
  background: rgba(15,17,23,0.85);
  backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}

.topnav-logo {
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-decoration: none;
}

.topnav-logo:hover { text-decoration: none; }

.topnav-logo .name {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.3px;
}

.topnav-logo .sub {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.topnav-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.topnav-right a {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.topnav-right a:hover { color: var(--text); text-decoration: none; }

.topnav-right .badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--green);
  border: 1px solid #2ecc7144;
  padding: 3px 10px;
  border-radius: 100px;
  letter-spacing: 0.5px;
}

/* ===== In-page section nav ===== */
.topnav-sections {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-right: 6px;
}

.topnav-sections a {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.topnav-sections a:hover {
  color: var(--text);
  text-decoration: none;
}

.topnav-sections a.active {
  color: var(--text);
  border-bottom-color: var(--red-light);
}

/* Hamburger (hidden on desktop) */
.topnav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  width: 36px;
  height: 32px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.topnav-toggle svg { width: 18px; height: 18px; }

/* ===== TABLET: collapse section nav when crowded ===== */
@media (max-width: 900px) {
  .topnav-sections {
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: rgba(15,17,23,0.97);
    backdrop-filter: blur(16px) saturate(1.4);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    gap: 0;
    padding: 8px 16px;
    margin-right: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease, padding 0.25s ease;
  }

  .topnav-sections.open {
    max-height: 400px;
    padding: 8px 16px 16px;
  }

  .topnav-sections a {
    padding: 12px 4px;
    border-bottom: 1px solid var(--border);
    width: 100%;
  }

  .topnav-sections a:last-child { border-bottom: none; }

  .topnav-sections a.active {
    border-bottom-color: var(--border);
    color: var(--red-light);
  }

  .topnav-toggle { display: inline-flex; }
}

/* ===== MOBILE ===== */
@media (max-width: 640px) {
  .topnav { padding: 0 16px; }
  .topnav-logo .name { font-size: 15px; }
  .topnav-logo .sub { display: none; }
  .topnav-right .badge { display: none; }
  .topnav-right a[href*="github"] { display: none; }
}
