/* Energy Provider Pilot Survey — provider survey styles.
   Builds on base.css tokens and controls. Mobile-first and calm: verified at
   360px with no horizontal scrolling; touch targets are at least 44px. */

/* Author styles (e.g. .btn { display: inline-flex }) would otherwise beat the
   browser's [hidden] rule. */
[hidden] { display: none !important; }

/* Keep focused fields clear of the sticky header and bottom navigation. */
html { scroll-padding-top: 100px; scroll-padding-bottom: 104px; }

body.survey-app {
  display: flex; flex-direction: column;
  min-height: 100vh; min-height: 100dvh;
}

/* ---------- Header ----------
   Charcoal bar: the CL Science lockup, the survey name with the save status,
   and the Sections button (or, on the start page only, the link back to the
   website). Phones: lockup and button on the first row, name and status
   below. From 640px: one row. Focus rings switch to light ochre here. */
.app-header {
  position: sticky; top: 0; z-index: 30;
  --focus: var(--ochre-300);
  background: var(--charcoal); color: var(--paper);
  border-bottom: 1px solid var(--slate);
}
.app-header-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 6px var(--gutter) 8px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "brand action" "meta meta";
  align-items: center; column-gap: 12px; row-gap: 2px;
}
.app-header .brand-lockup { grid-area: brand; }
.app-meta { grid-area: meta; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 10px; min-width: 0; }
.save-status:empty { display: none; }
.app-name { margin: 0; font-weight: 600; font-size: 0.9rem; line-height: 1.3; color: var(--paper); }
.sections-btn, .site-link { grid-area: action; justify-self: end; }
.save-status {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px;
  min-height: 1.3em; font-family: var(--font-mono); font-size: 0.75rem; line-height: 1.3;
  letter-spacing: 0.02em; color: var(--concrete);
}
.save-status.status-error { color: #f4a097; font-weight: 500; }
.save-status.status-offline,
.save-status.status-conflict { color: var(--ochre-300); font-weight: 500; }
.retry-btn {
  min-height: 44px; padding: 0 8px; margin: -12px 0;
  font: inherit; font-weight: 500; color: var(--paper);
  background: none; border: 0; text-decoration: underline; text-decoration-color: var(--ochre); text-underline-offset: 3px; cursor: pointer;
}
/* The Sections button and the website link, light on the charcoal bar. */
.app-header .sections-btn { background: transparent; color: var(--paper); border-color: #6b7075; }
.app-header .sections-btn:hover { background: var(--slate); border-color: var(--concrete); color: var(--paper); }
.site-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 2px;
  font-size: 0.9rem; font-weight: 600; color: var(--paper); text-decoration: none; white-space: nowrap;
}
.site-link:hover { color: var(--ochre-300); text-decoration: underline; text-decoration-thickness: 1px; }

/* ---------- Main ---------- */
main {
  flex: 1 0 auto; width: 100%; max-width: var(--maxw);
  margin: 0 auto; padding: 20px var(--gutter) 40px;
}
main:focus { outline: none; }
.loading { color: var(--hint); }
.banners > * + * { margin-top: 0; }
.banners .notice p:last-child { margin-bottom: 0; }
.conflict-list { list-style: none; margin: 4px 0 8px; padding: 0; }
.conflict-list li { padding: 6px 0; border-bottom: 1px solid var(--border-strong); }
.banners .conflict-list p { margin: 0; }
.conflict-label { font-weight: 600; }
.conflict-side { font-weight: 600; color: var(--text-2); }
.discarded-list { margin: 4px 0 8px; padding-left: 20px; white-space: pre-wrap; }
.banners .btn-row + p { margin-top: 8px; }
.banner-title { margin-bottom: 4px; }

.view h1 { margin-bottom: 12px; }
/* Mono section label with a small ochre square (the logo's cell). */
.eyebrow {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 6px; font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--hint);
}
.eyebrow::before { content: ''; flex: 0 0 auto; width: 8px; height: 8px; background: var(--ochre); }
.lead { color: var(--text-2); }
.progress-row { display: grid; gap: 6px; margin: 0 0 16px; }
.progress > span { width: 0; transition: width 0.3s ease; }
.progress-text { margin: 0; font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.02em; color: var(--hint); }

