/* Follow one lead (site/snippets/blocks/followlead.php, the Marketing
   systems page's demo; public/assets/js/followlead.js). A sample inquiry
   followed through five steps, with a two-way switch between by hand and
   connected. Linked by the block itself (peanut_page_css), once per page.
   Every selector names a followlead class. Tokens only. The shared hint,
   progress bar and sample controls are industry.css's (linked on any page
   with a demo- class). The switch follows twometros.css. */

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

  .followlead__outro {
    max-width: 44rem;
    margin: var(--space-4) 0 0;
  }

  .followlead__demo {
    display: grid;
    gap: var(--space-3);
  }

  /* ---------- the controls: hint, switch, progress ---------- */
  .followlead__controls {
    display: grid;
    gap: var(--space-2);
    max-width: 26rem;
  }

  .followlead__switch {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0.25rem;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-pill);
  }

  .followlead__switch[hidden] {
    display: none;
  }

  .followlead__switch::before {
    content: "";
    position: absolute;
    inset-block: 0.25rem;
    inset-inline-start: 0.25rem;
    width: calc(50% - 0.25rem);
    background: var(--color-brand);
    border: var(--border);
    border-radius: var(--radius-pill);
  }

  .followlead__switch[data-at="0"]::before {
    background: var(--color-accent-2);
  }

  .followlead__switch[data-at="1"]::before {
    transform: translateX(100%);
  }

  .followlead__pick {
    position: relative;
    min-height: 2.75rem;
    margin: 0;
    padding: 0.5rem 0.75rem;
    background: none;
    border: 0;
    border-radius: var(--radius-pill);
    color: var(--color-ink);
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.25;
    text-align: center;
    cursor: pointer;
  }

  .followlead__pick[aria-pressed="true"] {
    font-weight: 600;
  }

  .followlead__pick[aria-pressed="false"]:hover {
    text-decoration: underline;
    text-underline-offset: 0.2em;
  }

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

  /* ---------- the frame: the sample, on white with the 1px ink line ---------- */
  .followlead__frame {
    overflow: hidden;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-sm);
    color: var(--color-ink);
  }

  .followlead__bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-3);
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-3);
    background: var(--color-paper);
    border-block-end: var(--border);
  }

  .followlead__biz {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.4;
  }

  .followlead__bizname {
    font-weight: 600;
  }

  .followlead__places {
    color: var(--color-muted);
  }

  .followlead__sample {
    padding: 0.125rem 0.625rem;
    background: var(--color-butter);
    border: var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    line-height: 1.4;
    text-transform: uppercase;
  }

  .followlead__body {
    display: grid;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-3);
  }

  .followlead__caption {
    margin: 0;
    padding: var(--space-2) var(--space-3);
    border-block-start: var(--border);
    color: var(--color-muted);
    font-size: 0.8125rem;
    line-height: 1.5;
  }

  /* ---------- the inquiry: a small form card, read as text ---------- */
  .followlead__inquiry {
    align-self: start;
    padding: var(--space-3);
    background: var(--color-mint-pale);
    border: var(--border);
    border-radius: var(--radius-sm);
  }

  .followlead__formtitle {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    margin: 0 0 var(--space-3);
    font-weight: 600;
    line-height: 1.3;
  }

  .followlead__envelope {
    display: inline-flex;
    flex: none;
  }

  .followlead__fields {
    display: grid;
    gap: var(--space-2);
    margin: 0;
  }

  .followlead__field {
    display: grid;
    gap: 0.125rem;
  }

  .followlead__label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1.4;
  }

  .followlead__value {
    margin: 0;
    padding: 0.375rem 0.625rem;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }

  .followlead__field--where .followlead__value {
    font-weight: 600;
  }

  .followlead__send {
    display: inline-block;
    margin: var(--space-3) 0 0;
    padding: 0.5rem 1rem;
    border-radius: var(--btn-radius);
    font-size: var(--btn-font-size);
    font-weight: var(--btn-weight);
    letter-spacing: var(--btn-tracking);
    line-height: 1.2;
    text-transform: uppercase;
  }

  /* ---------- the steps: a numbered list on one line ---------- */
  .followlead__steps {
    position: relative;
    display: grid;
    gap: var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  /* the line the numbers sit on */
  .followlead__steps::before {
    content: "";
    position: absolute;
    inset-block: 1.25rem;
    inset-inline-start: 1.1875rem;
    border-inline-start: var(--border);
  }

  .followlead__step {
    position: relative;
    display: grid;
    grid-template-columns: 2.5rem minmax(0, 1fr);
    gap: var(--space-3);
    align-items: start;
  }

  .followlead__num {
    display: grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    background: var(--color-white);
    border: var(--border);
    border-radius: 50%;
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: var(--weight-heading);
  }

  .followlead__name {
    margin: 0.375rem 0 0.25rem;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.35;
  }

  .followlead__ways {
    display: grid;
    gap: var(--space-1);
  }

  .followlead__way {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.55;
  }

  .followlead__waylabel {
    font-weight: 600;
  }

  .followlead__time {
    display: inline-block;
    padding: 0 0.5rem;
    border: var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
  }

  .followlead__way--hand .followlead__time {
    background: var(--color-peach-pale);
  }

  .followlead__way--auto .followlead__time {
    background: var(--color-mint-pale);
  }

  .followlead__drop {
    display: inline-block;
    margin-inline-start: 0.125rem;
    padding: 0 0.5rem;
    background: var(--color-accent-2);
    border: var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.6;
  }

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

  .followlead__total {
    margin: 0;
    font-weight: 600;
    line-height: 1.5;
  }

  .followlead__total + .followlead__total {
    margin-block-start: var(--space-1);
  }

  /* ---------- live: one way at a time, both lines in one cell ---------- */
  .followlead__demo.is-live .followlead__ways,
  .followlead__demo.is-live .followlead__totals {
    display: grid;
  }

  .followlead__demo.is-live .followlead__way,
  .followlead__demo.is-live .followlead__total {
    grid-area: 1 / 1;
  }

  .followlead__demo.is-live .followlead__total + .followlead__total {
    margin-block-start: 0;
  }

  .followlead__demo.is-live [data-fl-way][data-off] {
    visibility: hidden;
  }

  /* the switch already names the way: the label stays for screen readers only */
  .followlead__demo.is-live .followlead__waylabel {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* the numbers in the way shown: coral where the lead can go quiet by hand, mint when connected */
  .followlead__demo[data-way="hand"] .followlead__step--drop .followlead__num {
    background: var(--color-accent-2);
  }

  .followlead__demo[data-way="auto"] .followlead__num {
    background: var(--color-brand);
  }

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

    .followlead__controls {
      grid-template-columns: auto minmax(14rem, 22rem);
      align-items: center;
      gap: var(--space-2) var(--space-4);
      max-width: none;
    }

    .followlead__progress {
      grid-column: 2;
    }

    .followlead__fields {
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: var(--space-2) var(--space-3);
    }

    .followlead__field--message {
      grid-column: 1 / -1;
    }
  }

  @media (min-width: 64rem) {
    .followlead__body {
      grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
      gap: var(--space-6);
    }

    .followlead__fields {
      grid-template-columns: minmax(0, 1fr);
    }

    .followlead__field--message {
      grid-column: auto;
    }
  }

  @media print {
    .followlead__demo.is-live [data-fl-way][data-off] {
      visibility: visible;
    }

    .followlead__demo.is-live .followlead__ways,
    .followlead__demo.is-live .followlead__totals {
      display: block;
    }

    .followlead__demo.is-live .followlead__waylabel {
      position: static;
      width: auto;
      height: auto;
      clip-path: none;
    }

    .followlead__switch {
      display: none;
    }
  }
}

@layer motion {
  @media screen and (prefers-reduced-motion: no-preference) {
    html[data-fx~="diagrams"] .followlead__switch::before {
      transition: transform 300ms var(--ease-out), background-color 300ms var(--ease-out);
    }

    html[data-fx~="diagrams"] .followlead__demo.is-live .followlead__num {
      transition: background-color 300ms var(--ease-out);
      transition-delay: calc(var(--fl-i, 0) * 350ms);
    }

    html[data-fx~="diagrams"] .followlead__demo.is-live [data-fl-way]:not([data-off]) {
      animation: followlead-in 420ms var(--ease-out) both;
    }

    html[data-fx~="diagrams"] .followlead__demo.is-live .followlead__step [data-fl-way]:not([data-off]) {
      animation-delay: calc(var(--fl-i, 0) * 350ms);
    }
  }

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

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