/* What the brand keeps, and what each location owns
   (site/snippets/blocks/brandparts.php, the Network tier page;
   public/assets/js/brandparts.js). One sample location page in the Pick a
   location frame, its parts tinted (the brand's in butter, the location's in
   mint), a legend under it and the two lists beside it (under it below
   64rem). Linked by the block itself (peanut_page_css), once per page. Every
   selector names a bparts class. Tokens only. The shared hint and the drawn
   sample button are industry.css's (linked on any page with a demo- class). */

@layer blocks {
  .bparts {
    --bparts-brand: var(--color-butter);
    --bparts-location: var(--color-brand);
  }

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

  .bparts__title {
    margin: 0;
  }

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

  /* ---------- the stage: the picture, then the lists (side by side from 64rem) ---------- */
  .bparts__stage {
    display: grid;
    gap: var(--space-5);
    align-items: start;
  }

  @media (min-width: 64rem) {
    .bparts__stage {
      grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    }
  }

  /* ---------- the sample page ---------- */
  .bparts__frame {
    container-type: inline-size;
    overflow: hidden;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-sm);
    color: var(--color-ink);
    font-size: var(--step--1);
    line-height: 1.45;
  }

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

  .bparts__dots {
    flex: none;
    width: 0.4375rem;
    height: 0.4375rem;
    margin-inline-end: 1.75rem;
    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;
  }

  .bparts__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;
  }

  /* "Sample": the demo standard's label, in the bar, as in Pick a location */
  .bparts__sample {
    flex: none;
    padding: 0.0625rem 0.5rem;
    background: var(--color-butter);
    border: var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    line-height: 1.6;
    text-transform: uppercase;
  }

  /* the page: its parts as tinted tiles with white between them */
  .bparts__page {
    display: grid;
    gap: 0.5rem;
    padding: 0.5rem;
  }

  .bparts__top,
  .bparts__pair {
    display: grid;
    gap: 0.5rem;
  }

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

    .bparts__pair {
      grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    }
  }

  .bparts__part {
    position: relative;
    display: grid;
    gap: 0.375rem;
    align-content: start;
    padding: 0.875rem 1rem;
    border-radius: calc(var(--radius-sm) / 2);
  }

  .bparts__part--brand {
    background: var(--bparts-brand);
  }

  .bparts__part--location {
    background: var(--bparts-location);
  }

  .bparts__part p {
    margin: 0;
  }

  .bparts__part ul {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  /* one part marked: it keeps its tint and gets an ink edge, the rest go pale */
  .bparts.has-mark .bparts__part:not(.is-on) {
    background: var(--color-paper);
  }

  .bparts__part.is-on {
    outline: 2px solid var(--color-ink);
    outline-offset: -2px;
  }

  .bparts.is-live .bparts__part[data-bp-has] {
    cursor: pointer;
  }

  /* the marked part's line, as a tag on its top edge */
  .bparts__tag {
    position: absolute;
    z-index: 1;
    inset-block-start: -0.625rem;
    inset-inline-end: 0.75rem;
    max-width: calc(100% - 1.5rem);
    padding: 0.125rem 0.625rem;
    background: var(--color-ink);
    border-radius: var(--radius-pill);
    color: var(--color-white);
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.4;
    visibility: hidden;
  }

  .bparts__part.is-on > .bparts__tag {
    visibility: visible;
  }

  /* the header: name, logo and tagline; the main menu beside it */
  .bparts__brand {
    display: flex;
    gap: 0.625rem;
    align-items: center;
    font-family: var(--font-heading);
    font-size: var(--step-1);
    font-weight: var(--weight-heading);
    line-height: 1.2;
  }

  .bparts__logo {
    display: grid;
    flex: none;
    place-items: center;
    width: 2rem;
    height: 2rem;
    background: var(--color-brand);
    border: var(--border);
    border-radius: 50%;
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 600;
  }

  .bparts__tagline {
    font-size: 0.75rem;
  }

  .bparts__menupart {
    align-content: center;
  }

  .bparts__part .bparts__menu {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    font-size: 0.75rem;
    font-weight: 500;
  }

  /* the location: its place, heading and the cities it serves */
  .bparts__place {
    display: flex;
    gap: 0.375rem;
    align-items: center;
    font-weight: 600;
  }

  .bparts__pin {
    flex: none;
  }

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

  .bparts__small {
    font-size: 0.75rem;
  }

  .bparts__label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    line-height: 1.6;
    text-transform: uppercase;
  }

  /* the team and the owner's story */
  .bparts__person,
  .bparts__faces {
    display: flex;
    gap: 0.5rem;
    align-items: center;
  }

  .bparts__face {
    display: grid;
    flex: none;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    background: var(--color-white);
    border: var(--border);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
  }

  .bparts__face--small {
    width: 1.5rem;
    height: 1.5rem;
    font-size: 0.625rem;
  }

  .bparts__faces .bparts__face--small + .bparts__face--small {
    margin-inline-start: -0.75rem;
  }

  .bparts__faces {
    font-size: 0.75rem;
  }

  .bparts__who {
    display: grid;
    line-height: 1.3;
  }

  .bparts__pname {
    font-weight: 600;
  }

  /* the story and the review in the body face: Trirong Thin at this size reads too faint */
  .bparts__story {
    line-height: 1.4;
  }

  /* hours, phone and booking */
  .bparts__cta {
    padding-block-start: 0.25rem;
  }

  .bparts__btn {
    display: inline-block;
    padding: 0.625rem var(--space-2);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: var(--tracking-caps);
    line-height: 1.3;
    text-transform: uppercase;
  }

  /* the services, named and described the same everywhere */
  .bparts__part .bparts__services {
    display: grid;
    gap: 0.5rem 1rem;
  }

  @container (min-width: 30rem) {
    .bparts__part .bparts__services {
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }
  }

  .bparts__services li {
    display: grid;
    gap: 0.125rem;
  }

  .bparts__sname {
    font-weight: 600;
  }

  /* the local review */
  .bparts__stars {
    display: flex;
  }

  .bparts__quote {
    line-height: 1.4;
  }

  /* the footer: legal and policy links */
  .bparts__foot {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem var(--space-3);
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
  }

  .bparts__part .bparts__legal {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    font-weight: 500;
  }

  /* the legend under the frame */
  .bparts__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem var(--space-3);
    margin: 0.875rem 0 0;
    padding: 0;
    font-size: 0.8125rem;
    font-weight: 500;
    list-style: none;
  }

  .bparts__legend li {
    display: flex;
    gap: 0.5rem;
    align-items: center;
  }

  .bparts__swatch {
    flex: none;
    width: 0.875rem;
    height: 0.875rem;
    border: var(--border);
    border-radius: calc(var(--radius-sm) / 4);
  }

  .bparts__swatch--brand {
    background: var(--bparts-brand);
  }

  .bparts__swatch--location {
    background: var(--bparts-location);
  }

  /* ---------- the lists ---------- */
  .bparts__hint {
    margin: 0 0 var(--space-3);
  }

  .bparts__lists {
    display: grid;
    gap: var(--space-4);
  }

  @media (min-width: 40rem) and (max-width: 63.99rem) {
    .bparts__lists {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  .bparts__listtitle {
    display: flex;
    gap: 0.625rem;
    align-items: center;
    margin: 0 0 0.75rem;
    font-size: var(--step-2);
  }

  .bparts__listtitle .bparts__swatch {
    width: 1rem;
    height: 1rem;
  }

  .bparts__lines {
    margin: 0;
    padding: 0;
    border-block-start: 1px solid var(--color-ink-line-faint);
    list-style: none;
  }

  .bparts__line {
    border-block-end: 1px solid var(--color-ink-line-faint);
  }

  /* a line: plain text without the script, a button with it (the same box) */
  .bparts__row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    box-sizing: border-box;
    width: 100%;
    min-height: 2.75rem;
    margin: 0;
    padding: 0.6875rem 0.75rem;
    background: transparent;
    border: 0;
    border-radius: 0;
    color: var(--color-ink);
    font: inherit;
    line-height: 1.5;
    text-align: start;
  }

  button.bparts__row {
    cursor: pointer;
  }

  .bparts__mark {
    flex: none;
    width: 0.75rem;
    height: 0.75rem;
    margin-block-start: 0.375em;
    border: var(--border);
    border-radius: calc(var(--radius-sm) / 4);
  }

  .bparts__list--brand .bparts__mark {
    background: var(--bparts-brand);
  }

  .bparts__list--location .bparts__mark {
    background: var(--bparts-location);
  }

  .bparts__list--brand .bparts__row.is-on {
    background: var(--bparts-brand);
  }

  .bparts__list--location .bparts__row.is-on {
    background: var(--bparts-location);
  }

  /* pressed: an ink bar on its leading edge, so the press reads without color */
  .bparts__row[aria-pressed="true"] {
    box-shadow: inset 3px 0 0 var(--color-ink);
  }

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

  .bparts__outro {
    margin: var(--space-4) 0 0;
    font-weight: 500;
  }

  /* Above a full-width photo band the photo does the separating (no divider
     there, site.css), so a full section pad under the line reads as a gap:
     half of it here (48px wide, 32px on phones) */
  .section.block-brandparts:is(:has(+ .section--flush), :has(+ :not(.section) + .section--flush)) {
    padding-block-end: calc(var(--section-pad-bottom) / 2);
  }

  @media print {
    .bparts__tag {
      display: none;
    }

    .bparts.has-mark .bparts__part--brand:not(.is-on) {
      background: var(--bparts-brand);
    }

    .bparts.has-mark .bparts__part--location:not(.is-on) {
      background: var(--bparts-location);
    }

    .bparts__part.is-on {
      outline: 0;
    }
  }
}

@layer motion {
  @media screen and (prefers-reduced-motion: no-preference) {
    .bparts.is-live :is(.bparts__part, .bparts__row) {
      transition: background-color 200ms var(--ease);
    }
  }
}
