/*
 * Healthcare practice page (classes p09-) and the blocks its brief
 * introduced, which any industry page can use: the data strip and the route
 * builder. Clear, calm and structured: white, mint accents, a tidy grid.
 * Linked only on pages with those classes (peanut_scoped_css()). Layer
 * blocks, then motion. Tokens only.
 */

@layer blocks {
  /* ---------- Live card practice-new-patient: "New patient" gets tapped,
     the insurance chips appear, then the office picker and the button.
     The static card is the finished one. ---------- */

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

  .p09-lcard__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin: 0 0 var(--space-2);
    padding: 0;
    list-style: none;
  }

  .p09-lcard__chip {
    padding: 0.25rem 0.75rem;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 500;
  }

  .p09-lcard__offices {
    margin-block-end: var(--space-2);
  }

  .p09-lcard__book {
    margin: 0;
    padding: 0.75rem var(--space-2);
    background: var(--color-ink);
    color: var(--color-white);
    font-size: var(--btn-font-size);
    font-weight: var(--btn-weight);
    letter-spacing: var(--btn-tracking);
    text-align: center;
    text-transform: uppercase;
  }

  /* ---------- The drawings' own parts (the problems, the two minis) ---------- */

  .diagram .p09-term__text,
  .diagram .p09-callus__text,
  .diagram .p09-nomatch,
  .diagram .p09-strong {
    font-size: 11px;
    font-weight: 600;
  }

  .diagram .p09-callus__text {
    fill: var(--color-white);
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .diagram .p09-strong {
    font-size: 12px;
  }

  .diagram .p09-road {
    fill: none;
    stroke: var(--color-ink);
    stroke-width: 1.5;
    stroke-linecap: round;
    opacity: 0.4;
  }

  .diagram .p09-trail {
    fill: none;
    stroke: var(--color-ink);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-dasharray: 4 5;
    opacity: 0.5;
  }

  .diagram .p09-moon {
    fill: var(--color-butter);
    stroke: var(--color-ink);
    stroke-width: 1.5;
    stroke-linejoin: round;
  }

  .diagram .p09-blank {
    opacity: 0.6;
  }

  .diagram .p09-ghost {
    opacity: 0.45;
  }

  .diagram .p09-ghost__strike {
    fill: none;
    stroke: var(--color-ink);
    stroke-width: 1.5;
    stroke-linecap: round;
  }

  .diagram .p09-field__box {
    opacity: 0.8;
  }

  .diagram .p09-chip {
    stroke: var(--color-ink);
    stroke-width: 1;
  }

  /* ---------- What to expect (visuals/p09-expect): three steps on a line,
     then the second sequence, smaller ---------- */

  .p09-expect {
    display: grid;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-sm);
  }

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

  .p09-expect__kind--alt {
    margin-block-start: var(--space-3);
    padding-block-start: var(--space-3);
    border-block-start: var(--border);
  }

  .p09-expect__row {
    --disc: 2.25rem;
    --gap: var(--space-4);
    display: grid;
    gap: var(--space-3) var(--gap);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .p09-expect__step {
    position: relative;
    display: grid;
    grid-template-columns: var(--disc) minmax(0, 1fr);
    gap: 0.125rem 0.75rem;
    align-content: start;
    align-items: start;
  }

  .p09-expect__disc {
    grid-row: 1 / 3;
    display: grid;
    place-items: center;
    width: var(--disc);
    height: var(--disc);
    background: var(--color-brand);
    border: var(--border);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
  }

  .p09-expect__name {
    font-family: var(--font-heading);
    font-size: var(--step-2);
    font-weight: var(--weight-heading);
    line-height: 1.15;
  }

  .p09-expect__line {
    font-size: var(--step--1);
    line-height: 1.45;
  }

  /* the connector: down the disc's column on phones, across to the next disc from 48rem */
  .p09-expect__step:not(:last-child)::before {
    content: "";
    position: absolute;
    top: calc(var(--disc) + 0.375rem);
    bottom: calc(0.375rem - var(--space-3));
    left: calc(var(--disc) / 2 - 0.75px);
    width: 1.5px;
    background: var(--color-ink);
    opacity: 0.45;
    transform-origin: top;
  }

  .p09-expect__row--alt {
    --disc: 1.75rem;
  }

  .p09-expect__row--alt .p09-expect__name {
    font-size: var(--step-1);
  }

  @media (min-width: 48rem) {
    .p09-expect__row {
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .p09-expect__step {
      grid-template-columns: minmax(0, 1fr);
      gap: 0.375rem;
    }

    .p09-expect__disc {
      grid-row: auto;
      margin-block-end: 0.375rem;
    }

    .p09-expect__step:not(:last-child)::before {
      top: calc(var(--disc) / 2 - 0.75px);
      right: calc(0.5rem - var(--gap));
      bottom: auto;
      left: calc(var(--disc) + 0.5rem);
      width: auto;
      height: 1.5px;
      transform-origin: left;
    }
  }

  /* ---------- Data strip (blocks/datastrip): figures that start a sentence,
     a line beside them, the source under ---------- */

  .datastrip {
    /* a slim strip: trims the section's padding to the strip's own */
    margin-block: calc(var(--space-4) - var(--section-pad-top)) calc(var(--space-4) - var(--section-pad-bottom));
  }

  .datastrip__head {
    margin-block-end: var(--space-3);
  }

  .datastrip__title {
    margin: 0;
  }

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

  .datastrip__band {
    display: grid;
    gap: var(--space-3) var(--space-5);
    padding-block: var(--space-4);
    border-block: var(--border);
  }

  .datastrip__figures {
    display: grid;
    gap: var(--space-3) var(--space-5);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .datastrip__item {
    display: grid;
    gap: 0.25rem;
    align-content: start;
  }

  .datastrip__figure {
    font-family: var(--font-heading);
    font-size: var(--step-5);
    font-weight: var(--weight-heading);
    line-height: 1;
    letter-spacing: -0.01em;
  }

  .datastrip__text {
    max-width: 26rem;
    line-height: 1.5;
  }

  .datastrip__text strong {
    font-weight: 600;
  }

  .datastrip__aside {
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--step-2);
    font-weight: var(--weight-heading);
    line-height: 1.3;
    text-wrap: balance;
  }

  .datastrip__source {
    margin: var(--space-2) 0 0;
    font-size: var(--step--1);
    line-height: 1.5;
  }

  .datastrip__source-label {
    margin-inline-end: 0.375rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
  }

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

  @media (min-width: 60rem) {
    .datastrip--n3 .datastrip__figures {
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .datastrip--aside .datastrip__band {
      grid-template-columns: minmax(0, 3fr) minmax(0, 1fr);
      align-items: center;
    }

    .datastrip--aside .datastrip__aside {
      padding-inline-start: var(--space-5);
      border-inline-start: var(--border);
    }
  }

  /* ---------- Route builder (blocks/routebuilder): the columns of choices,
     the line between them, the end button ---------- */

  .routebuilder__head {
    max-width: 44rem;
    margin-block-end: var(--space-5);
  }

  .routebuilder__title {
    margin: 0;
  }

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

  .routebuilder__board {
    --gap: var(--space-5);
    position: relative;
    display: grid;
    gap: var(--space-4);
  }

  .routebuilder__lines {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    overflow: visible;
    pointer-events: none;
  }

  .routebuilder__path {
    fill: none;
    stroke: var(--color-ink);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-dasharray: 1;
    stroke-dashoffset: 0;
    opacity: 0.7;
  }

  .routebuilder__col {
    position: relative;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .routebuilder__legend {
    display: flex;
    gap: 0.625rem;
    align-items: center;
    margin: 0 0 var(--space-2);
    padding: 0;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
  }

  .routebuilder__num {
    display: grid;
    flex: none;
    place-items: center;
    width: 1.375rem;
    height: 1.375rem;
    background: var(--color-brand);
    border: var(--border);
    border-radius: 50%;
    font-size: 0.6875rem;
    letter-spacing: 0;
  }

  .routebuilder__options {
    display: grid;
    gap: 0.5rem;
  }

  .routebuilder__option {
    position: relative;
    display: flex;
    gap: 0.625rem;
    align-items: center;
    padding: 0.625rem 0.875rem;
    background: var(--color-white);
    border: var(--border);
    border-radius: 0.5rem;
    line-height: 1.3;
    cursor: pointer;
    transition: background-color 200ms var(--ease-out);
  }

  .routebuilder__option[hidden] {
    display: none;
  }

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

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

  .routebuilder__radio {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
    pointer-events: none;
  }

  .routebuilder__mark {
    position: relative;
    flex: none;
    width: 1rem;
    height: 1rem;
    background: var(--color-white);
    border: var(--border);
    border-radius: 50%;
  }

  .routebuilder__option:has(:checked) .routebuilder__mark::after {
    content: "";
    position: absolute;
    inset: 0.1875rem;
    background: var(--color-ink);
    border-radius: 50%;
  }

  .routebuilder__label {
    display: grid;
    font-weight: 500;
  }

  .routebuilder__note {
    font-size: 0.6875rem;
    font-weight: 400;
  }

  .routebuilder__end {
    position: relative;
  }

  .routebuilder__legend--end .routebuilder__num {
    background: var(--color-white);
  }

  .routebuilder__result {
    margin: 0;
  }

  .routebuilder__btn {
    display: block;
    padding: var(--btn-padding);
    background: var(--color-ink);
    border-radius: var(--btn-radius);
    color: var(--color-white);
    font-size: var(--btn-font-size);
    font-weight: var(--btn-weight);
    letter-spacing: var(--btn-tracking);
    line-height: 1.3;
    text-align: center;
    text-transform: uppercase;
  }

  /* stacked (under 64rem): the script draws the route down a spine 12px left
     of the options (routebuilder.js), so the line crosses no text; before the
     script, a short line down between the stacked columns stands for the
     default route */
  .routebuilder:not(.is-live) .routebuilder__col + .routebuilder__col::before,
  .routebuilder:not(.is-live) .routebuilder__end::before {
    content: "";
    position: absolute;
    top: calc(-1 * var(--space-4));
    left: 0.6875rem;
    width: 1.5px;
    height: var(--space-4);
    background: var(--color-ink);
    opacity: 0.45;
  }

  .routebuilder__needs {
    display: grid;
    gap: var(--space-4);
    margin: var(--space-6) 0 0;
    padding: 0;
    list-style: none;
  }

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

  .routebuilder__needtext {
    margin: 0;
  }

  .routebuilder__outro {
    max-width: 44rem;
    margin: var(--space-5) 0 0;
    padding: var(--space-3) var(--space-4);
    background: var(--color-paper);
    border: var(--border);
    border-radius: var(--radius-sm);
  }

  .section--paper .routebuilder__outro {
    background: var(--color-white);
  }

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

  @media (min-width: 64rem) {
    .routebuilder__board {
      grid-template-columns: repeat(var(--cols), minmax(0, 1fr)) minmax(0, 1fr);
      column-gap: var(--gap);
      align-items: start;
    }

    .routebuilder--n2 .routebuilder__board {
      --cols: 2;
    }

    .routebuilder--n3 .routebuilder__board {
      --cols: 3;
    }

    .routebuilder--n4 .routebuilder__board {
      --cols: 4;
      --gap: var(--space-4);
    }

    /* before the script: the first options sit in one row, so a straight
       connector across each gap draws the default route */
    .routebuilder:not(.is-live) .routebuilder__col + .routebuilder__col::before,
    .routebuilder:not(.is-live) .routebuilder__end::before {
      display: none;
    }

    .routebuilder:not(.is-live) .routebuilder__option:has(:checked)::after {
      content: "";
      position: absolute;
      top: 50%;
      left: calc(100% + 1px);
      width: var(--gap);
      height: 1.5px;
      background: var(--color-ink);
      opacity: 0.45;
    }
  }
}

@layer blocks {
  /* The showcase toggle (showcase.js): one sequence at a time. Without the
     script both show. */
  .showcase__visual[data-view="1"] :is(.p09-expect__kind, .p09-expect__row--alt) {
    display: none;
  }

  .showcase__visual[data-view="2"] :is(.p09-expect__kind, .p09-expect__row:not(.p09-expect__row--alt)) {
    display: none;
  }
}

@layer motion {
  @media screen and (prefers-reduced-motion: no-preference) {
    /* Live card: the chips pop in one after another */
    .lcard.is-live .p09-lcard__chip {
      transition: opacity 320ms var(--ease-out), translate 320ms var(--ease-out);
      transition-delay: calc(var(--i, 0) * 140ms + 120ms);
    }

    .lcard.is-live [data-at]:not(.is-on) .p09-lcard__chip {
      opacity: 0;
      translate: 0 0.375rem;
    }

    /* Problem 01: the road to the first visit draws itself */
    html[data-fx~="diagrams"] .pb-practice-term .p09-road {
      stroke-dasharray: 1;
      animation: p09-draw 1200ms var(--ease-out) 1000ms both;
    }

    /* Problem 02: the cursor moves toward "Call us", then pulls back */
    html[data-fx~="diagrams"] .pb-practice-insurance .p09-hover {
      animation: p09-hesitate 2200ms var(--ease-out) 1700ms both;
    }

    /* Problem 03: the search finds nothing, so the empty space blinks once */
    html[data-fx~="diagrams"] .pb-practice-brochure .p09-blank {
      animation: p09-blink 1400ms steps(1, end) 1900ms both;
    }

    /* What to expect: the connectors grow, the discs pop, the words rise,
       one step after another; the second sequence follows */
    html.js-motion .showcase__visual[data-play] .p09-expect__step::before {
      transition: transform 520ms var(--ease-out);
      transition-delay: calc(var(--i, 0) * 380ms + 420ms);
    }

    html.js-motion .showcase__visual[data-play] .p09-expect__disc {
      transition: transform 480ms var(--ease-pop);
      transition-delay: calc(var(--i, 0) * 380ms + 120ms);
    }

    html.js-motion .showcase__visual[data-play] :is(.p09-expect__name, .p09-expect__line) {
      transition: opacity 420ms var(--ease-out), translate 420ms var(--ease-out);
      transition-delay: calc(var(--i, 0) * 380ms + 240ms);
    }

    html.js-motion .showcase__visual[data-play] .p09-expect__kind--alt {
      transition: opacity 420ms var(--ease-out);
      transition-delay: 1500ms;
    }

    html.js-motion .showcase__visual[data-play]:not(.is-in) .p09-expect__step::before {
      transform: scaleX(0);
    }

    html.js-motion .showcase__visual[data-play]:not(.is-in) .p09-expect__disc {
      transform: scale(0.4);
    }

    html.js-motion .showcase__visual[data-play]:not(.is-in) :is(.p09-expect__name, .p09-expect__line, .p09-expect__kind--alt) {
      opacity: 0;
    }

    html.js-motion .showcase__visual[data-play]:not(.is-in) :is(.p09-expect__name, .p09-expect__line) {
      translate: 0 0.375rem;
    }

    @media (max-width: 47.99rem) {
      html.js-motion .showcase__visual[data-play]:not(.is-in) .p09-expect__step::before {
        transform: scaleY(0);
      }
    }

    /* First contact: the three fields draw themselves, the ghost field is
       struck through and fades */
    html.js-motion .minis__drawing[data-play] .p09-field__box {
      stroke-dasharray: 1;
      transition: stroke-dashoffset 700ms var(--ease-out);
      transition-delay: calc(var(--i, 0) * 360ms + 200ms);
    }

    html.js-motion .minis__drawing[data-play] .p09-field text {
      transition: opacity 400ms var(--ease-out);
      transition-delay: calc(var(--i, 0) * 360ms + 100ms);
    }

    html.js-motion .minis__drawing[data-play]:not(.is-in) .p09-field__box {
      stroke-dashoffset: 1;
    }

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

    html.js-motion .minis__drawing[data-play] .p09-ghost__strike {
      stroke-dasharray: 1;
      transition: stroke-dashoffset 500ms var(--ease-out) 1500ms;
    }

    html.js-motion .minis__drawing[data-play] .p09-ghost {
      transition: opacity 600ms var(--ease-out) 1700ms;
    }

    html.js-motion .minis__drawing[data-play]:not(.is-in) .p09-ghost__strike {
      stroke-dashoffset: 1;
    }

    html.js-motion .minis__drawing[data-play]:not(.is-in) .p09-ghost {
      opacity: 1;
    }

    /* Found locally: the result slides in */
    html.js-motion .minis__drawing[data-play] .p09-result {
      transition: opacity 520ms var(--ease-out) 300ms, translate 520ms var(--ease-out) 300ms;
    }

    html.js-motion .minis__drawing[data-play]:not(.is-in) .p09-result {
      opacity: 0;
      translate: 0 10px;
    }

    /* Route builder: the line draws from choice to choice (routebuilder.js
       sets the dash offset back to 1 and lets this transition bring it in) */
    html[data-fx~="diagrams"] .routebuilder.is-live .routebuilder__path {
      transition: stroke-dashoffset 700ms var(--ease-out);
    }
  }

  @keyframes p09-draw {
    from {
      stroke-dashoffset: 1;
    }

    to {
      stroke-dashoffset: 0;
    }
  }

  @keyframes p09-hesitate {
    0% {
      transform: translate(0, 0);
    }

    45% {
      transform: translate(-96px, 24px);
    }

    65% {
      transform: translate(-96px, 24px);
    }

    100% {
      transform: translate(0, 0);
    }
  }

  @keyframes p09-blink {
    0% {
      opacity: 0.6;
    }

    30% {
      opacity: 0.15;
    }

    60% {
      opacity: 0.6;
    }

    100% {
      opacity: 0.6;
    }
  }
}
