I am confused by a basic feature of US constitutional law. Does the US constitution restrict state laws as well as federal ones? Specifically, can a state law (or even a city law) ban the possession of guns or, say, the sale of pornography?
No. The Fourteenth Amendment prevents this (it was originally implemented to enforce the 13th Amendment on the States, when the Confederate states returned to the Union after the Civil War.).
The idea here is that if the Constitution says it is a right of the People, all citizens of the Federal Nation must be afforded the right. Now, the Constitution does allow for regulation by states and lower levels of government. All Federal Level Gun regulation is based on the Interstate Commerce Clause for justification. The States may further regulate so long as that regulation does not ban the sale of fire arms (Though some states will try to make effective bans.).
SCOTUS case Heller v. D.C. effectively confirmed this by overturning a Washington D.C. law banning the use of Fire Arms for self-defense in private property.