/* Which care plan fits? (site/snippets/blocks/carechooser.php,
   public/assets/js/carechooser.js; the Website care page's demo, decision
   P67). Two questions as fieldsets of radio rows and a white result card:
   the plan's name large, what it costs against buying the hours as credits,
   the plan's own button into the care form, and the support hours line.
   Built on planfinder.css (same layout and behaviour). Linked by the block
   itself (peanut_page_css), once per page. Every selector names a
   carechooser class. Tokens only.

   Finished by default (no script, print): the questions hidden, every
   result one under the other as a plain list, each opening with its
   situation line. The script adds .is-live on screens: the questions on
   the left and the card on the right from 64rem (under them below), the
   results in one cell (the tallest sets the height, the others data-off,
   visibility hidden), so a new answer never moves the page. After the
   first tap (.is-free) narrow screens let the shown result set the height.
   The hint and progress bar come from industry.css. */

@layer blocks {
  .carechooser__head {
    max-width: 44rem;
    margin-block-end: var(--space-5);
  }

  .carechooser__title {
    margin: 0;
  }

  .carechooser__intro {
    margin: var(--space-3) 0 0;
  }

  .carechooser__demo {
    display: grid;
    gap: var(--space-4);
    max-width: 68rem;
  }

  /* A1 (bulk fixes 2026-11-29): from 64rem the head is centered and the
     questions and card use the container's width */
  @media (min-width: 64rem) {
    .carechooser__head {
      max-width: 52rem;
      margin-inline: auto;
      text-align: center;
    }

    .carechooser__demo {
      max-width: none;
    }
  }

  /* ---------- the questions (shown by the script) ---------- */
  /* hidden without the script, in print and where the scripting media feature is unknown */
  .carechooser__ask {
    display: none;
    gap: var(--space-2);
    align-content: start;
    min-width: 0;
  }

  .carechooser__hint {
    margin: 0;
  }

  .carechooser__questions {
    display: grid;
    gap: var(--space-4);
    margin-block-start: var(--space-2);
  }

  .carechooser__q {
    display: grid;
    gap: var(--space-1);
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .carechooser__legend {
    margin: 0 0 var(--space-2);
    padding: 0;
    font-family: var(--font-heading);
    font-size: var(--step-2);
    font-weight: var(--weight-heading);
    line-height: var(--leading-heading);
  }

  .carechooser__option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 2.75rem;
    padding: 0.625rem 1rem;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-sm);
    color: var(--color-ink);
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.35;
    cursor: pointer;
  }

  .carechooser__option:hover {
    background: var(--color-paper);
  }

  .carechooser__option:has(:checked) {
    background: var(--color-brand);
  }

  .carechooser__option:has(:focus-visible) {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
  }

  .carechooser__radio {
    flex: none;
    width: 1.125rem;
    height: 1.125rem;
    margin: 0;
    accent-color: var(--color-ink);
    cursor: pointer;
  }

  /* the outline sits on the row, not on the small circle */
  .carechooser__radio:focus-visible {
    outline: none;
  }

  .carechooser__answer {
    min-width: 0;
    overflow-wrap: break-word;
  }

  /* ---------- the card ---------- */
  .carechooser__card {
    display: grid;
    gap: var(--space-4);
    align-content: start;
    min-width: 0;
    padding: var(--space-4) var(--space-3);
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-sm);
    color: var(--color-ink);
  }

  .carechooser__results {
    display: grid;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .carechooser__result {
    min-width: 0;
  }

  .carechooser__result + .carechooser__result {
    margin-block-start: var(--space-4);
    padding-block-start: var(--space-4);
    border-block-start: var(--border);
  }

  .carechooser__situation {
    margin: 0 0 var(--space-1);
    font-weight: 600;
  }

  .carechooser__kicker {
    display: none;
    margin: 0 0 var(--space-1);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    line-height: 1.6;
    text-transform: uppercase;
  }

  .carechooser__plan {
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--step-3);
    font-weight: var(--weight-display);
    line-height: var(--leading-heading);
  }

  .carechooser__text {
    max-width: 36rem;
    margin: var(--space-2) 0 0;
  }

  .carechooser__start {
    margin: var(--space-3) 0 0;
  }

  /* the support hours line, under every result */
  .carechooser__note {
    margin: 0;
    padding-block-start: var(--space-3);
    border-block-start: var(--border);
    font-size: 0.875rem;
    line-height: var(--leading-body);
  }

  @media (min-width: 48rem) {
    .carechooser__card {
      padding: var(--space-5);
    }
  }

  /* ---------- live: screens with scripting on (print and no script keep the list) ----------
     The live layout holds from the first paint, before the script runs: the questions keep
     their space (invisible until .is-live) and only the first answers' result shows, so the
     script never moves the page when it starts. */
  @media screen and (scripting: enabled) {
    .carechooser__ask {
      display: grid;
    }

    .carechooser__demo:not(.is-live) .carechooser__ask {
      visibility: hidden;
    }

    .carechooser__result {
      grid-area: 1 / 1;
    }

    .carechooser__result + .carechooser__result {
      margin: 0;
      padding: 0;
      border: 0;
    }

    .carechooser__demo:not(.is-live) .carechooser__result:not([data-cc-first]),
    .carechooser__demo.is-live .carechooser__result[data-off] {
      visibility: hidden;
    }

    .carechooser__situation {
      display: none;
    }

    .carechooser__kicker {
      display: block;
    }

    .carechooser__plan {
      font-size: var(--step-5);
    }

    @media (max-width: 63.99rem) {
      .carechooser__demo.is-live.is-free .carechooser__result[data-off] {
        display: none;
      }
    }

    @media (min-width: 64rem) {
      .carechooser__demo {
        grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
        grid-template-areas: "ask card";
        column-gap: var(--space-6);
        row-gap: var(--space-5);
        align-items: start;
      }

      .carechooser__ask {
        grid-area: ask;
      }

      .carechooser__card {
        grid-area: card;
      }
    }
  }

  /* ---------- on a black band ---------- */
  .section--ink .carechooser__option {
    border-color: var(--color-ink);
  }

  .section--ink .carechooser__card {
    --focus-ring: var(--color-ink);
    border-color: var(--color-ink);
  }

  /* the card stays white on a black band: its call button keeps the ink fill
     (blocks.css inverts .btn--fill on ink bands) */
  .section--ink .carechooser__card .btn--fill {
    --_bg: var(--color-ink);
    --_fg: var(--color-white);
    --_border: var(--color-ink);
    --_hover-bg: var(--color-white);
    --_hover-fg: var(--color-ink);
  }

  @media print {
    .carechooser__result {
      break-inside: avoid;
    }
  }
}

@layer motion {
  @media screen and (prefers-reduced-motion: no-preference) {
    html[data-fx~="diagrams"] .carechooser__demo.is-live .carechooser__result.is-new:not([data-off]) {
      animation: carechooser-in 320ms var(--ease) both;
    }
  }

  @keyframes carechooser-in {
    from {
      opacity: 0;
      transform: translateY(0.375rem);
    }

    to {
      opacity: 1;
      transform: none;
    }
  }
}
