/* Concept B: the "See my options" quiz. One widget, used in the pop-up (<dialog id="hhl-quiz-dialog">) and inline on options.html. */

/* ---------- dialog shell ---------- */
html.hhlq-lock { overflow: hidden; }
.hhlq-dialog { padding: 0; border: 0; border-radius: 24px; width: min(1000px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 32px); overflow: hidden; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.hhlq-dialog::backdrop { background: rgba(var(--shadow-rgb), .62); }
@media (prefers-reduced-motion: no-preference) {
  .hhlq-dialog[open] { animation: hhlq-in .2s ease-out; }
  @keyframes hhlq-in { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }
}
.hhlq-dialog .qw { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.hhlq-dialog .qw-body { flex: 1; min-height: 0; }
.hhlq-dialog .qw-main { overflow-y: auto; overscroll-behavior: contain; }
@media (max-width: 639px) {
  .hhlq-dialog { width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
  .hhlq-dialog .qw { height: 100dvh; max-height: 100dvh; }
}

/* ---------- inline on options.html ---------- */
.op-quiz .qw { background: var(--surface); border-radius: 24px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.op-quiz .qw-close { display: none; }
.op-quiz .qw-foot { position: sticky; bottom: 0; border-radius: 0 0 24px 24px; }
@media (max-width: 479px) { .op-quiz .qw { border-radius: 18px; } .op-quiz .qw-foot { border-radius: 0 0 18px 18px; } }

/* ---------- widget ---------- */
.qw { position: relative; }
.qw-head { padding: 20px 28px 16px; border-bottom: 1px solid var(--line); background: var(--surface); border-radius: 24px 24px 0 0; }
.qw-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.qw-head h2 { margin: 0; font-size: 1.35rem; }
.qw-head h2:focus { outline: none; }
.qw-head h2:focus-visible { outline: 3px solid var(--focus); }
.qw-close { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--tint); color: var(--ink); display: grid; place-items: center; cursor: pointer; flex: none; }
.qw-close:hover { background: var(--tint-hover); }
.qw-talk { margin: 2px 0 12px; font-size: .925rem; color: var(--muted); }
.qw-talk a { font-weight: 600; display: inline-flex; align-items: center; gap: 4px; min-height: 32px; }
.qw-talk .icon { width: 1em; height: 1em; }
.q-bar { height: 6px; border-radius: 6px; background: var(--tint); overflow: hidden; }
.q-bar span { display: block; height: 100%; width: 25%; border-radius: 6px; background: linear-gradient(90deg, var(--primary), var(--primary-2)); transition: width .25s ease; }
@media (prefers-reduced-motion: reduce) { .q-bar span { transition: none; } }
.q-labels { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; font-size: .825rem; color: var(--muted); }
.q-labels li { display: flex; align-items: center; gap: 6px; }
.q-labels .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .75rem; background: var(--tint); color: var(--muted); flex: none; }
.q-labels li.on { color: var(--ink); font-weight: 600; }
.q-labels li.on .n { background: var(--primary); color: var(--on-primary); }
.q-labels li.done .n { background: var(--accent); color: var(--on-accent); }
.q-count { margin: 8px 0 0; font-size: .85rem; font-weight: 600; color: var(--ink); }
@media (max-width: 559px) { .q-labels .l { display: none; } .q-labels { display: none; } .qw-head { padding: 14px 16px 12px; border-radius: 0; } }

.qw-body { display: grid; }
@media (min-width: 880px) { .qw-body { grid-template-columns: 1fr 290px; } }
.qw-main { padding: 24px 28px 28px; min-width: 0; }
@media (max-width: 559px) { .qw-main { padding: 18px 16px 24px; } }
.q-form { margin: 0; }
.q-step h3 { font-size: clamp(1.25rem, 1.1rem + .6vw, 1.55rem); margin-bottom: 18px; }
.q-step h3:focus { outline: none; }
@media (prefers-reduced-motion: no-preference) {
  .q-enter { animation: q-in .18s ease-out; }
  @keyframes q-in { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
}
.q-fs { border: 0; margin: 0 0 22px; padding: 0; min-width: 0; }
.q-fs legend { padding: 0; margin-bottom: 10px; font-weight: 600; color: var(--ink); }
.q-fs legend .opt, .q-field label .opt { display: block; font-weight: 400; color: var(--muted); font-size: .875rem; margin-top: 2px; }
.q-pair { display: grid; gap: 0 20px; }
@media (min-width: 600px) { .q-pair { grid-template-columns: 1fr 1fr; } }

/* hidden-but-focusable native inputs */
.card input, .chip input, .seg input, .q-consent input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.card, .chip, .seg label { position: relative; }

.cards { display: grid; gap: 12px; }
@media (min-width: 520px) { .cards-goal { grid-template-columns: 1fr 1fr; } }
.card-in { display: grid; grid-template-columns: 48px 1fr; grid-template-rows: auto auto; column-gap: 14px; align-items: center; padding: 16px; min-height: 84px; border: 2px solid var(--line); border-radius: 16px; cursor: pointer; transition: border-color .12s, background-color .12s; }
.card-in .icon { grid-row: span 2; width: 48px; height: 48px; padding: 11px; border-radius: 12px; background: var(--tint); color: var(--primary); }
.card-in .t { font: 600 1.05rem var(--font-h); color: var(--ink); }
.card-in .h { font-size: .875rem; color: var(--muted); }
.card:hover .card-in { border-color: var(--line-2); background: var(--tint-2); }
.card input:checked + .card-in { border-color: var(--primary); background: var(--tint); box-shadow: inset 0 0 0 1px var(--primary); }
.card input:checked + .card-in .icon { background: var(--primary); color: var(--on-primary); }
.card input:focus-visible + .card-in { outline: 3px solid var(--focus); outline-offset: 3px; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip span { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 10px 16px; border: 2px solid var(--line); border-radius: 999px; cursor: pointer; font-weight: 500; color: var(--ink); background: var(--surface); transition: border-color .12s, background-color .12s; }
.chip span::before { content: ""; width: 18px; height: 18px; border-radius: 6px; border: 2px solid var(--line-2); flex: none; background: var(--surface) center / 12px no-repeat; }
.chip input[type="radio"] + span::before { border-radius: 50%; }
.chip:hover span { border-color: var(--line-2); }
.chip input:checked + span { border-color: var(--primary); background: var(--tint); }
.chip input:checked + span::before { border-color: var(--primary); background-color: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 12.5 9.5 17.5 19.5 6.5'/%3E%3C/svg%3E"); }
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.chips-states { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 560px) { .chips-states { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.chips-states .chip span { width: 100%; border-radius: 14px; padding: 10px 10px; gap: 6px; font-size: .95rem; }
@media (max-width: 379px) { .chips-states { grid-template-columns: 1fr; } }
.chips-states b { font-family: var(--font-h); color: var(--primary); white-space: nowrap; }
.st-other span { color: var(--muted); }

.seg { display: grid; gap: 8px; }
.seg-2 { grid-template-columns: repeat(2, 1fr); }
.seg-3 { grid-template-columns: repeat(3, 1fr); }
.seg-4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .seg-4 { grid-template-columns: repeat(4, 1fr); } }
.seg span { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 8px 10px; text-align: center; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; font-weight: 600; color: var(--ink); background: var(--surface); line-height: 1.2; transition: border-color .12s, background-color .12s; }
.seg .icon { width: 1.1em; height: 1.1em; color: var(--primary); }
.seg label:hover span { border-color: var(--line-2); }
.seg input:checked + span { border-color: var(--primary); background: var(--primary); color: var(--on-primary); }
.seg input:checked + span .icon { color: var(--on-primary); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.seg-sm span { min-height: 46px; font-size: .95rem; }
@media (prefers-reduced-motion: reduce) { .card-in, .chip span, .seg span { transition: none; } }

.q-field { margin-bottom: 18px; }
.q-field label { display: block; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.q-input { width: 100%; min-height: 52px; padding: 12px 14px; border: 1.5px solid var(--line-2); border-radius: 12px; font: 500 1.0625rem var(--font-b); color: var(--ink); background: var(--surface); }
.q-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(var(--primary-rgb), .16); }
.q-input[aria-invalid="true"] { border-color: var(--err); }
#q-zip { max-width: 180px; letter-spacing: .08em; }

.q-err { display: flex; align-items: flex-start; gap: 8px; color: var(--err); font-weight: 600; font-size: .925rem; margin: 0 0 8px; }
.q-err::before { content: "!"; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--err); color: var(--on-err); font-size: .75rem; flex: none; margin-top: 2px; }
.has-error .card-in, .has-error .chip span, .has-error .seg span { border-color: var(--err-line); }
.q-errsum { border: 2px solid var(--err); border-left-width: 6px; background: var(--err-soft); border-radius: 12px; padding: 14px 18px; margin-bottom: 20px; }
.q-errsum:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
.q-errsum h4 { margin: 0 0 6px; color: var(--err); font-size: 1rem; }
.q-errsum ul { margin: 0; padding-left: 18px; }
.q-errsum a { color: var(--err); font-weight: 600; }

.q-unlicensed { border: 2px solid var(--line-2); background: var(--tint-2); border-radius: 16px; padding: 20px; margin-bottom: 20px; }
.q-unlicensed h4 { font-size: 1.1rem; margin-bottom: 6px; }
.q-unlicensed p:last-child { margin: 0; }

.q-consent { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--tint-2); cursor: pointer; font-size: .9rem; line-height: 1.5; color: var(--text); margin-bottom: 14px; }
.q-consent::before { content: ""; width: 22px; height: 22px; border: 2px solid var(--line-2); border-radius: 6px; background: var(--surface) center / 14px no-repeat; flex: none; margin-top: 1px; }
.q-consent:has(input:checked)::before { background-color: var(--primary); border-color: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 12.5 9.5 17.5 19.5 6.5'/%3E%3C/svg%3E"); }
.q-consent:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.q-privacy { display: flex; gap: 8px; align-items: flex-start; font-size: .875rem; color: var(--muted); margin: 0; }
.q-privacy .icon { color: var(--ok); margin-top: 2px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.q-nojs { padding: 12px 14px; background: var(--tint); border-radius: 10px; font-size: .9rem; }

/* review */
.q-review { display: grid; gap: 12px; }
.rv { border: 1.5px solid var(--line); border-radius: 14px; padding: 14px 18px; }
.rvq-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0; }
.rvq-head h4 { margin: 0; font-size: 1rem; }
.rv-edit { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line-2); background: var(--surface); color: var(--primary); font: 600 .9rem var(--font-b); cursor: pointer; }
.rv-edit:hover { border-color: var(--primary); background: var(--tint); }
.rv dl { margin: 6px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: .95rem; }
.rv dt { color: var(--muted); }
.rv dd { margin: 0; color: var(--ink); font-weight: 500; overflow-wrap: anywhere; }

/* summary */
.qw-sum { display: none; background: var(--tint-2); border-left: 1px solid var(--line); padding: 24px 22px; }
@media (min-width: 880px) { .qw-sum { display: block; } .hhlq-dialog .qw-sum { overflow-y: auto; } }
.qw-sum h3 { font-size: 1rem; margin-bottom: 12px; }
.q-summary { display: grid; gap: 12px; font-size: .925rem; }
.sum-sec h4 { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 0 2px; font: 600 .75rem var(--font-h); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sum-sec p { margin: 0; color: var(--ink); font-weight: 500; overflow-wrap: anywhere; }
.sum-sec p.empty { color: var(--muted-2); font-weight: 400; font-style: italic; }
.sum-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.sum-tags span { padding: 3px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line-2); font-size: .85rem; color: var(--ink); }
.sum-change { background: none; border: 0; padding: 0 2px; min-height: 28px; color: var(--primary); font: 600 .8rem var(--font-b); text-transform: none; letter-spacing: 0; cursor: pointer; text-decoration: underline; }
.sum-note { display: flex; gap: 6px; align-items: center; margin: 18px 0 0; font-size: .825rem; color: var(--muted); }
.sum-note .icon { color: var(--ok); width: 1em; height: 1em; }

/* footer */
.qw-foot { border-top: 1px solid var(--line); background: var(--surface); padding: 12px 28px; display: grid; gap: 8px; }
@media (max-width: 559px) { .qw-foot { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); } }
.qw-btns { display: flex; justify-content: space-between; gap: 12px; }
.qw-btns #q-next { margin-left: auto; }
.qw-btns .btn { min-height: 52px; }
@media (max-width: 559px) { .qw-btns #q-next { flex: 1; } }
.sum-mini { border: 1.5px solid var(--line); border-radius: 12px; font-size: .9rem; }
@media (min-width: 880px) { .sum-mini { display: none; } }
.sum-mini summary { padding: 8px 12px; min-height: 44px; display: flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; overflow: hidden; white-space: nowrap; }
.sum-mini summary::-webkit-details-marker { display: none; }
.sum-mini summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--primary); border-bottom: 2px solid var(--primary); transform: rotate(45deg); margin-left: auto; flex: none; }
.sum-mini[open] summary::after { transform: rotate(-135deg); }
.sm-l { font-weight: 600; color: var(--ink); flex: none; }
#sum-bar-text { overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.sum-mini .q-summary { padding: 4px 12px 12px; max-height: 32vh; overflow: auto; }

/* without JS: one long form */
html:not(.js) .qw-progress, html:not(.js) #q-back, html:not(.js) .sum-mini, html:not(.js) .qw-sum, html:not(.js) .qw-close { display: none; }

/* done */
.q-done { text-align: center; padding: 24px 8px 8px; max-width: 560px; margin: 0 auto; }
.done-mark { width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; box-shadow: 0 0 0 8px var(--tint), 0 0 0 12px var(--accent); }
.done-mark .icon { width: 38px; height: 38px; stroke-width: 3; }
.q-done h3 { font-size: 1.6rem; }
.q-done h3:focus { outline: none; }
.done-msg { font-size: 1.1rem; color: var(--ink); }
.done-ref { background: var(--tint-2); border: 1px dashed var(--line-2); border-radius: 14px; padding: 12px 16px; display: inline-block; }
.done-ref strong { font: 700 1.15rem var(--font-h); color: var(--primary); letter-spacing: .04em; }
.done-ref span { font-size: .85rem; color: var(--muted); }
.done-next { display: grid; gap: 12px; justify-items: center; margin-top: 12px; }
.done-next p { color: var(--muted); margin: 0 0 4px; }
.done-next .btn { white-space: normal; text-align: center; }
@media (max-width: 559px) { .done-next .btn { width: 100%; } }
.demo-note { margin-top: 18px; font-size: .85rem; color: var(--muted); }
.qw[data-state="done"] .qw-sum, .qw[data-state="done"] .qw-foot, .qw[data-state="done"] .qw-progress { display: none; }
.qw[data-state="done"] .qw-body { grid-template-columns: 1fr; }
