/* Copied or written metro pages (site/snippets/blocks/metroswitch.php, the
   Multi-location SEO page's demo; public/assets/js/metroswitch.js). One
   white frame with a "Sample" label: the mode switch and the metros on the
   side, the sample search and the page it gets beside them. Linked by the
   block itself (peanut_page_css), once per page. Every selector names a
   metroswitch class. Tokens only. The switch is twometros' (one pill track,
   a mint thumb behind the pressed side); the shared hint, progress bar and
   sample controls are industry.css's.

   Finished by default (no script, reduced motion, print): no controls, both
   modes one under the other, each under its h3, every metro's panel (one
   column, every metro side by side from 64rem). The script adds .is-live
   (screen only): every panel in one grid cell (the tallest sets the
   height), the others data-off. Copied parts carry a coral mark and edge,
   written parts a mint one. */

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

  .metroswitch__title {
    margin: 0;
  }

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

  /* ---------- the frame ---------- */
  .metroswitch__demo {
    max-width: 68rem;
    padding: var(--space-3);
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-sm);
    color: var(--color-ink);
  }

  .metroswitch__top {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    align-items: center;
    margin-block-end: var(--space-3);
  }

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

  .metroswitch__brandname {
    font-size: 0.875rem;
    font-weight: 600;
  }

  .metroswitch__stage {
    display: grid;
    gap: var(--space-4);
    align-items: start;
  }

  /* ---------- the controls (shown by the script) ---------- */
  .metroswitch__side[hidden] {
    display: none;
  }

  .metroswitch__side {
    display: grid;
    gap: var(--space-2);
    align-content: start;
    min-width: 0;
  }

  .metroswitch__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-lg);
  }

  .metroswitch__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-lg);
  }

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

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

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

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

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

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

  .metroswitch__metros {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .metroswitch__metro {
    display: inline-flex;
    gap: 0.5rem;
    align-items: center;
    min-height: 2.75rem;
    margin: 0;
    padding: 0.5rem 0.875rem;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-pill);
    color: var(--color-ink);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    text-align: start;
    cursor: pointer;
  }

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

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

  .metroswitch__metromark {
    flex: none;
    width: 0.75rem;
    height: 0.75rem;
    background: var(--color-gold-soft);
    border: 1.5px solid var(--color-ink);
    border-radius: 50%;
  }

  .metroswitch__firstnote {
    font-weight: 400;
  }

  /* ---------- the views: without the script, both modes stand ---------- */
  .metroswitch__views {
    min-width: 0;
  }

  .metroswitch__mode-set + .metroswitch__mode-set {
    margin-block-start: var(--space-4);
    padding-block-start: var(--space-4);
    border-block-start: var(--border);
  }

  .metroswitch__modetitle {
    display: flex;
    gap: 0.625rem;
    align-items: center;
    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);
  }

  .metroswitch__modemark {
    flex: none;
    width: 1rem;
    height: 1rem;
    border: var(--border);
    border-radius: 0.25rem;
  }

  .metroswitch__mode-set--copied .metroswitch__modemark {
    background: var(--color-accent-2);
  }

  .metroswitch__mode-set--written .metroswitch__modemark {
    background: var(--color-brand);
  }

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

  @media (min-width: 64rem) {
    .metroswitch__demo:not(.is-live) .metroswitch__panels {
      grid-auto-columns: minmax(0, 1fr);
      grid-auto-flow: column;
      gap: var(--space-3);
    }

    /* the two panels side by side share their rows (the search, the line under
       it, the drawn page, what a search engine sees), so the two pages and
       the two verdicts start and end level (bulk fixes A2, 2026-11-29) */
    .metroswitch__demo:not(.is-live) .metroswitch__panels:has(> .metroswitch__panel > .metroswitch__result) {
      grid-template-rows: repeat(5, auto);
      row-gap: 0.625rem;
    }

    .metroswitch__demo:not(.is-live) .metroswitch__panels:has(> .metroswitch__panel > .metroswitch__result) > .metroswitch__panel {
      grid-row: span 5;
      grid-template-rows: subgrid;
    }
  }

  /* ---------- one panel: the search, then the page it gets ---------- */
  .metroswitch__panel {
    display: grid;
    gap: 0.625rem;
    align-content: start;
    min-width: 0;
  }

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

  .metroswitch__search {
    margin: 0;
  }

  .metroswitch__box {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    max-width: 24rem;
    padding: 0.5rem 0.875rem;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.35;
  }

  .metroswitch__lens,
  .metroswitch__down {
    flex: none;
  }

  .metroswitch__gets {
    display: flex;
    gap: 0.375rem;
    align-items: center;
    margin: 0;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
  }

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

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

  .metroswitch__dots {
    flex: none;
    width: 0.375rem;
    height: 0.375rem;
    margin-inline-end: 1.375rem;
    background: var(--color-ink);
    border-radius: 50%;
    box-shadow: 0.625rem 0 0 var(--color-ink), 1.25rem 0 0 var(--color-ink);
    opacity: 0.35;
  }

  .metroswitch__url {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    padding: 0.0625rem 0.5rem;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-pill);
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .metroswitch__brandbar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-block-end: var(--border);
    font-family: var(--font-heading);
    font-size: var(--step-0);
    font-weight: var(--weight-heading);
  }

  .metroswitch__logo {
    display: grid;
    flex: none;
    place-items: center;
    width: 1.5rem;
    height: 1.5rem;
    background: var(--color-ink);
    border-radius: 50%;
    color: var(--color-white);
    font-family: var(--font-body);
    font-size: 0.6875rem;
    font-weight: 600;
  }

  .metroswitch__body {
    display: grid;
    gap: 0.625rem;
    padding: 0.75rem;
  }

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

    .metroswitch__part:first-child,
    .metroswitch__part:last-child {
      grid-column: 1 / -1;
    }
  }

  /* each part, edged in its mode's color, its mark on top */
  .metroswitch__part {
    display: grid;
    gap: 0.25rem;
    align-content: start;
    min-width: 0;
    padding: 0.5rem 0.625rem 0.625rem;
    border-inline-start: 4px solid var(--color-brand);
    border-radius: 0.25rem;
    background: var(--color-paper);
  }

  .metroswitch__panel--copied .metroswitch__part {
    border-inline-start-color: var(--color-accent-2);
  }

  .metroswitch__tag {
    justify-self: start;
    padding: 0 0.4375rem;
    border: var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    line-height: 1.7;
    text-transform: uppercase;
  }

  .metroswitch__tag--copied {
    background: var(--color-accent-2);
  }

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

  .metroswitch__heading {
    margin: 0.125rem 0 0;
    font-family: var(--font-heading);
    font-size: var(--step-2);
    font-weight: var(--weight-heading);
    line-height: 1.15;
  }

  .metroswitch__opening,
  .metroswitch__answer {
    margin: 0;
  }

  .metroswitch__label {
    margin: 0.125rem 0 0;
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    line-height: 1.6;
    text-transform: uppercase;
  }

  .metroswitch__cities {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .metroswitch__cities li {
    padding: 0.0625rem 0.5rem;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 500;
  }

  .metroswitch__team {
    display: grid;
    gap: 0.375rem;
    margin: 0;
    padding: 0;
    list-style: none;
  }

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

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

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

  .metroswitch__pname {
    font-weight: 500;
  }

  .metroswitch__role {
    font-size: 0.75rem;
  }

  .metroswitch__question {
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--step-1);
    font-weight: var(--weight-heading);
    line-height: 1.3;
  }

  /* what a search engine sees: coral for the copies, mint for written pages */
  .metroswitch__result {
    padding: 0.75rem var(--space-2);
    background: var(--color-brand);
    border: var(--border);
    border-radius: var(--radius-sm);
  }

  .metroswitch__panel--copied .metroswitch__result {
    background: var(--color-accent-2);
  }

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

  .metroswitch__resulttext {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.55;
  }

  .metroswitch__note {
    max-width: var(--measure);
    margin: var(--space-4) 0 0;
  }

  /* ---------- live (screen only, so print keeps both modes) ---------- */
  @media screen {
    .metroswitch__demo.is-live .metroswitch__views {
      display: grid;
    }

    .metroswitch__demo.is-live :is(.metroswitch__mode-set, .metroswitch__panels) {
      display: contents;
    }

    .metroswitch__demo.is-live :is(.metroswitch__modetitle, .metroswitch__kicker) {
      display: none;
    }

    .metroswitch__demo.is-live .metroswitch__panel {
      grid-area: 1 / 1;
    }

    .metroswitch__demo.is-live .metroswitch__panel[data-off] {
      visibility: hidden;
    }
  }

  /* after the reader's first tap (.is-free), narrow screens let the shown panel set the height */
  @media screen and (max-width: 63.99rem) {
    .metroswitch__demo.is-live.is-free .metroswitch__panel[data-off] {
      display: none;
    }
  }

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

    .metroswitch__demo.is-live .metroswitch__stage {
      grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
      gap: var(--space-5);
    }
  }

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

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

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

    html[data-fx~="diagrams"] .metroswitch__metro {
      transition: background-color 300ms var(--ease-out);
    }

    html[data-fx~="diagrams"] .metroswitch__demo.is-live .metroswitch__panel:not([data-off]) .metroswitch__part {
      animation: metroswitch-in 400ms var(--ease-out) both;
    }

    html[data-fx~="diagrams"] .metroswitch__demo.is-live .metroswitch__panel:not([data-off]) .metroswitch__part:nth-child(2) {
      animation-delay: 80ms;
    }

    html[data-fx~="diagrams"] .metroswitch__demo.is-live .metroswitch__panel:not([data-off]) .metroswitch__part:nth-child(3) {
      animation-delay: 160ms;
    }

    html[data-fx~="diagrams"] .metroswitch__demo.is-live .metroswitch__panel:not([data-off]) .metroswitch__part:nth-child(4) {
      animation-delay: 240ms;
    }
  }

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

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