/* ---------- Bottom navigation ---------- */
.bottom-nav {
  position: sticky; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px rgba(15, 17, 19, 0.06);
  padding: 8px var(--gutter) calc(8px + env(safe-area-inset-bottom, 0px));
}
.bottom-nav-inner { max-width: calc(var(--maxw) - 2 * var(--gutter)); margin: 0 auto; display: flex; gap: 12px; }
.bottom-nav .btn { flex: 1 1 0; min-width: 0; min-height: 48px; white-space: nowrap; }
.sections-btn { white-space: nowrap; }

/* Short or very narrow screens (a phone at 200% zoom is about 180x370): the
   header and bottom bar scroll with the page instead of covering the field
   being edited, and the header stacks so no word is split. */
@media (max-height: 560px), (max-width: 300px) {
  .app-header, .bottom-nav { position: static; }
  html { scroll-padding: 0; }
}
@media (max-width: 300px) {
  .app-header-inner { grid-template-columns: minmax(0, 1fr); grid-template-areas: "brand" "meta" "action"; row-gap: 6px; }
  .sections-btn, .site-link { justify-self: start; }
  .brand-name, .brand-sub { white-space: normal; }
  .bottom-nav-inner { flex-wrap: wrap; }
  .input-affix > .affix { white-space: normal; min-width: 0; overflow-wrap: anywhere; }
  /* 200% zoom on a phone (~180px wide): one column, less nested padding, and
     choice text drops under its control rather than being squeezed. */
  .choices.cols-2 { grid-template-columns: minmax(0, 1fr); }
  .choice { flex-wrap: wrap; padding-inline: 8px; }
  .req-card, .sub-panel > .panel-body { padding-inline: 8px; }
}

/* ---------- Groups ---------- */
.group { margin: 28px 0 8px; }
.group > .group-title {
  font-size: 1.15rem; margin: 0 0 14px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
details.group-expandable { margin-top: 24px; }
details.panel > summary h2 { margin: 0; font-size: 1.1rem; font-stretch: 100%; font-weight: 650; }
.group-intro { color: var(--text-2); }
.info-block p { margin: 0; }

/* Per-option groups (one checklist per ticked activity): folding panels
   that slide in when their option is ticked. The base reduced-motion rule
   turns the animation off. */
details.group-option { margin-top: 20px; }
details.group-option > summary { align-items: flex-start; }
.group-summary { display: grid; gap: 2px; min-width: 0; }
.label-context { font-weight: 400; color: var(--hint); }
.group-option .group-status { font-weight: 400; color: var(--hint); }
.group-option > .panel-body { padding-top: 4px; }
.group.is-revealed { animation: group-reveal 0.25s ease-out; }
@keyframes group-reveal {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}
.group-back { margin: 4px 0 0; }

/* "Go to a checklist below" links under the activities question. */
.option-jumps { margin: -8px 0 22px; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.option-jumps-title { margin: 0 0 2px; font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-2); }
.option-jump-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 16px; }

/* ---------- Fields ---------- */
.field { min-width: 0; }
.field-choice > fieldset { margin-bottom: 0; }
.field-msg { margin: 6px 0 0; font-size: 0.95rem; font-weight: 600; color: var(--danger); }
.choice-text { min-width: 0; }
/* Long checkbox lists: tighter rows (still 44px targets) so more fits on a
   phone screen while scrolling through them. */
.choices.choices-long { gap: 6px; }
.choices-long .choice { min-height: 44px; padding-block: 7px; line-height: 1.35; }
.clear-answer { margin-top: 6px; }
.other-field { margin: 10px 0 0; padding-left: 12px; border-left: 3px solid var(--border); }
.other-field > label { font-weight: 600; display: block; margin-bottom: 4px; }

