{"id":260,"date":"2025-09-03T13:59:19","date_gmt":"2025-09-03T13:59:19","guid":{"rendered":"https:\/\/shhlumber.com\/?page_id=260"},"modified":"2026-10-04T12:58:55","modified_gmt":"2026-10-04T12:58:55","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 [hidden]{display:none !important} #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  #shq a{color:#2f4bb8} #shq .hero a{color:#fff} #shq .chip[data-selected=\"true\"]{border:2px solid #2f4bb8} #shq .chip[data-selected=\"true\"]::before{content:\"\\2713  \"} #shq .note{padding:12px;border-radius:10px;margin:.6rem 0} #shq .note.info{background:#EEF3FF;border:1px solid #CBD8FF} #shq .note.warn{background:#FFF5E9;border:1px solid #FFD9B5;color:#6b3c00} #shq .note.good{background:#EDF8F0;border:1px solid #BFE3C9} #shq details summary{cursor:pointer;margin:.6rem 0;font-weight:600} #shq .src{font-size:.85rem;margin-top:10px}\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 questions (about 5 minutes). We\u2019ll highlight things that may be affecting your sleep and point you to guidance and simple tools. This is general information, not a diagnosis. Your answers stay in your browser.<\/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 to come back to this later?<\/strong>\n        <div class=\"muted\">Your answers stay in this browser only, so your results will be here when you return. Nothing is sent to us.<\/div>\n        <div class=\"muted src\">Based on <a href=\"https:\/\/cks.nice.org.uk\/topics\/insomnia\/\" target=\"_blank\" rel=\"noopener\">NICE guidance on insomnia<\/a> and <a href=\"https:\/\/www.nhs.uk\/conditions\/insomnia\/\" target=\"_blank\" rel=\"noopener\">NHS advice<\/a>. General information only.<\/div>\n        <\/div>\n        <span class=\"row\" style=\"gap:8px\"><button class=\"btn alt\" type=\"button\" id=\"shq-edit\">Change my answers<\/button><button class=\"btn alt\" type=\"button\" id=\"shq-retake\">Retake quiz<\/button><\/span>\n      <\/div>\n    <\/section>\n  <\/div>\n<\/div>\n<script>\n(function(){\n  const mount = document.getElementById('shq');\n  const els = { start:document.getElementById('shq-start'), reset:document.getElementById('shq-reset'), stage:document.getElementById('shq-stage'), label:document.getElementById('shq-section-label'), q:document.getElementById('shq-question'), choices:document.getElementById('shq-choices'), back:document.getElementById('shq-back'), next:document.getElementById('shq-next'), bar:document.getElementById('shq-bar'), results:document.getElementById('shq-results'), summary:document.getElementById('shq-summary'), recos:document.getElementById('shq-recos'), footer:document.getElementById('shq-footer') };\n  const KEY = 'shhlumber_quiz_v2';\n  const P = '\/index.php\/';\n  const HUB = P + 'sleep-solutions\/';\n  const NHS = 'https:\/\/www.nhs.uk\/conditions\/';\n  const ART = { stress:P+'stress-racing-thoughts-wind-down-routines-that-actually-work\/', light:P+'light-exposure-a-simple-guide-to-darker-nights-and-brighter-mornings\/', noise:P+'noise-mask-sound-and-calm-a-busy-environment\/', temp:P+'room-temperature-get-your-sleep-climate-just-right\/', reflux:P+'digestion-reflux-night-time-habits-that-reduce-discomfort\/', snore:P+'snoring-breathing-when-to-tweak-when-to-see-a-professional\/' };\n  const SOL = { stress:HUB+'stress-racing-thoughts\/', light:HUB+'light\/', noise:HUB+'noise\/', temp:HUB+'room-temperature\/', reflux:HUB+'digestion-reflux\/', snore:HUB+'snoring-breathing\/' };\n  const ch = (id,label,fx)=>({id:id,label:label,fx:fx||[]});\n  const noPrior = (id,not)=>(s)=>{ const a=s.path.find(p=>p.id===id); return !!a && a.choiceId!==not; };\n  const affected = (s)=>(s.tags.impact||0)>0;\n\n  const flow = [\n    {id:'S1',section:'About your sleep',q:'Over the past month, how much has poor sleep affected your days (energy, mood, concentration)?',choices:[ch('none','Not at all'),ch('little','A little',[['impact',1]]),ch('lot','Quite a lot',[['impact',2]]),ch('very','Very much',[['impact',3]])]},\n    {id:'S2',section:'About your sleep',ask_if:affected,q:'On how many nights a week do you have a problem with your sleep?',choices:[ch('lt3','Fewer than 3'),ch('3-4','3 or 4',[['freq',1]]),ch('5-7','5 to 7',[['freq',2]])]},\n    {id:'S3',section:'About your sleep',ask_if:affected,q:'How long has this been going on?',choices:[ch('lt1','Under a month'),ch('1-3','1 to 3 months',[['dur',1]]),ch('gt3','More than 3 months',[['dur',2]])]},\n    {id:'S4',section:'About your sleep',ask_if:affected,q:'What is the main problem?',choices:[ch('onset','Getting to sleep',[['pat_onset',1]]),ch('maint','Staying asleep',[['pat_maint',1]]),ch('early','Waking too early',[['pat_early',1]]),ch('unref','Waking unrefreshed',[['pat_unref',1]]),ch('mixed','A bit of everything')]},\n\n    {id:'B1',section:'Daily habits',q:'How much tea, coffee, cola or energy drink do you have after midday?',choices:[ch('none','None'),ch('12','1 to 2 drinks',[['caffeine',2]]),ch('3p','3 or more',[['caffeine',4]])]},\n    {id:'B2',section:'Daily habits',q:'Do you drink alcohol in the evening, or to help you sleep?',choices:[ch('no','No'),ch('occ','Occasionally',[['alcohol',2]]),ch('most','Most nights',[['alcohol',4]])]},\n    {id:'B3',section:'Daily habits',q:'Do you smoke or vape in the evening?',choices:[ch('no','No'),ch('yes','Yes',[['nicotine',3]])]},\n    {id:'B4',section:'Daily habits',q:'How often do you use screens in the hour before bed?',choices:[ch('never','Never'),ch('some','Sometimes',[['blue_light',2]]),ch('always','Always',[['blue_light',4]])]},\n    {id:'B5',section:'Daily habits',q:'How would you describe your exercise?',choices:[ch('reg','Regular, and finished more than an hour before bed'),ch('rare','I rarely exercise',[['inactivity',2]]),ch('late','Often vigorous, within an hour of bed',[['late_exercise',3]])]},\n    {id:'B6',section:'Daily habits',q:'Do you nap for more than 30 minutes, or after 3pm?',choices:[ch('no','No'),ch('yes','Yes',[['napping',3]])]},\n    {id:'B7',section:'Daily habits',q:'Do you get up at about the same time every day, including weekends?',choices:[ch('yes','Yes'),ch('var','It varies quite a bit',[['irregular_schedule',3]])]},\n    {id:'B8',section:'Daily habits',q:'Do you use your bed for work, TV or scrolling, or check the clock during the night?',choices:[ch('no','No'),ch('some','Sometimes',[['bed_habits',2]]),ch('often','Often',[['bed_habits',3]])]},\n\n    {id:'C1',section:'Your bedroom',q:'Is your bedroom affected by noise?',choices:[ch('no','No'),ch('occ','Occasionally',[['noise',2]]),ch('often','Often',[['noise',4]])]},\n    {id:'C2',section:'Your bedroom',q:'Does light disrupt your sleep?',choices:[ch('no','No'),ch('yes','Yes',[['light_exposure',3]])]},\n    {id:'C3',section:'Your bedroom',q:'Do you wake feeling too hot, too cold or sweaty?',choices:[ch('no','No'),ch('yes','Yes',[['temperature',3]])]},\n    {id:'C4',section:'Your bedroom',q:'How comfortable is your pillow and mattress?',choices:[ch('good','Good'),ch('ok','Okay',[['bedding_comfort',2]]),ch('poor','Poor',[['bedding_comfort',4]])]},\n    {id:'C5',section:'Your bedroom',q:'Do your clothes or bedding feel itchy or sweaty?',choices:[ch('no','No'),ch('yes','Yes',[['fabric_comfort',2],['temperature',1]])]},\n\n    {id:'D1',section:'Your body',q:'Do you have ongoing pain (back, neck, joints, headaches)?',choices:[ch('no','No'),ch('yes','Yes',[['pain',4]])]},\n    {id:'D2',section:'Your body',q:'Do you get heartburn, indigestion or reflux at night?',choices:[ch('no','No'),ch('some','Sometimes',[['reflux',2]]),ch('often','Often',[['reflux',4]])]},\n    {id:'D3',section:'Your body',q:'Do you snore loudly, stop breathing, or wake gasping?',choices:[ch('no','No'),ch('snore','Someone has noticed snoring',[['snoring',3]]),ch('severe','Gasping or pauses in breathing, or very sleepy by day',[['snoring',5],['daytime_sleepiness',3]])]},\n    {id:'D3b',section:'Your body',ask_if:noPrior('D3','no'),q:'How likely are you to doze off during the day?',choices:[ch('rare','Rarely'),ch('some','Sometimes',[['daytime_sleepiness',2]]),ch('often','Often',[['daytime_sleepiness',4]])]},\n    {id:'D4',section:'Your body',q:'Do you have restless legs or an urge to move them at night?',choices:[ch('no','No'),ch('yes','Yes',[['restless_legs',4]])]},\n    {id:'D5',section:'Your body',q:'Do you wake to pass urine two or more times on most nights?',choices:[ch('no','No'),ch('yes','Yes',[['nocturia',3]])]},\n    {id:'D6',section:'Your body',q:'Do you have menopause symptoms such as hot flushes or night sweats?',choices:[ch('no','No'),ch('yes','Yes',[['menopause',4],['temperature',1]]),ch('skip','Prefer not to say')]},\n    {id:'D7',section:'Your body',q:'Do allergies or a blocked nose disturb your nights?',choices:[ch('no','No'),ch('yes','Yes',[['allergy',3]])]},\n\n    {id:'A1',section:'Your mind',q:'Do you feel stressed or anxious at night?',choices:[ch('never','Never'),ch('some','Sometimes',[['stress',2]]),ch('often','Often',[['stress',4]])]},\n    {id:'A2',section:'Your mind',ask_if:noPrior('A1','never'),q:'Do racing thoughts keep you awake?',choices:[ch('never','Never'),ch('some','Sometimes',[['stress',2]]),ch('often','Often',[['stress',3]])]},\n    {id:'A3',section:'Your mind',q:'Have you been feeling low, or had a major life change or loss recently?',choices:[ch('no','No'),ch('yes','Yes',[['mood',2],['stress',1]]),ch('skip','Prefer not to say')]},\n\n    {id:'E1',section:'Your body clock',q:'Do you work shifts or irregular hours?',choices:[ch('no','No'),ch('yes','Yes',[['shift_work',4],['light_exposure',1]])]},\n    {id:'E2',section:'Your body clock',q:'Do you go to bed very late and struggle to get up early, even when you want to?',choices:[ch('no','No'),ch('yes','Yes',[['delayed_phase',4]])]},\n    {id:'E3',section:'Your body clock',q:'Do you wake much earlier than you want to and struggle to get back to sleep?',choices:[ch('no','No'),ch('yes','Yes',[['early_waking',3]])]},\n\n    {id:'M1',section:'Your health',q:'Do you take regular medicines that could affect sleep (for example steroid tablets, some antidepressants, or beta-blockers)?',choices:[ch('no','No'),ch('yes','Yes, or I am not sure',[['meds',3]]),ch('skip','Prefer not to say')]}\n  ];\n\n  const hubLink = {hub:true};\n  const leaves = {\n    stress:{title:'Stress and racing thoughts',copy:'A busy mind is one of the most common reasons for trouble getting to sleep. A short, regular wind-down can help.',art:ART.stress,sol:SOL.stress},\n    blue_light:{title:'Screens and bright light before bed',copy:'NICE advises keeping devices and bright light away for at least an hour before bed.',art:ART.light,sol:SOL.light},\n    light_exposure:{title:'Light in the bedroom',copy:'Light at the wrong time can disturb sleep. Darker evenings and brighter mornings help your body clock.',art:ART.light,sol:SOL.light},\n    noise:{title:'Noise',copy:'Irregular sounds can break up sleep. A steady background sound or earplugs help some people.',art:ART.noise,sol:SOL.noise},\n    temperature:{title:'Room temperature',copy:'A bedroom that is too hot or too cold can disturb sleep. A cool, steady room usually helps.',art:ART.temp,sol:SOL.temp},\n    bedding_comfort:{title:'Pillow and mattress comfort',copy:'A comfortable sleeping environment matters. Small changes to your pillow or bedding may help.',art:ART.temp,sol:SOL.temp},\n    fabric_comfort:{title:'Sleepwear and bedding fabric',copy:'Breathable, softer fabrics may keep you more comfortable overnight.',art:ART.temp,sol:SOL.temp},\n    caffeine:{title:'Caffeine',copy:'NICE advises avoiding caffeine after midday. It can stay in your body for hours.',hub:true},\n    alcohol:{title:'Alcohol',copy:'Alcohol may make you drowsy, but it is a common self-treatment that can make staying asleep harder. NICE suggests avoiding it within 2 hours of bed.',hub:true},\n    nicotine:{title:'Nicotine',copy:'Nicotine is a stimulant. NICE suggests avoiding it within 2 hours of bedtime.',hub:true},\n    late_exercise:{title:'Late, vigorous exercise',copy:'Exercise helps sleep, but NICE suggests avoiding vigorous exercise in the hour before bed.',hub:true},\n    inactivity:{title:'Daytime activity',copy:'Regular activity earlier in the day is generally helpful for sleep.',hub:true},\n    napping:{title:'Daytime naps',copy:'Long or late naps can make it harder to feel sleepy at bedtime. NICE suggests avoiding daytime naps.',hub:true},\n    irregular_schedule:{title:'A regular wake-up time',copy:'NICE suggests getting up at the same time every day, including weekends, and getting bright light in the morning.',hub:true},\n    bed_habits:{title:'How you use your bed',copy:'NICE suggests keeping the bed for sleep and intimacy, and avoiding checking the clock during the night.',art:ART.stress,sol:SOL.stress},\n    reflux:{title:'Digestion and reflux',copy:'Night-time reflux or discomfort can disturb sleep. Raising your head and gentler evenings can help.',art:ART.reflux,sol:SOL.reflux},\n    pain:{title:'Pain and comfort',copy:'Ongoing pain can break up sleep. Positioning and comfort aids may help, and a GP can advise on pain itself.',art:ART.temp,sol:SOL.temp},\n    snoring:{title:'Snoring and breathing',copy:'Snoring may be playing a role. Simple changes can help, and some signs are worth checking with a GP (see below).',art:ART.snore,sol:SOL.snore},\n    restless_legs:{title:'Restless legs',copy:'Restless legs can make settling hard. The NHS suggests seeing a GP if it stops you sleeping.',nhs:'restless-legs-syndrome\/',nhsLabel:'NHS: restless legs'},\n    allergy:{title:'Allergies and congestion',copy:'Night allergies or a blocked nose may be involved. Bedroom allergy control can help.',art:ART.temp,sol:SOL.temp},\n    shift_work:{title:'Shift work',copy:'Shift work makes light and darkness timing key. Dark, quiet sleep and planned light exposure can help.',art:ART.light,sol:SOL.light},\n    delayed_phase:{title:'A late body clock',copy:'You may be a natural night owl. Bright light earlier in the day and dimmer evenings can help shift your clock.',art:ART.light,sol:SOL.light},\n    early_waking:{title:'Waking too early',copy:'Early waking is a common insomnia symptom. Morning light, a steady routine and a restful bedroom can help. If it keeps happening, mention it to your GP.',art:ART.light,sol:SOL.light}\n  };\n  const patternBoost = {\n    onset:['stress','caffeine','blue_light','irregular_schedule','napping','delayed_phase','bed_habits','nicotine'],\n    maint:['alcohol','temperature','noise','reflux','pain','snoring','allergy','bed_habits'],\n    early:['light_exposure','early_waking','alcohol','stress'],\n    unref:['snoring','restless_legs','pain']\n  };\n\n  let state = load() || {i:0,path:[],tags:{}};\n  let first = true;\n  function save(){ try{ localStorage.setItem(KEY, JSON.stringify(state)); }catch(e){} }\n  function load(){ try{ const r=localStorage.getItem(KEY); return r?JSON.parse(r):null; }catch(e){ return null; } }\n  const T = (t)=>state.tags[t]||0;\n  function addFx(fx){ fx.forEach(([t,w])=>{ state.tags[t]=(state.tags[t]||0)+w; }); }\n  function subFx(fx){ fx.forEach(([t,w])=>{ state.tags[t]=(state.tags[t]||0)-w; if(state.tags[t]<=0) delete state.tags[t]; }); }\n  function eligible(n){ return !n.ask_if || n.ask_if(state); }\n  function nextIdx(from){ for(let k=from;k<flow.length;k++){ if(eligible(flow[k])) return k; } return flow.length; }\n  function prevIdx(from){ for(let k=from;k>=0;k--){ if(eligible(flow[k])) return k; } return -1; }\n  function prune(){ let c=true; while(c){ c=false; for(let k=state.path.length-1;k>=0;k--){ const p=state.path[k]; const n=flow.find(x=>x.id===p.id); if(n && !eligible(n)){ state.path.splice(k,1); subFx(p.fx); c=true; } } } }\n  function evt(name){ try{ window.dispatchEvent(new CustomEvent('shhlumber:'+name)); if(typeof window.gtag==='function'){ window.gtag('event',name); } }catch(e){} }\n\n  function reset(){\n    state = {i:0,path:[],tags:{}};\n    try{ localStorage.removeItem(KEY); }catch(e){}\n    els.summary.innerHTML=''; els.recos.innerHTML=''; els.choices.innerHTML='';\n    els.bar.style.width='0%'; els.stage.hidden=true; els.results.hidden=true; els.footer.hidden=true;\n    els.reset.style.display='none'; renderIntro();\n  }\n  function renderIntro(){\n    els.start.style.display=''; els.stage.hidden=true; els.results.hidden=true; els.footer.hidden=true; els.reset.style.display=state.path.length?'inline-flex':'none';\n    els.start.textContent = state.path.length>0 ? 'Continue where I left off' : 'Start the quiz';\n    updateBar();\n  }\n  function updateBar(){\n    const el = flow.filter(eligible); const answered = state.path.filter(p=>{ const n=flow.find(x=>x.id===p.id); return n && eligible(n); }).length;\n    els.bar.style.width = (state.done?100:Math.min(100,Math.round(answered\/Math.max(1,el.length)*100)))+'%';\n  }\n  function start(){\n    evt('quiz_start');\n    els.summary.innerHTML=''; els.recos.innerHTML='';\n    els.stage.hidden=false; els.results.hidden=true; els.footer.hidden=true; els.reset.style.display='inline-flex';\n    state.done=false;\n    if(state.path.length===0 || typeof state.i!=='number' || state.i>=flow.length){ state.i=nextIdx(0); }\n    save(); renderNode();\n  }\n  function renderNode(){\n    updateBar();\n    if(state.i>=flow.length){ return finish(); }\n    const node = flow[state.i];\n    if(!eligible(node)){ state.i=nextIdx(state.i+1); return renderNode(); }\n    const el = flow.filter(eligible);\n    els.label.textContent = node.section+' \u00b7 Question '+(el.indexOf(node)+1)+' of '+el.length;\n    els.q.textContent = node.q;\n    els.choices.innerHTML=''; els.next.disabled=true;\n    delete state._pending;\n    const prev = state.path.find(p=>p.id===node.id);\n    if(prev){ state._pending={id:prev.id,choiceId:prev.choiceId,fx:prev.fx}; els.next.disabled=false; }\n    node.choices.forEach(c=>{\n      const b=document.createElement('button'); b.className='chip'; b.type='button'; b.textContent=c.label; b.setAttribute('data-id',c.id);\n      const sel = !!prev && prev.choiceId===c.id; b.setAttribute('data-selected',sel?'true':'false'); b.setAttribute('aria-pressed',sel?'true':'false');\n      b.addEventListener('click',()=>{\n        [...els.choices.children].forEach(x=>{ x.setAttribute('data-selected','false'); x.setAttribute('aria-pressed','false'); });\n        b.setAttribute('data-selected','true'); b.setAttribute('aria-pressed','true');\n        els.next.disabled=false; state._pending={id:node.id,choiceId:c.id,fx:c.fx};\n      });\n      els.choices.appendChild(b);\n    });\n    els.back.onclick=()=>{ const p=prevIdx(state.i-1); if(p<0){ renderIntro(); return; } state.i=p; save(); renderNode(); };\n    els.next.onclick=()=>{\n      if(!state._pending) return;\n      const sel=state._pending; delete state._pending;\n      const idx=state.path.findIndex(p=>p.id===node.id); if(idx>=0){ subFx(state.path.splice(idx,1)[0].fx); }\n      state.path.push(sel); addFx(sel.fx); prune(); state.i=nextIdx(state.i+1); save(); renderNode();\n    };\n    if(!first){ els.q.setAttribute('tabindex','-1'); els.q.focus({preventScroll:true}); }\n    first=false;\n  }\n\n  function why(tag){\n    const out=[]; state.path.forEach(p=>{ if(p.fx.some(f=>f[0]===tag)){ const n=flow.find(x=>x.id===p.id); const c=n&&n.choices.find(x=>x.id===p.choiceId); if(n&&c) out.push('\u201c'+c.label+'\u201d to \u201c'+n.q+'\u201d'); } });\n    return out.slice(0,2);\n  }\n  function links(l){\n    let h='';\n    if(l.art) h+='<a class=\"chip\" href=\"'+l.art+'\">Read the guide<\/a>';\n    if(l.sol) h+='<a class=\"chip\" href=\"'+l.sol+'\">Browse solutions<\/a>';\n    if(l.hub) h+='<a class=\"chip\" href=\"'+HUB+'\">Browse sleep solutions<\/a><a class=\"chip\" href=\"https:\/\/www.nhs.uk\/conditions\/insomnia\/\" target=\"_blank\" rel=\"noopener\">NHS: insomnia<\/a>';\n    if(l.nhs) h+='<a class=\"chip\" href=\"'+NHS+l.nhs+'\" target=\"_blank\" rel=\"noopener\">'+l.nhsLabel+'<\/a>';\n    return h?'<div class=\"row\" style=\"gap:8px;margin-top:6px\">'+h+'<\/div>':'';\n  }\n  function card(tag,compact){\n    const l=leaves[tag]; const w=why(tag);\n    return '<div class=\"card\" style=\"margin-bottom:10px;background:#fff\"><div class=\"h2\" style=\"margin:0 0 6px\">'+l.title+'<\/div><div>'+l.copy+'<\/div>'+(w.length?'<div class=\"muted\" style=\"margin-top:6px\">Because you answered '+w.join('; ')+'.<\/div>':'')+(compact?'':links(l))+'<\/div>';\n  }\n  function exploreHtml(){\n    const X=[['Light','light'],['Noise','noise'],['Room temperature','room-temperature'],['Stress and racing thoughts','stress-racing-thoughts'],['Digestion and reflux','digestion-reflux'],['Snoring and breathing','snoring-breathing']];\n    return '<h3 class=\"h2\" style=\"margin-top:14px\">Explore every topic<\/h3><div class=\"row\" style=\"gap:8px\">'+X.map(([t,s])=>'<a class=\"chip\" href=\"'+HUB+s+'\/\">'+t+'<\/a>').join('')+'<\/div>';\n  }\n  function finish(){\n    state.done=true; save(); updateBar();\n    els.start.style.display='none'; els.reset.style.display='inline-flex'; els.stage.hidden=true;\n    evt('quiz_complete');\n    const ans=(id)=>state.path.find(p=>p.id===id);\n    const s1=ans('S1'); const notAffected = !!s1 && s1.choiceId==='none';\n    const impact=T('impact'), freq=T('freq'), dur=T('dur');\n    const chronic = dur>=2 && freq>=1 && impact>=1;\n    const settling = !chronic && freq>=1 && impact>=2 && (dur>=1 || impact>=3);\n    let sum='<h3 class=\"h2\">Your results<\/h3>';\n    if(notAffected){\n      sum+='<div class=\"note good\"><strong>Your sleep is not affecting your days.<\/strong><br>Sleep needs vary from person to person, and there is no single \u201cnormal\u201d. The ideas below are optional extras, not a to-do list.<\/div>';\n    } else if(chronic){\n      sum+='<div class=\"note info\"><strong>A sensible next step: talk to your GP about CBT for insomnia.<\/strong><br>Your answers fit a pattern of long-term insomnia: at least 3 nights a week, for 3 months or more, affecting your days. NICE recommends cognitive behavioural therapy for insomnia (CBT-I) as the first treatment. In England it is available face to face or online, including the NICE-recommended Sleepio programme. The habits and products on this site may help, but they are not a substitute. This quiz is not a diagnosis.<\/div>';\n    } else if(settling){\n      sum+='<div class=\"note info\"><strong>If this is not settling, speak to your GP.<\/strong><br>NICE recommends CBT for insomnia as the first treatment when poor sleep is not likely to clear up soon. The ideas below are a good place to start.<\/div>';\n    } else {\n      sum+='<div class=\"note info\"><strong>Short spells of poor sleep are common.<\/strong><br>They are often linked to stress or change. Try the ideas below. If it is still a problem in a few weeks, speak to your GP.<\/div>';\n    }\n    const flags=[];\n    if(T('daytime_sleepiness')>=2 || T('snoring')>=4) flags.push('If you ever feel sleepy while driving, do not drive. In the UK you may need to tell the DVLA if a condition such as sleep apnoea makes you excessively sleepy; your GP can advise.');\n    if(T('snoring')>=4 || (T('snoring')>=3 && T('daytime_sleepiness')>=3)) flags.push('Some answers may point to a breathing problem during sleep, such as sleep apnoea. It is worth speaking to your GP (<a href=\"'+NHS+'sleep-apnoea\/\" target=\"_blank\" rel=\"noopener\">NHS: sleep apnoea<\/a>).');\n    if(T('restless_legs')>=4) flags.push('The NHS suggests seeing a GP about restless legs if it stops you sleeping or affects your mood. It can be linked to things such as low iron, kidney problems, pregnancy and some medicines.');\n    if(T('pain')>=4 && dur>=2) flags.push('Ongoing pain can keep sleep light. A GP or physiotherapist can advise on pain itself.');\n    if(T('meds')>=3) flags.push('Some medicines can affect sleep. Ask your prescriber or pharmacist, and do not stop or change a medicine on your own.');\n    if(T('nocturia')>=3) flags.push('Waking to pass urine most nights can have several causes. It is worth mentioning to your GP.');\n    if(T('menopause')>=4) flags.push('Menopause symptoms can disturb sleep. Your GP can talk through options with you.');\n    if(T('mood')>=2) flags.push('Low mood and poor sleep often go together and can affect each other. Your GP or doctor can help with both. If you are struggling to cope: in the UK call Samaritans free on 116 123, any time; in the US call or text 988. For urgent help in the UK call NHS 111. In an emergency call 999 (UK) or 911 (US).');\n    if(flags.length) sum+='<div class=\"note warn\"><strong>When to seek personalised advice<\/strong><ul style=\"margin:.4rem 0 0 1rem\">'+flags.map(f=>'<li>'+f+'<\/li>').join('')+'<\/ul><\/div>';\n    sum+='<p class=\"muted\" style=\"margin-top:10px\">This is general information based on NICE and NHS guidance. It is not medical advice or a diagnosis.<\/p>';\n    els.summary.innerHTML=sum;\n\n    const pat=['onset','maint','early','unref'].find(k=>T('pat_'+k)>0);\n    const scored=Object.keys(leaves).map(t=>{ let s=T(t); if(s>0 && pat && patternBoost[pat].indexOf(t)>-1) s+=1; return [t,s]; }).filter(x=>x[1]>0).sort((a,b)=>b[1]-a[1]);\n    const strong=scored.filter(x=>x[1]>=4), possible=scored.filter(x=>x[1]===3), minor=scored.filter(x=>x[1]<3);\n    let rec='<h3 class=\"h2\">Things that may be affecting your sleep<\/h3>';\n    if(!scored.length){ rec+='<div class=\"muted\">Nothing stood out strongly from your answers.<\/div>'; }\n    if(strong.length){ rec+='<div class=\"muted\" style=\"margin-bottom:6px\">Strong signals<\/div>'+strong.map(x=>card(x[0])).join(''); }\n    if(possible.length){ rec+='<div class=\"muted\" style=\"margin:10px 0 6px\">Possible factors<\/div>'+possible.map(x=>card(x[0])).join(''); }\n    if(minor.length){ rec+='<details><summary>Also worth a look ('+minor.length+')<\/summary>'+minor.map(x=>card(x[0],false)).join('')+'<\/details>'; }\n    rec+=exploreHtml();\n    els.recos.innerHTML=rec;\n    els.results.hidden=false; els.footer.hidden=false;\n  }\n\n  els.start.addEventListener('click', start);\n  els.reset.addEventListener('click', reset);\n  const rt=document.getElementById('shq-retake'); if(rt){ rt.addEventListener('click',()=>{ reset(); start(); window.scrollTo({top:mount.offsetTop,behavior:'smooth'}); }); }\n  const ed=document.getElementById('shq-edit'); if(ed){ ed.addEventListener('click',()=>{ const last=state.path[state.path.length-1]; if(!last) return; state.done=false; state.i=flow.findIndex(n=>n.id===last.id); save(); els.results.hidden=true; els.footer.hidden=true; els.stage.hidden=false; els.start.style.display='none'; els.reset.style.display='inline-flex'; renderNode(); window.scrollTo({top:mount.offsetTop,behavior:'smooth'}); }); }\n  if(state.path.length){ els.reset.style.display='inline-flex'; }\n  renderIntro();\n  if(state.done){ finish(); }\n})();\n<\/script>\n","protected":false},"excerpt":{"rendered":"<p>Struggling to sleep? Take the Shhlumber Sleep Quiz Answer a few questions (about 5 minutes). We\u2019ll highlight things that may be affecting your sleep and point you to guidance and simple tools. This is general information, not a diagnosis. Your answers stay in your browser. Start the quiz Start over Back Next Want to come&#8230;<\/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":7,"href":"https:\/\/shhlumber.com\/index.php\/wp-json\/wp\/v2\/pages\/260\/revisions"}],"predecessor-version":[{"id":347,"href":"https:\/\/shhlumber.com\/index.php\/wp-json\/wp\/v2\/pages\/260\/revisions\/347"}],"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}]}}