/* Homebridge Alliance surveys. Hand-written; no build step, no third-party code.
   Palette from the live site (docs/brand.md). Teal, sage and copper are NOT used for
   body text: they fail 4.5:1 on cream. Motion lives only on navigation and progress,
   never on the answer options (they must carry equal weight at every timepoint). */

@font-face { font-family: "Jaapokki"; src: url("/static/fonts/jaapokkienchance-regular.woff") format("woff"),
  url("/static/fonts/jaapokkienchance-regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Muller"; src: url("/static/fonts/muller-regular.ttf") format("truetype");
  font-weight: 400; font-display: swap; }
@font-face { font-family: "Muller"; src: url("/static/fonts/muller-bold.ttf") format("truetype");
  font-weight: 700; font-display: swap; }

:root {
  --cream: #F8F7F3; --white: #FFFFFF; --sand: #D2B486; --sage: #69866E; --teal: #4D817E;
  --chocolate: #593D36; --copper: #BA7D5D; --ink: #393939;
  --line: #E4DCCD;            /* decorative hairlines only */
  --control: #7A6A63;         /* borders that identify a control: >= 3:1 on white */
  --tint: rgba(77, 129, 126, .09);
  --radius-card: 32px; --radius-field: 20px; --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(89, 61, 54, .06), 0 22px 50px -24px rgba(89, 61, 54, .28);
  --font-display: "Jaapokki", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "Muller", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(.22, .8, .3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; color: var(--ink); background-color: var(--cream);
  font-family: var(--font-body); font-size: 1.0625rem; line-height: 1.65; -webkit-font-smoothing: antialiased;
  position: relative;
}
/* The colour washes sit on their own fixed layer: iOS Safari ignores background-attachment: fixed. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    radial-gradient(60rem 38rem at -8% -6%, rgba(210, 180, 134, .38), transparent 62%),
    radial-gradient(50rem 34rem at 108% 12%, rgba(105, 134, 110, .24), transparent 60%),
    radial-gradient(56rem 36rem at 78% 112%, rgba(77, 129, 126, .22), transparent 62%),
    radial-gradient(40rem 26rem at -4% 104%, rgba(186, 125, 93, .16), transparent 60%);
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; color: var(--chocolate); margin: 0; }
h1 { font-size: clamp(2.1rem, 6.4vw, 3.4rem); line-height: 1.08; letter-spacing: -.01em; }
h2 { font-size: clamp(1.6rem, 4.6vw, 2.1rem); line-height: 1.15; }
p { margin: 0 0 1em; }
a { color: var(--chocolate); text-underline-offset: .2em; text-decoration-thickness: .08em; }
img { max-width: 100%; height: auto; display: block; }

.skip { position: absolute; left: -9999px; top: 0; background: var(--chocolate); color: var(--cream);
  padding: .75rem 1.25rem; border-radius: 0 0 16px 0; z-index: 10; }
.skip:focus { left: 0; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; border-radius: 6px; }

/* ---- shell ---------------------------------------------------------------------- */
.shell { width: 100%; max-width: 44rem; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .25rem .25rem 1.1rem; }
.brand img { height: 2.35rem; width: auto; }
.top .step { font-size: .875rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink); opacity: .85; }
.card { background: var(--white); border-radius: var(--radius-card); box-shadow: var(--shadow);
  padding: clamp(1.4rem, 5vw, 2.75rem); }
.foot { text-align: center; font-size: .875rem; padding-top: 1.5rem; color: var(--ink); }
.foot p { margin: 0 auto .5rem; max-width: 34rem; }
.foot .support-line { opacity: 1; }

/* ---- progress: a row of segments, styled by class only (the CSP forbids inline styles) -- */
.progress { display: flex; gap: .4rem; margin: 0 .25rem 1.25rem; }
.progress span { flex: 1; height: .6rem; border-radius: var(--radius-pill); background: rgba(89, 61, 54, .13);
  position: relative; overflow: hidden; }
.progress span.done, .progress span.now::after { background: linear-gradient(90deg, var(--sage), var(--teal)); }
.progress span.now::after { content: ""; position: absolute; inset: 0; border-radius: inherit; transform-origin: left; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---- intro ---------------------------------------------------------------------- */
.eyebrow { font-size: .8125rem; letter-spacing: .16em; text-transform: uppercase; margin: 0 0 .9rem; color: var(--ink); }
.lead { font-size: 1.2rem; line-height: 1.6; margin: 1.1rem 0 1.75rem; }
.points { list-style: none; margin: 0 0 2rem; padding: 0; display: grid; gap: .9rem; }
.points li { display: grid; grid-template-columns: 2.6rem 1fr; gap: 1rem; align-items: start; padding: 1rem 1.1rem;
  border-radius: 24px; background: rgba(105, 134, 110, .10); }
.points .dot { width: 2.6rem; height: 2.6rem; border-radius: 50% 46% 54% 50%; background: var(--sand); opacity: .9; }
.points li:nth-child(2) .dot { background: var(--sage); border-radius: 46% 54% 50% 50%; }
.points li:nth-child(3) .dot { background: var(--teal); border-radius: 54% 46% 50% 50%; }
.points strong { display: block; font-weight: 700; color: var(--chocolate); }

/* ---- questions ------------------------------------------------------------------ */
.q { border: 0; padding: 0; margin: 0 0 2.4rem; min-width: 0; }
.q[hidden] { display: none; }
.q legend, .q > label.qtext { display: block; padding: 0; width: 100%; font-size: 1.1875rem; line-height: 1.5;
  color: var(--ink); margin-bottom: .35rem; }
.hint { display: block; font-size: .9375rem; margin: 0 0 .9rem; color: var(--ink); opacity: .85; }
.options { display: grid; gap: .65rem; }
.option { display: flex; align-items: flex-start; gap: .9rem; padding: .95rem 1.1rem; min-height: 3.5rem;
  border: 1.5px solid var(--line); border-radius: 22px; background: var(--white); cursor: pointer; }
.option:hover { border-color: var(--control); }
.option:has(input:checked) { border-color: var(--teal); background: var(--tint); box-shadow: inset 0 0 0 1px var(--teal); }
.option:has(input:focus-visible) { outline: 3px solid var(--teal); outline-offset: 3px; }
.option input { appearance: none; -webkit-appearance: none; flex: none; width: 1.6rem; height: 1.6rem; margin: .1rem 0 0;
  border: 2px solid var(--control); background: var(--white); display: grid; place-content: center; cursor: pointer; }
.option input[type=radio] { border-radius: 50%; }
.option input[type=checkbox] { border-radius: 9px; }
.option input::after { content: ""; width: .8rem; height: .8rem; transform: scale(0); background: var(--cream); }
.option input[type=radio]::after { border-radius: 50%; }
.option input[type=checkbox]::after { clip-path: polygon(14% 52%, 0 66%, 38% 100%, 100% 22%, 86% 8%, 38% 70%); }
.option input:checked { background: var(--chocolate); border-color: var(--chocolate); }
.option input:checked::after { transform: scale(1); }
.option input:focus-visible { outline: none; }
.option span { padding-top: .02rem; }
.consent .option { align-items: flex-start; }

.field, .area { width: 100%; font: inherit; color: var(--ink); background: var(--white); border: 1.5px solid var(--control);
  border-radius: var(--radius-field); padding: .9rem 1.1rem; min-height: 3.5rem; }
.area { min-height: 7.5rem; resize: vertical; }
.field:focus, .area:focus { outline: 3px solid var(--teal); outline-offset: 2px; border-color: var(--teal); }
.more { margin-top: .75rem; }
.more label { display: block; font-size: .9375rem; margin-bottom: .35rem; }
.trio { display: grid; gap: .9rem; }
.trio label { display: block; font-size: .9375rem; margin-bottom: .3rem; }

/* ---- errors --------------------------------------------------------------------- */
.summary { display: flex; gap: .9rem; align-items: flex-start; padding: 1rem 1.2rem; margin-bottom: 1.75rem;
  border-radius: 22px; background: #F6EDE6; border: 2px solid var(--chocolate); color: var(--chocolate); font-weight: 700; }
.summary svg, .err svg { flex: none; width: 1.4rem; height: 1.4rem; margin-top: .1rem; }
.q.has-error .options .option, .q.has-error .field, .q.has-error .area { border-color: var(--chocolate); }
.err { display: flex; gap: .5rem; align-items: center; margin-top: .65rem; color: var(--chocolate); font-weight: 700; font-size: .9375rem; }

/* ---- actions -------------------------------------------------------------------- */
.actions { display: flex; flex-direction: column-reverse; gap: .85rem; margin-top: 2.25rem; align-items: stretch; }
.btn { appearance: none; font: inherit; font-weight: 700; letter-spacing: .01em; cursor: pointer; text-align: center;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
  min-height: 3.5rem; padding: .85rem 2rem; border-radius: var(--radius-pill); border: 2px solid var(--chocolate); }
.btn.primary { background: var(--chocolate); color: var(--cream); }
.btn.quiet { background: transparent; color: var(--chocolate); }
.btn:active { transform: scale(.985); }

/* ---- thank you ------------------------------------------------------------------ */
.rings { width: 7.5rem; height: 7.5rem; margin: 0 0 1.5rem; position: relative; }
.rings i { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--sage); opacity: .55; }
.rings i:nth-child(2) { inset: 1.1rem; border-color: var(--teal); }
.rings i:nth-child(3) { inset: 2.2rem; background: var(--sand); border: 0; opacity: .9; }
.support { margin-top: 2rem; padding: 1.4rem 1.5rem; border-radius: 26px; background: rgba(210, 180, 134, .22); }
.support h2 { font-size: 1.4rem; margin-bottom: .75rem; }
.support ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.support li { display: flex; justify-content: space-between; gap: 1rem; padding-bottom: .5rem; border-bottom: 1px solid rgba(89, 61, 54, .15); }
.support li:last-child { border: 0; padding: 0; }
.support .name::first-letter { text-transform: uppercase; }
.support .num { font-weight: 700; color: var(--chocolate); white-space: nowrap; }

@media (min-width: 40rem) {
  .actions { flex-direction: row; justify-content: space-between; align-items: center; }
  .trio { grid-template-columns: 1.3fr 1fr 1fr; }
  .shell { padding-top: 2.5rem; }
}

/* ---- motion: navigation and progress only ----------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root) { animation: 240ms var(--ease) both fade-out; }
  ::view-transition-new(root) { animation: 520ms var(--ease) both rise; }
  .card { animation: rise 640ms var(--ease) both; }
  .progress span.now::after { animation: grow 900ms var(--ease) both; }
  .btn { transition: background-color .2s, transform .12s; }
  .btn.primary:hover { background: #46302A; }
  .rings i { animation: breathe 7s ease-in-out infinite; }
  .rings i:nth-child(2) { animation-delay: -2.3s; }
  .rings i:nth-child(3) { animation-delay: -4.6s; }
  @keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
  @keyframes fade-out { to { opacity: 0; } }
  @keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
  @keyframes breathe { 0%, 100% { transform: scale(.94); } 50% { transform: scale(1.04); } }
}
@media (forced-colors: active) {
  .option:has(input:checked) { outline: 2px solid Highlight; }
  .progress span.done, .progress span.now::after { background: Highlight; }
}


/* ---- admin portal -------------------------------------------------------------------- */
:root { --alarm: #B3261E; --alarm-tint: #FBEAE8; }
.shell.wide { max-width: 66rem; }
.who { display: flex; align-items: center; gap: .9rem; font-size: .9375rem; }
.linkbtn { appearance: none; background: none; border: 0; padding: .25rem .1rem; font: inherit; color: var(--chocolate);
  text-decoration: underline; text-underline-offset: .2em; cursor: pointer; }
.adminnav { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 .25rem 1.25rem; }
.adminnav a { text-decoration: none; padding: .5rem 1rem; border-radius: var(--radius-pill); color: var(--chocolate);
  background: rgba(255, 255, 255, .6); border: 1.5px solid transparent; }
.adminnav a[aria-current="page"] { background: var(--chocolate); color: var(--cream); }
.panel { border-radius: 26px; background: rgba(248, 247, 243, .85); border: 1.5px solid var(--line);
  padding: 1.25rem 1.4rem; margin: 0 0 1.25rem; }
.panel h2 { font-size: 1.4rem; margin-bottom: .75rem; }
.panel.urgent, .urgent .chip.urgent { border-color: var(--alarm); }
.panel.urgent { background: var(--alarm-tint); }
.muted { opacity: .85; font-size: .9375rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8125rem; word-break: break-all; }
.table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.table th { text-align: left; font-weight: 700; color: var(--chocolate); padding: .5rem .6rem; border-bottom: 2px solid var(--line); }
.table td { padding: .65rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr.urgent td { background: var(--alarm-tint); }
.table tr.urgent td:first-child { box-shadow: inset 4px 0 0 var(--alarm); }
.chip { display: inline-block; padding: .15rem .7rem; border-radius: var(--radius-pill); font-size: .8125rem; font-weight: 700;
  background: rgba(105, 134, 110, .18); color: var(--chocolate); border: 1.5px solid transparent; text-transform: capitalize; }
.chip.on { background: var(--chocolate); color: var(--cream); }
.chip.urgent { background: var(--alarm); color: #fff; }
.btn.small { min-height: 2.5rem; padding: .4rem 1.1rem; font-size: .9375rem; }
form.inline { display: inline-flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.field.small { min-height: 2.5rem; padding: .4rem .8rem; width: 14rem; max-width: 100%; }
select.field { appearance: auto; }
.grid2 { display: grid; gap: 0 1.25rem; }
.tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr)); gap: .75rem; }
.tiles li { background: var(--white); border-radius: 20px; padding: .9rem 1rem; border: 1.5px solid var(--line); }
.tiles strong { display: block; font-family: var(--font-display); font-size: 1.9rem; color: var(--chocolate); line-height: 1.1; }
.tiles span { font-size: .875rem; text-transform: capitalize; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.25rem; margin: 0; }
.facts dt { font-weight: 700; color: var(--chocolate); }
.facts dd { margin: 0; }
.routelist { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.callrow { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; padding: .6rem .8rem; border-radius: 16px; }
.callrow.urgent { background: var(--alarm-tint); box-shadow: inset 4px 0 0 var(--alarm); }
.answers { display: grid; gap: .9rem; margin-bottom: 1.4rem; padding-bottom: 1.2rem; border-bottom: 1px solid var(--line); }
.qq { margin: 0 0 .2rem; font-size: .9375rem; opacity: .9; }
.aa { margin: 0; font-weight: 700; color: var(--chocolate); }
.gate { list-style: none; margin: 0; padding: 0; display: grid; gap: .65rem; }
.gate li { display: flex; gap: 1rem; align-items: flex-start; padding: .9rem 1.1rem; border-radius: 22px; background: var(--white); border: 1.5px solid var(--line); }
.gate li.done { border-color: var(--teal); background: var(--tint); }
.gate p { margin: 0; }
.tick { appearance: none; flex: none; width: 2rem; height: 2rem; border-radius: 10px; border: 2px solid var(--control); background: var(--white);
  color: var(--cream); font-weight: 700; cursor: pointer; display: grid; place-content: center; padding: 0; }
.gate li.done .tick { background: var(--chocolate); border-color: var(--chocolate); }
.err { color: var(--chocolate); font-weight: 700; }
@media (min-width: 40rem) { .grid2 { grid-template-columns: 1fr 1fr; } }
@media print {
  body { background: #fff; font-size: 12pt; } body::before, .top, .adminnav, .foot, .noprint, .skip { display: none !important; }
  .card { box-shadow: none; padding: 0; } .shell { max-width: none; padding: 0; }
}

.summary.alarm { background: var(--alarm-tint); border-color: var(--alarm); color: var(--ink); font-weight: 400; }
.summary.alarm a { color: var(--chocolate); }

/* Narrow screens: tables become stacked cards, so nothing is ever wider than the screen. */
@media (max-width: 40rem) {
  .table thead { position: absolute; left: -9999px; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: .7rem .4rem; border-bottom: 1px solid var(--line); }
  .table td { border: 0; padding: .2rem .4rem; }
  .table tr.urgent { background: var(--alarm-tint); box-shadow: inset 4px 0 0 var(--alarm); border-radius: 12px; }
  .table tr.urgent td, .table tr.urgent td:first-child { background: none; box-shadow: none; }
  .table td:last-child { padding-top: .5rem; }
  .callrow form.inline, .callrow .field.small { width: 100%; }
  .facts { grid-template-columns: 1fr; gap: 0; } .facts dd { margin-bottom: .6rem; }
}

/* Answers that raised a route get a soft background behind the answer itself. The route is also said
   in words for screen readers and on hover, so colour is not the only cue. */
.hl { padding: .08em .5em; margin: 0 -.15em; border-radius: 999px; color: inherit; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.hl-urgent { background: rgba(176, 36, 31, .14); }
.hl-call { background: rgba(186, 125, 93, .22); }
.hl-note { background: rgba(210, 180, 134, .35); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.blockhead { font-size: 1.5rem; margin: 0 0 .4rem; }
.blockintro { margin: 0 0 1.25rem; }

/* 0 to 10 questions: eleven points along one line, the number under each dot and the two ends named
   below, at every screen width so the ends always sit under 0 and 10. No motion on the choices. */
.options.scale { display: flex; position: relative; gap: 0; padding-top: .15rem; }
.options.scale::before { content: ""; position: absolute; left: calc(100% / 22); right: calc(100% / 22); top: 1.05rem;
  height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--sand), var(--copper)); opacity: .55; }
.options.scale .option { flex: 1 1 0; position: relative; z-index: 1; flex-direction: column; align-items: center; gap: .4rem;
  padding: .1rem 0 .5rem; min-height: 0; border: 0; background: none; box-shadow: none; border-radius: 14px; }
.options.scale .option:has(input:checked) { background: none; box-shadow: none; }
.options.scale .option input { width: 1.35rem; height: 1.35rem; margin: .25rem 0 0; border-width: 2px; }
.options.scale .option:hover input { border-color: var(--teal); }
.options.scale .option input::after { width: .55rem; height: .55rem; }
.options.scale .option span { padding: 0; font-size: .9375rem; }
.options.scale .option:has(input:checked) span { font-weight: 700; color: var(--chocolate); }
.scale-ends { display: flex; justify-content: space-between; gap: 1rem; margin-top: .3rem; font-size: .9375rem;
  color: var(--chocolate); font-weight: 700; }
@media (min-width: 640px) {
  .options.scale::before { top: 1.25rem; }
  .options.scale .option { gap: .55rem; }
  .options.scale .option input { width: 1.9rem; height: 1.9rem; }
  .options.scale .option input::after { width: .8rem; height: .8rem; }
  .options.scale .option span { font-size: 1rem; }
}

/* Agree and frequency scales: from tablet width, the points sit along a line with each label under its dot.
   "Don't know" and "No such situation" are not part of the scale, so they sit apart below it. On a phone the
   choices stay as stacked cards, which read better than five narrow columns. */
.options.aside { margin-top: .9rem; }
.options.aside .option { display: inline-flex; width: fit-content; min-height: 0; padding: .55rem 1.1rem; }
@media (min-width: 640px) {
  .options.agree { display: flex; gap: 0; position: relative; padding-top: .15rem; }
  .options.agree::before { content: ""; position: absolute; top: 1.25rem; height: 4px; border-radius: 4px; opacity: .55;
    background: linear-gradient(90deg, var(--sand), var(--copper)); }
  .options.agree-4::before { left: 12.5%; right: 12.5%; }
  .options.agree-5::before { left: 10%; right: 10%; }
  .options.agree-6::before { left: 8.33%; right: 8.33%; }
  .options.agree-7::before { left: 7.14%; right: 7.14%; }
  .options.agree .option { flex: 1 1 0; position: relative; z-index: 1; flex-direction: column; align-items: center; gap: .6rem;
    padding: .1rem .3rem .5rem; min-height: 0; border: 0; background: none; box-shadow: none; border-radius: 14px; text-align: center; }
  .options.agree .option:has(input:checked) { background: none; box-shadow: none; }
  .options.agree .option input { width: 1.9rem; height: 1.9rem; margin: .2rem 0 0; border-width: 2px; }
  .options.agree .option:hover input { border-color: var(--teal); }
  .options.agree .option input::after { width: .8rem; height: .8rem; }
  .options.agree .option span { padding: 0; font-size: .9375rem; line-height: 1.3; }
  .options.agree .option:has(input:checked) span { font-weight: 700; color: var(--chocolate); }
}
