Thanks for that update. Let’s fix this step by step — your original dark mode CSS was working, except for the mobile menu in the Twenty Twenty-Five theme. Now it's completely broken when we've overcomplicated it — let’s roll it back and approach this with clarity.
✅ GOAL:
- Dark mode styles applied via
@media (prefers-color-scheme: dark) should continue working.
- Mobile menu opened after clicking the hamburger (in the Twenty Twenty-Five theme) should also reflect dark mode styles (text/background/colors).
🧠 What likely happened:
The recent CSS or JavaScript overrides broke the working dark mode, likely due to:
- Bad specificity causing overrides to fail.
- Incorrect media query nesting.
- Overuse of universal selectors (
*), which interfere with cascade order.
- JavaScript changing styles suddenly/caching issues.
✅ Step-by-Step Fix
🔄 1. Start with a cleaned-up @media query (WHAT WORKED)
Let’s go back to your original, working dark mode CSS and simply expand it incrementally to target the mobile menu.
Keep everything you already have, but ADD JUST THIS BLOCK at the end of your dark mode CSS:
/* Add inside your existing @media (prefers-color-scheme: dark) { ... } */
@media (max-width: 782px) {
/* This targets the open mobile menu in Twenty Twenty-Five */
.wp-block-navigation__responsive-container.is-menu-open,
.wp-block-navigation__responsive-container.is-menu-open * {
background-color: #121212 !important;
color: #f5f0e1 !important;
}
/* Target specific menu item links in mobile */
.wp-block-navigation__responsive-container.is-menu-open a {
color: #FFD700 !important; /* Gold for visible links */
}
/* Target headings (site title inside menu, if present) */
.wp-block-navigation__responsive-container.is-menu-open h1,
.wp-block-navigation__responsive-container.is-menu-open h2,
.wp-block-navigation__responsive-container.is-menu-open h3 {
color: #8AFFFF !important;
}
}
✅ Explanation:
Twenty Twenty-Five uses block-based navigation and a responsive container with the class:
.wp-block-navigation__responsive-container.is-menu-open
That means your selectors must target that class when the hamburger menu is opened.
💡 Bonus tip: Check styles aren’t cached
If you're not seeing any changes:
- Clear browser cache
- Completely hard refresh (
Cmd+Shift+R / Ctrl+Shift+R)
- If you're using a caching plugin (like WP Rocket, W3 Total Cache), purge all caches
- Ensure your changes are in a CSS file or Customizer that is still loaded
🧪 Test Results
Here's a full working minimal snippet:
@media (prefers-color-scheme: dark) {
body {
background-color: #121212 !important;
color: #f5f0e1 !important;
}
p, span, a, div, li, td, th, label, input, textarea, button {
color: #f5f0e1 !important;
}
h1, h2, h3, h4, h5, h6 {
color: #FFD700 !important;
}
.site-title a {
color: #FFD700 !important;
-webkit-text-fill-color: #FFD700 !important;
}
/* 🔧 Mobile menu fix */
@media (max-width: 782px) {
.wp-block-navigation__responsive-container.is-menu-open,
.wp-block-navigation__responsive-container.is-menu-open * {
background-color: #121212 !important;
color: #f5f0e1 !important;
}
.wp-block-navigation__responsive-container.is-menu-open a {
color: #FFD700 !important;
}
.wp-block-navigation__responsive-container.is-menu-open h1,
.wp-block-navigation__responsive-container.is-menu-open h2,
.wp-block-navigation__responsive-container.is-menu-open h3 {
color: #8AFFFF !important;
}
}
}
🎯 Final Checklist
| Check | Item |
|---|
| ✅ | Dark mode works on main site |
| ✅ | Dark mode applies to mobile menu after clicking hamburger |
| ✅ | Site title = gold |
| ✅ | Headings inside mobile menu = light cyan |
| ✅ | Normal links = light gold or off-white |
If it still doesn’t work — please:
- Paste just the relevant HTML from DevTools showing the menu that opens
- Show your site URL (if public)
- Confirm how you're applying custom CSS (Customizer > Additional CSS, child theme, plugin?)
This fixes most dark mode + mobile menu problems with block themes like Twenty Twenty-Five. Let me know how it goes.