diff --git a/index.html b/index.html index 60fcbc9..f90ce20 100644 --- a/index.html +++ b/index.html @@ -252,6 +252,20 @@ }); for (var a of menu.querySelectorAll('a')) { a.addEventListener('click', closeMenu); } } + var nav = document.getElementById('nav'); + var sections = Array.prototype.slice.call(document.querySelectorAll('[data-bg]')); + function updateNavTheme() { + var dark = false; + for (var s of sections) { + var r = s.getBoundingClientRect(); + if (r.top <= 30 && r.bottom > 30) { dark = (s.dataset.bg === 'dark'); break; } + } + nav.classList.toggle('on-dark', dark); + if (menu) menu.classList.toggle('on-dark', dark); + } + updateNavTheme(); + window.addEventListener('scroll', function () { window.requestAnimationFrame(updateNavTheme); }, { passive: true }); + window.addEventListener('resize', updateNavTheme); })(); diff --git a/style.css b/style.css index 7dd5d6f..46eea09 100644 --- a/style.css +++ b/style.css @@ -95,6 +95,17 @@ a.tel { text-decoration: none; } .nav-mobile-menu .nav-cta { color: #fff !important; } @keyframes navFadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } } +/* Adaptive: over a dark section, flip nav + menu to dark frosted with light text */ +.nav.on-dark { background: rgba(15, 23, 41, 0.5); border-bottom-color: rgba(247, 244, 239, 0.14); } +.nav.on-dark .nav-links-desktop a { color: rgba(247, 244, 239, 0.85); } +.nav.on-dark .nav-links-desktop a:hover { color: #fff; } +.nav.on-dark .nav-logo-img { filter: brightness(0) invert(1); } +.nav.on-dark .nav-toggle-icon .bar, .nav.on-dark .nav-toggle-icon .o-ring { stroke: #f7f4ef; } +.nav-mobile-menu.on-dark { background: rgba(15, 23, 41, 0.55); border-bottom-color: rgba(247, 244, 239, 0.14); } +.nav-mobile-menu.on-dark a { color: rgba(247, 244, 239, 0.9); } +.nav-mobile-menu.on-dark a:hover { color: #fff; } +.nav-mobile-menu.on-dark .nav-cta { color: #fff !important; } + @media (max-width: 900px) { .nav { padding: 0.7rem 1.5rem; } .nav-links-desktop { display: none; }