/*
 * Doula page, final pass (owner, 2026-11-20): the two interactive parts,
 * classes p06x-. "The questions she asks at three in the morning" (the
 * nightsection block, layout phone: the question chips above a phone at
 * 3:12 AM showing the site's FAQ) and "Found by a parent who has never heard
 * your name" (visuals/p06x-searches in a showcase: four example searches,
 * each with its result and the page it opens). Linked only on pages with
 * those classes (peanut_scoped_css()). Tokens only. Layer blocks for the
 * static state, layer motion for what moves. Nothing here loops.
 */

@layer blocks {
  /* ---------- The questions at three in the morning (blocks/nightsection,
     layout phone): the black section and its faint warm glow; the head and
     the closing line on the left, the sample (label, chips, phone) on the
     right ---------- */

  .p06x-night {
    position: relative;
    isolation: isolate;
    display: grid;
    gap: var(--space-5);
  }

  .p06x-night__glow {
    position: absolute;
    z-index: -1;
    /* out to the gutters, so on a phone it runs to the screen's edge; on wide
       screens it fades out well inside them, so no edge shows */
    inset: calc(-1 * var(--section-pad-top)) calc(-1 * var(--gutter)) calc(-1 * var(--section-pad-bottom));
    background: radial-gradient(ellipse 24rem 20rem at 70% 10%, var(--color-butter), transparent 70%);
    opacity: 0.14;
    pointer-events: none;
  }

  .p06x-night__head {
    max-width: 40rem;
  }

  .p06x-night .eyebrow {
    color: var(--color-on-ink-label);
  }

  .p06x-night__title {
    margin: 0;
    color: var(--color-white);
  }

  .p06x-night__title em {
    color: var(--color-brand);
  }

  .p06x-night__intro {
    margin: var(--space-3) 0 0;
    color: var(--color-on-ink-text);
    line-height: var(--leading-body);
  }

  .p06x-night__sample {
    display: grid;
    gap: var(--space-3);
    margin: 0;
    min-width: 0;
  }

  .p06x-night__label {
    margin: 0;
    color: var(--color-on-ink-label);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
  }

  /* the questions as search suggestions */
  .p06x-night__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .p06x-night__chips[hidden] {
    display: none;
  }

  .p06x-night__chip {
    min-height: 2.75rem;
    margin: 0;
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--color-on-ink-line-strong);
    border-radius: var(--radius-pill);
    color: var(--color-white);
    font: inherit;
    font-size: var(--step--1);
    font-weight: 500;
    line-height: 1.35;
    text-align: start;
    cursor: pointer;
  }

  .p06x-night__chip:hover {
    border-color: var(--color-white);
  }

  .p06x-night__chip[aria-pressed="true"] {
    background: var(--color-brand);
    border-color: var(--color-brand);
    color: var(--color-ink);
  }

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

  /* the phone: its screen is the doula's site, lit up in the dark */
  .p06x-phone {
    width: min(100% - 1rem, 22rem);
    padding-block-end: var(--space-2);
    background: var(--color-paper);
    border: 1px solid var(--color-on-ink-line-strong);
    border-radius: 2rem;
    box-shadow: 0 0 0 0.5rem var(--color-ink), 0 0 0 calc(0.5rem + 1px) var(--color-on-ink-line-strong), 0 0 4rem var(--color-brand-glow);
    color: var(--color-ink);
    margin-inline: 0.5rem;
  }

  .p06x-phone__status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1.5rem 0.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }

  .p06x-phone__icons {
    display: flex;
    gap: 0.375rem;
    align-items: center;
  }

  .p06x-phone__signal {
    width: 0.875rem;
    height: 0.625rem;
    background: linear-gradient(to right, var(--color-ink) 0 20%, transparent 20% 40%, var(--color-ink) 40% 60%, transparent 60% 80%, var(--color-ink) 80%);
    clip-path: polygon(0 100%, 100% 0, 100% 100%);
  }

  .p06x-phone__battery {
    position: relative;
    width: 1.25rem;
    height: 0.625rem;
    border: 1px solid var(--color-ink);
    border-radius: 0.1875rem;
  }

  .p06x-phone__battery::after {
    content: "";
    position: absolute;
    inset: 1px 45% 1px 1px;
    background: var(--color-ink);
    border-radius: 0.0625rem;
  }

  .p06x-phone__bar {
    display: flex;
    gap: 0.375rem;
    justify-content: center;
    align-items: center;
    margin: 0.375rem 0.875rem 0;
    padding: 0.375rem 0.75rem;
    background: var(--color-white);
    border: 1px solid var(--color-ink-line-faint);
    border-radius: var(--radius-pill);
    font-size: 0.6875rem;
    font-weight: 500;
  }

  .p06x-phone__lock {
    width: 0.4375rem;
    height: 0.375rem;
    margin-block-start: 0.1875rem;
    background: var(--color-ink);
    border-radius: 0.0625rem;
    box-shadow: 0 -0.25rem 0 -0.0625rem var(--color-paper), 0 -0.25rem 0 0 var(--color-ink);
  }

  /* the search: two lines tall whatever it holds, so the typing moves nothing */
  .p06x-phone__search {
    display: flex;
    gap: 0.625rem;
    align-items: center;
    height: 3.75rem;
    margin: var(--space-2) 0.875rem 0;
    padding: 0.5rem 1rem;
    overflow: hidden;
    background: var(--color-white);
    border: var(--border);
    border-radius: 1rem;
    font-size: var(--step--1);
    font-weight: 500;
    line-height: 1.35;
  }

  .p06x-phone__search[hidden] {
    display: none;
  }

  .p06x-phone__glass,
  .p06x-searches__glass {
    position: relative;
    flex: none;
    width: 0.75rem;
    height: 0.75rem;
    margin-inline-end: 0.125rem;
    border: 1.5px solid currentColor;
    border-radius: 50%;
  }

  .p06x-phone__glass::after,
  .p06x-searches__glass::after {
    content: "";
    position: absolute;
    right: -0.25rem;
    bottom: -0.25rem;
    width: 0.3125rem;
    height: 1.5px;
    background: currentColor;
    transform: rotate(45deg);
  }

  .p06x-phone__typed {
    min-width: 0;
  }

  .p06x-phone__caret {
    flex: none;
    align-self: center;
    width: 1px;
    height: 1.1em;
    margin-inline-start: -0.5rem;
    background: var(--color-ink);
    opacity: 0;
  }

  .p06x-night.is-typing .p06x-phone__caret {
    opacity: 1;
  }

  .p06x-phone__answers {
    margin: 0;
    padding: var(--space-3) 1.25rem var(--space-2);
  }

  .p06x-phone__qa + .p06x-phone__qa {
    margin-block-start: var(--space-3);
    padding-block-start: var(--space-3);
    border-block-start: 1px solid var(--color-ink-line-faint);
  }

  .p06x-phone__q {
    font-family: var(--font-heading);
    font-size: var(--step-1);
    font-weight: var(--weight-heading);
    line-height: 1.25;
  }

  .p06x-phone__a {
    margin: var(--space-1) 0 0;
    font-size: 0.875rem;
    line-height: 1.6;
  }

  /* with the script the answers share one cell: the tallest sets the height */
  .p06x-night.is-live .p06x-phone__answers {
    display: grid;
  }

  .p06x-night.is-live .p06x-phone__qa {
    grid-area: 1 / 1;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .p06x-night.is-live .p06x-phone__qa[data-off] {
    visibility: hidden;
  }

  .p06x-night__outro {
    max-width: 30rem;
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--step-3);
    font-weight: var(--weight-heading);
    line-height: 1.3;
    color: var(--color-white);
    text-wrap: balance;
  }

  @media (min-width: 60rem) {
    .p06x-night {
      grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
      grid-template-rows: auto 1fr;
      grid-template-areas:
        "head sample"
        "outro sample";
      column-gap: var(--space-7);
      row-gap: var(--space-5);
      align-items: start;
    }

    .p06x-night__head {
      grid-area: head;
    }

    .p06x-night__sample {
      grid-area: sample;
    }

    .p06x-night__outro {
      grid-area: outro;
    }
  }

  /* ---------- Found by a parent (visuals/p06x-searches, blocks/showcase):
     four example searches as buttons, each showing its result and the page
     it opens ---------- */

  .p06x-searches {
    container-type: inline-size;
    display: grid;
    gap: var(--space-2);
    font-size: var(--step--1);
    line-height: 1.4;
  }

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

  .p06x-searches__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .p06x-searches__chips[hidden] {
    display: none;
  }

  .p06x-searches__chip {
    display: inline-flex;
    gap: 0.5rem;
    align-items: center;
    min-height: 2.75rem;
    margin: 0;
    padding: 0.5rem 1rem;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-pill);
    color: var(--color-ink);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
  }

  .p06x-searches__chip[aria-pressed="true"] {
    background: var(--color-ink);
    color: var(--color-white);
  }

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

  .p06x-searches__stack {
    display: grid;
    gap: var(--space-4);
    margin-block-start: var(--space-1);
  }

  .p06x-searches__set {
    display: grid;
    gap: 0.75rem;
    align-items: center;
  }

  .p06x-searches__query {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-self: start;
    margin: 0;
    padding: 0.375rem 0.875rem;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-pill);
    font-weight: 500;
  }

  .p06x-searches__result,
  .p06x-searches__page {
    display: grid;
    gap: 0.375rem;
    align-self: stretch;
    align-content: start;
    padding: var(--space-2);
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-sm);
  }

  .p06x-searches__result {
    align-self: start;
    background: var(--color-brand);
  }

  .p06x-searches__url,
  .p06x-searches__line {
    margin: 0;
  }

  .p06x-searches__title {
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--step-1);
    font-weight: var(--weight-heading);
    line-height: 1.2;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
  }

  .p06x-searches__h {
    margin: 0 0 0.25rem;
    font-family: var(--font-heading);
    font-size: var(--step-2);
    font-weight: var(--weight-heading);
    line-height: 1.2;
  }

  /* a drawn button: the sample page's, not a control */
  .p06x-searches__btn {
    justify-self: start;
    margin: 0.5rem 0 0;
    padding: 0.5rem 0.875rem;
    background: var(--color-ink);
    color: var(--color-white);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
  }

  /* from the result down to its page */
  .p06x-searches__arrow {
    position: relative;
    justify-self: center;
    width: 1px;
    height: 1.25rem;
    background: var(--color-ink);
  }

  .p06x-searches__arrow::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: -0.25rem;
    width: 0.5rem;
    height: 0.5rem;
    border-right: 1px solid var(--color-ink);
    border-bottom: 1px solid var(--color-ink);
    transform: rotate(45deg);
  }

  @container (min-width: 30rem) {
    .p06x-searches__set {
      grid-template-columns: minmax(0, 1fr) 2rem minmax(0, 1fr);
    }

    .p06x-searches__query {
      grid-column: 1 / -1;
    }

    .p06x-searches__arrow {
      align-self: start;
      width: 100%;
      height: 1px;
      margin-block-start: 3.5rem;
    }

    .p06x-searches__arrow::after {
      top: -0.25rem;
      right: 0;
      bottom: auto;
      left: auto;
      border-top: 1px solid var(--color-ink);
      border-bottom: 0;
    }
  }

  /* with the script: the buttons say the search, the four share one cell */
  .p06x-searches.is-live .p06x-searches__query {
    display: none;
  }

  .p06x-searches.is-live .p06x-searches__stack {
    gap: 0;
  }

  .p06x-searches.is-live .p06x-searches__set {
    grid-area: 1 / 1;
  }

  .p06x-searches.is-live .p06x-searches__set[data-off] {
    visibility: hidden;
  }

  /* Print: no buttons; every answer and every search, one after the other,
     as without the script */
  @media print {
    .p06x-night__chips,
    .p06x-phone__search,
    .p06x-searches__chips {
      display: none;
    }

    .p06x-night__glow {
      display: none;
    }

    .p06x-phone {
      width: auto;
      box-shadow: none;
    }

    .p06x-night.is-live .p06x-phone__answers,
    .p06x-searches.is-live .p06x-searches__stack {
      display: block;
    }

    .p06x-night.is-live .p06x-phone__qa[data-off],
    .p06x-searches.is-live .p06x-searches__set[data-off] {
      visibility: visible;
    }

    .p06x-night.is-live .p06x-phone__qa + .p06x-phone__qa {
      margin-block-start: var(--space-3);
      padding-block-start: var(--space-3);
      border-block-start: 1px solid var(--color-ink-line-faint);
    }

    .p06x-searches.is-live .p06x-searches__query {
      display: flex;
    }

    .p06x-searches.is-live .p06x-searches__set + .p06x-searches__set {
      margin-block-start: var(--space-4);
    }

    .p06x-phone__qa,
    .p06x-searches__set {
      break-inside: avoid;
    }
  }
}

@layer motion {
  @media screen and (prefers-reduced-motion: no-preference) {
    .p06x-night__chip,
    .p06x-searches__chip {
      transition: background-color 300ms var(--ease-out), border-color 300ms var(--ease-out), color 300ms var(--ease-out);
    }

    .p06x-night.is-live .p06x-phone__qa,
    .p06x-searches.is-live .p06x-searches__set {
      transition: opacity 500ms var(--ease-out), visibility 0s;
    }

    .p06x-night.is-live .p06x-phone__qa[data-off],
    .p06x-searches.is-live .p06x-searches__set[data-off] {
      opacity: 0;
      transition: opacity 300ms var(--ease-out), visibility 0s 300ms;
    }

    /* while the question types, its answer waits out of sight */
    .p06x-night.is-typing .p06x-phone__qa:not([data-off]) {
      opacity: 0;
      transition-duration: 0s;
    }
  }
}