.privacy-note { margin: 0; font-size: 0.95rem; }
.privacy-note.is-active {
  margin-top: 8px; padding: 8px 12px; color: var(--text);
  background: var(--warn-soft); border-left: 4px solid var(--warn); border-radius: var(--radius-sm);
}

/* Special states: visibly different from answers. */
.state-line { margin: 0 0 8px; }
.state-note { font-size: 0.9rem; color: var(--text-2); }
.state-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 8px; }
.state-row-label { font-size: 0.9rem; color: var(--hint); }
.btn-state {
  min-height: 44px; padding: 6px 12px; cursor: pointer;
  font: inherit; font-size: 0.9rem; line-height: 1.2;
  color: var(--special); background: var(--surface);
  border: 1.5px dashed var(--special); border-radius: var(--radius-sm);
}
.btn-state:hover { background: var(--special-soft); }
.btn-state[aria-pressed="true"] { color: #fff; background: var(--special); border-style: solid; }
.btn-state[aria-pressed="true"]::before { content: "✓ "; content: "✓ " / ""; }
@media (forced-colors: active) {
  .btn-state[aria-pressed="true"] { forced-color-adjust: none; color: HighlightText; background: Highlight; border-color: Highlight; }
}
.btn-state:disabled { cursor: default; opacity: 0.7; }
.has-state input:not([type="radio"]):not([type="checkbox"]),
.has-state textarea { color: var(--text-2); background: var(--surface-2); border-style: dashed; }
.has-state .input-affix > .affix { border-style: dashed; }
.has-state .choice,
.has-state .choice:has(input:checked) { background: var(--surface-2); border-style: dashed; border-color: var(--border-strong); }

/* Repeaters */
.field-label { font-weight: 600; margin: 0 0 4px; }
.rep-items { list-style: none; margin: 0 0 12px; padding: 0; }
.rep-item { padding: 14px; }
.rep-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.rep-head h3 { margin: 0; }
.rep-limit { margin-top: 8px; }
.confirm-box { margin: 8px 0; padding: 12px; background: var(--danger-soft); border-radius: var(--radius-sm); }
.confirm-box p { font-weight: 600; }
.confirm-box p.confirm-detail { font-weight: 400; }

/* ---------- Requirement cards and checklist items ---------- */
.matrix, .checklist { min-width: 0; }
.act-switch { margin: 0 0 16px; }
.card-nav {
  display: grid; gap: 10px; margin: 0 0 12px; padding: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.card-nav-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.card-pos { margin: 0; font-family: var(--font-mono); font-weight: 500; }
.card-nav-steps, .card-pager { display: flex; flex-wrap: wrap; gap: 8px; }
.card-pager { justify-content: space-between; margin: 0 0 20px; }
.jump { display: grid; gap: 4px; grid-template-columns: minmax(0, 1fr); }
.jump label { font-size: 0.95rem; font-weight: 600; }

.req-card { padding: 16px 14px; }
.req-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 6px 10px; }
.req-title { margin: 0; }
.req-for { margin: 4px 0 6px; color: var(--text-2); }
.req-hint { margin-bottom: 4px; }
.req-actions { display: flex; flex-wrap: wrap; gap: 4px 8px; margin: 4px 0 0 -12px; }
.rename-box { margin: 8px 0; padding: 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.rename-box .btn { margin-top: 8px; }
.custom-editor { margin-top: 8px; }
.req-remove-note { font-size: 0.85rem; margin: 2px 0 0; }

.stage { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--border); }
.stage > legend { float: left; width: 100%; margin-bottom: 2px; }
.stage > legend + * { clear: left; }
.stage .hint { margin-bottom: 8px; }
.apply-all { margin-top: 6px; }
.next-activity { margin: -8px 0 20px; }
.next-activity .hint { margin-bottom: 6px; }
.pill.special span { color: var(--special); border-color: var(--special); border-style: dashed; }
.pill.special input:checked + span { color: #fff; border-style: solid; }

.req-details { margin: 18px 0 0; }
details.sub-panel { box-shadow: none; margin: 12px 0 0; }
details.sub-panel > summary { font-weight: 600; }
.details-mode { margin-bottom: 16px; }
.copy-row { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.copy-row > label { display: block; margin-bottom: 4px; font-weight: 600; }
.copy-controls { display: flex; gap: 8px; }
.copy-controls select { flex: 1 1 auto; min-width: 0; }
.copy-controls .btn { flex: 0 0 auto; }

.plain-list { list-style: none; margin: 0; padding: 0; }
ul.panel-body { padding-top: 0; }
.removed-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 0; border-bottom: 1px solid var(--border);
}
.add-form .btn { margin-top: 4px; }

.links-summary { margin: 8px 0 0; font-size: 0.95rem; }
.links-summary li { padding: 4px 0; border-bottom: 1px dashed var(--border); }
.link-cat { font-weight: 600; }

/* ---------- Section footer ---------- */
.section-actions {
  display: grid; justify-items: start; gap: 8px;
  margin: 32px 0 8px; padding-top: 16px; border-top: 1px solid var(--border);
}
.inactive-note p:last-child { margin-bottom: 0; }

/* ---------- Start ---------- */
/* Short display heading: Archivo, expanded upper case (brand board). */
.view-start h1 {
  font-size: 1.75rem; font-weight: 800; font-stretch: 118%; letter-spacing: 0.01em;
  line-height: 1.08; text-transform: uppercase; margin-bottom: 14px;
}
/* Key facts as a ruled list with ochre squares. */
.key-facts { list-style: none; margin: 0 0 24px; padding: 0; border-top: 1px solid var(--border); }
.key-facts li { position: relative; margin: 0; padding: 10px 0 10px 22px; border-bottom: 1px solid var(--border); }
.key-facts li::before { content: ''; position: absolute; left: 2px; top: calc(10px + 0.75em - 4px); width: 8px; height: 8px; background: var(--ochre); }
.start-actions { display: grid; gap: 8px; margin: 0 0 24px; }
.start-actions p { margin: 0; }
.start-actions .confirm-box p { margin: 0 0 0.75em; }
.start-actions .notice { margin: 0; }
.current-label { font-weight: 600; }
.current-interview { font-family: var(--font-mono); font-size: 0.85rem; }
.current-interview .current-label { font-family: var(--font); font-size: 1rem; }
.next-interview { margin: 4px 0 8px; }
.next-interview .confirm-box { text-align: left; }
.privacy h2, .resume h2, .clear-device h2 { font-size: 1.15rem; }
.privacy { border-top: 3px solid var(--charcoal); border-radius: 0; }
.privacy p { margin-bottom: 0.5em; }
.privacy p:last-child { margin-bottom: 0; }
.resume { margin-top: 24px; }
.resume-form .field { margin-bottom: 12px; }

/* Stand-alone links get a full-size touch target. */
.start-actions a:not(.btn),
.section-one a,
.review-link a,
.group-links a,
.issue-go,
.section-summary-item > a,
.inactive-note a,
.readonly-banner a,
.privacy-policy a,
.jump-submit a,
.notice-actions a,
.option-jump-list a,
.group-back a {
  display: inline-flex; align-items: center; min-height: 44px; font-weight: 600;
}
/* Short links ("Edit", "View") also get a 44px-wide target. */
.section-one a,
.section-summary-item > a,
.issue-go { min-width: 44px; justify-content: center; padding: 0 8px; }

/* ---------- Overview ---------- */
.pitch .pitch-title { font-size: 1.05rem; margin-bottom: 4px; }
.pitch p:last-child { margin-bottom: 0; }
.section-one { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; }
.section-one-title { margin: 0; }
.continue-btn { margin: 0 0 20px; }
.overview-card > summary { align-items: flex-start; }
.overview-head { display: grid; gap: 4px; min-width: 0; }
.overview-title { margin: 0; font-size: 1.1rem; }
.overview-status { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 0; font-weight: 400; }
.overview-card.is-inactive > summary { color: var(--text-2); }
.group-links { margin: 0 0 12px; padding-left: 20px; }
.review-link { margin-top: 8px; }

/* ---------- Review ---------- */
.blocking { outline: none; }
.blocking h2 { font-size: 1.1rem; }
.section-summary-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.section-summary-item p { margin: 0; }
.section-summary-item > div { min-width: 0; }
.section-summary-item > a { flex: 0 0 auto; }
.section-summary-item .badge { margin-right: 4px; }
.jump-submit { margin: 12px 0 0; }
.open-items { margin-top: 24px; }
.open-section { margin: 20px 0 4px; font-size: 1.05rem; }
.gap-panel { margin: 0 0 10px; }
.gap-summary { min-width: 0; }
.issue-text .issue-message { margin-top: 2px; color: var(--text-2); }
.issue-list { list-style: none; margin: 0 0 12px; padding: 0; }
.issue {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 12px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.issue-text p { margin: 0; }
.issue-label { font-weight: 600; }
.issue-label .badge { margin-right: 2px; vertical-align: 1px; }
.submit-block { margin-top: 28px; }
.submit-block fieldset { margin-bottom: 16px; }
.submit-block .choice { align-items: flex-start; }
.submit-block .choice input { margin-top: 2px; }
.submit-error { outline: none; }
.submit-note { margin: 10px 0 0; }

/* ---------- Resume link ---------- */
.link-label { margin-bottom: 6px; font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-2); }
.resume-url {
  display: block; margin: 0 0 12px; padding: 10px 12px;
  font-family: var(--font-mono); font-size: 0.85rem; word-break: break-all; overflow-wrap: anywhere;
  background: var(--surface-2); border-radius: var(--radius-sm); user-select: all;
}
.copy-msg { margin: 8px 0 0; }
.qr { display: grid; justify-items: center; gap: 6px; margin: 0 0 16px; }
.qr svg {
  display: block; width: min(232px, 100%); height: auto; padding: 8px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.qr figcaption { color: var(--hint); }
.clipboard-helper { position: fixed; top: 0; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.clear-device { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ---------- Done ---------- */
.facts { display: grid; gap: 10px; }
.facts > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; }
.facts > div { padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.facts > div:last-child { padding-bottom: 0; border-bottom: 0; }
.facts dt { font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-2); align-self: center; }
.website-back { margin: 4px 0 8px; }
.facts dd { margin: 0; }

/* ---------- Summary ---------- */
.summary-meta { color: var(--text-2); }
.summary-section { margin-top: 24px; }
.summary-section h2 { font-size: 1.15rem; padding-bottom: 6px; border-bottom: 1px solid var(--charcoal); }
.summary-list { margin: 0; }
.summary-row { padding: 8px 0; border-bottom: 1px solid var(--border); }
.summary-row dt { font-size: 0.95rem; font-weight: 600; color: var(--text-2); }
.summary-row dd { margin: 2px 0 0; white-space: pre-wrap; }

/* ---------- Wider screens ---------- */
@media (min-width: 640px) {
  .app-header-inner { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "brand meta action"; padding-block: 8px; }
  .app-meta { display: grid; align-content: center; gap: 1px; min-height: 36px; padding-left: 16px; border-left: 1px solid #3a3f44; }
  .view-start h1 { font-size: 2.25rem; }
  .jump { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; }
}

/* ---------- Print (#/summary and the browser's print command) ---------- */
@media print {
  .app-header, .bottom-nav, .skip-link, .banners, .no-print, .section-actions,
  .clear-device, .option-jumps, .group-back, button, .btn { display: none !important; }
  body.survey-app { display: block; background: #fff; }
  main { max-width: none; padding: 0; }
  .card { box-shadow: none; }
  .summary-row, .issue { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}
