function Navbar() {
  const [scrolled, setScrolled] = React.useState(false);
  const [menuOpen, setMenuOpen] = React.useState(false);

  React.useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 50);
    window.addEventListener('scroll', onScroll, { passive: true });
    return () => window.removeEventListener('scroll', onScroll);
  }, []);

  React.useEffect(() => {
    document.body.style.overflow = menuOpen ? 'hidden' : '';
    return () => { document.body.style.overflow = ''; };
  }, [menuOpen]);

  const links = ['Menu', 'Events', 'Gallery', 'About'];
  const WA_HREF = "https://wa.me/23058582020?text=Hi%2C%20I'd%20like%20to%20make%20a%20reservation%20at%20After5%20Lounge%20Bar";

  return (
    <>
      <style>{`
        /* ── Base nav ── */
        .a5-nav {
          position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
          height: 80px;
          display: flex; align-items: center;
          padding: 0 48px;
          transition: background 0.45s cubic-bezier(0.16,1,0.3,1),
                      border-color 0.45s cubic-bezier(0.16,1,0.3,1);
          border-bottom: 1px solid transparent;
        }
        .a5-nav.scrolled {
          background: rgba(12,12,12,0.96);
          backdrop-filter: blur(24px);
          -webkit-backdrop-filter: blur(24px);
          border-bottom-color: rgba(255,255,255,0.07);
        }

        /* ── Logo ── */
        .a5-logo {
          width: 54px; height: 54px;
          border-radius: 50%;
          object-fit: cover; flex-shrink: 0;
          transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1),
                      opacity 0.25s ease;
          display: block;
        }
        .a5-logo:hover { transform: scale(1.06); opacity: 0.88; }

        /* ── Center links ── */
        .a5-links {
          position: absolute; left: 50%; transform: translateX(-50%);
          display: flex; align-items: center; gap: 44px;
          list-style: none;
        }
        .a5-link {
          font-family: 'Josefin Sans', sans-serif;
          font-size: 10.5px; font-weight: 400;
          letter-spacing: 0.25em; text-transform: uppercase;
          color: rgba(255,255,255,0.65);
          text-decoration: none;
          position: relative; padding: 6px 0;
          transition: color 0.22s ease;
        }
        .a5-link::after {
          content: '';
          position: absolute; bottom: 0; left: 0;
          width: 0; height: 1px;
          background: #E84800;
          transition: width 0.32s cubic-bezier(0.16,1,0.3,1);
        }
        .a5-link:hover { color: #fff; }
        .a5-link:hover::after { width: 100%; }
        .a5-link:focus-visible {
          outline: none; color: #fff;
          box-shadow: 0 0 0 2px rgba(232,72,0,0.5);
          border-radius: 2px;
        }

        /* ── Reserve CTA ── */
        .a5-reserve {
          font-family: 'Josefin Sans', sans-serif;
          font-size: 10.5px; font-weight: 600;
          letter-spacing: 0.22em; text-transform: uppercase;
          color: #fff; background: #E84800;
          border: none; padding: 11px 26px;
          border-radius: 100px; cursor: pointer;
          text-decoration: none;
          display: inline-flex; align-items: center; gap: 8px;
          box-shadow: 0 4px 22px rgba(232,72,0,0.32);
          transition: background 0.22s ease,
                      transform 0.22s cubic-bezier(0.34,1.56,0.64,1),
                      box-shadow 0.22s ease;
          white-space: nowrap;
        }
        .a5-reserve:hover {
          background: #ff5c1a;
          transform: translateY(-2px);
          box-shadow: 0 8px 32px rgba(232,72,0,0.48);
        }
        .a5-reserve:active {
          transform: translateY(0);
          box-shadow: 0 3px 14px rgba(232,72,0,0.28);
        }
        .a5-reserve:focus-visible {
          outline: 2px solid rgba(232,72,0,0.7);
          outline-offset: 3px;
        }

        /* ── Nav right slot ── */
        .a5-nav-right {
          margin-left: auto;
          display: flex; align-items: center; gap: 16px;
        }

        /* ── Hamburger ── */
        .a5-hamburger {
          display: none;
          flex-direction: column; justify-content: center; gap: 5px;
          width: 36px; height: 36px;
          cursor: pointer; background: none; border: none;
          padding: 4px; flex-shrink: 0;
        }
        .a5-hline {
          width: 22px; height: 1.5px;
          background: rgba(255,255,255,0.88);
          border-radius: 2px; transform-origin: center;
          transition: transform 0.38s cubic-bezier(0.16,1,0.3,1),
                      opacity 0.22s ease, width 0.3s ease;
        }
        .a5-hamburger.open .a5-hline:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
        .a5-hamburger.open .a5-hline:nth-child(2) { opacity: 0; width: 0; }
        .a5-hamburger.open .a5-hline:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }
        .a5-hamburger:focus-visible { outline: 2px solid rgba(232,72,0,0.6); border-radius: 4px; }

        /* ── Mobile overlay ── */
        .a5-mobile {
          position: fixed; inset: 0; z-index: 999;
          background: #0C0C0C;
          display: flex; flex-direction: column;
          align-items: center; justify-content: center;
          transform: translateY(-100%); opacity: 0;
          transition: transform 0.52s cubic-bezier(0.16,1,0.3,1),
                      opacity 0.38s ease;
          pointer-events: none;
        }
        .a5-mobile.open {
          transform: translateY(0); opacity: 1;
          pointer-events: all;
        }
        /* Noise grain overlay */
        .a5-mobile::before {
          content: '';
          position: absolute; inset: 0; pointer-events: none;
          background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
          opacity: 0.6;
        }
        /* Orange glow radial */
        .a5-mobile::after {
          content: '';
          position: absolute;
          top: 50%; left: 50%;
          transform: translate(-50%, -50%);
          width: 600px; height: 600px;
          background: radial-gradient(ellipse at center, rgba(232,72,0,0.06) 0%, transparent 70%);
          pointer-events: none;
        }
        .a5-mobile-links {
          display: flex; flex-direction: column;
          align-items: center; gap: 4px;
          position: relative; z-index: 1;
        }
        .a5-mlink {
          font-family: 'Playfair Display', serif;
          font-size: 44px; font-weight: 400; font-style: italic;
          color: rgba(255,255,255,0.12);
          text-decoration: none; padding: 8px 32px;
          letter-spacing: -0.015em; line-height: 1.2;
          transition: color 0.25s ease,
                      transform 0.28s cubic-bezier(0.34,1.56,0.64,1);
        }
        .a5-mlink:hover { color: #fff; transform: translateX(10px); }
        .a5-mlink:focus-visible { outline: none; color: rgba(232,72,0,0.9); }

        /* Divider line */
        .a5-divider {
          width: 1px; height: 56px; margin: 24px 0;
          background: linear-gradient(to bottom, transparent, #E84800 50%, transparent);
          position: relative; z-index: 1;
        }
        .a5-mobile-bottom {
          position: relative; z-index: 1;
          display: flex; flex-direction: column;
          align-items: center; gap: 14px;
        }
        .a5-mphone {
          font-family: 'Josefin Sans', sans-serif;
          font-size: 11px; font-weight: 400; letter-spacing: 0.2em;
          text-transform: uppercase; color: rgba(255,255,255,0.3);
          text-decoration: none;
          transition: color 0.22s ease;
        }
        .a5-mphone:hover { color: rgba(255,255,255,0.7); }

        /* ── Responsive ── */
        @media (max-width: 900px) {
          .a5-nav { padding: 0 24px; height: 68px; }
          .a5-links { display: none; }
          .a5-reserve-d { display: none; }
          .a5-hamburger { display: flex; }
        }
        @media (min-width: 901px) {
          .a5-hamburger { display: none; }
        }
      `}</style>

      {/* ── Mobile overlay ── */}
      <div className={`a5-mobile ${menuOpen ? 'open' : ''}`} aria-hidden={!menuOpen}>
        <nav className="a5-mobile-links">
          {links.map(l => (
            <a
              key={l}
              href={`#${l.toLowerCase()}`}
              className="a5-mlink"
              onClick={() => setMenuOpen(false)}
              tabIndex={menuOpen ? 0 : -1}
            >
              {l}
            </a>
          ))}
        </nav>
        <div className="a5-divider" />
        <div className="a5-mobile-bottom">
          <a href={WA_HREF} className="a5-reserve" target="_blank" rel="noopener noreferrer" tabIndex={menuOpen ? 0 : -1}>
            Reserve a Table
          </a>
          <a href="tel:+2302898888" className="a5-mphone" tabIndex={menuOpen ? 0 : -1}>
            +230 289 8888
          </a>
        </div>
      </div>

      {/* ── Navbar ── */}
      <header className={`a5-nav ${scrolled ? 'scrolled' : ''}`} role="banner">
        {/* Logo */}
        <a href="/" aria-label="After5 Lounge Bar — Home">
          <img src="./brand_assets/logo.webp" alt="After5 Lounge Bar" className="a5-logo" />
        </a>

        {/* Center nav links */}
        <ul className="a5-links" role="list">
          {links.map(l => (
            <li key={l}>
              <a href={`#${l.toLowerCase()}`} className="a5-link">{l}</a>
            </li>
          ))}
        </ul>

        {/* Right: CTA + hamburger */}
        <div className="a5-nav-right">
          <a
            href={WA_HREF}
            className="a5-reserve a5-reserve-d"
            target="_blank"
            rel="noopener noreferrer"
          >
            Reserve
          </a>
          <button
            className={`a5-hamburger ${menuOpen ? 'open' : ''}`}
            onClick={() => setMenuOpen(v => !v)}
            aria-label={menuOpen ? 'Close menu' : 'Open menu'}
            aria-expanded={menuOpen}
          >
            <span className="a5-hline" />
            <span className="a5-hline" />
            <span className="a5-hline" />
          </button>
        </div>
      </header>
    </>
  );
}
