/*
 * Midwife page (2026-11-20): the Problem drawings, Trust settled first and Who has room. Loaded for the class prefix p07x-
 * (site/plugins/peanut-site/extensions/stylesheets.php).
 *
 * Trust, settled first (the trustmock block, site/snippets/blocks/
 * trustmock.php): the explanations on the left, a sample home page on the
 * right, marked as sample answers; the badges and training lines slot in
 * under the name, then the questions open one at a time
 * (public/assets/js/p07x-trust.js). Who has room (the roomtoggle block,
 * site/snippets/blocks/roomtoggle.php): the heading and text on the left,
 * the availability switch and a sample team page on the right, its two
 * views changing with a crossfade (public/assets/js/p07x-room.js). The
 * drawings' own styles are in problems-scene.css (classes pmw-).
 *
 * Tokens only. Layer blocks for the static state, layer motion for what
 * moves. Nothing here loops. Every selector names a p07x- class.
 */

@layer blocks {
  /* ---------- Shared: two columns, a sample page in a browser frame ---------- */

  .p07x-trust__grid,
  .p07x-room__grid {
    display: grid;
    gap: var(--space-5);
  }

  .p07x-trust__title,
  .p07x-room__title {
    margin: 0;
  }

  .p07x-trust__intro,
  .p07x-room__intro {
    max-width: 40rem;
    margin: var(--space-3) 0 0;
    font-size: var(--text-body);
    line-height: var(--leading-body);
  }

  .p07x-trust__site,
  .p07x-room__site {
    overflow: hidden;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 1.25rem 2.5rem -1.5rem var(--color-shadow-card);
    font-size: var(--step--1);
    line-height: 1.45;
  }

  .p07x-trust__bar,
  .p07x-room__bar {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    padding: 0.5rem var(--space-2);
    background: var(--color-paper);
    border-block-end: var(--border);
    font-size: 0.75rem;
  }

  .p07x-trust__dots,
  .p07x-room__dots {
    flex: none;
    width: 0.4375rem;
    height: 0.4375rem;
    margin-inline-end: 1.5rem;
    background: var(--color-ink);
    border-radius: 50%;
    box-shadow: 0.75rem 0 0 var(--color-ink), 1.5rem 0 0 var(--color-ink);
    opacity: 0.35;
  }

  .p07x-trust__url,
  .p07x-room__url {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    padding: 0.125rem 0.625rem;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-pill);
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* ---------- Trust, settled first ---------- */

  .p07x-trust__items {
    display: grid;
    gap: var(--space-4);
    margin-block-start: var(--space-5);
  }

  .p07x-trust__item {
    padding-block-start: var(--space-3);
    border-block-start: 1px solid var(--color-ink-line-faint);
  }

  .p07x-trust__name {
    margin: 0;
    font-size: var(--step-2);
  }

  .p07x-trust__text {
    margin: var(--space-2) 0 0;
    font-size: var(--text-body);
    line-height: var(--leading-body);
  }

  .p07x-trust__outro {
    margin: var(--space-4) 0 0;
    font-size: var(--step--1);
    line-height: 1.6;
  }

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

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

  .p07x-trust__body {
    display: grid;
    gap: var(--space-3);
    padding: var(--space-3);
  }

  .p07x-trust__intro-card {
    display: grid;
    gap: var(--space-2);
    padding-block-end: var(--space-3);
    border-block-end: 1px solid var(--color-ink-line-faint);
  }

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

  .p07x-trust__who {
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--step-4);
    font-weight: var(--weight-heading);
    line-height: 1.1;
  }

  .p07x-trust__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .p07x-trust__badge {
    padding: 0.25rem 0.75rem;
    background: var(--color-brand);
    border: var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
  }

  .p07x-trust__badge:nth-child(2) {
    background: var(--color-butter);
  }

  .p07x-trust__badge:nth-child(3) {
    background: var(--color-accent-2);
  }

  .p07x-trust__training {
    display: grid;
    gap: 0.375rem;
    margin: 0;
  }

  /* phones: the label over its line; wider: side by side */
  .p07x-trust__line {
    display: grid;
    gap: 0 var(--space-2);
    align-items: baseline;
  }

  @media (min-width: 30rem) {
    .p07x-trust__line {
      grid-template-columns: minmax(0, 9.5rem) minmax(0, 1fr);
    }
  }

  .p07x-trust__line dt {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .p07x-trust__line dd {
    margin: 0;
  }

  .p07x-trust__qs {
    display: grid;
    gap: var(--space-1);
    align-content: start;
    margin: 0;
  }

  .p07x-trust__qa {
    border: var(--border);
    border-radius: 0.375rem;
  }

  .p07x-trust__q {
    padding: 0.625rem 0.75rem 0;
    font-weight: 600;
  }

  .p07x-trust__a {
    margin: 0;
    padding: 0.25rem 0.75rem 0.75rem;
  }

  /* live: each question is a button that opens its answer */
  .p07x-trust.is-live .p07x-trust__q {
    padding: 0;
  }

  .p07x-trust__qbtn {
    display: flex;
    gap: var(--space-2);
    justify-content: space-between;
    align-items: center;
    width: 100%;
    min-height: 2.75rem;
    margin: 0;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: 0;
    border-radius: 0.375rem;
    color: inherit;
    font: inherit;
    font-weight: 600;
    text-align: start;
    cursor: pointer;
  }

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

  .p07x-trust__chev {
    flex: none;
    width: 0.5rem;
    height: 0.5rem;
    border-inline-end: 1.5px solid var(--color-ink);
    border-block-end: 1.5px solid var(--color-ink);
    rotate: 45deg;
    translate: 0 -0.125rem;
  }

  .p07x-trust__qa.is-open {
    background: var(--color-mint-pale);
  }

  .p07x-trust__qa.is-open .p07x-trust__chev {
    rotate: 225deg;
    translate: 0 0.125rem;
  }

  .p07x-trust.is-live .p07x-trust__a {
    padding-block-start: 0;
  }

  /* a closed answer: not displayed on screen (out of the reading order); print shows it */
  @media screen {
    .p07x-trust.is-live .p07x-trust__qa:not(.is-open) .p07x-trust__a {
      display: none;
    }
  }

  /* waiting to play: the badges and lines are out of sight, their room kept */
  .p07x-trust.is-waiting .p07x-trust__in {
    opacity: 0;
  }

  @media (min-width: 64rem) {
    .p07x-trust__grid {
      grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
      gap: var(--space-6);
      align-items: start;
    }
  }

  /* ---------- Who has room ---------- */

  .p07x-room__demo {
    display: grid;
    gap: var(--space-2);
  }

  /* "Tap the switch", over the switch at the end of the settings bar; the
     hint and its mark are the shared ones (snippets/demo/hint.php,
     industry.css) */
  .p07x-room__hint {
    justify-self: end;
  }

  .p07x-room__settings {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-3);
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.5rem 0.5rem var(--space-2);
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-sm);
  }

  /* the hint and the switch keep their space, out of sight until the
     script runs (never a dead control); with scripting off, not there */
  .p07x-room:not(.is-live) .p07x-room__hint,
  .p07x-room:not(.is-live) .p07x-room__settings {
    visibility: hidden;
  }

  @media (scripting: none) {
    .p07x-room__hint,
    .p07x-room__settings {
      display: none;
    }
  }

  /* scripting off: the page's label (Taking May clients) says what it
     shows, in place of the switch */
  @media screen and (scripting: none) {
    .p07x-room .p07x-room__view:not([data-off]) .p07x-room__label {
      display: block;
    }
  }

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

  /* at the end of the bar, also when it wraps under the label */
  .p07x-room__switch {
    position: relative;
    display: inline-flex;
    gap: 0.75rem;
    align-items: center;
    min-height: 2.75rem;
    margin: 0 0 0 auto;
    padding: 0.375rem 0.5rem 0.375rem 0.75rem;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-pill);
    color: inherit;
    font: inherit;
    font-size: var(--step--1);
    font-weight: 500;
    text-align: start;
    cursor: pointer;
  }

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

  /* the track: coral with the knob at the start when off, mint with the
     knob at the end when on */
  .p07x-room__track {
    position: relative;
    flex: none;
    width: 2.75rem;
    height: 1.5rem;
    background: var(--color-accent-2);
    border: var(--border);
    border-radius: var(--radius-pill);
  }

  .p07x-room__switch[aria-checked="true"] .p07x-room__track {
    background: var(--color-brand);
  }

  .p07x-room__knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: calc(1.5rem - 6px);
    height: calc(1.5rem - 6px);
    background: var(--color-white);
    border: var(--border);
    border-radius: 50%;
  }

  .p07x-room__switch[aria-checked="true"] .p07x-room__knob {
    translate: 1.25rem 0;
  }

  /* the tap's ring on the track (motion only) */
  .p07x-room__track::after {
    content: "";
    position: absolute;
    inset: -0.3125rem;
    border: 2px solid var(--color-ink);
    border-radius: var(--radius-pill);
    opacity: 0;
    pointer-events: none;
  }

  /* the state in words, in its color: On (mint) or Off (coral); both share
     one cell, so the switch never changes width */
  .p07x-room__state {
    display: inline-grid;
    vertical-align: baseline;
  }

  .p07x-room__on,
  .p07x-room__off {
    grid-area: 1 / 1;
    padding: 0 0.5rem;
    border: var(--border);
    border-radius: var(--radius-pill);
    font-weight: 600;
    text-align: center;
  }

  .p07x-room__on {
    background: var(--color-brand);
  }

  .p07x-room__off {
    background: var(--color-accent-2);
  }

  .p07x-room__switch[aria-checked="true"] .p07x-room__off,
  .p07x-room__switch[aria-checked="false"] .p07x-room__on {
    visibility: hidden;
  }

  /* the shared cursor (diagrams/cursor): its tip on the track, seen only
     while auto-play runs */
  .p07x-room .p07x-room__cursor {
    position: absolute;
    top: calc(50% + 0.125rem);
    left: calc(2.25rem + 1px);
    z-index: 1;
    width: 1.25rem;
    height: auto;
    overflow: visible;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transform-origin: 0 0;
  }

  .p07x-room.is-playing .p07x-room__cursor {
    opacity: 1;
    visibility: visible;
  }

  .p07x-room__view {
    display: grid;
    gap: var(--space-2);
    align-content: start;
    padding: var(--space-3);
  }

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

  .p07x-room__heading {
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--step-3);
    font-weight: var(--weight-heading);
    line-height: 1.15;
  }

  .p07x-room__banner {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin: 0;
    padding: 0.5rem 0.75rem;
    background: var(--color-paper);
    border: var(--border);
    border-radius: 0.375rem;
  }

  .p07x-room__months-label {
    margin: 0;
    font-weight: 500;
  }

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

  .p07x-room__month {
    padding: 0.125rem 0.625rem;
    background: var(--color-brand);
    border: var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
  }

  .p07x-room__month--full {
    background: var(--color-accent-2);
  }

  .p07x-room__team {
    display: grid;
    gap: 0.625rem;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .p07x-room__person {
    display: grid;
    grid-template-columns: 2.25rem minmax(0, 1fr);
    gap: 0.75rem;
    align-items: center;
  }

  .p07x-room__face {
    width: 2.25rem;
    height: 2.25rem;
    background: var(--color-brand);
    border: var(--border);
    border-radius: 50%;
  }

  .p07x-room__face--1 {
    background: var(--color-butter);
  }

  .p07x-room__face--2 {
    background: var(--color-peach-pale);
  }

  .p07x-room__personname {
    font-weight: 600;
  }

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

  .p07x-room__btn {
    display: inline-block;
    padding: 0.625rem 1rem;
    background: var(--color-ink);
    color: var(--color-white);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
  }

  /* on screen the two views share one cell, the taller sets the height; the
     off one is out of sight (the still state is the first, on) */
  @media screen {
    .p07x-room__views {
      display: grid;
    }

    .p07x-room__view {
      grid-area: 1 / 1;
    }

    .p07x-room__label {
      display: none;
    }

    .p07x-room__view[data-off] {
      visibility: hidden;
      opacity: 0;
    }
  }

  /* the lines under the page: both listed, the current one marked "Now" */
  .p07x-room__notes {
    display: grid;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--step--1);
    line-height: 1.5;
  }

  .p07x-room__note {
    display: grid;
    grid-template-columns: 3.25rem minmax(0, 1fr);
    gap: 0.5rem;
    align-items: start;
  }

  /* one line tall with or without the mark, so moving it moves nothing */
  .p07x-room__slot {
    display: flex;
    align-items: center;
    height: 1.5em;
  }

  .p07x-room__note.is-current {
    font-weight: 500;
  }

  .p07x-room__now {
    display: inline-block;
    padding: 0 0.5rem;
    background: var(--color-brand);
    border: var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    line-height: 1.6;
    text-transform: uppercase;
  }

  .p07x-room__note[data-r-note="1"] .p07x-room__now {
    background: var(--color-accent-2);
  }

  /* with motion and the script: one line, the current one, in one cell
     (the longer sets the height); the "Now" mark is read, not seen */
  @media screen and (prefers-reduced-motion: no-preference) and (scripting: enabled) {
    html[data-fx~="diagrams"] .p07x-room:not(.is-still) .p07x-room__note {
      grid-area: 1 / 1;
      grid-template-columns: minmax(0, 1fr);
    }

    html[data-fx~="diagrams"] .p07x-room:not(.is-still) .p07x-room__note:not(.is-current) {
      visibility: hidden;
    }

    html[data-fx~="diagrams"] .p07x-room:not(.is-still) .p07x-room__slot {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip-path: inset(50%);
      white-space: nowrap;
    }
  }

  .p07x-room__outro {
    max-width: 44rem;
    margin: var(--space-5) 0 0;
    padding-block-start: var(--space-3);
    border-block-start: 1px solid var(--color-ink-line-faint);
    font-size: var(--text-body);
    line-height: var(--leading-body);
  }

  @media (min-width: 64rem) {
    .p07x-room__grid {
      grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
      gap: var(--space-6);
      align-items: center;
    }
  }

  /* Print: everything shows, one after the other; no switch, nothing mirrored */
  @media print {
    .p07x-room__hint,
    .p07x-room__settings,
    .p07x-trust__chev {
      display: none;
    }

    .p07x-room__view + .p07x-room__view {
      border-block-start: var(--border);
    }

    .p07x-trust.is-waiting .p07x-trust__in {
      opacity: 1;
    }

    .p07x-trust__site,
    .p07x-room__site {
      box-shadow: none;
    }
  }
}

