/* Inside a metro hub (site/snippets/blocks/hubmap.php, the Regional tier
   page; public/assets/js/hubmap.js). A drawn sample hub page in a browser
   frame, its parts numbered, beside the numbered list; then the strip of
   what sits around the hubs. Linked by the block itself (peanut_page_css),
   once per page. Every selector names a hubmap class. Tokens only.

   Finished by default (no script, reduced motion, print): the plain list
   and every drawn part, none lit. The script swaps the list for the number
   buttons and the reading box (.is-live) and lights one part (.is-lit):
   colors only, so nothing moves or changes size. The hint, the progress
   bar and the sample controls are the shared ones (industry.css). */

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

  .hubmap__title {
    margin: 0;
  }

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

  /* ---------- the demo: the drawing, then the list; side by side from 64rem ---------- */
  .hubmap__demo {
    display: grid;
    grid-template-areas: "frame" "side";
    gap: var(--space-4);
    align-items: start;
  }

  .hubmap__side {
    grid-area: side;
    display: grid;
    gap: var(--space-2);
    min-width: 0;
  }

  .hubmap__frame {
    grid-area: frame;
    min-width: 0;
  }

  @media (min-width: 64rem) {
    .hubmap__demo {
      grid-template-areas: "side frame";
      grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
      gap: var(--space-5);
    }
  }

  /* the number a list part and its drawn part share */
  .hubmap__num {
    display: inline-grid;
    flex: none;
    place-items: center;
    width: 1.5rem;
    height: 1.5rem;
    border: 1px solid var(--color-ink);
    border-radius: 50%;
    background: var(--color-white);
    color: var(--color-ink);
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
  }

  /* ---------- no script: the plain numbered list ---------- */
  .hubmap__list,
  .hubmap__picks {
    display: grid;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .hubmap__list {
    gap: var(--space-2);
  }

  .hubmap__list[hidden],
  .hubmap__pick[hidden] {
    display: none;
  }

  .hubmap__item {
    display: flex;
    gap: 0.75rem;
    align-items: start;
  }

  .hubmap__itemtext {
    display: grid;
    gap: 0.25rem;
    min-width: 0;
  }

  .hubmap__label,
  .hubmap__readlabel {
    margin: 0;
    font-weight: 600;
    line-height: 1.4;
  }

  .hubmap__item .hubmap__label {
    padding-block-start: 0.0625rem;
  }

  .hubmap__text {
    margin: 0;
    font-size: var(--text-body);
    line-height: var(--leading-body);
  }

  .hubmap__note {
    margin: 0;
    padding-inline-start: 0.75rem;
    border-inline-start: 1px solid var(--color-ink);
    font-size: 0.875rem;
    line-height: 1.6;
  }

  /* ---------- with the script: the number buttons and the reading box ---------- */
  .hubmap__pick {
    display: grid;
    gap: var(--space-2);
  }

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

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

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

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

  /* every text in one cell: the tallest sets the height, so a press never moves the page */
  .hubmap__read {
    display: grid;
    padding: var(--space-3);
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-sm);
  }

  .hubmap__panel {
    grid-area: 1 / 1;
    display: grid;
    align-content: start;
    gap: 0.5rem;
    min-width: 0;
  }

  .hubmap__panel:not(.is-shown) {
    visibility: hidden;
  }

  .hubmap__readlabel {
    display: flex;
    gap: 0.625rem;
    align-items: center;
  }

  .hubmap__readlabel .hubmap__num {
    background: var(--color-brand);
  }

  /* ---------- the drawing: a sample hub page in a browser frame ---------- */
  .hubmap__frame {
    overflow: hidden;
    background: var(--color-white);
    border: var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-hard);
    color: var(--color-ink);
    font-size: 0.8125rem;
    line-height: 1.45;
  }

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

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

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

  /* the drawing's one Sample label */
  .hubmap__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;
  }

  .hubmap__site {
    container-type: inline-size;
  }

  .hubmap__top {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.625rem var(--space-2);
    border-block-end: 1px solid var(--color-ink-line-faint);
  }

  .hubmap__logo {
    display: inline-grid;
    flex: none;
    place-items: center;
    width: 1.5rem;
    height: 1.5rem;
    background: var(--color-accent-2);
    border: 1px solid var(--color-ink);
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-size: 0.875rem;
    font-weight: var(--weight-heading);
    line-height: 1;
  }

  .hubmap__brand {
    font-weight: 600;
  }

  .hubmap__menu {
    margin-inline-start: auto;
    font-size: 0.75rem;
    font-weight: 500;
  }

  .hubmap__page {
    display: grid;
    gap: 1rem 0.75rem;
    padding: 1.25rem var(--space-2) var(--space-2);
  }

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

    .hubmap__part--1,
    .hubmap__part--6,
    .hubmap__part--7 {
      grid-column: 1 / -1;
    }
  }

  /* each part, its number on its top-left corner */
  .hubmap__part {
    position: relative;
    display: grid;
    align-content: start;
    gap: 0.375rem;
    min-width: 0;
    padding: 1rem 0.75rem 0.75rem;
    background: var(--color-white);
    border: 1px solid var(--color-ink-line-faint);
    border-radius: var(--radius-sm);
  }

  .hubmap__part > .hubmap__num {
    position: absolute;
    top: -0.75rem;
    left: 0.5rem;
  }

  .hubmap__part.is-lit {
    background: var(--color-mint-pale);
    border-color: var(--color-ink);
  }

  .hubmap__part.is-lit > .hubmap__num {
    background: var(--color-ink);
    color: var(--color-white);
  }

  .hubmap__part p,
  .hubmap__part ul {
    margin: 0;
  }

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

  .hubmap__crumb,
  .hubmap__cap {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
  }

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

  .hubmap__cities {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem 1rem;
  }

  .hubmap__city {
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 0.2em;
  }

  .hubmap__team {
    display: grid;
    gap: 0.375rem;
  }

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

  .hubmap__face {
    display: inline-grid;
    flex: none;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    background: var(--color-butter);
    border: 1px solid var(--color-ink);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
  }

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

  .hubmap__name {
    font-weight: 600;
  }

  .hubmap__role {
    font-size: 0.75rem;
  }

  .hubmap__stars {
    display: flex;
    gap: 0.125rem;
  }

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

  .hubmap__quote {
    font-weight: 500;
    line-height: 1.45;
  }

  .hubmap__cite {
    font-size: 0.75rem;
  }

  .hubmap__qs {
    display: grid;
  }

  .hubmap__qs li {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    padding-block: 0.375rem;
    border-block-end: 1px solid var(--color-ink-line-faint);
  }

  .hubmap__qs li:last-child {
    border-block-end: 0;
    padding-block-end: 0;
  }

  /* a drawn plus mark */
  .hubmap__plus {
    position: relative;
    flex: none;
    width: 0.625rem;
    height: 0.625rem;
  }

  .hubmap__plus::before,
  .hubmap__plus::after {
    content: "";
    position: absolute;
    background: var(--color-ink);
  }

  .hubmap__plus::before {
    inset: 50% 0 auto;
    height: 1px;
  }

  .hubmap__plus::after {
    inset: 0 auto 0 50%;
    width: 1px;
  }

  .hubmap__book {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: center;
  }

  /* a drawn button (the shared sample-btn look: an ink line, no fill) */
  .hubmap__btn {
    padding: 0.4375rem 0.875rem;
    border-radius: 2px;
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
  }

  .hubmap__phone {
    font-weight: 600;
  }

  .hubmap__data {
    display: grid;
    gap: 0.0625rem;
  }

  @container (min-width: 30rem) {
    .hubmap__data {
      grid-template-columns: 7.5rem minmax(0, 1fr);
      gap: 0.75rem;
    }
  }

  .hubmap__key {
    font-size: 0.75rem;
    font-weight: 600;
  }

  .hubmap__data--alt {
    padding-block-start: 0.375rem;
    border-block-start: 1px dashed var(--color-ink-line-faint);
  }

  /* ---------- the strip under the map ---------- */
  .hubmap__strip {
    display: grid;
    gap: var(--space-3);
    margin-block-start: var(--space-6);
  }

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

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

  @media (min-width: 48rem) {
    .hubmap__stripitems {
      grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
      gap: var(--space-4);
    }
  }

  .hubmap__stripitem {
    display: grid;
    align-content: start;
    gap: var(--space-1);
    padding-block-start: var(--space-2);
    border-block-start: 1px solid var(--color-ink);
  }

  .hubmap__stripname {
    margin: 0;
    font-family: var(--font-body);
    font-size: var(--step-0);
    font-weight: 600;
    line-height: 1.4;
  }

  .hubmap__striptext {
    margin: 0;
  }

  /* print: the plain list and every drawn part, none lit */
  @media print {
    .hubmap__pick {
      display: none;
    }

    .hubmap__frame {
      box-shadow: none;
    }

    .hubmap__part.is-lit {
      background: var(--color-white);
      border-color: var(--color-ink-line-faint);
    }

    .hubmap__part.is-lit > .hubmap__num {
      background: var(--color-white);
      color: var(--color-ink);
    }
  }
}

/* print: the list the script hid comes back. In the last layer, beside the
   site's [hidden] rule (site.css), which it outranks by one class */
@layer utilities {
  @media print {
    .hubmap__list[hidden] {
      display: grid;
    }
  }
}

@layer motion {
  @media screen and (prefers-reduced-motion: no-preference) {
    /* a lit part fades its fill in */
    .hubmap__part,
    .hubmap__part > .hubmap__num {
      transition: background-color 250ms var(--ease), border-color 250ms var(--ease), color 250ms var(--ease);
    }
  }
}
