{"id":260,"date":"2025-09-03T13:59:19","date_gmt":"2025-09-03T13:59:19","guid":{"rendered":"https:\/\/shhlumber.com\/?page_id=260"},"modified":"2025-09-03T14:10:31","modified_gmt":"2025-09-03T14:10:31","slug":"sleep-quiz","status":"publish","type":"page","link":"https:\/\/shhlumber.com\/index.php\/sleep-quiz\/","title":{"rendered":"Sleep Quiz"},"content":{"rendered":"\n<!--\nShhlumber Sleep Quiz (WordPress embed)\nPaste this whole snippet into a WordPress \"Custom HTML\" block on \/sleep-quiz\/.\nNo dependencies. Accessible, keyboard-friendly, mobile responsive.\nColors use the \"Midnight & Mist\" palette.\n-->\n<div id=\"shhlumber-quiz\"><\/div>\n<style>\n  :root{\n    --night:#0B1526;--indigo:#1B2A4A;--mist:#F7F9FC;--cloud:#E7ECF3;--slate:#5D6B82;--peri:#8FAAF5;--cta:#F4A261;--ink:#111827;\n  }\n  #shq{font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;color:var(--ink);}\n  #shq *{box-sizing:border-box}\n  #shq .card{background:var(--mist);border:1px solid rgba(0,0,0,.06);border-radius:14px;padding:18px}\n  #shq .btn{display:inline-flex;gap:.5rem;align-items:center;background:var(--cta);color:var(--night);border:none;border-radius:999px;padding:.75rem 1.1rem;font-weight:600;cursor:pointer}\n  #shq .btn[disabled]{opacity:.6;cursor:not-allowed}\n  #shq .btn.alt{background:transparent;color:var(--peri);border:1px solid var(--peri)}\n  #shq .h1{font-size:clamp(1.5rem,2.2vw+1rem,2.4rem);font-weight:800;margin:.25rem 0 1rem}\n  #shq .h2{font-size:1.1rem;font-weight:700;margin:.75rem 0; color:black}\n  #shq .muted{color:var(--slate)}\n  #shq .stack{display:grid;gap:14px}\n  #shq .row{display:flex;flex-wrap:wrap;gap:12px}\n  #shq .chip{border:1px solid rgba(0,0,0,.1);border-radius:10px;padding:.65rem .8rem;background:#fff;cursor:pointer}\n  #shq .chip[data-selected=\"true\"]{border-color:var(--peri);box-shadow:0 0 0 3px #8FAAF522}\n  #shq .progress{height:8px;background:var(--cloud);border-radius:999px;overflow:hidden}\n  #shq .bar{height:100%;background:linear-gradient(90deg,var(--peri),#9bb7ff);width:0%}\n  #shq .hero{background:linear-gradient(180deg,var(--night),var(--indigo));color:#fff;border-radius:18px;padding:22px}\n  #shq .hero .btn.alt{border-color:#fff;color:#fff}\n  #shq .footer-cta{background:var(--cloud);border-radius:14px;padding:14px}\n  #shq a{color:var(--peri);text-decoration:none}\n  #shq a:hover{text-decoration:underline}\n  #shq .two{display:grid;grid-template-columns:1fr;gap:16px}\n  @media(min-width:880px){#shq .two{grid-template-columns:1.1fr .9fr}}\n<\/style>\n<div id=\"shq\" aria-live=\"polite\">\n  <div class=\"stack\">\n    <section class=\"hero\">\n      <div class=\"h1\">Struggling to sleep? Take the Shhlumber Sleep Quiz<\/div>\n      <p class=\"muted\">Answer a few quick questions. We\u2019ll highlight likely causes and suggest friendly guidance and simple tools. No spam, no gimmicks.<\/p>\n      <div class=\"row\">\n        <button class=\"btn\" id=\"shq-start\">Start the quiz<\/button>\n        <button class=\"btn alt\" id=\"shq-reset\" style=\"display:none\">Start over<\/button>\n      <\/div>\n      <div class=\"progress\" style=\"margin-top:14px\"><div class=\"bar\" id=\"shq-bar\"><\/div><\/div>\n    <\/section>\n\n    <section id=\"shq-stage\" class=\"card\" hidden>\n      <div class=\"muted\" id=\"shq-section-label\"><\/div>\n      <h2 class=\"h2\" id=\"shq-question\"><\/h2>\n      <div id=\"shq-choices\" class=\"row\" role=\"group\" aria-label=\"Choices\"><\/div>\n      <div class=\"row\" style=\"margin-top:10px\">\n        <button class=\"btn alt\" id=\"shq-back\">Back<\/button>\n        <button class=\"btn\" id=\"shq-next\" disabled>Next<\/button>\n      <\/div>\n    <\/section>\n\n    <section id=\"shq-results\" class=\"two\" hidden>\n      <div class=\"card\" id=\"shq-summary\"><\/div>\n      <div class=\"card\" id=\"shq-recos\"><\/div>\n    <\/section>\n\n    <section id=\"shq-footer\" class=\"footer-cta\" hidden>\n      <div class=\"row\" style=\"justify-content:space-between;align-items:center\">\n        <div>\n          <strong>Want tailored tips by email?<\/strong>\n          <div class=\"muted\">Save your result and plan for later.<\/div>\n        <\/div>\n        <a class=\"btn alt\" href=\"\/sleep-quiz\/\" onclick=\"window.dispatchEvent(new CustomEvent('shhlumber:quiz_cta',{detail:{where:'footer'}}))\">Retake quiz<\/a>\n      <\/div>\n    <\/section>\n  <\/div>\n<\/div>\n<script>\n(function(){\n  const mount = document.getElementById('shq');\n  const els = {\n    start: document.getElementById('shq-start'),\n    reset: document.getElementById('shq-reset'),\n    stage: document.getElementById('shq-stage'),\n    label: document.getElementById('shq-section-label'),\n    q: document.getElementById('shq-question'),\n    choices: document.getElementById('shq-choices'),\n    back: document.getElementById('shq-back'),\n    next: document.getElementById('shq-next'),\n    bar: document.getElementById('shq-bar'),\n    results: document.getElementById('shq-results'),\n    summary: document.getElementById('shq-summary'),\n    recos: document.getElementById('shq-recos'),\n    footer: document.getElementById('shq-footer')\n  };\n\n  const KEY = 'shhlumber_quiz_v1';\n\n  const config = {\n    sections: [\n      { id:'A', title:'Emotional & mental health', nodes:[\n        {id:'A1',type:'single',q:'Do you feel stressed or anxious at night?',choices:[\n          {id:'never',label:'Never',fx:[]},\n          {id:'sometimes',label:'Sometimes',fx:[['stress',2]]},\n          {id:'often',label:'Often',fx:[['stress',4]]}\n        ]},\n        {id:'A2',type:'single',q:'Do racing thoughts keep you awake?',ask_if:(state)=>getTag(state,'stress')>0,choices:[\n          {id:'never',label:'Never',fx:[]},\n          {id:'sometimes',label:'Sometimes',fx:[['stress',2]]},\n          {id:'often',label:'Often',fx:[['stress',3]]}\n        ]},\n        {id:'A3',type:'single',q:'Have you had low mood, grief or major life change recently?',choices:[\n          {id:'no',label:'No',fx:[]},\n          {id:'yes',label:'Yes',fx:[['depression_flag',2],['stress',1]]}\n        ]}\n      ]},\n      { id:'B', title:'Lifestyle & habits', nodes:[\n        {id:'B1',type:'single',q:'How much caffeine do you have after midday?',choices:[\n          {id:'none',label:'None',fx:[]},\n          {id:'12',label:'1\u20132 drinks',fx:[['caffeine',2]]},\n          {id:'3p',label:'3+ drinks',fx:[['caffeine',4]]}\n        ]},\n        {id:'B2',type:'single',q:'Alcohol within 3\u20134 hours of bed?',choices:[\n          {id:'no',label:'No',fx:[]},\n          {id:'oc',label:'Occasionally',fx:[['alcohol',2]]},\n          {id:'often',label:'Most nights',fx:[['alcohol',4]]}\n        ]},\n        {id:'B3',type:'single',q:'Nicotine in the evening?',choices:[\n          {id:'no',label:'No',fx:[]},\n          {id:'yes',label:'Yes',fx:[['nicotine',3]]}\n        ]},\n        {id:'B4',type:'single',q:'Screens in the last hour before bed?',choices:[\n          {id:'never',label:'Never',fx:[]},\n          {id:'sometimes',label:'Sometimes',fx:[['blue_light',2]]},\n          {id:'always',label:'Always',fx:[['blue_light',4]]}\n        ]},\n        {id:'B5',type:'single',q:'Exercise pattern?',choices:[\n          {id:'reg',label:'Regular, not late',fx:[]},\n          {id:'rare',label:'Rarely',fx:[['inactivity',2]]},\n          {id:'late',label:'Vigorous late evening',fx:[['late_exercise',2]]}\n        ]},\n        {id:'B6',type:'single',q:'Daytime naps over 30 minutes or after 3pm?',choices:[\n          {id:'no',label:'No',fx:[]},\n          {id:'yes',label:'Yes',fx:[['napping',3]]}\n        ]},\n        {id:'B7',type:'single',q:'Are your bed\/wake times fairly regular?',choices:[\n          {id:'yes',label:'Yes',fx:[]},\n          {id:'var',label:'Quite variable',fx:[['irregular_schedule',3]]}\n        ]},\n        {id:'B8',type:'single',q:'How long have sleep issues been going on?',choices:[\n          {id:'lt2',label:'Under 2 weeks',fx:[]},\n          {id:'2to8',label:'2\u20138 weeks',fx:[]},\n          {id:'gt8',label:'Over 8 weeks',fx:[['chronicity',1]]}\n        ]}\n      ]},\n      { id:'C', title:'Environment', nodes:[\n        {id:'C1',type:'single',q:'Is your bedroom affected by noise?',choices:[\n          {id:'no',label:'No',fx:[]},\n          {id:'some',label:'Occasionally',fx:[['noise',2]]},\n          {id:'often',label:'Often',fx:[['noise',4]]}\n        ]},\n        {id:'C2',type:'single',q:'Does light disrupt your sleep?',choices:[\n          {id:'no',label:'No',fx:[]},\n          {id:'yes',label:'Yes',fx:[['light_exposure',3]]}\n        ]},\n        {id:'C3',type:'single',q:'Do you wake hot, cold or sweaty?',choices:[\n          {id:'no',label:'No',fx:[]},\n          {id:'yes',label:'Yes',fx:[['temperature',3]]}\n        ]},\n        {id:'C4',type:'single',q:'How comfortable is your pillow\/mattress?',choices:[\n          {id:'good',label:'Good',fx:[]},\n          {id:'ok',label:'Okay',fx:[['bedding_comfort',2]]},\n          {id:'poor',label:'Poor',fx:[['bedding_comfort',4]]}\n        ]},\n        {id:'C5',type:'single',q:'Do clothes or bedding feel itchy or sweaty?',choices:[\n          {id:'no',label:'No',fx:[]},\n          {id:'yes',label:'Yes',fx:[['fabric_comfort',2],['temperature',1]]}\n        ]}\n      ]},\n      { id:'D', title:'Physical health', nodes:[\n        {id:'D1',type:'single',q:'Do you have chronic pain (back\/neck\/arthritis\/migraine)?',choices:[\n          {id:'no',label:'No',fx:[]},\n          {id:'yes',label:'Yes',fx:[['pain',4]]}\n        ]},\n        {id:'D2',type:'single',q:'Heartburn, indigestion or reflux at night?',choices:[\n          {id:'no',label:'No',fx:[]},\n          {id:'some',label:'Sometimes',fx:[['reflux',2]]},\n          {id:'often',label:'Often',fx:[['reflux',4]]}\n        ]},\n        {id:'D2b',type:'single',q:'When does reflux bother you most?',ask_if:(s)=>getTag(s,'reflux')>0,choices:[\n          {id:'late',label:'After late\/spicy\/fatty meals',fx:[['reflux',1]]},\n          {id:'empty',label:'Even on an empty stomach',fx:[['reflux',1]]}\n        ]},\n        {id:'D3',type:'single',q:'Snore loudly, stop breathing or wake gasping?',choices:[\n          {id:'no',label:'No',fx:[]},\n          {id:'snore',label:'Partner notices snoring',fx:[['snoring',3]]},\n          {id:'gasp',label:'Gasping\/pauses or very sleepy by day',fx:[['snoring',5],['daytime_sleepiness',3]]}\n        ]},\n        {id:'D3b',type:'single',q:'How likely are you to doze in the day?',ask_if:(s)=>getTag(s,'snoring')>0,choices:[\n          {id:'rare',label:'Rarely',fx:[]},\n          {id:'some',label:'Sometimes',fx:[['daytime_sleepiness',2]]},\n          {id:'often',label:'Often',fx:[['daytime_sleepiness',4]]}\n        ]},\n        {id:'D4',type:'single',q:'Restless legs or urge to move at night?',choices:[\n          {id:'no',label:'No',fx:[]},\n          {id:'yes',label:'Yes',fx:[['restless_legs',4]]}\n        ]},\n        {id:'D5',type:'single',q:'Wake to urinate 2+ times most nights?',choices:[\n          {id:'no',label:'No',fx:[]},\n          {id:'yes',label:'Yes',fx:[['nocturia',3]]}\n        ]},\n        {id:'D6',type:'single',q:'Menopause symptoms (hot flushes\/night sweats)?',choices:[\n          {id:'no',label:'No',fx:[]},\n          {id:'yes',label:'Yes',fx:[['menopause',4],['temperature',1]]}\n        ]},\n        {id:'D7',type:'single',q:'Night allergies or congestion?',choices:[\n          {id:'no',label:'No',fx:[]},\n          {id:'yes',label:'Yes',fx:[['allergy',3]]}\n        ]},\n        {id:'D7b',type:'single',q:'Likely triggers?',ask_if:(s)=>getTag(s,'allergy')>0,choices:[\n          {id:'dust',label:'Dust\/pets\/bedding',fx:[['allergy',1]]},\n          {id:'unk',label:'Not sure',fx:[]}\n        ]}\n      ]},\n      { id:'E', title:'Sleep rhythm', nodes:[\n        {id:'E1',type:'single',q:'Do you work shifts or irregular hours?',choices:[\n          {id:'no',label:'No',fx:[]},\n          {id:'yes',label:'Yes',fx:[['shift_work',4],['light_exposure',1]]}\n        ]},\n        {id:'E2',type:'single',q:'Night owl: go to bed very late and struggle to wake early?',choices:[\n          {id:'no',label:'No',fx:[]},\n          {id:'yes',label:'Yes',fx:[['delayed_phase',4]]}\n        ]},\n        {id:'E3',type:'single',q:'Early bird: sleepy early evening, wake very early?',choices:[\n          {id:'no',label:'No',fx:[]},\n          {id:'yes',label:'Yes',fx:[['advanced_phase',4]]}\n        ]}\n      ]}\n    ],\n    leaves:{\n      stress:{title:'Stress & racing thoughts',copy:'Your answers suggest stress or a busy mind may be affecting your sleep. A short wind-down helps many people.',articles:['\/advice\/stress-wind-down\/'],products:['\/shop\/stress-solutions\/']},\n      blue_light:{title:'Evening screens & light',copy:'Evening light and screens can keep you alert. Aim for warm, low lighting and a darker bedroom.',articles:['\/advice\/light-exposure\/'],products:['\/shop\/light-solutions\/']},\n      light_exposure:{title:'Evening light & bedroom darkness',copy:'Light exposure looks relevant. Small changes to lamps, masks and curtains can help.',articles:['\/advice\/light-exposure\/'],products:['\/shop\/light-solutions\/']},\n      noise:{title:'Noise',copy:'Irregular sounds are likely disturbing you. A steady masking sound + earplugs can help.',articles:['\/advice\/noise-sleep\/'],products:['\/shop\/noise-solutions\/']},\n      temperature:{title:'Room temperature',copy:'Comfort seems affected by temperature. Aim for a cool, steady room and breathable bedding.',articles:['\/advice\/room-temperature\/'],products:['\/shop\/temperature-solutions\/']},\n      bedding_comfort:{title:'Pillow & mattress comfort',copy:'Comfort matters. Consider pillow\/mattress tweaks that match your sleep position.',articles:['\/advice\/room-temperature\/'],products:['\/shop\/bedding\/']},\n      fabric_comfort:{title:'Sleepwear & bedding fabric',copy:'Breathable, softer fabrics may keep you more comfortable overnight.',articles:['\/advice\/room-temperature\/'],products:['\/shop\/bedding\/']},\n      caffeine:{title:'Caffeine timing',copy:'Caffeine after midday looks relevant. Try earlier cut-offs.',articles:['\/advice\/stress-wind-down\/'],products:['\/shop\/stress-solutions\/']},\n      irregular_schedule:{title:'Routine & regularity',copy:'Variable sleep times or long naps may be part of the picture.',articles:['\/advice\/stress-wind-down\/'],products:['\/shop\/stress-solutions\/']},\n      napping:{title:'Daytime napping',copy:'Late or long naps can push sleep later.',articles:['\/advice\/stress-wind-down\/'],products:['\/shop\/stress-solutions\/']},\n      reflux:{title:'Digestion & reflux',copy:'Night-time reflux\/discomfort looks relevant. Elevation and gentler evenings can help.',articles:['\/advice\/digestion-reflux\/'],products:['\/shop\/reflux-digestion\/']},\n      pain:{title:'Pain & comfort',copy:'Persistent pain can fragment sleep. Positioning and comfort aids may help.',articles:['\/advice\/room-temperature\/'],products:['\/shop\/bedding\/']},\n      snoring:{title:'Snoring & breathing',copy:'Snoring may be playing a role. Simple tweaks can help; see notes below.',articles:['\/advice\/snoring-breathing\/'],products:['\/shop\/snoring-breathing\/']},\n      restless_legs:{title:'Restless legs',copy:'Leg restlessness can make nights tricky. A calm routine and comfort aids may help.',articles:['\/advice\/stress-wind-down\/'],products:['\/shop\/stress-solutions\/']},\n      allergy:{title:'Allergies',copy:'Night allergies or congestion may be involved. Bedroom allergy control can help.',articles:['\/advice\/room-temperature\/'],products:['\/shop\/bedding\/']},\n      shift_work:{title:'Shift work',copy:'Your schedule suggests shift work. Light and darkness timing become key tools.',articles:['\/advice\/light-exposure\/'],products:['\/shop\/light-solutions\/']},\n      delayed_phase:{title:'Late body clock',copy:'You may be a night owl. Nudge light earlier in the morning and dim in the evening.',articles:['\/advice\/light-exposure\/'],products:['\/shop\/light-solutions\/']},\n      advanced_phase:{title:'Early body clock',copy:'Very early wake-ups suggest an advanced sleep phase.',articles:['\/advice\/light-exposure\/'],products:['\/shop\/light-solutions\/']}\n    },\n    thresholds:{primary:3,maxTop:4},\n    redflags:[\n      {id:'apnoea', test:(t)=> t.snoring>=4 || (t.snoring>=3 && (t.daytime_sleepiness||0)>=3), message:'Some answers suggest possible obstructive sleep apnoea. If snoring is loud\/regular or there are breathing pauses or severe daytime sleepiness, it\u2019s sensible to speak to your GP for personalised advice.'},\n      {id:'chronic_pain', test:(t)=> (t.pain||0)>=4 && (t.chronicity||0)>=1, message:'Ongoing pain can keep sleep light. A GP or physiotherapist can advise on tailored options.'}\n    ]\n  };\n\n  \/\/ ---------- engine state ----------\n  let state = load() || {i:0, path:[], tags:{}};\n\n  function save(){ try { localStorage.setItem(KEY, JSON.stringify(state)); } catch(e) { \/* storage may be unavailable; carry on without persistence *\/ } }\n  function load(){ try { const raw = localStorage.getItem(KEY); return raw ? JSON.parse(raw) : null; } catch(e) { return null; } }\n  function reset(){\n      \/\/ fully clear state and UI\n      state = { i:0, path:[], tags:{} };\n      try { localStorage.removeItem(KEY); } catch(e){}\n      els.summary.innerHTML = '';\n      els.recos.innerHTML = '';\n      els.choices.innerHTML = '';\n      els.bar.style.width = '0%';\n      els.stage.hidden = true;\n      els.results.hidden = true;\n      els.footer.hidden = true;\n      els.reset.style.display='none';\n      renderIntro();\n    }\n  function getTag(s,tag){ return (s.tags[tag]||0); }\n  function addFx(effects){ effects.forEach(([tag,w])=>{ state.tags[tag]=(state.tags[tag]||0)+w; }); }\n\n  \/\/ flatten nodes with branching\n  function buildFlow(){\n    const seq=[];\n    config.sections.forEach(sec=>{\n      sec.nodes.forEach(n=>{ seq.push({...n,section:sec.title}); });\n    });\n    return seq;\n  }\n  const flow = buildFlow();\n\n  function nextEligibleIndex(from){\n    for(let idx=from; idx<flow.length; idx++){\n      const n = flow[idx];\n      if(!n.ask_if || n.ask_if(state)) return idx;\n    }\n    return flow.length; \/\/ done\n  }\n\n  function start(){\n    window.dispatchEvent(new CustomEvent('shhlumber:quiz_start'));\n    els.summary.innerHTML=''; els.recos.innerHTML='';\n    els.bar.style.width='0%';\n    els.stage.hidden=false; els.results.hidden=true; els.footer.hidden=true; els.reset.style.display='inline-flex';\n    state.i = nextEligibleIndex(0); save(); renderNode();\n  }\n\n  function renderIntro(){\n    els.stage.hidden=true; els.results.hidden=true; els.footer.hidden=true; els.reset.style.display='none';\n    const done = state.path.length>0;\n    els.start.textContent = done? 'Continue where I left off' : 'Start the quiz';\n    updateBar();\n  }\n\n  function updateBar(){\n    const answered = state.path.length;\n    const total = flow.length; \/\/ simple, stable estimate\n    const pct = Math.min(100, Math.round((answered\/Math.max(1,total))*100));\n    els.bar.style.width = pct + '%';\n  }\n\n  function renderNode(){\n    updateBar();\n    if(state.i>=flow.length){ return finish(); }\n    const node = flow[state.i];\n    if(node.ask_if && !node.ask_if(state)){ state.i = nextEligibleIndex(state.i+1); return renderNode(); }\n\n    els.label.textContent = node.section;\n    els.q.textContent = node.q;\n    els.choices.innerHTML='';\n    els.next.disabled=true;\n\n    const selected = state.path.find(p=>p.id===node.id)?.choiceId || null;\n\n    node.choices.forEach(ch=>{\n      const btn=document.createElement('button');\n      btn.className='chip'; btn.type='button'; btn.textContent=ch.label; btn.setAttribute('data-id',ch.id);\n      btn.setAttribute('data-selected', selected===ch.id ? 'true':'false');\n      btn.addEventListener('click',()=>{\n        [...els.choices.children].forEach(c=>c.setAttribute('data-selected','false'));\n        btn.setAttribute('data-selected','true');\n        els.next.disabled=false;\n        state._pendingChoice = {id:node.id, choiceId:ch.id, fx:ch.fx};\n      });\n      els.choices.appendChild(btn);\n    });\n\n    els.back.onclick = ()=>{\n      if(state.path.length===0){ renderIntro(); return; }\n      \/\/ pop until previous visible node\n      const prev = state.path.pop();\n      \/\/ reverse fx\n      prev.fx.forEach(([tag,w])=>{ state.tags[tag]-=w; if(state.tags[tag]<=0) delete state.tags[tag]; });\n      \/\/ find previous index that is eligible given new state\n      for(let i=state.i-1;i>=0;i--){ const n=flow[i]; if(!n.ask_if || n.ask_if(state)){ state.i=i; break; } }\n      save(); renderNode();\n    };\n\n    els.next.onclick = ()=>{\n      if(!state._pendingChoice){ return; }\n      const sel=state._pendingChoice; delete state._pendingChoice;\n      \/\/ remove any previous answer for this node\n      const idx=state.path.findIndex(p=>p.id===node.id);\n      if(idx>=0){ const old=state.path.splice(idx,1)[0]; old.fx.forEach(([t,w])=>{ state.tags[t]-=w; if(state.tags[t]<=0) delete state.tags[t]; }); }\n      state.path.push(sel); addFx(sel.fx); save();\n      state.i = nextEligibleIndex(state.i+1);\n      renderNode();\n    };\n  }\n\n  function finish(){\n    els.stage.hidden = true; updateBar();\n    window.dispatchEvent(new CustomEvent('shhlumber:quiz_complete',{detail:{tags:state.tags}}));\n\n    const tags = state.tags;\n    const entries = Object.entries(tags).sort((a,b)=>b[1]-a[1]);\n    const picks = entries.filter(([k,v])=>v>=config.thresholds.primary).slice(0,config.thresholds.maxTop);\n    const red = config.redflags.filter(r=>{ try{return r.test(tags);}catch(e){return false;} });\n\n    \/\/ If there are no recommendations and no red flags, hide results entirely\n    if(picks.length===0 && red.length===0){\n      els.summary.innerHTML='';\n      els.recos.innerHTML='';\n      els.results.hidden = true;\n      els.footer.hidden = false; \/\/ keep the CTA visible\n      return;\n    }\n\n    els.results.hidden = false; els.footer.hidden = false;\n\n    \/\/ summary\n    let html = '<h3 class=\"h2\">Your likely sleep disruptors<\/h3>';\n    picks.forEach(([tag,score])=>{\n      const leaf=config.leaves[tag]||{title:tag,copy:'\u00a0'};\n      html += `<div style=\\\"margin:.6rem 0\\\"><strong>${leaf.title}<\/strong> <span class=\\\"muted\\\">(score ${score})<\/span><br>${leaf.copy}<\/div>`;\n    });\n    if(red.length){\n      html += '<div style=\"margin-top:10px;padding:10px;border-radius:10px;background:#FFF5E9;border:1px solid #FFD9B5;color:#6b3c00\">'+\n              '<strong>When to seek personalised advice<\/strong><ul style=\"margin:.4rem 0 0 1rem\">'+\n              red.map(r=>`<li>${r.message}<\/li>`).join('')+\n              '<\/ul><\/div>';\n    }\n    html += '<p class=\"muted\" style=\"margin-top:10px\">This is general guidance. Keep what helps, ignore the rest.<\/p>';\n    els.summary.innerHTML = html;\n\n    \/\/ recos\n    let rec = '<h3 class=\"h2\">Next steps<\/h3>';\n    picks.forEach(([tag])=>{\n      const leaf=config.leaves[tag]; if(!leaf) return;\n      rec += `<div class=\\\"card\\\" style=\\\"margin-bottom:10px;background:#fff\\\"><div class=\\\"h2\\\" style=\\\"margin:0 0 6px\\\">${leaf.title}<\/div>`+\n             `<div class=\\\"row\\\" style=\\\"gap:8px;margin:.2rem 0 .6rem\\\">`+\n             (leaf.articles||[]).map(u=>`<a class=\\\"chip\\\" href=\\\"${u}\\\">Read advice<\/a>`).join('')+\n             (leaf.products?`<a class=\\\"chip\\\" href=\\\"${leaf.products[0]}\\\">Browse solutions<\/a>`:'')+\n             `<\/div><\/div>`;\n    });\n    const seenCats=new Set();\n    picks.forEach(([tag])=>{ const leaf=config.leaves[tag]; if(leaf&&leaf.products){ seenCats.add(leaf.products[0]); } });\n    if(seenCats.size){ rec += `<div class=\\\"muted\\\">Helpful categories: ${[...seenCats].map(u=>`<a href=\\\"${u}\\\">${u.split('\/').filter(Boolean).pop().replaceAll('-', ' ')}<\/a>`).join(' \u00b7 ')}<\/div>`; }\n    els.recos.innerHTML = rec;\n  }\n\n  \/\/ wire buttons\n  els.start.addEventListener('click', start);\n  els.reset.addEventListener('click', reset);\n\n  \/\/ initial paint\n  if(state.path.length){ els.reset.style.display='inline-flex'; }\n  renderIntro();\n})();\n<\/script>\n","protected":false},"excerpt":{"rendered":"<p>Struggling to sleep? Take the Shhlumber Sleep Quiz Answer a few quick questions. We\u2019ll highlight likely causes and suggest friendly guidance and simple tools. No spam, no gimmicks. Start the quiz Start over Back Next Want tailored tips by email? Save your result and plan for later. Retake quiz<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"hk_page","meta":{"saved_in_kubio":false,"footnotes":""},"class_list":["post-260","page","type-page","status-publish","hentry"],"kubio_ai_page_context":{"short_desc":"","purpose":"general"},"_links":{"self":[{"href":"https:\/\/shhlumber.com\/index.php\/wp-json\/wp\/v2\/pages\/260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shhlumber.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/shhlumber.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/shhlumber.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shhlumber.com\/index.php\/wp-json\/wp\/v2\/comments?post=260"}],"version-history":[{"count":2,"href":"https:\/\/shhlumber.com\/index.php\/wp-json\/wp\/v2\/pages\/260\/revisions"}],"predecessor-version":[{"id":265,"href":"https:\/\/shhlumber.com\/index.php\/wp-json\/wp\/v2\/pages\/260\/revisions\/265"}],"wp:attachment":[{"href":"https:\/\/shhlumber.com\/index.php\/wp-json\/wp\/v2\/media?parent=260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}