{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"css-hamburger-menu-collection-with-12-animated-icons-and-accessible-mobile-nav","type":"registry:block","title":"CSS Hamburger Menu Collection with 12 Animated Icons and an Accessible Mobile Nav","description":"Free CSS hamburger menu set: 12 animated icons, a slide-in drawer, a dropdown and a no-JavaScript checkbox menu, plus a React and Tailwind version to copy.","dependencies":[],"files":[{"path":"components/we-inc/css-hamburger-menu-collection-with-12-animated-icons-and-accessible-mobile-nav.tsx","type":"registry:component","content":"import { createElement, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\n\n/* ---------- one tree, two outputs ----------\n  Every piece is written once as a small tree of elements. The same tree renders the live\n  preview and the HTML you copy, so the code you take is the code you saw working.\n  \"&\" in a class, id or CSS rule is replaced with the piece's own class name. */\ntype Attrs = Record<string, string | boolean | undefined>;\ntype El = { t: string; a: Attrs; k: HNode[] };\ntype HNode = string | El;\ntype Kid = HNode | (HNode | null | undefined)[] | null | false | undefined;\n\nfunction h(t: string, a: Attrs = {}, ...k: Kid[]): El {\n  const kids: HNode[] = [];\n  for (const x of k) {\n    if (x === null || x === false || x === undefined) continue;\n    if (Array.isArray(x)) kids.push(...x.filter((y) => y !== null && y !== undefined));\n    else kids.push(x);\n  }\n  return { t, a, k: kids };\n}\n\nconst sc = (s: string, name: string) => s.replace(/&/g, name);\nconst esc = (s: string) => s.replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\");\nconst SVG_SELF = new Set([\"path\", \"circle\", \"line\", \"rect\", \"polyline\"]);\n\nfunction attrStr(a: Attrs, name: string): string {\n  return Object.entries(a)\n    .filter(([, v]) => v !== undefined && v !== false)\n    .map(([k, v]) => (v === true ? ` ${k}` : ` ${k}=\"${sc(String(v), name)}\"`))\n    .join(\"\");\n}\n\nfunction toHtml(n: HNode, name: string, d = 0): string {\n  const pad = \"  \".repeat(d);\n  if (typeof n === \"string\") return pad + esc(n);\n  const open = `<${n.t}${attrStr(n.a, name)}`;\n  if (SVG_SELF.has(n.t)) return `${pad}${open} />`;\n  if (n.t === \"input\") return `${pad}${open}>`;\n  if (!n.k.length) return `${pad}${open}></${n.t}>`;\n  if (n.k.every((c) => typeof c === \"string\")) return `${pad}${open}>${n.k.map((c) => esc(c as string)).join(\"\")}</${n.t}>`;\n  return `${pad}${open}>\\n${n.k.map((c) => toHtml(c, name, d + 1)).join(\"\\n\")}\\n${pad}</${n.t}>`;\n}\n\nconst RMAP: Record<string, string> = {\n  class: \"className\",\n  for: \"htmlFor\",\n  tabindex: \"tabIndex\",\n  checked: \"defaultChecked\",\n  \"stroke-width\": \"strokeWidth\",\n  \"stroke-linecap\": \"strokeLinecap\",\n  \"stroke-linejoin\": \"strokeLinejoin\",\n};\n\nfunction toReact(n: HNode, name: string, key?: number): ReactNode {\n  if (typeof n === \"string\") return n;\n  const p: Record<string, unknown> = { key };\n  for (const [k, v] of Object.entries(n.a)) {\n    if (v === undefined || v === false) continue;\n    p[RMAP[k] ?? k] = v === true ? (k.startsWith(\"aria-\") || k.startsWith(\"data-\") ? \"\" : true) : sc(String(v), name);\n  }\n  return createElement(n.t, p, ...n.k.map((c, i) => toReact(c, name, i)));\n}\n\n/* ---------- copy helpers and shared UI ---------- */\nasync function copyText(text: string): Promise<boolean> {\n  try {\n    await navigator.clipboard.writeText(text);\n    return true;\n  } catch {\n    return false;\n  }\n}\n\nconst ICON_COPY = \"M9 9h11v11H9zM5 15H4V4h11v1\";\nconst ICON_CHECK = \"M5 12.5l4.5 4.5L19 7\";\nconst ICON_CODE = \"M8 7l-5 5 5 5M16 7l5 5-5 5\";\n\nfunction Svg({ d, className = \"h-4 w-4\" }: { d: string; className?: string }) {\n  return (\n    <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" className={className}>\n      <path d={d} />\n    </svg>\n  );\n}\n\nconst FOCUS = \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2\";\n\n/** A live piece with its own Show code and Copy buttons. */\nfunction Card({\n  id,\n  name,\n  note,\n  code,\n  copyLabel,\n  stage,\n  stageClass,\n  wide,\n  ring,\n  onAnnounce,\n}: {\n  id: string;\n  name: string;\n  note?: string;\n  code: string;\n  copyLabel: string;\n  stage: ReactNode;\n  stageClass: string;\n  wide?: boolean;\n  ring: string;\n  onAnnounce: (s: string) => void;\n}) {\n  const [open, setOpen] = useState(false);\n  const [copied, setCopied] = useState(false);\n  const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n  useEffect(() => () => {\n    if (timer.current) clearTimeout(timer.current);\n  }, []);\n  async function copy() {\n    const ok = await copyText(code);\n    if (!ok) setOpen(true);\n    setCopied(ok);\n    onAnnounce(ok ? `${name}: ${copyLabel} copied` : \"Copy was blocked, the code is shown so you can select it\");\n    if (timer.current) clearTimeout(timer.current);\n    timer.current = setTimeout(() => setCopied(false), 1600);\n  }\n  return (\n    <li className={`overflow-hidden rounded-2xl border border-stone-200 bg-white shadow-[0_1px_2px_rgba(22,24,29,0.04)] ${wide || open ? \"col-span-full\" : \"\"}`}>\n      <div className={stageClass}>{stage}</div>\n      <div className=\"flex flex-wrap items-center gap-2 border-t border-stone-200 px-3 py-2.5\">\n        <div className=\"min-w-[7.5rem] flex-1\">\n          <p className=\"text-[13px] font-semibold leading-snug text-stone-900\">{name}</p>\n          {note && <p className=\"text-[12px] leading-snug text-stone-600\">{note}</p>}\n        </div>\n        <button\n          type=\"button\"\n          aria-expanded={open}\n          aria-controls={`${id}-code`}\n          aria-label={`${open ? \"Hide\" : \"Show\"} code for ${name}`}\n          onClick={() => setOpen(!open)}\n          className={`grid h-10 w-10 shrink-0 place-items-center rounded-lg text-stone-600 transition-colors hover:bg-stone-100 hover:text-stone-900 ${FOCUS} ${ring}`}\n        >\n          <Svg d={ICON_CODE} />\n        </button>\n        <button\n          type=\"button\"\n          onClick={copy}\n          aria-label={`Copy ${copyLabel} for ${name}`}\n          className={`inline-flex h-10 shrink-0 items-center gap-1.5 rounded-lg px-3 text-[12.5px] font-semibold transition-colors ${FOCUS} ${ring} ${copied ? \"bg-emerald-700 text-white\" : \"bg-stone-100 text-stone-900 hover:bg-stone-200\"}`}\n        >\n          <Svg d={copied ? ICON_CHECK : ICON_COPY} className=\"h-3.5 w-3.5\" />\n          {copied ? \"Copied\" : \"Copy\"}\n        </button>\n      </div>\n      {open && (\n        <pre id={`${id}-code`} tabIndex={0} className=\"max-h-96 overflow-auto whitespace-pre-wrap break-words border-t border-stone-800 bg-[#111318] p-4 font-mono text-[11.5px] leading-[1.65] text-slate-200\">\n          <code>{code}</code>\n        </pre>\n      )}\n    </li>\n  );\n}\n\n/** The view switcher at the top of each collection. */\nfunction Views<T extends string>({ views, value, onChange, ring, label }: { views: [T, string, number?][]; value: T; onChange: (v: T) => void; ring: string; label: string }) {\n  return (\n    <div className=\"flex flex-wrap gap-1.5\" role=\"group\" aria-label={label}>\n      {views.map(([k, text, n]) => {\n        const on = value === k;\n        return (\n          <button\n            key={k}\n            type=\"button\"\n            aria-pressed={on}\n            onClick={() => onChange(k)}\n            className={`inline-flex min-h-[40px] items-center gap-1.5 whitespace-nowrap rounded-full px-4 text-[13px] font-medium transition-colors ${FOCUS} ${ring} ${on ? \"bg-[#16181d] text-white\" : \"bg-white text-stone-700 ring-1 ring-inset ring-stone-300 hover:bg-stone-100\"}`}\n          >\n            {text}\n            {n !== undefined && <span className={`font-mono text-[11px] ${on ? \"text-white/70\" : \"text-stone-500\"}`}>{n}</span>}\n          </button>\n        );\n      })}\n    </div>\n  );\n}\n\n/** A block of source code with one Copy button, used for the React + Tailwind versions. */\nfunction CodeBlock({ code, label, ring, onAnnounce, id }: { code: string; label: string; ring: string; onAnnounce: (s: string) => void; id: string }) {\n  const [copied, setCopied] = useState(false);\n  const [show, setShow] = useState(true);\n  async function copy() {\n    const ok = await copyText(code);\n    setCopied(ok);\n    if (!ok) setShow(true);\n    onAnnounce(ok ? `${label} copied` : \"Copy was blocked, the code is shown so you can select it\");\n    setTimeout(() => setCopied(false), 1600);\n  }\n  return (\n    <div className=\"overflow-hidden rounded-2xl border border-stone-800 bg-[#111318]\">\n      <div className=\"flex items-center justify-between gap-2 border-b border-white/10 px-3 py-2\">\n        <p className=\"font-mono text-[12px] text-slate-300\">{label}</p>\n        <div className=\"flex gap-1.5\">\n          <button type=\"button\" aria-expanded={show} aria-controls={id} onClick={() => setShow(!show)} className={`h-10 rounded-lg px-3 text-[12.5px] font-semibold text-slate-200 hover:bg-white/10 ${FOCUS} ${ring} focus-visible:ring-offset-[#111318]`}>\n            {show ? \"Hide code\" : \"Show code\"}\n          </button>\n          <button type=\"button\" onClick={copy} className={`inline-flex h-10 items-center gap-1.5 rounded-lg px-3 text-[12.5px] font-semibold ${FOCUS} ${ring} focus-visible:ring-offset-[#111318] ${copied ? \"bg-emerald-600 text-white\" : \"bg-white/10 text-white hover:bg-white/20\"}`}>\n            <Svg d={copied ? ICON_CHECK : ICON_COPY} className=\"h-3.5 w-3.5\" />\n            {copied ? \"Copied\" : \"Copy\"}\n          </button>\n        </div>\n      </div>\n      {show && (\n        <pre id={id} tabIndex={0} className=\"max-h-[520px] overflow-auto p-4 font-mono text-[11.5px] leading-[1.65] text-slate-200\">\n          <code>{code}</code>\n        </pre>\n      )}\n    </div>\n  );\n}\n\nconst SECTION_FONT = { fontFamily: 'Inter, ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif' };\n\n/* ---------- hamburger icons ---------- */\nconst OPEN = `.&[aria-expanded=\"true\"]`;\n\nconst iconBase = (chrome: string, box = \"width: 22px; height: 16px;\") => `.& {\n  display: inline-flex; align-items: center; justify-content: center; gap: 10px;\n  min-width: 44px; height: 44px; padding: 0; border: 0; cursor: pointer;\n  font: 600 14px/1 system-ui, sans-serif;\n  -webkit-tap-highlight-color: transparent;\n  ${chrome}\n}\n.&:focus-visible { outline: 2px solid #2563eb; outline-offset: 3px; }\n.&__box { position: relative; display: block; ${box} }\n.&__line {\n  position: absolute; left: 0; width: 100%; height: 2px; border-radius: 2px;\n  background: currentColor;\n  transition: transform .3s cubic-bezier(.2, .7, .2, 1), opacity .2s;\n}\n.&__line:nth-child(1) { top: 0; }\n.&__line:nth-child(2) { top: 7px; }\n.&__line:nth-child(3) { top: 14px; }`;\n\nconst REDUCED = `@media (prefers-reduced-motion: reduce) {\n  .&, .& * { transition-duration: .01ms !important; transition-delay: 0s !important; }\n}`;\n\nconst cross = (o = OPEN) => `${o} .&__line:nth-child(1) { transform: translateY(7px) rotate(45deg); }\n${o} .&__line:nth-child(2) { opacity: 0; }\n${o} .&__line:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }`;\n\nconst INK = \"background: #16181d; color: #fff; border-radius: 10px;\";\nconst LIGHT = \"background: #fff; color: #16181d; border-radius: 10px; box-shadow: inset 0 0 0 1px #d6d3d1;\";\nconst ROUND = \"background: #16181d; color: #fff; border-radius: 50%;\";\nconst GHOST = \"background: transparent; color: #16181d; border-radius: 10px;\";\nconst TEAL = \"background: #0f766e; color: #fff; border-radius: 12px;\";\nconst BLUE = \"background: #1d4ed8; color: #fff; border-radius: 999px;\";\nconst PILL = \"background: #fff; color: #16181d; border-radius: 999px; box-shadow: inset 0 0 0 1px #d6d3d1; padding: 0 16px 0 14px;\";\nconst TINT = \"background: #efedea; color: #16181d; border-radius: 8px;\";\n\nconst ICON_JS = `  // Flips aria-expanded on click. The CSS draws the open state from that attribute.\n  // In a real header, also add aria-controls=\"your-menu-id\" and show that menu here.\n  document.querySelectorAll(\".&\").forEach(function (button) {\n    button.addEventListener(\"click\", function () {\n      var open = button.getAttribute(\"aria-expanded\") === \"true\";\n      button.setAttribute(\"aria-expanded\", String(!open));\n    });\n  });`;\n\nfunction iconTree(lines = 3, text?: string): El {\n  return h(\n    \"button\",\n    { class: \"&\", type: \"button\", \"aria-expanded\": \"false\", \"aria-label\": text ? undefined : \"Menu\" },\n    h(\"span\", { class: \"&__box\", \"aria-hidden\": \"true\" }, Array.from({ length: lines }, () => h(\"span\", { class: \"&__line\" }))),\n    text ? h(\"span\", {}, text) : null,\n  );\n}\n\ntype Item = { name: string; cls: string; note: string; css: string; tree: El; js?: string; beh: \"icon\" | \"menu\" | \"none\"; demoOpen?: boolean };\n\nconst ICONS: Item[] = [\n  { name: \"Cross\", cls: \"menu-cross\", note: \"Top and bottom bars meet in an X\", beh: \"icon\", js: ICON_JS, tree: iconTree(), css: `${iconBase(INK)}\\n${cross()}\\n${REDUCED}` },\n  {\n    name: \"Spin\", cls: \"menu-spin\", note: \"The whole icon turns half a circle\", beh: \"icon\", js: ICON_JS, tree: iconTree(),\n    css: `${iconBase(ROUND)}\\n.&__box { transition: transform .45s cubic-bezier(.2, .7, .2, 1); }\\n${OPEN} .&__box { transform: rotate(180deg); }\\n${cross()}\\n${REDUCED}`,\n  },\n  {\n    name: \"Squeeze\", cls: \"menu-squeeze\", note: \"Bars gather in the middle, then turn\", beh: \"icon\", js: ICON_JS, tree: iconTree(),\n    css: `${iconBase(TEAL)}\n.&__line { transition: top .16s .16s, transform .16s 0s, opacity 0s .16s; }\n${OPEN} .&__line { transition: top .16s 0s, transform .16s .16s, opacity 0s .16s; }\n${OPEN} .&__line:nth-child(1) { top: 7px; transform: rotate(45deg); }\n${OPEN} .&__line:nth-child(2) { opacity: 0; }\n${OPEN} .&__line:nth-child(3) { top: 7px; transform: rotate(-45deg); }\n${REDUCED}`,\n  },\n  {\n    name: \"Arrow back\", cls: \"menu-arrow-back\", note: \"Folds into a left arrow for sub-menus\", beh: \"icon\", js: ICON_JS, tree: iconTree(),\n    css: `${iconBase(GHOST)}\n.&:hover { background: #f0efec; }\n.&__line { transform-origin: left center; }\n${OPEN} .&__line:nth-child(1) { transform: translateY(7px) rotate(-40deg) scaleX(.55); }\n${OPEN} .&__line:nth-child(3) { transform: translateY(-7px) rotate(40deg) scaleX(.55); }\n${REDUCED}`,\n  },\n  {\n    name: \"Arrow forward\", cls: \"menu-arrow-forward\", note: \"Points right, for a panel that slides in\", beh: \"icon\", js: ICON_JS, tree: iconTree(),\n    css: `${iconBase(LIGHT)}\n.&__line { transform-origin: right center; }\n${OPEN} .&__line:nth-child(1) { transform: translateY(7px) rotate(40deg) scaleX(.55); }\n${OPEN} .&__line:nth-child(3) { transform: translateY(-7px) rotate(-40deg) scaleX(.55); }\n${REDUCED}`,\n  },\n  {\n    name: \"Collapse\", cls: \"menu-collapse\", note: \"All three bars stack into one line\", beh: \"icon\", js: ICON_JS, tree: iconTree(),\n    css: `${iconBase(INK.replace(\"10px\", \"6px\"))}\n.&__box { transition: transform .3s cubic-bezier(.2, .7, .2, 1); }\n${OPEN} .&__box { transform: scaleX(.75); }\n${OPEN} .&__line:nth-child(1) { transform: translateY(7px); }\n${OPEN} .&__line:nth-child(3) { transform: translateY(-7px); }\n${REDUCED}`,\n  },\n  {\n    name: \"Two bars with label\", cls: \"menu-two-bar\", note: \"Visible word, two bars that cross\", beh: \"icon\", js: ICON_JS, tree: iconTree(2, \"Menu\"),\n    css: `${iconBase(PILL, \"width: 18px; height: 10px;\")}\n.&__line:nth-child(1) { top: 1px; }\n.&__line:nth-child(2) { top: 7px; }\n${OPEN} .&__line:nth-child(1) { transform: translateY(3px) rotate(45deg); }\n${OPEN} .&__line:nth-child(2) { transform: translateY(-3px) rotate(-45deg); }\n${REDUCED}`,\n  },\n  {\n    name: \"Uneven bars\", cls: \"menu-uneven\", note: \"Short bars grow to full width as they cross\", beh: \"icon\", js: ICON_JS, tree: iconTree(),\n    css: `${iconBase(TINT)}\n.&__line { left: auto; right: 0; transition: transform .3s cubic-bezier(.2, .7, .2, 1), width .3s, opacity .2s; }\n.&__line:nth-child(2) { width: 60%; }\n.&__line:nth-child(3) { width: 80%; }\n${OPEN} .&__line { width: 100%; }\n${cross()}\n${REDUCED}`,\n  },\n  {\n    name: \"Plus\", cls: \"menu-plus\", note: \"Turns into a plus for expanding panels\", beh: \"icon\", js: ICON_JS, tree: iconTree(),\n    css: `${iconBase(BLUE)}\n.&__box { transition: transform .4s cubic-bezier(.2, .7, .2, 1); }\n${OPEN} .&__box { transform: rotate(180deg) scale(.85); }\n${OPEN} .&__line:nth-child(1) { transform: translateY(7px); }\n${OPEN} .&__line:nth-child(2) { opacity: 0; }\n${OPEN} .&__line:nth-child(3) { transform: translateY(-7px) rotate(90deg); }\n${REDUCED}`,\n  },\n  {\n    name: \"Ring\", cls: \"menu-ring\", note: \"A circle draws in around a smaller X\", beh: \"icon\", js: ICON_JS, tree: iconTree(),\n    css: `${iconBase(GHOST.replace(\"10px\", \"50%\"))}\n.& { position: relative; }\n.&::before {\n  content: \"\"; position: absolute; inset: 3px; border-radius: 50%;\n  border: 2px solid currentColor; opacity: 0; transform: scale(.6);\n  transition: transform .35s cubic-bezier(.2, .7, .2, 1), opacity .25s;\n}\n.&__box { transition: transform .35s cubic-bezier(.2, .7, .2, 1); }\n${OPEN}::before { opacity: 1; transform: none; }\n${OPEN} .&__box { transform: scale(.72); }\n${cross()}\n${REDUCED}`,\n  },\n  {\n    name: \"Elastic\", cls: \"menu-elastic\", note: \"Middle bar slides out, the rest overshoot\", beh: \"icon\", js: ICON_JS, tree: iconTree(),\n    css: `${iconBase(INK)}\n.& { overflow: hidden; }\n.&__line { transition: transform .5s cubic-bezier(.68, -.55, .27, 1.55), opacity .3s; }\n${OPEN} .&__line:nth-child(1) { transform: translateY(7px) rotate(45deg); }\n${OPEN} .&__line:nth-child(2) { transform: translateX(24px); opacity: 0; }\n${OPEN} .&__line:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }\n${REDUCED}`,\n  },\n  {\n    name: \"Flip\", cls: \"menu-flip\", note: \"Tips over on its horizontal axis\", beh: \"icon\", js: ICON_JS, tree: iconTree(),\n    css: `${iconBase(LIGHT.replace(\"10px\", \"14px\"))}\n.& { perspective: 120px; }\n.&__box { transition: transform .5s cubic-bezier(.2, .7, .2, 1); }\n${OPEN} .&__box { transform: rotateX(180deg); }\n${cross()}\n${REDUCED}`,\n  },\n];\n\n/* ---------- full mobile menus ---------- */\nconst MENU_JS = `  // Opens and closes the menu, keeps aria-expanded in step, closes on Escape.\n  // With data-trap on the root, focus moves into the panel and Tab stays inside it.\n  document.querySelectorAll(\".&\").forEach(function (root) {\n    var toggle = root.querySelector(\"[aria-controls]\");\n    var panel = document.getElementById(toggle.getAttribute(\"aria-controls\"));\n    var trap = root.hasAttribute(\"data-trap\");\n    function setOpen(open, moveFocus) {\n      toggle.setAttribute(\"aria-expanded\", String(open));\n      root.classList.toggle(\"is-open\", open);\n      if (!moveFocus) return;\n      if (open) panel.querySelector(\"a, button\").focus();\n      else toggle.focus();\n    }\n    toggle.addEventListener(\"click\", function () {\n      setOpen(toggle.getAttribute(\"aria-expanded\") !== \"true\", trap);\n    });\n    root.querySelectorAll(\"[data-close]\").forEach(function (el) {\n      el.addEventListener(\"click\", function () { setOpen(false, true); });\n    });\n    root.addEventListener(\"keydown\", function (event) {\n      if (toggle.getAttribute(\"aria-expanded\") !== \"true\") return;\n      if (event.key === \"Escape\") { setOpen(false, true); return; }\n      if (event.key !== \"Tab\" || !trap) return;\n      var items = panel.querySelectorAll(\"a, button\");\n      var first = items[0];\n      var last = items[items.length - 1];\n      if (event.shiftKey ? document.activeElement === first : document.activeElement === last) {\n        event.preventDefault();\n        (event.shiftKey ? last : first).focus();\n      }\n    });\n  });`;\n\nconst LINKS = [\"Work\", \"Services\", \"Studio\", \"Journal\", \"Contact\"];\n\nconst menuBase = `/* The demo sits in a 420px frame. On a real page, make the panel and scrim position: fixed. */\n.& { position: relative; height: 420px; overflow: hidden; background: #fafaf9; color: #16181d; font: 15px/1.5 system-ui, sans-serif; }\n.& a { color: inherit; text-decoration: none; }\n.& a:focus-visible, .& button:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }\n.&__bar { position: relative; z-index: 3; display: flex; align-items: center; justify-content: space-between; height: 60px; padding: 0 8px 0 18px; background: #fff; border-bottom: 1px solid #e7e5e4; }\n.&__brand { font-weight: 650; letter-spacing: -.01em; border-radius: 6px; }\n.&__toggle { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: #16181d; cursor: pointer; }\n.&__box { position: relative; display: block; width: 22px; height: 16px; }\n.&__line { position: absolute; left: 0; width: 100%; height: 2px; border-radius: 2px; background: currentColor; transition: transform .3s cubic-bezier(.2, .7, .2, 1), opacity .2s; }\n.&__line:nth-child(1) { top: 0; }\n.&__line:nth-child(2) { top: 7px; }\n.&__line:nth-child(3) { top: 14px; }\n.&__page { padding: 24px 18px; }\n.&__page p { margin: 0; color: #57534e; }\n.&__page p:first-child { margin-bottom: 10px; color: #16181d; font-size: 25px; line-height: 1.15; font-weight: 650; letter-spacing: -.02em; }`;\n\nconst page = () =>\n  h(\"div\", { class: \"&__page\" }, h(\"p\", {}, \"Fitted kitchens and joinery, drawn and built in one workshop.\"), h(\"p\", {}, \"Book a site visit and we will measure up within the week.\"));\n\nconst lines3 = () => h(\"span\", { class: \"&__box\", \"aria-hidden\": \"true\" }, h(\"span\", { class: \"&__line\" }), h(\"span\", { class: \"&__line\" }), h(\"span\", { class: \"&__line\" }));\nconst closeSvg = () =>\n  h(\"svg\", { viewBox: \"0 0 24 24\", width: \"20\", height: \"20\", fill: \"none\", stroke: \"currentColor\", \"stroke-width\": \"2\", \"stroke-linecap\": \"round\", \"aria-hidden\": \"true\" }, h(\"path\", { d: \"M6 6l12 12M18 6L6 18\" }));\nconst linkList = (cls: string) => h(\"ul\", { class: cls }, LINKS.map((l, i) => h(\"li\", {}, h(\"a\", { href: \"#\", \"aria-current\": i === 0 ? \"page\" : undefined }, l))));\n\nconst MENUS: Item[] = [\n  {\n    name: \"Slide-in drawer\",\n    cls: \"nav-drawer\",\n    note: \"JavaScript, aria-expanded, focus trap, Escape\",\n    beh: \"menu\",\n    demoOpen: true,\n    js: MENU_JS,\n    tree: h(\n      \"div\",\n      { class: \"&\", \"data-trap\": \"\" },\n      h(\"header\", { class: \"&__bar\" }, h(\"a\", { class: \"&__brand\", href: \"#\" }, \"Fernbrook Studio\"), h(\"button\", { class: \"&__toggle\", type: \"button\", \"aria-expanded\": \"false\", \"aria-controls\": \"&-panel\", \"aria-label\": \"Menu\" }, lines3())),\n      page(),\n      h(\"div\", { class: \"&__scrim\", \"data-close\": \"\" }),\n      h(\n        \"nav\",\n        { class: \"&__panel\", id: \"&-panel\", \"aria-label\": \"Main\" },\n        h(\"button\", { class: \"&__close\", type: \"button\", \"data-close\": \"\", \"aria-label\": \"Close menu\" }, closeSvg()),\n        linkList(\"&__links\"),\n        h(\"a\", { class: \"&__cta\", href: \"#\" }, \"Start a project\"),\n      ),\n    ),\n    css: `${menuBase}\n.&__scrim { position: absolute; inset: 0; z-index: 4; background: rgba(12, 10, 9, .42); opacity: 0; visibility: hidden; transition: opacity .3s, visibility 0s .3s; }\n.&__panel { position: absolute; top: 0; right: 0; bottom: 0; z-index: 5; display: flex; flex-direction: column; width: min(300px, 84%); padding: 10px 16px 18px; background: #fff; box-shadow: -18px 0 40px -20px rgba(0, 0, 0, .35); transform: translateX(100%); visibility: hidden; transition: transform .35s cubic-bezier(.2, .7, .2, 1), visibility 0s .35s; }\n.&.is-open .&__scrim { opacity: 1; visibility: visible; transition: opacity .3s; }\n.&.is-open .&__panel { transform: none; visibility: visible; transition: transform .35s cubic-bezier(.2, .7, .2, 1); }\n.&.is-open .&__line:nth-child(1) { transform: translateY(7px) rotate(45deg); }\n.&.is-open .&__line:nth-child(2) { opacity: 0; }\n.&.is-open .&__line:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }\n.&__close { align-self: flex-end; display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 10px; background: #f5f5f4; color: #16181d; cursor: pointer; }\n.&__links { list-style: none; margin: 8px 0 0; padding: 0; }\n.&__links a { display: block; padding: 10px 10px; border-radius: 8px; font-size: 18px; font-weight: 550; }\n.&__links a:hover { background: #f5f5f4; }\n.&__links a[aria-current=\"page\"] { color: #0f766e; }\n.&__cta { margin-top: auto; padding: 12px 16px; border-radius: 10px; background: #0f766e; color: #fff !important; text-align: center; font-weight: 600; }\n${REDUCED}`,\n  },\n  {\n    name: \"Dropdown panel\",\n    cls: \"nav-dropdown\",\n    note: \"JavaScript, aria-expanded, Escape returns focus\",\n    beh: \"menu\",\n    demoOpen: true,\n    js: MENU_JS,\n    tree: h(\n      \"div\",\n      { class: \"&\" },\n      h(\"header\", { class: \"&__bar\" }, h(\"a\", { class: \"&__brand\", href: \"#\" }, \"Fernbrook Studio\"), h(\"button\", { class: \"&__toggle\", type: \"button\", \"aria-expanded\": \"false\", \"aria-controls\": \"&-panel\", \"aria-label\": \"Menu\" }, lines3())),\n      h(\n        \"nav\",\n        { class: \"&__panel\", id: \"&-panel\", \"aria-label\": \"Main\" },\n        linkList(\"&__links\"),\n        h(\"div\", { class: \"&__actions\" }, h(\"a\", { href: \"#\" }, \"Sign in\"), h(\"a\", { href: \"#\" }, \"Get a quote\")),\n      ),\n      page(),\n    ),\n    css: `${menuBase}\n.&__panel { position: absolute; top: 60px; left: 0; right: 0; z-index: 2; padding: 6px 14px 16px; background: #fff; border-bottom: 1px solid #e7e5e4; box-shadow: 0 30px 40px -28px rgba(0, 0, 0, .35); opacity: 0; transform: translateY(-10px); visibility: hidden; transition: opacity .2s, transform .25s cubic-bezier(.2, .7, .2, 1), visibility 0s .25s; }\n.&.is-open .&__panel { opacity: 1; transform: none; visibility: visible; transition: opacity .2s, transform .25s cubic-bezier(.2, .7, .2, 1); }\n.&.is-open .&__line:nth-child(1) { transform: translateY(7px) rotate(45deg); }\n.&.is-open .&__line:nth-child(2) { opacity: 0; }\n.&.is-open .&__line:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }\n.&__links { list-style: none; margin: 0; padding: 0; }\n.&__links li + li { border-top: 1px solid #f0efec; }\n.&__links a { display: flex; align-items: center; min-height: 46px; padding: 0 4px; font-weight: 550; }\n.&__links a[aria-current=\"page\"] { color: #1d4ed8; }\n.&__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }\n.&__actions a { display: grid; place-items: center; height: 44px; border-radius: 10px; font-weight: 600; box-shadow: inset 0 0 0 1px #d6d3d1; }\n.&__actions a + a { background: #16181d; color: #fff; box-shadow: none; }\n${REDUCED}`,\n  },\n  {\n    name: \"Pure CSS overlay\",\n    cls: \"nav-css\",\n    note: \"No JavaScript: a hidden checkbox and a label\",\n    beh: \"none\",\n    tree: h(\n      \"div\",\n      { class: \"&\" },\n      h(\"input\", { class: \"&__check\", type: \"checkbox\", id: \"&-check\" }),\n      h(\n        \"header\",\n        { class: \"&__bar\" },\n        h(\"a\", { class: \"&__brand\", href: \"#\" }, \"Fernbrook Studio\"),\n        h(\"label\", { class: \"&__toggle\", for: \"&-check\" }, h(\"span\", { class: \"&__sr\" }, \"Menu\"), lines3()),\n      ),\n      h(\"nav\", { class: \"&__panel\", \"aria-label\": \"Main\" }, linkList(\"&__links\")),\n      page(),\n    ),\n    css: `${menuBase}\n.&__check { position: absolute; top: 8px; right: 8px; z-index: 6; width: 44px; height: 44px; margin: 0; opacity: 0; cursor: pointer; }\n.&__check:focus-visible ~ .&__bar .&__toggle { outline: 2px solid #2563eb; outline-offset: 2px; }\n.&__check:checked ~ .&__bar { background: #16181d; color: #fff; border-color: #16181d; }\n.&__check:checked ~ .&__bar .&__toggle { color: #fff; }\n.&__check:checked ~ .&__bar .&__line:nth-child(1) { transform: translateY(7px) rotate(45deg); }\n.&__check:checked ~ .&__bar .&__line:nth-child(2) { opacity: 0; }\n.&__check:checked ~ .&__bar .&__line:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }\n.&__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n.&__panel { position: absolute; inset: 60px 0 0; z-index: 2; padding: 12px 18px; background: #16181d; color: #fff; clip-path: inset(0 0 100% 0); visibility: hidden; transition: clip-path .4s cubic-bezier(.2, .7, .2, 1), visibility 0s .4s; }\n.&__check:checked ~ .&__panel { clip-path: inset(0); visibility: visible; transition: clip-path .4s cubic-bezier(.2, .7, .2, 1); }\n.&__links { list-style: none; margin: 0; padding: 0; }\n.&__links li { opacity: 0; transform: translateY(10px); transition: opacity .3s, transform .3s; border-bottom: 1px solid rgba(255, 255, 255, .12); }\n.&__check:checked ~ .&__panel li { opacity: 1; transform: none; }\n.&__check:checked ~ .&__panel li:nth-child(2) { transition-delay: .05s; }\n.&__check:checked ~ .&__panel li:nth-child(3) { transition-delay: .1s; }\n.&__check:checked ~ .&__panel li:nth-child(4) { transition-delay: .15s; }\n.&__check:checked ~ .&__panel li:nth-child(5) { transition-delay: .2s; }\n.&__links a { display: block; padding: 12px 0; font-size: 26px; font-weight: 600; letter-spacing: -.02em; }\n.&__links a[aria-current=\"page\"] { color: #5eead4; }\n${REDUCED}`,\n  },\n];\n\nconst ALL: Item[] = [...ICONS, ...MENUS];\nconst nameOf = (i: number) => `hbx${i}`;\nconst codeFor = (it: Item) =>\n  `<!-- ${it.name} -->\\n${toHtml(it.tree, it.cls)}\\n\\n<style>\\n${sc(it.css, it.cls)}\\n</style>\\n` + (it.js ? `\\n<script>\\n${sc(it.js, it.cls)}\\n</script>\\n` : \"\");\n\n/* ---------- the same behaviour inside the preview ---------- */\nfunction attachIcon(button: HTMLElement): () => void {\n  const onClick = () => button.setAttribute(\"aria-expanded\", String(button.getAttribute(\"aria-expanded\") !== \"true\"));\n  button.addEventListener(\"click\", onClick);\n  return () => button.removeEventListener(\"click\", onClick);\n}\n\nfunction attachMenu(root: HTMLElement, demoOpen: boolean): () => void {\n  const toggle = root.querySelector<HTMLElement>(\"[aria-controls]\");\n  const panel = toggle ? root.querySelector<HTMLElement>(`#${toggle.getAttribute(\"aria-controls\")}`) : null;\n  if (!toggle || !panel) return () => undefined;\n  const trap = root.hasAttribute(\"data-trap\");\n  const setOpen = (open: boolean, moveFocus: boolean) => {\n    toggle.setAttribute(\"aria-expanded\", String(open));\n    root.classList.toggle(\"is-open\", open);\n    if (!moveFocus) return;\n    if (open) panel.querySelector<HTMLElement>(\"a, button\")?.focus();\n    else toggle.focus();\n  };\n  const onToggle = () => setOpen(toggle.getAttribute(\"aria-expanded\") !== \"true\", trap);\n  const onClose = () => setOpen(false, true);\n  const onKey = (event: KeyboardEvent) => {\n    if (toggle.getAttribute(\"aria-expanded\") !== \"true\") return;\n    if (event.key === \"Escape\") {\n      setOpen(false, true);\n      return;\n    }\n    if (event.key !== \"Tab\" || !trap) return;\n    const items = panel.querySelectorAll<HTMLElement>(\"a, button\");\n    const first = items[0];\n    const last = items[items.length - 1];\n    if (event.shiftKey ? document.activeElement === first : document.activeElement === last) {\n      event.preventDefault();\n      (event.shiftKey ? last : first).focus();\n    }\n  };\n  const closers = Array.from(root.querySelectorAll<HTMLElement>(\"[data-close]\"));\n  toggle.addEventListener(\"click\", onToggle);\n  closers.forEach((el) => el.addEventListener(\"click\", onClose));\n  root.addEventListener(\"keydown\", onKey);\n  if (demoOpen) setOpen(true, false);\n  return () => {\n    toggle.removeEventListener(\"click\", onToggle);\n    closers.forEach((el) => el.removeEventListener(\"click\", onClose));\n    root.removeEventListener(\"keydown\", onKey);\n  };\n}\n\n/* ---------- React + Tailwind version (the code below is this exact component) ---------- */\nconst NAV_LINKS = [\"Work\", \"Services\", \"Studio\", \"Journal\", \"Contact\"];\n\nfunction MobileNav() {\n  const [open, setOpen] = useState(false);\n  const toggleRef = useRef<HTMLButtonElement>(null);\n  const panelRef = useRef<HTMLElement>(null);\n\n  useEffect(() => {\n    if (!open) return;\n    panelRef.current?.querySelector<HTMLElement>(\"a, button\")?.focus();\n    function onKey(e: KeyboardEvent) {\n      if (e.key === \"Escape\") {\n        setOpen(false);\n        toggleRef.current?.focus();\n        return;\n      }\n      if (e.key !== \"Tab\" || !panelRef.current) return;\n      const items = panelRef.current.querySelectorAll<HTMLElement>(\"a, button\");\n      const first = items[0];\n      const last = items[items.length - 1];\n      if (e.shiftKey ? document.activeElement === first : document.activeElement === last) {\n        e.preventDefault();\n        (e.shiftKey ? last : first).focus();\n      }\n    }\n    document.addEventListener(\"keydown\", onKey);\n    return () => document.removeEventListener(\"keydown\", onKey);\n  }, [open]);\n\n  function close() {\n    setOpen(false);\n    toggleRef.current?.focus();\n  }\n\n  const bar = \"absolute left-0 h-0.5 w-full rounded bg-current transition duration-300 motion-reduce:transition-none\";\n\n  return (\n    <header className=\"relative flex h-16 items-center justify-between border-b border-stone-200 bg-white px-4\">\n      <a href=\"#\" className=\"rounded text-[15px] font-semibold text-stone-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600\">\n        Fernbrook Studio\n      </a>\n      <button\n        ref={toggleRef}\n        type=\"button\"\n        aria-label=\"Menu\"\n        aria-expanded={open}\n        aria-controls=\"mobile-nav\"\n        onClick={() => setOpen(!open)}\n        className=\"grid h-11 w-11 place-items-center rounded-lg bg-stone-900 text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600 focus-visible:ring-offset-2\"\n      >\n        <span aria-hidden=\"true\" className=\"relative block h-4 w-[22px]\">\n          <span className={bar + \" top-0 \" + (open ? \"translate-y-[7px] rotate-45\" : \"\")} />\n          <span className={bar + \" top-[7px] \" + (open ? \"opacity-0\" : \"\")} />\n          <span className={bar + \" top-[14px] \" + (open ? \"-translate-y-[7px] -rotate-45\" : \"\")} />\n        </span>\n      </button>\n      <div\n        onClick={close}\n        className={\"fixed inset-0 z-40 bg-stone-950/40 transition-opacity duration-300 motion-reduce:transition-none \" + (open ? \"opacity-100\" : \"pointer-events-none opacity-0\")}\n      />\n      <nav\n        ref={panelRef}\n        id=\"mobile-nav\"\n        aria-label=\"Main\"\n        className={\"fixed inset-y-0 right-0 z-50 flex w-72 max-w-[85%] flex-col bg-white p-4 shadow-2xl transition-[transform,visibility] duration-300 motion-reduce:transition-none \" + (open ? \"visible translate-x-0\" : \"invisible translate-x-full\")}\n      >\n        <button\n          type=\"button\"\n          onClick={close}\n          aria-label=\"Close menu\"\n          className=\"grid h-11 w-11 place-items-center self-end rounded-lg bg-stone-100 text-stone-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600\"\n        >\n          <svg viewBox=\"0 0 24 24\" className=\"h-5 w-5\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" aria-hidden=\"true\">\n            <path d=\"M6 6l12 12M18 6L6 18\" />\n          </svg>\n        </button>\n        <ul className=\"mt-2\">\n          {NAV_LINKS.map((label, i) => (\n            <li key={label}>\n              <a\n                href=\"#\"\n                aria-current={i === 0 ? \"page\" : undefined}\n                className=\"block rounded-lg px-3 py-2.5 text-[17px] font-medium text-stone-800 hover:bg-stone-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600 aria-[current=page]:text-teal-700\"\n              >\n                {label}\n              </a>\n            </li>\n          ))}\n        </ul>\n        <a href=\"#\" className=\"mt-auto rounded-lg bg-teal-700 px-4 py-3 text-center font-semibold text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600 focus-visible:ring-offset-2\">\n          Start a project\n        </a>\n      </nav>\n    </header>\n  );\n}\n\nconst REACT_CODE = `import { useEffect, useRef, useState } from \"react\";\n\nconst NAV_LINKS = [\"Work\", \"Services\", \"Studio\", \"Journal\", \"Contact\"];\n\nexport default function MobileNav() {\n  const [open, setOpen] = useState(false);\n  const toggleRef = useRef<HTMLButtonElement>(null);\n  const panelRef = useRef<HTMLElement>(null);\n\n  useEffect(() => {\n    if (!open) return;\n    panelRef.current?.querySelector<HTMLElement>(\"a, button\")?.focus();\n    function onKey(e: KeyboardEvent) {\n      if (e.key === \"Escape\") {\n        setOpen(false);\n        toggleRef.current?.focus();\n        return;\n      }\n      if (e.key !== \"Tab\" || !panelRef.current) return;\n      const items = panelRef.current.querySelectorAll<HTMLElement>(\"a, button\");\n      const first = items[0];\n      const last = items[items.length - 1];\n      if (e.shiftKey ? document.activeElement === first : document.activeElement === last) {\n        e.preventDefault();\n        (e.shiftKey ? last : first).focus();\n      }\n    }\n    document.addEventListener(\"keydown\", onKey);\n    return () => document.removeEventListener(\"keydown\", onKey);\n  }, [open]);\n\n  function close() {\n    setOpen(false);\n    toggleRef.current?.focus();\n  }\n\n  const bar = \"absolute left-0 h-0.5 w-full rounded bg-current transition duration-300 motion-reduce:transition-none\";\n\n  return (\n    <header className=\"relative flex h-16 items-center justify-between border-b border-stone-200 bg-white px-4\">\n      <a href=\"#\" className=\"rounded text-[15px] font-semibold text-stone-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600\">\n        Fernbrook Studio\n      </a>\n      <button\n        ref={toggleRef}\n        type=\"button\"\n        aria-label=\"Menu\"\n        aria-expanded={open}\n        aria-controls=\"mobile-nav\"\n        onClick={() => setOpen(!open)}\n        className=\"grid h-11 w-11 place-items-center rounded-lg bg-stone-900 text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600 focus-visible:ring-offset-2\"\n      >\n        <span aria-hidden=\"true\" className=\"relative block h-4 w-[22px]\">\n          <span className={bar + \" top-0 \" + (open ? \"translate-y-[7px] rotate-45\" : \"\")} />\n          <span className={bar + \" top-[7px] \" + (open ? \"opacity-0\" : \"\")} />\n          <span className={bar + \" top-[14px] \" + (open ? \"-translate-y-[7px] -rotate-45\" : \"\")} />\n        </span>\n      </button>\n      <div\n        onClick={close}\n        className={\"fixed inset-0 z-40 bg-stone-950/40 transition-opacity duration-300 motion-reduce:transition-none \" + (open ? \"opacity-100\" : \"pointer-events-none opacity-0\")}\n      />\n      <nav\n        ref={panelRef}\n        id=\"mobile-nav\"\n        aria-label=\"Main\"\n        className={\"fixed inset-y-0 right-0 z-50 flex w-72 max-w-[85%] flex-col bg-white p-4 shadow-2xl transition-[transform,visibility] duration-300 motion-reduce:transition-none \" + (open ? \"visible translate-x-0\" : \"invisible translate-x-full\")}\n      >\n        <button\n          type=\"button\"\n          onClick={close}\n          aria-label=\"Close menu\"\n          className=\"grid h-11 w-11 place-items-center self-end rounded-lg bg-stone-100 text-stone-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600\"\n        >\n          <svg viewBox=\"0 0 24 24\" className=\"h-5 w-5\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" aria-hidden=\"true\">\n            <path d=\"M6 6l12 12M18 6L6 18\" />\n          </svg>\n        </button>\n        <ul className=\"mt-2\">\n          {NAV_LINKS.map((label, i) => (\n            <li key={label}>\n              <a\n                href=\"#\"\n                aria-current={i === 0 ? \"page\" : undefined}\n                className=\"block rounded-lg px-3 py-2.5 text-[17px] font-medium text-stone-800 hover:bg-stone-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600 aria-[current=page]:text-teal-700\"\n              >\n                {label}\n              </a>\n            </li>\n          ))}\n        </ul>\n        <a href=\"#\" className=\"mt-auto rounded-lg bg-teal-700 px-4 py-3 text-center font-semibold text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-600 focus-visible:ring-offset-2\">\n          Start a project\n        </a>\n      </nav>\n    </header>\n  );\n}\n`;\n\n/* ---------- reference ---------- */\nconst REF: [string, string, string, string][] = [\n  [\"Checkbox and label\", \"No\", \"A checkbox named Menu, checked or not checked\", \"Space toggles it. Escape does nothing and focus is not managed.\"],\n  [\"Button with aria-expanded\", \"A few lines\", \"A button named Menu, expanded or collapsed\", \"Enter and Space toggle it. You add Escape and outside click.\"],\n  [\"Drawer with focus trap\", \"Yes\", \"Expanded state, then focus lands on the first item in the panel\", \"Tab cycles inside the panel, Escape closes and focus returns to the button.\"],\n];\n\ntype View = \"icons\" | \"menus\" | \"react\" | \"ref\";\n\nexport default function CssHamburgerMenuCollection() {\n  const [view, setView] = useState<View>(\"icons\");\n  const [announce, setAnnounce] = useState(\"\");\n  const gridRef = useRef<HTMLUListElement>(null);\n  const reduce = useRef(false);\n  const styleSheet = useMemo(() => ALL.map((it, i) => sc(it.css, nameOf(i))).join(\"\\n\"), []);\n  const codes = useMemo(() => ALL.map(codeFor), []);\n\n  useEffect(() => {\n    const grid = gridRef.current;\n    if (!grid) return;\n    const offs: (() => void)[] = [];\n    ALL.forEach((it, i) => {\n      const el = grid.querySelector<HTMLElement>(`.${nameOf(i)}`);\n      if (!el) return;\n      if (it.beh === \"icon\") offs.push(attachIcon(el));\n      if (it.beh === \"menu\") offs.push(attachMenu(el, !!it.demoOpen));\n    });\n    // A gentle demo: the icons open and close on their own until someone touches one.\n    let timer: ReturnType<typeof setInterval> | null = null;\n    reduce.current = typeof window !== \"undefined\" && window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    if (view === \"icons\" && !reduce.current) {\n      let open = false;\n      timer = setInterval(() => {\n        open = !open;\n        grid.querySelectorAll<HTMLElement>(\"button[aria-label='Menu'], button[aria-expanded]\").forEach((b) => {\n          if (b.closest(\"[data-icon]\")) b.setAttribute(\"aria-expanded\", String(open));\n        });\n      }, 1300);\n      const stop = () => {\n        if (timer) clearInterval(timer);\n        timer = null;\n      };\n      grid.addEventListener(\"pointerdown\", stop);\n      grid.addEventListener(\"keydown\", stop);\n      offs.push(() => {\n        grid.removeEventListener(\"pointerdown\", stop);\n        grid.removeEventListener(\"keydown\", stop);\n      });\n    }\n    return () => {\n      if (timer) clearInterval(timer);\n      offs.forEach((f) => f());\n    };\n  }, [view]);\n\n  const ring = \"focus-visible:ring-teal-700 focus-visible:ring-offset-[#f7f6f3]\";\n  const list = view === \"icons\" ? ICONS.map((it, i) => ({ it, i })) : MENUS.map((it, k) => ({ it, i: ICONS.length + k }));\n\n  return (\n    <section className=\"bg-[#f7f6f3] px-4 py-12 text-[#16181d] sm:px-8 sm:py-14\" style={SECTION_FONT}>\n      <style>{styleSheet}</style>\n      <div className=\"mx-auto max-w-6xl\">\n        <header className=\"max-w-3xl\">\n          <p className=\"font-mono text-[12px] uppercase tracking-[0.18em] text-stone-600\">HTML · CSS · React and Tailwind</p>\n          <h2 className=\"mt-3 text-[32px] font-semibold leading-[1.05] tracking-[-0.03em] sm:text-[44px]\">CSS hamburger menus that open a real menu</h2>\n          <p className=\"mt-4 max-w-2xl text-[15px] leading-relaxed text-stone-600\">\n            Twelve animated menu icons, three complete phone menus and a React version. Each icon is a button whose aria-expanded value drives the animation, so the state you see is the state a screen reader hears. Press any icon to try it.\n          </p>\n        </header>\n\n        <div className=\"mt-7 border-y border-stone-300/70 py-4\">\n          <Views\n            label=\"Choose what to show\"\n            ring={ring}\n            value={view}\n            onChange={setView}\n            views={[\n              [\"icons\", \"Animated icons\", ICONS.length],\n              [\"menus\", \"Mobile menus\", MENUS.length],\n              [\"react\", \"React + Tailwind\"],\n              [\"ref\", \"Which to use\"],\n            ]}\n          />\n        </div>\n        <p className=\"sr-only\" aria-live=\"polite\">{announce}</p>\n\n        <div className=\"mt-6 h-[700px] overflow-y-auto overscroll-contain pr-1\" tabIndex={0} aria-label=\"Hamburger menu examples\">\n          {(view === \"icons\" || view === \"menus\") && (\n            <ul ref={gridRef} className={`grid items-start gap-3 ${view === \"icons\" ? \"grid-cols-2 md:grid-cols-3 lg:grid-cols-4\" : \"grid-cols-1 md:grid-cols-2 lg:grid-cols-3\"}`}>\n              {list.map(({ it, i }) => (\n                <Card\n                  key={i}\n                  id={`hb-${i}`}\n                  name={it.name}\n                  note={it.note}\n                  code={codes[i]}\n                  copyLabel={it.js ? \"HTML, CSS, JS\" : \"HTML and CSS\"}\n                  ring={ring}\n                  onAnnounce={setAnnounce}\n                  stageClass={view === \"icons\" ? \"grid h-28 place-items-center bg-white sm:h-36\" : \"bg-stone-100 p-3\"}\n                  stage={\n                    view === \"icons\" ? (\n                      <div data-icon=\"\">{toReact(it.tree, nameOf(i))}</div>\n                    ) : (\n                      <div className=\"overflow-hidden rounded-xl border border-stone-200\">{toReact(it.tree, nameOf(i))}</div>\n                    )\n                  }\n                />\n              ))}\n            </ul>\n          )}\n\n          {view === \"react\" && (\n            <div className=\"grid gap-5 lg:grid-cols-[380px_1fr]\">\n              <div>\n                <div className=\"relative h-[460px] overflow-hidden rounded-2xl border border-stone-200 bg-stone-50 [transform:translateZ(0)]\">\n                  <MobileNav />\n                  <div className=\"p-5\">\n                    <p className=\"text-[24px] font-semibold leading-tight tracking-[-0.02em]\">Fitted kitchens and joinery, drawn and built in one workshop.</p>\n                    <p className=\"mt-2 text-[15px] text-stone-600\">Press the menu button. Tab stays inside the drawer and Escape closes it.</p>\n                  </div>\n                </div>\n                <p className=\"mt-3 text-[13px] leading-relaxed text-stone-600\">\n                  The drawer and scrim use position fixed. This preview frame has a transform on it, which makes fixed elements stay inside the frame; on your page they cover the screen.\n                </p>\n              </div>\n              <CodeBlock id=\"hb-react-code\" code={REACT_CODE} label=\"MobileNav.tsx\" ring={ring} onAnnounce={setAnnounce} />\n            </div>\n          )}\n\n          {view === \"ref\" && (\n            <div className=\"space-y-6\">\n              <div className=\"overflow-x-auto rounded-2xl border border-stone-200 bg-white\">\n                <table className=\"w-full min-w-[640px] border-collapse text-left text-[13.5px]\">\n                  <caption className=\"sr-only\">How the three menu techniques compare</caption>\n                  <thead className=\"bg-stone-50 text-stone-900\">\n                    <tr>\n                      <th scope=\"col\" className=\"px-4 py-3 font-semibold\">Technique</th>\n                      <th scope=\"col\" className=\"px-4 py-3 font-semibold\">JavaScript</th>\n                      <th scope=\"col\" className=\"px-4 py-3 font-semibold\">What a screen reader hears</th>\n                      <th scope=\"col\" className=\"px-4 py-3 font-semibold\">Keyboard</th>\n                    </tr>\n                  </thead>\n                  <tbody>\n                    {REF.map((r) => (\n                      <tr key={r[0]} className=\"border-t border-stone-200 align-top\">\n                        <th scope=\"row\" className=\"px-4 py-3 font-semibold text-stone-900\">{r[0]}</th>\n                        <td className=\"px-4 py-3 text-stone-700\">{r[1]}</td>\n                        <td className=\"px-4 py-3 text-stone-700\">{r[2]}</td>\n                        <td className=\"px-4 py-3 text-stone-700\">{r[3]}</td>\n                      </tr>\n                    ))}\n                  </tbody>\n                </table>\n              </div>\n              <div className=\"grid gap-4 md:grid-cols-3\">\n                {[\n                  [\"Name the button\", \"An icon has no text, so give the button aria-label=\\\"Menu\\\" and leave the label alone when it opens. The expanded state already tells people it is open.\"],\n                  [\"Hide what is closed\", \"A closed panel should use visibility: hidden or display: none, not just a transform. Otherwise its links stay in the tab order while nobody can see them.\"],\n                  [\"Respect reduced motion\", \"Every snippet ends with a prefers-reduced-motion rule that removes the transitions, so the icon and panel switch state at once.\"],\n                ].map(([t, d]) => (\n                  <div key={t} className=\"rounded-2xl border border-stone-200 bg-white p-5\">\n                    <h3 className=\"text-[15px] font-semibold\">{t}</h3>\n                    <p className=\"mt-2 text-[13.5px] leading-relaxed text-stone-600\">{d}</p>\n                  </div>\n                ))}\n              </div>\n            </div>\n          )}\n        </div>\n      </div>\n    </section>\n  );\n}\n"}]}
