/*
 * Therapist page (classes p05-) and the block its brief introduced, which
 * any page can use: the Before and after morph (morph). Linked only on pages
 * with those classes (peanut_scoped_css()). Tokens only. Layer blocks for
 * the static state, layer motion for what moves (docs/design/components.md,
 * "Industry pages"). The quietest page on the site: nothing here loops, and
 * each part plays once, slowly, then rests.
 */

@layer blocks {
  /* ---------- Live card therapist-availability: the practice name, the
     switch (on), three rows and a soft button. The static card is the
     finished one ---------- */

  .p05-switch {
    display: flex;
    gap: var(--space-1);
    align-items: center;
    margin: 0 0 var(--space-2);
    font-weight: 500;
  }

  .p05-switch__track {
    position: relative;
    flex: none;
    width: 2.25rem;
    height: 1.25rem;
    background: var(--color-brand);
    border: var(--border);
    border-radius: var(--radius-pill);
  }

  .p05-switch__knob {
    position: absolute;
    top: 1px;
    left: 1px;
    width: calc(1.25rem - 6px);
    height: calc(1.25rem - 6px);
    background: var(--color-white);
    border: var(--border);
    border-radius: 50%;
    translate: 1rem 0;
  }

  .p05-row--consult {
    display: flex;
    gap: var(--space-2);
    justify-content: space-between;
    align-items: center;
  }

  .p05-row__btn {
    padding: 0.25rem 0.625rem;
    background: var(--color-brand);
    border: var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.625rem;
    font-weight: 500;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    white-space: nowrap;
  }

  /* ---------- The drawings' own parts (the three problems, the four small
     drawings): the static drawing is the finished one ---------- */

  .diagram .p05-head {
    fill: var(--color-ink);
    opacity: 0.18;
  }

  .diagram .p05-faint {
    opacity: 0.5;
  }

  .diagram .p05-strong {
    font-weight: 600;
  }

  .diagram .p05-caps {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }

  .diagram .p05-ontext {
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    fill: var(--color-white);
  }

  .diagram .p05-chip {
    opacity: 1;
    stroke-width: 1.2;
  }

  .diagram .p05-profile__card,
  .diagram .p05-sheet {
    stroke: var(--color-ink);
    stroke-width: 1.2;
  }

  .diagram .p05-field {
    fill: var(--color-white);
    stroke: var(--color-ink);
    stroke-width: 1.2;
    stroke-dasharray: 4 4;
    opacity: 0.8;
  }

  /* the map: the land white with an ink edge, the state lines faint, the
     licensed states mint, their labels in pills under the map */
  .p05-states .hm-land {
    fill: var(--color-white);
    stroke: var(--color-ink);
    stroke-width: 1.5;
    stroke-linejoin: round;
  }

  .p05-states .hm-states {
    fill: none;
    stroke: var(--color-ink);
    stroke-width: 1;
    opacity: 0.18;
  }

  .p05-states .p05-state {
    fill: var(--color-brand);
    stroke: var(--color-ink);
    stroke-width: 1.5;
    stroke-linejoin: round;
  }

  .p05-states .p05-leader {
    fill: none;
    stroke: var(--color-ink);
    stroke-width: 2;
    opacity: 0.4;
  }

  .p05-states .p05-leader-dot {
    fill: var(--color-gold-soft);
    stroke: var(--color-ink);
    stroke-width: 1.5;
  }

  .p05-states .p05-pill {
    fill: var(--color-white);
    stroke: var(--color-ink);
    stroke-width: 1.5;
  }

  .p05-states .p05-mapcaps {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }

  .p05-states .p05-maptext {
    font-size: 26px;
    font-weight: 500;
  }

  /* the small drawings are wider than the default on this page: the map and
     the doors need the room, the cards keep their text legible */
  .minis__drawing:has(.p05-mini) {
    max-width: 22rem;
  }

  .minis__drawing:has(.p05-states) {
    max-width: 30rem;
  }

  .minis__drawing:has(.p05-doors) {
    max-width: 20rem;
  }

  /* the smaller "In your language" line under the two columns */
  .minis:has(.p05-states) .minis__outro {
    max-width: 44rem;
    font-size: var(--step--1);
    line-height: var(--leading-body);
  }

  /* ---------- Before and after (blocks/morph.php, 2026-11-20): the copy on
     top, then one row: the profile, the arrow with its caption, the website.
     Phones: the three stacked. Nothing sticks. The highlights' timing is in
     the motion layer ---------- */

  .morph {
    display: grid;
    gap: var(--space-5);
  }

  .morph__copy {
    max-width: 46rem;
  }

  .morph__head {
    max-width: 44rem;
  }

  .morph__title {
    margin: 0;
  }

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

  .morph__more {
    margin: var(--space-2) 0 0;
  }

  .morph__items {
    display: grid;
    gap: var(--space-3);
    max-width: 44rem;
    margin: var(--space-4) 0 0;
    padding: 0;
    list-style: none;
  }

  .morph__name {
    margin: 0 0 var(--space-1);
  }

  .morph__text,
  .morph__outro {
    margin: 0;
  }

  .morph__stage {
    display: grid;
    gap: var(--space-3);
    align-items: center;
  }

  .morph__state {
    display: grid;
    gap: var(--space-2);
    min-width: 0;
  }

  .morph__state--before {
    width: 100%;
    max-width: 20rem;
    justify-self: center;
  }

  .morph__label {
    margin: 0;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
  }

  .morph__arrow {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    align-items: center;
    justify-self: center;
  }

  .morph__arrowhead {
    display: block;
    width: 3.5rem;
    height: auto;
    rotate: 90deg;
  }

  .morph__arrowline {
    fill: none;
    stroke: var(--color-ink);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .morph__caption {
    padding: 0.25rem 0.75rem;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    white-space: nowrap;
  }

  /* The row from 48rem: the profile small on the left, the website on the
     right, sized so the whole row fits one screen at 1440 */
  @media (min-width: 48rem) {
    .morph__stage {
      grid-template-columns: minmax(0, 15rem) auto minmax(0, 38rem);
      gap: var(--space-4);
      justify-content: center;
    }

    .morph__state--before {
      max-width: none;
    }

    .morph__arrowhead {
      rotate: 0deg;
    }

    /* two lines beside the arrow: a soft box, not a pill */
    .morph__arrow .morph__caption {
      max-width: 12rem;
      padding: 0.375rem 0.75rem;
      border-radius: var(--radius-sm);
      text-align: center;
      white-space: normal;
    }
  }

  @media (min-width: 64rem) {
    .morph__stage {
      grid-template-columns: minmax(0, 17rem) auto minmax(0, 40rem);
      gap: var(--space-5);
    }
  }

  /* ---------- The highlights (aftertype own-site, data-hl on four parts of
     the website): static, which is the finished state, all four lit, each
     with its note on its top edge. A lit part is mint with the mint ring,
     like the mockups' lit parts, and a thin ink line around the ring ---------- */

  .morph--hl [data-hl] {
    position: relative;
    border-radius: 0.5rem;
    background: var(--color-brand);
    box-shadow: 0 0 0 0.375rem var(--color-brand);
    outline: 1.5px solid var(--color-ink);
    outline-offset: 0.375rem;
  }

  .morph-hl__note {
    position: absolute;
    top: -0.375rem;
    right: var(--space-2);
    z-index: 2;
    padding: 0.1875rem 0.5rem;
    background: var(--color-ink);
    color: var(--color-white);
    border-radius: var(--radius-pill);
    font-size: 0.5625rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
    translate: 0 -50%;
  }

  /* the first row is a grid of two parts: its note spans the row, not a cell */
  .morph-site__row[data-hl] > .morph-hl__note {
    grid-column: 1 / -1;
  }

  /* playing (morph.js): only the current part is lit; after the last, all four */
  .morph.is-ready:not(.is-done) [data-hl] {
    background: transparent;
    box-shadow: 0 0 0 0.375rem transparent;
    outline-color: transparent;
  }

  .morph.is-ready:not(.is-done) .morph-site__part--on[data-hl] {
    background: var(--color-brand);
  }

  .morph.is-ready:not(.is-done) .morph-hl__note {
    opacity: 0;
  }

  .morph.is-ready[data-step="0"] [data-hl="0"],
  .morph.is-ready[data-step="1"] [data-hl="1"],
  .morph.is-ready[data-step="2"] [data-hl="2"],
  .morph.is-ready[data-step="3"] [data-hl="3"] {
    background: var(--color-brand);
    box-shadow: 0 0 0 0.375rem var(--color-brand);
    outline-color: var(--color-ink);
  }

  .morph.is-ready[data-step="0"] [data-hl="0"] > .morph-hl__note,
  .morph.is-ready[data-step="1"] [data-hl="1"] > .morph-hl__note,
  .morph.is-ready[data-step="2"] [data-hl="2"] > .morph-hl__note,
  .morph.is-ready[data-step="3"] [data-hl="3"] > .morph-hl__note {
    opacity: 1;
  }

  /* a compact website in the row, so it fits one screen: the three fields
     of the first message side by side from 64rem */
  @media (min-width: 64rem) {
    .morph--hl .morph-site__hero {
      padding-block: var(--space-2);
    }

    .morph--hl .morph-site__photo {
      max-width: 4rem;
    }

    .morph--hl .morph-site__fields {
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .morph--hl .morph-site__fields li {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

  /* ---------- Morph state directory-profile: the card ---------- */

  .morph-card {
    display: grid;
    gap: var(--space-2);
    padding: var(--space-3);
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.6875rem;
    line-height: 1.35;
  }

  .morph-card__top {
    display: flex;
    gap: var(--space-2);
    align-items: center;
  }

  .morph-card__photo {
    flex: none;
    width: 3rem;
    height: 3rem;
    background: var(--color-paper);
    border: var(--border);
    border-radius: 50%;
  }

  .morph-card__name {
    margin: 0;
    font-weight: 600;
  }

  .morph-card__meta {
    margin: 0.125rem 0 0;
    opacity: 0.6;
  }

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

  .morph-card__fields li {
    display: flex;
    gap: var(--space-2);
    justify-content: space-between;
    padding: 0.4375rem 0;
    border-block-start: 1px solid var(--color-ink-line-faint);
  }

  .morph-card__fields b {
    font-weight: 500;
    text-align: right;
    opacity: 0.7;
  }

  .morph-card__btn {
    margin: 0;
    padding: 0.5rem;
    border: var(--border);
    border-radius: 0.25rem;
    font-weight: 500;
    text-align: center;
  }

  /* ---------- Morph state own-site: the website, on the mock classes ---------- */

  .morph-site__body {
    gap: var(--space-2);
  }

  .morph-site__hero {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: var(--space-2);
    align-items: center;
    padding: var(--space-3) var(--space-2);
    background: var(--color-paper);
    border-radius: 0.5rem;
  }

  .morph-site__words {
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--step-1);
    font-weight: var(--weight-heading);
    line-height: 1.2;
  }

  .morph-site__photo {
    display: block;
    justify-self: end;
    width: 100%;
    max-width: 5rem;
    aspect-ratio: 4 / 5;
    background: var(--color-butter);
    border: 1px solid var(--color-ink);
    border-radius: 0.5rem;
  }

  .morph-site__row {
    display: grid;
    gap: var(--space-2);
  }

  .morph-site__part {
    display: grid;
    gap: 0.375rem;
    align-content: start;
    padding: var(--space-2);
    border: var(--border);
    border-radius: 0.5rem;
  }

  .morph-site__part--on {
    align-content: center;
    background: var(--color-brand);
  }

  .morph-site__label {
    margin: 0;
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
  }

  .morph-site__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .morph-site__chips li {
    padding: 0.25rem 0.625rem;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-pill);
    font-weight: 500;
  }

  .morph-site__list {
    display: grid;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .morph-site__line--mid {
    width: 64%;
  }

  .morph-site__switch {
    display: flex;
    gap: var(--space-1);
    align-items: center;
    margin: 0;
    font-weight: 500;
  }

  .morph-site__track {
    position: relative;
    flex: none;
    width: 2rem;
    height: 1.125rem;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-pill);
  }

  .morph-site__knob {
    position: absolute;
    top: 1px;
    right: 1px;
    width: calc(1.125rem - 6px);
    height: calc(1.125rem - 6px);
    background: var(--color-ink);
    border-radius: 50%;
  }

  .morph-site__fields {
    display: grid;
    gap: 0.375rem;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .morph-site__fields li {
    padding: 0.375rem 0.625rem;
    background: var(--color-white);
    border: 1px dashed var(--color-ink);
    border-radius: 0.375rem;
    opacity: 0.75;
  }

  .morph-site__btn {
    justify-self: start;
    padding: 0.5rem 0.875rem;
    background: var(--color-ink);
    color: var(--color-white);
    font-size: 0.625rem;
    font-weight: 500;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
  }

  @media (min-width: 48rem) {
    .morph-site__row {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }
}

@layer motion {
  @media screen and (prefers-reduced-motion: no-preference) {
    /* The live card: once the card starts, the switch turns on, then the
       three rows rise in one after another; then nothing moves again */
    html[data-fx~="diagrams"] .lcard.is-live .p05-switch__track {
      animation: p05-switch 700ms var(--ease-out) 600ms both;
    }

    html[data-fx~="diagrams"] .lcard.is-live .p05-switch__knob {
      animation: p05-knob 700ms var(--ease-out) 600ms both;
    }

    html[data-fx~="diagrams"] .lcard.is-live .p05-row {
      animation: p05-rise 800ms var(--ease-out) both;
    }

    html[data-fx~="diagrams"] .lcard.is-live .p05-row--0 {
      animation-delay: 1500ms;
    }

    html[data-fx~="diagrams"] .lcard.is-live .p05-row--1 {
      animation-delay: 2100ms;
    }

    html[data-fx~="diagrams"] .lcard.is-live .p05-row--2 {
      animation-delay: 2700ms;
    }

    /* The small drawings, once their item comes into view: the fees card
       and the form fade in; the doors fade in one after another; the
       licensed states fill in one after another, then their labels */
    html.js-motion .minis__drawing[data-play] .p05-mini {
      transition: opacity 800ms var(--ease-out);
    }

    html.js-motion .minis__drawing[data-play]:not(.is-in) .p05-mini {
      opacity: 0;
    }

    html.js-motion .minis__drawing[data-play] .p05-door {
      transition: opacity 700ms var(--ease-out);
    }

    html.js-motion .minis__drawing[data-play] .p05-door--1 {
      transition-delay: 350ms;
    }

    html.js-motion .minis__drawing[data-play] .p05-door--2 {
      transition-delay: 700ms;
    }

    html.js-motion .minis__drawing[data-play]:not(.is-in) .p05-door {
      opacity: 0;
    }

    html.js-motion .minis__drawing[data-play] .p05-state {
      transition: opacity 900ms var(--ease-out);
    }

    html.js-motion .minis__drawing[data-play] .p05-state--1 {
      transition-delay: 350ms;
    }

    html.js-motion .minis__drawing[data-play] .p05-state--2 {
      transition-delay: 700ms;
    }

    html.js-motion .minis__drawing[data-play] .p05-maplabel {
      transition: opacity 700ms var(--ease-out);
      transition-delay: 1100ms;
    }

    html.js-motion .minis__drawing[data-play] .p05-maplabel--1 {
      transition-delay: 1400ms;
    }

    html.js-motion .minis__drawing[data-play] .p05-maplabel--2 {
      transition-delay: 1700ms;
    }

    html.js-motion .minis__drawing[data-play]:not(.is-in) :is(.p05-state, .p05-maplabel) {
      opacity: 0;
    }

    /* The morph: the row fades in once as it comes into view; the
       highlights ease between parts (morph.js sets the steps) */
    html.js-motion .morph__stage[data-play] {
      transition: opacity 900ms var(--ease-out);
    }

    html.js-motion .morph__stage[data-play]:not(.is-in) {
      opacity: 0;
    }

    .morph.is-ready [data-hl] {
      transition: background-color 400ms var(--ease-out), box-shadow 400ms var(--ease-out), outline-color 400ms var(--ease-out);
    }

    .morph.is-ready .morph-hl__note {
      transition: opacity 400ms var(--ease-out);
    }
  }

  @keyframes p05-switch {
    from {
      background-color: var(--color-white);
    }
  }

  @keyframes p05-knob {
    from {
      translate: 0 0;
    }
  }

  @keyframes p05-rise {
    from {
      opacity: 0;
      translate: 0 6px;
    }
  }
}
