/* What a machine reads (site/snippets/blocks/schemaswitch.php, the
   Technical SEO and schema page; public/assets/js/schemaswitch.js). One
   sample demo in a white frame: the two-way switch (the twometros pill
   track), a sample location page in a browser frame ("Sample" in its
   address bar) and an ink card "What a machine reads" for each state; under
   the demo, the same comparison as a real table (the compare block's look:
   the written column in mint, a card a row on phones). Linked by the block
   itself (peanut_page_css), once per page. Every selector names a
   schemaswitch class. Tokens only.

   Finished by default (no script, print): the switch hidden, both cards one
   under the other, no part lit. The script adds .is-live (the cards share
   one cell, the taller sets the height, the other is data-off) and
   data-mode on the frame: each part of the sample page whose data-reads
   names that mode lights in mint with an ink edge. The part boxes keep
   their border and padding in every state (transparent when unlit), so
   lighting one never moves anything. */

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

  .schemaswitch__title {
    margin: 0;
  }

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

  /* ---------- the frame ---------- */
  .schemaswitch__demo {
    padding: var(--space-3);
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-sm);
    color: var(--color-ink);
  }

  .schemaswitch__controls {
    display: grid;
    gap: var(--space-2);
    max-width: 32rem;
    margin-block-end: var(--space-3);
  }

  .schemaswitch__controls:has(.schemaswitch__switch[hidden]) {
    margin-block-end: 0;
  }

  /* ---------- the switch: two buttons on one pill track, a thumb behind the pressed one ---------- */
  .schemaswitch__switch {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0.25rem;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-pill);
  }

  .schemaswitch__switch[hidden] {
    display: none;
  }

  .schemaswitch__switch::before {
    content: "";
    position: absolute;
    inset-block: 0.25rem;
    inset-inline-start: 0.25rem;
    width: calc(50% - 0.25rem);
    background: var(--color-brand);
    border: var(--border);
    border-radius: var(--radius-pill);
  }

  .schemaswitch__switch[data-at="1"]::before {
    transform: translateX(100%);
  }

  .schemaswitch__pick {
    position: relative;
    min-height: 2.75rem;
    margin: 0;
    padding: 0.375rem 0.75rem;
    background: none;
    border: 0;
    border-radius: var(--radius-pill);
    color: var(--color-ink);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    text-align: center;
    cursor: pointer;
  }

  .schemaswitch__pick[aria-pressed="true"] {
    font-weight: 600;
  }

  .schemaswitch__pick[aria-pressed="false"]:hover {
    text-decoration: underline;
    text-underline-offset: 0.2em;
  }

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

  /* ---------- the stage: the page, then the card (side by side from 64rem) ---------- */
  .schemaswitch__stage {
    display: grid;
    gap: var(--space-3);
    align-items: start;
  }

  @media (min-width: 64rem) {
    .schemaswitch__demo {
      padding: var(--space-4);
    }

    .schemaswitch__stage {
      grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
      gap: var(--space-4);
    }
  }

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

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

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

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

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

  .schemaswitch__pagebody {
    display: grid;
    gap: 0.375rem;
    padding: var(--space-2);
  }

  /* every part keeps its box in every state: only its colors change */
  .schemaswitch__part {
    margin: 0;
    padding: 0.375rem 0.5rem;
    border: 1px dashed transparent;
    border-radius: 0.5rem;
  }

  .schemaswitch__demo[data-mode="auto"] .schemaswitch__part[data-reads~="auto"],
  .schemaswitch__demo[data-mode="written"] .schemaswitch__part[data-reads~="written"] {
    background: var(--color-brand);
    border-color: var(--color-ink);
    border-style: solid;
  }

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

  .schemaswitch__brand {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    font-weight: 600;
  }

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

  .schemaswitch__parent {
    font-size: 0.75rem;
    font-weight: 500;
  }

  .schemaswitch__heading {
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--step-2);
    font-weight: var(--weight-heading);
    line-height: var(--leading-heading);
  }

  .schemaswitch__opening {
    margin: 0.25rem 0 0;
  }

  .schemaswitch__where {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    font-weight: 500;
  }

  .schemaswitch__services {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    list-style: none;
  }

  .schemaswitch__services li {
    padding: 0.125rem 0.625rem;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 500;
  }

  .schemaswitch__team {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem var(--space-3);
    list-style: none;
  }

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

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

  .schemaswitch__who {
    display: grid;
  }

  .schemaswitch__pname {
    font-weight: 600;
  }

  .schemaswitch__role {
    font-size: 0.75rem;
  }

  .schemaswitch__q {
    margin: 0;
    font-weight: 600;
  }

  .schemaswitch__a {
    margin: 0 0 0.25rem;
  }

  .schemaswitch__a:last-child {
    margin-block-end: 0;
  }

  .schemaswitch__cta {
    margin: 0.25rem 0 0;
    padding-inline: 0.5rem;
  }

  .schemaswitch__btn {
    display: inline-block;
    padding: 0.375rem 0.875rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
  }

  /* ---------- the card: what a machine reads ---------- */
  .schemaswitch__reads {
    display: grid;
    gap: var(--space-3);
  }

  .schemaswitch__demo.is-live .schemaswitch__card {
    grid-area: 1 / 1;
  }

  .schemaswitch__demo.is-live .schemaswitch__card[data-off] {
    visibility: hidden;
  }

  .schemaswitch__card {
    padding: var(--space-3);
    background: var(--color-ink);
    border: var(--border);
    border-radius: var(--radius-sm);
    color: var(--color-white);
  }

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

  .schemaswitch__state {
    margin: 0.25rem 0 var(--space-2);
    font-family: var(--font-heading);
    font-size: var(--step-1);
    font-weight: var(--weight-heading);
    line-height: var(--leading-heading);
  }

  .schemaswitch__facts {
    display: grid;
    margin: 0;
  }

  .schemaswitch__fact {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    gap: var(--space-2);
    align-items: baseline;
    padding-block: 0.5rem;
    border-block-start: 1px solid var(--color-on-ink-line);
    font-size: 0.875rem;
    line-height: 1.4;
  }

  .schemaswitch__label {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    color: var(--color-on-ink-label);
    font-weight: 600;
  }

  /* a dot: mint where the state reads the fact, an empty ring where it does not */
  .schemaswitch__label::before {
    content: "";
    flex: none;
    width: 0.5rem;
    height: 0.5rem;
    background: var(--color-brand);
    border: 1px solid var(--color-brand);
    border-radius: 50%;
  }

  .schemaswitch__fact--none .schemaswitch__label::before {
    background: none;
    border-color: var(--color-on-ink-label);
  }

  .schemaswitch__value {
    min-width: 0;
    margin: 0;
    overflow-wrap: break-word;
  }

  .schemaswitch__fact--none .schemaswitch__value {
    justify-self: start;
    padding: 0 0.5rem;
    border: 1px dashed var(--color-on-ink-line-strong);
    border-radius: var(--radius-pill);
    color: var(--color-on-ink-label);
    font-size: 0.8125rem;
  }

  .schemaswitch__note {
    margin: var(--space-2) 0 0;
    padding-block-start: var(--space-2);
    border-block-start: 1px solid var(--color-on-ink-line);
    font-size: 0.8125rem;
    line-height: 1.5;
  }

  /* ---------- the same comparison as a table ---------- */
  .schemaswitch__compare {
    margin-block-start: var(--space-5);
  }

  .schemaswitch__tabletitle {
    margin: 0 0 var(--space-3);
    font-size: var(--step-2);
  }

  .schemaswitch__table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
  }

  .schemaswitch__col {
    padding: var(--space-2) var(--space-3);
    font-weight: 600;
    text-align: start;
    vertical-align: bottom;
  }

  .schemaswitch__col--what {
    width: 24%;
    padding-inline-start: 0;
  }

  .schemaswitch__col--written {
    background: var(--color-brand);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    color: var(--color-ink);
  }

  .schemaswitch__what {
    padding: var(--space-2) var(--space-3) var(--space-2) 0;
    border-block-start: var(--border);
    font-weight: 500;
    text-align: start;
    vertical-align: top;
  }

  .schemaswitch__cell {
    padding: var(--space-2) var(--space-3);
    border-block-start: var(--border);
    vertical-align: top;
  }

  .schemaswitch__cell--written {
    background: var(--color-brand);
    color: var(--color-ink);
  }

  .schemaswitch__row:last-child .schemaswitch__cell--written {
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  }

  .schemaswitch__celllabel {
    display: none;
  }

  .section--ink .schemaswitch__compare {
    --border: 1px solid var(--color-on-ink-line);
  }

  .schemaswitch__outro {
    max-width: var(--measure);
    margin: var(--space-3) 0 0;
  }

  .schemaswitch__outro > :last-child {
    margin-block-end: 0;
  }

  /* phones: the switch's words a little smaller; the table a card a row */
  @media (max-width: 47.99rem) {
    .schemaswitch__pick {
      padding-inline: 0.5rem;
      font-size: 0.8125rem;
    }

    .schemaswitch__demo {
      padding: var(--space-2);
    }

    .schemaswitch__fact {
      grid-template-columns: minmax(0, 1fr);
      gap: 0.125rem;
    }

    .schemaswitch__thead {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip-path: inset(50%);
    }

    .schemaswitch__table,
    .schemaswitch__table tbody,
    .schemaswitch__row,
    .schemaswitch__what,
    .schemaswitch__cell {
      display: block;
    }

    .schemaswitch__row {
      padding-block: var(--space-3);
      border-block-start: var(--border);
    }

    .schemaswitch__what {
      padding: 0 0 var(--space-1);
      border: 0;
      font-weight: 600;
    }

    .schemaswitch__cell {
      padding: 0.625rem var(--space-2);
      border: 0;
      border-radius: var(--radius-sm);
    }

    .schemaswitch__cell + .schemaswitch__cell {
      margin-block-start: 0.25rem;
    }

    .schemaswitch__row:last-child .schemaswitch__cell--written {
      border-radius: var(--radius-sm);
    }

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

  /* ---------- print: both states ---------- */
  @media print {
    .schemaswitch__switch,
    .schemaswitch__progress {
      display: none;
    }

    .schemaswitch__demo.is-live .schemaswitch__reads {
      display: block;
    }

    /* as specific as the live rule that hides it, and later, so it wins */
    .schemaswitch__demo.is-live .schemaswitch__card[data-off] {
      visibility: visible;
    }

    .schemaswitch__card + .schemaswitch__card {
      margin-block-start: var(--space-3);
    }

    /* both cards print, so no part of the page is lit for one of them */
    .schemaswitch__demo[data-mode="auto"] .schemaswitch__part[data-reads~="auto"],
    .schemaswitch__demo[data-mode="written"] .schemaswitch__part[data-reads~="written"] {
      background: none;
      border-color: transparent;
    }

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

@layer motion {
  @media screen and (prefers-reduced-motion: no-preference) {
    html[data-fx~="diagrams"] .schemaswitch__switch::before {
      transition: transform 300ms var(--ease);
    }

    html[data-fx~="diagrams"] .schemaswitch__part {
      transition: background-color 400ms var(--ease), border-color 400ms var(--ease);
    }

    html[data-fx~="diagrams"] .schemaswitch__demo.is-live .schemaswitch__card:not([data-off]) {
      animation: schemaswitch-in 400ms var(--ease) both;
    }
  }

  @keyframes schemaswitch-in {
    from {
      opacity: 0;
    }

    to {
      opacity: 1;
    }
  }
}
