/* Fix the business profile (site/snippets/blocks/profilefix.php, the Local
   SEO page's demo; public/assets/js/profilefix.js). A sample business
   profile card drawn as our own neutral card (the site's palette, no search
   engine's look), its problems marked with small numbered markers, beside
   the list of problems. Linked by the block itself (peanut_page_css), once
   per page. Every selector names a profilefix class. Tokens only. The shared
   hint, progress bar and sample controls are industry.css's.

   Finished by default (no script, reduced motion, print): the card before
   and the card after (old values struck through, new ones in mint) side by
   side from 48rem, and the list in words under them. The script adds
   .is-live (screen only): one card, the list as buttons, every row's old
   and new value in one grid cell (.is-fixed shows the new one), the lines
   on why each fix matters in one cell, so nothing moves. */

@layer blocks {
  .profilefix__head {
    max-width: 44rem;
    margin-block-end: var(--space-5);
  }

  .profilefix__title {
    margin: 0;
  }

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

  /* ---------- the stage ---------- */
  .profilefix__demo {
    display: grid;
    gap: var(--space-4);
    max-width: 68rem;
  }

  .profilefix__cards {
    display: grid;
    gap: var(--space-3);
    align-items: start;
    min-width: 0;
  }

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

    /* Before and after side by side (no script, reduced motion): the two
       cards share their rows, so each detail sits level with its fix and the
       cards end level (bulk fixes A2, 2026-11-29). A card's six parts over
       the details, then the five details (the rows list shares them too). */
    .profilefix__demo:not(.is-live) .profilefix__cards:has(> .profilefix__card:nth-child(2)) {
      grid-template-rows: repeat(11, auto);
      row-gap: 0;
      align-items: stretch;
    }

    .profilefix__demo:not(.is-live) .profilefix__cards:has(> .profilefix__card:nth-child(2)) > .profilefix__card {
      container-type: normal; /* a contained grid cannot be a subgrid */
      display: grid;
      grid-row: span 11;
      grid-template-rows: subgrid;
      align-content: start;
    }

    .profilefix__demo:not(.is-live) .profilefix__cards:has(> .profilefix__card:nth-child(2)) .profilefix__rows {
      display: grid;
      grid-row: span 5;
      grid-template-rows: subgrid;
    }

    .profilefix__demo:not(.is-live) .profilefix__cards:has(> .profilefix__card:nth-child(2)) .profilefix__row {
      align-content: start;
    }
  }

  .profilefix__side {
    min-width: 0;
  }

  /* ---------- the card ---------- */
  .profilefix__card {
    container-type: inline-size;
    width: 100%;
    max-width: 28rem;
    overflow: hidden;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-sm);
    color: var(--color-ink);
    font-size: 0.875rem;
    line-height: 1.45;
  }

  .profilefix__top {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem var(--space-2);
    border-block-end: var(--border);
  }

  :is(.profilefix__sample, .profilefix__state) {
    flex: none;
    padding: 0.0625rem 0.5rem;
    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;
  }

  .profilefix__sample {
    background: var(--color-butter);
  }

  .profilefix__state {
    background: var(--color-white);
  }

  .profilefix__card--after .profilefix__state {
    background: var(--color-brand);
  }

  /* a small drawn map strip at the top of the card (decoration) */
  .profilefix__map {
    height: 4.5rem;
    background: var(--color-paper);
    border-block-end: var(--border);
  }

  .profilefix__map svg {
    display: block;
    width: 100%;
    height: 100%;
  }

  .profilefix__road {
    fill: none;
    stroke: var(--color-ink);
    stroke-width: 6;
    stroke-linecap: round;
    opacity: 0.12;
  }

  .profilefix__road--thin {
    stroke-width: 3;
  }

  .profilefix__block {
    fill: var(--color-butter);
    stroke: var(--color-ink);
    stroke-width: 1;
    opacity: 0.7;
  }

  .profilefix__pin {
    fill: var(--color-brand);
    stroke: var(--color-ink);
    stroke-width: 1.5;
  }

  .profilefix__pindot {
    fill: var(--color-ink);
  }

  .profilefix__id {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: var(--space-2) var(--space-2) 0;
  }

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

  .profilefix__name {
    min-width: 0;
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--step-2);
    font-weight: var(--weight-heading);
    line-height: 1.15;
  }

  .profilefix__rating {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    align-items: center;
    margin: 0.5rem 0 0;
    padding-inline: var(--space-2);
    font-weight: 500;
  }

  .profilefix__stars {
    display: inline-flex;
    gap: 0.125rem;
  }

  .profilefix__star {
    fill: var(--color-ink);
  }

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

  .profilefix__chip {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.4;
  }

  .profilefix__contact {
    display: grid;
    gap: 0.125rem;
    margin: 0.75rem 0 0;
    padding: 0 var(--space-2) var(--space-2);
  }

  /* the rows that can be wrong */
  .profilefix__rows {
    margin: 0;
  }

  .profilefix__row {
    display: grid;
    gap: 0.25rem;
    padding: 0.625rem var(--space-2);
    border-block-start: 1px solid var(--color-ink-line-faint);
  }

  .profilefix__rowlabel {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    line-height: 1.6;
    text-transform: uppercase;
  }

  .profilefix__keep {
    margin: 0;
    font-style: normal;
  }

  .profilefix__vals {
    display: grid;
    gap: 0.25rem;
    justify-items: start;
    margin: 0;
  }

  .profilefix__old,
  .profilefix__new {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: break-word;
  }

  .profilefix__new {
    padding: 0.125rem 0.375rem;
    margin-inline-start: -0.375rem;
    background: var(--color-brand);
    border-radius: 0.25rem;
    color: var(--color-ink);
    font-weight: 500;
    text-decoration: none;
  }

  /* the card the script drives shows only its old values until then */
  .profilefix__card--live .profilefix__new {
    display: none;
  }

  /* the card after: the old value struck through over the new one */
  .profilefix__card--after .profilefix__old {
    font-size: 0.8125rem;
    text-decoration: line-through;
    text-decoration-thickness: 1px;
  }

  /* ---------- the marker: a number on coral, a tick on mint once fixed ---------- */
  .profilefix__mark {
    display: inline-grid;
    flex: none;
    place-items: center;
    width: 1.375rem;
    height: 1.375rem;
    background: var(--color-accent-2);
    border: var(--border);
    border-radius: 50%;
    color: var(--color-ink);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1;
  }

  .profilefix__mark > * {
    grid-area: 1 / 1;
  }

  .profilefix__tick {
    visibility: hidden;
  }

  .profilefix__card--after .profilefix__mark,
  .profilefix__row.is-fixed .profilefix__mark,
  .profilefix__btn[aria-pressed="true"] .profilefix__mark {
    background: var(--color-brand);
  }

  .profilefix__card--after .profilefix__marknum,
  .profilefix__row.is-fixed .profilefix__marknum,
  .profilefix__btn[aria-pressed="true"] .profilefix__marknum {
    visibility: hidden;
  }

  .profilefix__card--after .profilefix__tick,
  .profilefix__row.is-fixed .profilefix__tick,
  .profilefix__btn[aria-pressed="true"] .profilefix__tick {
    visibility: visible;
  }

  /* ---------- the list in words (no script, less motion, print) ---------- */
  .profilefix__listtitle {
    margin: 0 0 var(--space-3);
    font-family: var(--font-heading);
    font-size: var(--step-2);
    font-weight: var(--weight-heading);
    line-height: var(--leading-heading);
  }

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

  @media (min-width: 48rem) {
    .profilefix__list {
      grid-template-columns: repeat(2, minmax(0, 1fr));
      column-gap: var(--space-4);
    }
  }

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

  .profilefix__item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.75rem;
    align-items: start;
  }

  .profilefix__item > .profilefix__mark {
    margin-block-start: 0.125rem;
  }

  .profilefix__label {
    margin: 0;
    font-weight: 600;
    line-height: 1.45;
  }

  .profilefix__fix,
  .profilefix__whyline {
    margin: 0.375rem 0 0;
    font-size: var(--step--1);
    line-height: 1.55;
  }

  .profilefix__fixword {
    font-weight: 600;
  }

  /* ---------- the list as buttons (the script) ---------- */
  .profilefix__pick[hidden] {
    display: none;
  }

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

  .profilefix__picks {
    display: grid;
    gap: var(--space-1);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .profilefix__btn {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    width: 100%;
    min-height: 2.75rem;
    margin: 0;
    padding: 0.5rem 0.75rem;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-sm);
    color: var(--color-ink);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.35;
    text-align: start;
    cursor: pointer;
  }

  .profilefix__btn:hover {
    background: var(--color-paper);
  }

  .profilefix__btn[aria-pressed="true"] {
    background: var(--color-brand);
    font-weight: 600;
  }

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

  .profilefix__btnname {
    min-width: 0;
  }

  /* why it matters: every line in one cell, so the box keeps its height */
  .profilefix__why {
    display: grid;
    color: var(--color-ink);
    padding: var(--space-2);
    background: var(--color-paper);
    border: var(--border);
    border-radius: var(--radius-sm);
  }

  .profilefix__whytext {
    display: flex;
    grid-area: 1 / 1;
    gap: 0.625rem;
    align-items: flex-start;
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.55;
  }

  .profilefix__whytext[data-off] {
    visibility: hidden;
  }

  /* the line is about a fix: its marker in mint, the number kept to match the list */
  .profilefix__whytext > .profilefix__mark {
    margin-block-start: 0.0625rem;
    background: var(--color-brand);
  }

  .profilefix__reset {
    margin: 0;
  }

  .profilefix__reset[data-off] {
    visibility: hidden;
  }

  .profilefix__note {
    max-width: var(--measure);
    margin: var(--space-5) 0 0;
  }

  /* ---------- live (screen only, so print keeps the finished state) ---------- */
  @media screen {
    .profilefix__demo.is-live {
      align-items: start;
    }

    .profilefix__demo.is-live .profilefix__state {
      display: none;
    }

    .profilefix__demo.is-live .profilefix__card--live .profilefix__vals > * {
      grid-area: 1 / 1;
    }

    .profilefix__demo.is-live .profilefix__card--live .profilefix__new {
      display: block;
      visibility: hidden;
    }

    .profilefix__demo.is-live .profilefix__row.is-fixed .profilefix__old {
      visibility: hidden;
    }

    .profilefix__demo.is-live .profilefix__row.is-fixed .profilefix__new {
      visibility: visible;
    }

    .profilefix__demo.is-live .profilefix__listtitle {
      margin-block-end: var(--space-2);
    }
  }

  @media screen and (min-width: 60rem) {
    .profilefix__demo.is-live {
      grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
      gap: var(--space-5);
    }

    .profilefix__demo.is-live .profilefix__side {
      padding-block-start: var(--space-2);
    }
  }

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

    .profilefix__cards {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .profilefix__card {
      break-inside: avoid;
    }
  }
}

