/*
 * Learning needs page.
 *
 * Sits on top of site.css and uses its tokens (--cream, --ink, --terracotta
 * and so on). The fallbacks after each token keep the page readable if a
 * token is ever missing.
 *
 * Contrast (text on cream or white): ink #2B221C and muted #6B5A4C are above
 * 6:1, the error colour #A8442C above 5:1, the button #A4532E with cream text
 * above 5:1. Field and pill outlines use #8A7263, above 3:1 against both.
 */

.needs {
  --n-ink: var(--ink, #2B221C);
  --n-ink-soft: var(--ink-soft, #453729);
  --n-muted: var(--muted, #6B5A4C);
  --n-terracotta: var(--terracotta, #B4603C);
  --n-cream: var(--cream, #FBF5EE);
  --n-peach: var(--peach, #F2D9C6);
  --n-sage: var(--sage, #E8EBDC);
  --n-outline: #8A7263;
  --n-error: #A8442C;
  --n-sans: var(--sans, "Karla", "Helvetica Neue", Arial, sans-serif);

  padding-bottom: clamp(44px, 6vw, 72px);
}

.needs *,
.needs *::before,
.needs *::after {
  box-sizing: border-box;
}

.needs [hidden] {
  display: none !important;
}

.needs__inner {
  max-width: 720px;
  margin: 0 auto;
}

/* ------------------------------------------------------------------ *
 * Heading and introduction
 * ------------------------------------------------------------------ */

.needs__title {
  margin: 0 0 clamp(20px, 3vw, 28px);
  font-size: var(--size-h2-lg, clamp(28px, 21.6px + 1.77vw, 40px));
  line-height: 1.15;
  color: var(--n-ink);
}

.needs__lede {
  margin: 0 0 20px;
  font-size: 1.16em;
  line-height: 1.6;
  color: var(--n-ink);
}

.needs__body,
.needs__price {
  margin: 0 0 18px;
  line-height: 1.75;
  color: var(--n-ink-soft);
}

.needs__price {
  margin-bottom: clamp(30px, 4vw, 40px);
}

.needs__noscript {
  margin: 0 0 28px;
  padding: 14px 18px;
  font-family: var(--n-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--n-ink);
  background: var(--n-sage);
  border-radius: 14px;
}

.needs__noscript a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ------------------------------------------------------------------ *
 * Form
 * ------------------------------------------------------------------ */

.needs__form {
  display: flex;
  flex-direction: column;
  gap: 32px;
  margin: 0;
}

/* Honeypot: off-screen rather than display:none, so bots still fill it. */
.needs__trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
}

.needs-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.needs-field__label,
.needs-group__legend {
  margin: 0;
  padding: 0;
  float: none;
  font-family: var(--n-sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.14em;
  line-height: 1.5;
  text-transform: uppercase;
  color: var(--n-muted);
}

.needs-field input,
.needs-field select,
.needs-field textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 13px 16px;
  font-family: var(--n-sans);
  font-size: 16px; /* 16px keeps iOS from zooming the page on focus. */
  font-weight: 400;
  line-height: 1.45;
  color: var(--n-ink);
  background: #fff;
  border: 1px solid var(--n-outline);
  border-radius: var(--r-field, 14px);
}

.needs-field select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 44px;
  text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%236b5a4c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 12px 8px;
}

.needs-field textarea {
  min-height: 120px;
  line-height: 1.55;
  resize: vertical;
}

.needs-field input:focus-visible,
.needs-field select:focus-visible,
.needs-field textarea:focus-visible {
  border-color: var(--n-terracotta);
  outline: 3px solid var(--n-terracotta);
  outline-offset: 2px;
}

.needs-field.is-invalid input,
.needs-field.is-invalid select,
.needs-field.is-invalid textarea {
  border-color: var(--n-error);
  box-shadow: 0 0 0 3px rgba(168, 68, 44, 0.14);
}

.needs-field__error {
  font-family: var(--n-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--n-error);
}

.needs-field__error:empty {
  display: none;
}

/* ------------------------------------------------------------------ *
 * Groups (fieldsets) and help lines
 * ------------------------------------------------------------------ */

.needs-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.needs-group__help {
  margin: 0;
  font-family: var(--n-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--n-muted);
}

.needs-group.is-invalid .pill-toggle__text {
  border-color: var(--n-error);
}

/* ------------------------------------------------------------------ *
 * Toggle pills: a real checkbox or radio under a styled label
 * ------------------------------------------------------------------ */

.needs-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill-toggle {
  position: relative;
  display: inline-flex;
  max-width: 100%;
  cursor: pointer;
}

.pill-toggle input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.pill-toggle__text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 9px 18px;
  font-family: var(--n-sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.3;
  text-align: center;
  color: var(--n-ink);
  background: #fff;
  border: 1px solid var(--n-outline);
  border-radius: var(--r-pill, 100px);
  transition: background var(--speed, 180ms) ease, border-color var(--speed, 180ms) ease;
}

.pill-toggle:hover .pill-toggle__text {
  border-color: var(--n-terracotta);
}

/* Checked: tinted fill, a heavier outline and a tick, so colour is never the only signal. */
.pill-toggle input:checked + .pill-toggle__text {
  background: var(--n-peach);
  border-color: var(--n-terracotta);
  box-shadow: inset 0 0 0 1px var(--n-terracotta);
}

.pill-toggle input:checked + .pill-toggle__text::before {
  content: "";
  flex: none;
  width: 5px;
  height: 10px;
  margin-top: -3px;
  border-right: 2px solid var(--n-ink);
  border-bottom: 2px solid var(--n-ink);
  transform: rotate(45deg);
}

.pill-toggle input:focus-visible + .pill-toggle__text {
  outline: 3px solid var(--n-terracotta);
  outline-offset: 3px;
}

/* ------------------------------------------------------------------ *
 * Availability grid: days across, time bands down, one checkbox per slot
 * ------------------------------------------------------------------ */

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

.needs-grid {
  width: 100%;
  max-width: 100%;
}

.needs-grid__table {
  width: 100%;
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.needs-grid__label-col {
  width: 84px;
}

.needs-grid__day {
  padding: 0 0 6px;
  font-family: var(--n-sans);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  color: var(--n-ink);
}

.needs-grid__group th {
  padding: 16px 0 4px;
  font-family: var(--n-sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1.4;
  text-align: left;
  text-transform: uppercase;
  color: var(--n-muted);
}

tbody:first-of-type .needs-grid__group th {
  padding-top: 6px;
}

.needs-grid__band {
  padding: 0 8px 0 0;
  font-family: var(--n-sans);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.25;
  text-align: left;
  color: var(--n-ink-soft);
  overflow-wrap: anywhere;
}

.needs-grid td {
  padding: 2px 0;
  text-align: center;
  vertical-align: middle;
}

.needs-cell {
  position: relative;
  display: block;
  width: 100%;
  max-width: 40px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  cursor: pointer;
}

.needs-cell input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}

.needs-cell__box {
  position: absolute;
  inset: 0;
  display: block;
  background: #fff;
  border: 1px solid var(--n-outline);
  border-radius: 10px;
  transition: background var(--speed, 180ms) ease, border-color var(--speed, 180ms) ease;
}

.needs-cell:hover .needs-cell__box {
  border-color: var(--n-terracotta);
}

/* Checked: tinted fill, a heavier outline and a tick, so colour is never the only signal. */
.needs-cell input:checked + .needs-cell__box {
  background: var(--n-peach);
  border-color: var(--n-terracotta);
  box-shadow: inset 0 0 0 1px var(--n-terracotta);
}

.needs-cell input:checked + .needs-cell__box::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 46%;
  width: 6px;
  height: 11px;
  border-right: 2px solid var(--n-ink);
  border-bottom: 2px solid var(--n-ink);
  transform: translate(-50%, -50%) rotate(45deg);
}

.needs-cell input:focus-visible + .needs-cell__box {
  outline: 3px solid var(--n-terracotta);
  outline-offset: 2px;
}

.needs-group.is-invalid .needs-cell__box {
  border-color: var(--n-error);
}

@media (min-width: 601px) {
  .needs-grid__label-col {
    width: 120px;
  }

  .needs-grid__day,
  .needs-grid__band {
    font-size: 15px;
  }

  .needs-grid td {
    padding: 3px 0;
  }
}

@media (max-width: 360px) {
  .needs-grid__label-col {
    width: 70px;
  }

  .needs-grid__band {
    font-size: 12px;
    padding-right: 4px;
  }
}

/* The "Tell me how often" input under the frequency pills. */
.needs-field--other {
  max-width: 480px;
}

/* ------------------------------------------------------------------ *
 * Status, button, success panel
 * ------------------------------------------------------------------ */

.needs__status {
  margin: 0;
  font-family: var(--n-sans);
  font-size: 15px;
  line-height: 1.6;
}

.needs__status:empty {
  display: none;
}

.needs__status--error {
  padding: 12px 16px;
  color: var(--n-error);
  background: rgba(168, 68, 44, 0.08);
  border-radius: 12px;
}

.needs__foot {
  display: flex;
  margin-top: -6px;
}

.needs__submit {
  min-height: 50px;
  padding: 15px 34px;
  font-family: var(--n-sans);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--n-cream);
  background: #A4532E;
  border: 0;
  border-radius: var(--r-pill, 100px);
  cursor: pointer;
  transition: background var(--speed, 180ms) ease, opacity var(--speed, 180ms) ease;
}

.needs__submit:hover:not([disabled]) {
  background: var(--n-ink);
}

.needs__submit:focus-visible {
  outline: 3px solid var(--n-terracotta);
  outline-offset: 3px;
}

.needs__submit[disabled] {
  cursor: progress;
  opacity: 0.75;
}

.needs__sent {
  padding: 30px 28px 32px;
  background: var(--n-sage);
  border-radius: 20px;
}

.needs__sent:focus {
  outline: 3px solid var(--n-terracotta);
  outline-offset: 3px;
}

.needs__sent-title {
  margin: 0 0 8px;
  font-size: clamp(22px, 19px + 0.8vw, 26px);
  font-weight: 300;
  line-height: 1.3;
  color: var(--n-ink);
}

.needs__sent-body {
  margin: 0;
  font-family: var(--n-sans);
  font-size: 16px;
  line-height: 1.6;
  color: #3E4433;
}

.needs__sent-preview {
  margin: 14px 0 0;
  font-family: var(--n-sans);
  font-size: 14px;
  line-height: 1.5;
  color: #3E4433;
}

@media (max-width: 600px) {
  .needs__submit {
    width: 100%;
  }

  .needs__sent {
    padding: 24px 20px 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pill-toggle__text,
  .needs-cell__box,
  .needs__submit {
    transition: none;
  }
}