@layer motion {
  @media screen and (prefers-reduced-motion: no-preference) {
    /* the badges and training lines slot in under the name, one by one */
    .p07x-trust.is-built .p07x-trust__in {
      transition: opacity 360ms var(--ease-out) calc(var(--i, 0) * 220ms), translate 360ms var(--ease-out) calc(var(--i, 0) * 220ms);
    }

    .p07x-trust.is-waiting .p07x-trust__in {
      translate: 0 0.5rem;
    }

    /* the crossfade between the two team pages */
    .p07x-room__view {
      transition: opacity 300ms var(--ease-out), visibility 0s linear 0s;
    }

    .p07x-room__view[data-off] {
      transition: opacity 300ms var(--ease-out), visibility 0s linear 300ms;
    }

    /* what changed (the May chip, the button) pulses once on a flip */
    .p07x-room__view.is-pulse .p07x-room__month--diff,
    .p07x-room__view.is-pulse .p07x-room__btn--diff {
      animation: p07x-room-pulse 900ms var(--ease-out) both;
    }

    .p07x-room__knob {
      transition: translate 220ms var(--ease-out);
    }

    .p07x-room__track {
      transition: background-color 220ms var(--ease-out);
    }

    /* the cursor comes to the switch, taps it, and fades when play ends */
    .p07x-room .p07x-room__cursor {
      transition: opacity 300ms var(--ease-out), visibility 0s linear 300ms;
    }

    .p07x-room.is-playing .p07x-room__cursor {
      transition: opacity 300ms var(--ease-out), visibility 0s linear 0s;
      animation: p07x-room-arrive 800ms var(--ease-out) both;
    }

    .p07x-room.is-playing.is-tap .p07x-room__cursor {
      animation: p07x-room-press 420ms var(--ease) both;
    }

    .p07x-room.is-playing.is-tap .p07x-room__track::after {
      animation: p07x-room-ring 600ms var(--ease-out) both;
    }
  }

  @keyframes p07x-room-arrive {
    from {
      transform: translate(-2.5rem, 2.5rem);
    }

    to {
      transform: none;
    }
  }

  @keyframes p07x-room-press {
    0%,
    100% {
      transform: none;
    }

    40% {
      transform: scale(0.82);
    }
  }

  @keyframes p07x-room-ring {
    0% {
      opacity: 0.7;
      scale: 0.9;
    }

    100% {
      opacity: 0;
      scale: 1.15;
    }
  }

  @keyframes p07x-room-pulse {
    0% {
      box-shadow: 0 0 0 0 var(--color-ink);
      scale: 1;
    }

    35% {
      box-shadow: 0 0 0 3px var(--color-ink);
      scale: 1.12;
    }

    100% {
      box-shadow: 0 0 0 0.5rem transparent;
      scale: 1;
    }
  }
}