/* print: the after card and the list the script hid come back. In the last
   layer, beside [hidden] (site.css, utilities), so it wins */
@layer utilities {
  @media print {
    .profilefix__card--after[hidden] {
      display: block;
    }

    .profilefix__list[hidden] {
      display: grid;
    }
  }
}

@layer motion {
  @media screen and (prefers-reduced-motion: no-preference) {
    html[data-fx~="diagrams"] .profilefix__mark,
    html[data-fx~="diagrams"] .profilefix__btn {
      transition: background-color 300ms var(--ease-out);
    }

    /* a row just fixed: its new value settles in, the marker pops once */
    html[data-fx~="diagrams"] .profilefix__row.is-just .profilefix__new {
      animation: profilefix-in 450ms var(--ease-out) both;
    }

    html[data-fx~="diagrams"] .profilefix__row.is-just .profilefix__mark {
      animation: profilefix-pop 450ms var(--ease-out) both;
    }

    html[data-fx~="diagrams"] .profilefix__whytext:not([data-off]) {
      animation: profilefix-fade 350ms var(--ease-out) both;
    }
  }

  @keyframes profilefix-in {
    from {
      opacity: 0;
      transform: translateY(0.25rem);
    }

    to {
      opacity: 1;
      transform: none;
    }
  }

  @keyframes profilefix-pop {
    0% {
      transform: scale(1);
    }

    50% {
      transform: scale(1.2);
    }

    100% {
      transform: scale(1);
    }
  }

  @keyframes profilefix-fade {
    from {
      opacity: 0;
    }

    to {
      opacity: 1;
    }
  }
}
