/* Morale Survey (/survey/) */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

#survey-view, .results { max-width: 720px; margin: 32px auto; }

.survey-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 24px;
  justify-content: center;
  padding: 14px 20px;
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin: 0 0 24px;
}
.survey-meta strong { color: var(--ink); }
.footnote-ref { font-weight: 700; text-decoration: none; padding: 0 2px; }

.survey { display: grid; gap: 20px; }

.q { margin: 0; min-width: 0; }
.q legend, .q-label {
  display: block;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.35;
  text-wrap: balance;
  padding: 0;
  margin-bottom: 14px;
  float: left;      /* lets the legend sit inside the card padding */
  width: 100%;
}
.q legend + * { clear: both; }
.q-num {
  display: inline-grid;
  place-items: center;
  min-width: 1.8em;
  height: 1.8em;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--red);
  color: var(--on-red);
  font-size: 0.85em;
  vertical-align: 0.1em;
}
.q-hint { clear: both; margin: 0 0 12px; font-size: 0.95rem; color: var(--ink-soft); text-wrap: pretty; }

/* Sliders */
.slider { clear: both; }
.slider input[type="range"] {
  width: 100%;
  margin: 4px 0;
  accent-color: var(--red);
  height: 28px;
  cursor: pointer;
}
.slider input[type="range"]:focus-visible { outline: 3px solid var(--link); outline-offset: 4px; border-radius: 4px; }
.slider-ends {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.slider-ends span:last-child { text-align: right; }
.slider-value { margin: 10px 0 0; color: var(--ink-soft); }
.slider-value output {
  display: inline-block;
  font-weight: 700;
  background: var(--yellow);
  color: #2b2622;
  padding: 1px 8px;
  border-radius: 4px;
}

/* Likert rows: a radio group styled as a segmented row of buttons.
   Native radios keep arrow-key navigation; the input stays in the
   accessibility tree, only visually covered by its label. */
.likert {
  clear: both;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.likert label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 3.2em;
  padding: 8px 6px;
  border: 2px solid var(--ink-soft);
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.25;
  cursor: pointer;
  text-wrap: balance;
}
.likert input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.likert label:hover { border-color: var(--ink); }
.likert label:has(input:checked) {
  border-color: var(--ink);
  background: var(--yellow);
  color: #2b2622;
  box-shadow: var(--shadow-soft);
}
.likert label:has(input:focus-visible) { outline: 3px solid var(--link); outline-offset: 2px; }

/* Multiple choice */
.choices { clear: both; display: grid; gap: 8px; }
.choices label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 2px solid var(--ink-soft);
  border-radius: 8px;
  cursor: pointer;
  line-height: 1.4;
}
.choices label:hover { border-color: var(--ink); }
.choices label:has(input:checked) { border-color: var(--ink); background: color-mix(in srgb, var(--yellow) 30%, transparent); }
.choices input {
  accent-color: var(--red);
  width: 1.15em;
  height: 1.15em;
  margin: 0.12em 0 0;
  flex: none;
}
.choices input:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }

/* The shrinking comment box. --shrink goes from 1 (empty) toward 0 (very full). */
.shrink-wrap { clear: both; }
#sv-q10 {
  --shrink: 1;
  display: block;
  width: calc(12rem + (100% - 12rem) * var(--shrink));
  height: calc(4.5em + 8em * var(--shrink));
  min-height: 4.5em;
  font: inherit;
  font-size: calc(0.95rem + 0.1rem * var(--shrink));
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  resize: none;
  transition: width .35s ease, height .35s ease, font-size .35s ease;
}
#sv-q10:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
.shrink-status { margin: 10px 0 0; }

.survey-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 8px; }
#survey-privacy, .anon-note { text-align: center; margin: 0; text-wrap: pretty; }
.anon-note { margin-top: 16px; }

/* Results */
.results { text-align: center; }
.results h2:focus { outline: none; }
.results h2:focus-visible { outline: 3px solid var(--link); outline-offset: 4px; }
.results-verdict { font-size: 1.25rem; font-weight: 600; margin: 8px 0 18px; }
.stamp {
  display: inline-block;
  color: var(--red);
  border: 4px solid var(--red);
  border-radius: 8px;
  padding: 0.04em 0.28em;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  transform: rotate(-3deg);
}
.results-stamp { font-size: 1.6rem; font-weight: 800; margin: 6px 0 0 6px; }
.results.is-fresh .results-stamp { animation: stamp-in .45s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes stamp-in {
  from { transform: rotate(-12deg) scale(2.2); opacity: 0; }
  to   { transform: rotate(-3deg) scale(1); opacity: 1; }
}
.results-score { font-size: 1.1rem; margin: 0 0 20px; }
.results-score strong { font-size: 1.6rem; color: var(--red); }
.results h3 { font-size: 1.15rem; margin: 0 0 12px; }

.breakdown { list-style: none; padding: 0; margin: 0 auto 20px; display: grid; gap: 14px; text-align: left; max-width: 560px; }
.breakdown li { display: grid; gap: 4px; }
.breakdown .row { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; }
.breakdown .bar {
  height: 14px;
  border: 2px solid var(--line-strong);
  border-radius: 7px;
  background: var(--paper);
  overflow: hidden;
}
.breakdown .fill {
  --pct: 0;
  display: block;
  height: 100%;
  width: calc(min(var(--pct), 100) * 1%);
  background: var(--grass);
  transition: width .8s ease-out;
}
.breakdown .over .fill { background: var(--red); }
.breakdown .note { font-size: 0.9rem; color: var(--ink-soft); text-wrap: pretty; }

.results-heard {
  display: inline-block;
  font-weight: 700;
  font-size: 1.1rem;
  background: var(--yellow);
  color: #2b2622;
  border: 2px solid var(--line-strong);
  border-radius: 6px;
  padding: 8px 16px;
  box-shadow: var(--shadow-soft);
  margin: 4px 0 12px;
}

@media (max-width: 600px) {
  .q { padding: 18px; }
  .q legend, .q-label { font-size: 1.05rem; }
  .likert { grid-template-columns: 1fr; }
  .likert label { min-height: 2.75em; }
}

@media (prefers-reduced-motion: reduce) {
  #sv-q10, .breakdown .fill { transition: none; }
  .results.is-fresh .results-stamp { animation: none; }
}
