/* Polish sketches (Nov 3). Everything is scoped under .pl and lives in the sketches layer, so the
   shipped components stay untouched. Each refinement is one class on a .pl-refined wrapper
   (pl-l1… for the list, pl-h1… for the project header, pl-s1… for the sections), so the
   switches can turn them on and off one by one. */

@layer sketches {
  /* Sketch chrome */

  .pl-intro {
    display: grid;
    gap: var(--space-md);
    padding-block: var(--space-xl) var(--space-lg);
  }

  .pl-intro__title {
    font-size: var(--text-title);
    font-weight: var(--weight-display);
    line-height: 1.05;
    letter-spacing: var(--tracking-display);
    color: var(--navy);
  }

  .pl-intro__lede {
    max-width: 80ch;
    color: var(--ink-body);
  }

  .pl-refinements {
    display: grid;
    gap: var(--space-sm);
    max-width: 90ch;
    counter-reset: none;
  }

  .pl-refinement {
    display: grid;
    grid-template-columns: auto 1.75rem minmax(0, 1fr);
    gap: var(--space-sm);
    align-items: baseline;
    font-size: var(--text-sm);
    line-height: 1.5;
    color: var(--ink-body);
    cursor: pointer;

    & input {
      align-self: start;
      margin-top: var(--space-xs);
      width: 1rem;
      height: 1rem;
      accent-color: var(--navy);
    }

    & strong {
      font-weight: var(--weight-emphasis);
      color: var(--ink);
    }
  }

  .pl-refinement__number {
    font-weight: var(--weight-display);
    font-variant-numeric: tabular-nums;
    color: var(--navy);
  }

  .pl-refinement__values {
    color: var(--ink-muted);
  }

  .pl-links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs) var(--space-lg);
    font-size: var(--text-sm);

    & a {
      font-weight: var(--weight-emphasis);
      color: var(--blue);
      text-decoration: underline;
      text-underline-offset: 3px;
    }
  }

  .pl-part {
    display: grid;
    gap: var(--space-md);
    padding-block: var(--space-xl);
    border-top: 2px dashed var(--border);
  }

  .pl-part__title {
    font-size: var(--text-heading);
    font-weight: var(--weight-display);
    color: var(--ink);
  }

  .pl-part__caption {
    max-width: 85ch;
    font-size: var(--text-sm);
    color: var(--ink-muted);
  }

  /* A frame holds a slice of the real page at full width. overflow: clip (not hidden) so the
     sticky column heads still stick to the window. */
  .pl-frame {
    border-block: 1px solid var(--border);
    overflow: clip;
  }

  .pl-frame__label {
    padding: var(--space-sm) 0;
    font-size: var(--text-label);
    font-weight: var(--weight-emphasis);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--ink-muted);
    background: var(--paper);
    border-bottom: 1px dashed var(--border);
  }

  .pl-frame__label strong {
    color: var(--navy);
  }

  .pl-frame .page-bar {
    position: relative;
    top: auto;
  }

  .pl-frame .project__rail {
    position: static;
  }

  .pl-frame__end {
    height: var(--space-xl);
  }

  .pl-pair {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 34rem), 1fr));
    gap: var(--space-lg);
    align-items: start;
  }

  .pl-pair__item {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-sm);
    min-width: 0;
  }

  .pl-pair__label {
    font-size: var(--text-label);
    font-weight: var(--weight-emphasis);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--ink-muted);
  }

  .pl-crop {
    min-width: 0;
    overflow: clip;
    background: var(--paper);
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
  }

  .pl-crop__zoom {
    zoom: 1.5;
  }

  .pl-crop__zoom--2 {
    zoom: 2;
  }

  .pl-crop__zoom--tabs {
    zoom: 1.25;
  }

  .pl-closeup.pl-l3 .projects thead th {
    position: static;
  }

  .pl-crop__inner {
    width: 81rem;
    padding: var(--space-md);
  }

  .pl-crop__inner--band {
    padding: var(--space-md) var(--space-md) 0;
    background: var(--sheet-head);
  }

  .pl-crop__inner--column {
    width: 60rem;
  }

  .pl-crop:has(> .pl-crop__inner--column) {
    width: fit-content;
    max-width: 100%;
  }

  .pl-crop__inner--title {
    width: 26rem;
    padding-bottom: var(--space-md);
  }

  .pl-crop__inner--lines {
    width: 19rem;
    padding-bottom: var(--space-md);
  }

  .pl-phones {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-lg);
  }

  .pl-phone {
    display: grid;
    gap: var(--space-sm);
  }

  .pl-phone__screen {
    width: 390px;
    max-width: 100%;
    height: 780px;
    border: 1px solid var(--border);
    border-radius: 18px;
  }

  .pl-phone__caption {
    font-size: var(--text-sm);
    font-weight: var(--weight-emphasis);
    color: var(--ink);
  }

  .pl-column {
    max-width: 60rem;
  }

  .pl-guide {
    --pl-guide-x: calc(var(--space-md) + 9rem + var(--space-md));

    position: relative;
  }

  .pl-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 13rem;
    gap: var(--space-xl);
    align-items: start;
    width: auto;
  }

  .pl-guide::after {
    content: "";
    position: absolute;
    inset-block: 0;
    left: var(--pl-guide-x);
    border-left: 1px dashed var(--periwinkle);
    pointer-events: none;
  }

  /* Static stand-ins for hover and keyboard focus in the close-ups */

  .pl-closeup .projects__row:last-child {
    background: var(--sheet-head);
  }

  .pl-closeup .mailbox-tab.is-focus {
    outline: 2px solid var(--periwinkle);
    outline-offset: 2px;
  }

  .pl-closeup .project-heading {
    position: relative;
  }

  .pl-closeup .project-heading::before {
    content: "";
    position: absolute;
    top: 0;
    inset-inline: 0;
    border-top: 1px dashed var(--periwinkle);
    pointer-events: none;
  }

  /* ---------- The list ---------- */

  /* 1. Every cell sits on the row's first baseline, so the score's numeral lines up with the name. */
  .pl-l1 .projects__row > * {
    vertical-align: baseline;
  }

  @media (min-width: 721px) {
    .pl-l1 .projects__score {
      padding-top: 0.75rem;
    }
  }

  @media (max-width: 720px) {
    .pl-l1 .projects__row {
      align-items: baseline;
    }
  }

  /* 2. The whole row opens the project; hovering anywhere marks the name as the link. */
  .pl-l2 .projects__row {
    position: relative;
    cursor: pointer;
  }

  .pl-l2 .projects__name::after {
    content: "";
    position: absolute;
    inset: 0;
  }

  .pl-l2 .projects__name:focus-visible {
    outline: none;
  }

  .pl-l2 .projects__row:has(.projects__name:focus-visible) {
    outline: 2px solid var(--periwinkle);
    outline-offset: -2px;
  }

  .pl-l2 .projects__row:hover .projects__name,
  .pl-l2.pl-closeup .projects__row:last-child .projects__name {
    color: var(--blue);
    text-decoration: underline;
    text-underline-offset: 3px;
  }

  /* 3. The column heads stay under the navy bar while the list scrolls. */
  .pl-l3 .sheet {
    overflow: clip;
  }

  .pl-l3 .projects thead th {
    position: sticky;
    top: var(--header-height);
    z-index: 1;
    border-bottom: 0;
    box-shadow: inset 0 -1px 0 var(--border);
  }

  /* 4. A place stays on one line; the project name takes the wrap. */
  .pl-l4 .projects__location {
    white-space: nowrap;
  }

  /* 5. The filter sentence sits closer to the sheet it filters than to the tabs. */
  .pl-l5 .filters {
    margin-bottom: var(--space-md);
  }

  /* 6. The keyboard ring stays inside the tab, in the hover box's shape. */
  .pl-l6 .mailbox-tab:focus-visible,
  .pl-l6.pl-closeup .mailbox-tab.is-focus {
    outline: none;
  }

  .pl-l6 .mailbox-tab:not([aria-current="page"]):is(:focus-visible, .is-focus)::before {
    content: "";
    position: absolute;
    inset: var(--tab-hover-gap) calc(var(--tab-hover-gap) - var(--tab-radius));
    z-index: -1;
    background: var(--hairline);
    border-radius: var(--radius-md);
    box-shadow: 0 0 0 2px var(--periwinkle);
  }

  .pl-l6 .mailbox-tab[aria-current="page"]:is(:focus-visible, .is-focus) {
    outline: 2px solid var(--periwinkle);
    outline-offset: calc(var(--tab-hover-gap) * -1);
  }

  /* 7. On phones the campaign keeps its name: the industry leaves the bar (its name heads the
     campaign menu). */
  @media (max-width: 720px) {
    :root:has(.pl-l7) .app-header .switcher:first-child,
    :root:has(.pl-l7) .app-header__separator {
      display: none;
    }
  }

  /* ---------- Project header ---------- */

  /* 1. The score tag's top meets the title's capitals instead of the line box. */
  .pl-h1 .project-heading .score-tag {
    margin-top: var(--space-sm);
  }

  .pl-h1.pl-closeup .project-heading::before {
    top: var(--space-sm);
  }

  /* 2. Where it is reads before what it is. */
  .pl-h2 .project-heading__place {
    color: var(--ink-body);
  }

  .pl-h2 .project-heading__type {
    color: var(--ink-muted);
  }

  /* 3. Even space around the place line's dot (12 and 8px today). */
  .pl-h3 .project-heading__separator {
    margin-inline: var(--space-xs) var(--space-sm);
  }

  /* 4. The facts strip keeps its top rule only. */
  .pl-h4 .project-intro .header-facts {
    padding-bottom: 0;
    border-bottom: 0;
  }

  /* 5. Headings balance their lines, paragraphs avoid one-word last lines. */
  .pl-h5 :is(.page-head__title, .project-group__title, .project-section__title) {
    text-wrap: balance;
  }

  .pl-h5 :is(.project-lede, .project-text, .risk__text, .criteria__evidence, .person__role) {
    text-wrap: pretty;
  }

  /* ---------- Project sections ---------- */

  /* 1. One label column down the page. */
  .pl-s1 {
    --label-column: 9rem;
  }

  .pl-s1 :is(.risk, .organization) {
    grid-template-columns: var(--label-column) minmax(0, 1fr);
  }

  .pl-s1 .criteria__answer {
    grid-template-columns: var(--label-column) 5rem minmax(0, 1fr);
  }

  .pl-s1 .timeline__item {
    grid-template-columns: calc(var(--label-column) - var(--space-md) - 2px) minmax(0, 1fr);
  }

  /* 2. A kind is said once, and its rows sit together. */
  .pl-s2 .pl-kind-repeat .risk__kind,
  .pl-s2 .pl-kind-repeat .organization__kind {
    visibility: hidden;
  }

  .pl-s2 .rows__item.pl-kind-repeat {
    padding-top: var(--space-xs);
    border-top: 0;
  }

  /* 3. Best first contact under the name, so name, role and email start on one line. */
  .pl-s3 .person__who {
    display: flex;
    flex-direction: column;
  }

  .pl-s3 .person__tag {
    order: 1;
    margin: var(--space-xs) 0 0;
  }

  /* 4. One voice for "source" links: sentence case, blue, regular weight. */
  .pl-s4 .person__links {
    gap: 0 var(--space-sm);
    font-size: inherit;
    font-weight: var(--weight-text);
    letter-spacing: normal;
    text-transform: none;
  }

  .pl-s4 .header-facts__link {
    font-weight: var(--weight-text);
  }

  /* 5. Organization names in one colour; the website is a mark, emails are mail links. */
  .pl-org-name {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--ink);

    & .icon {
      flex: none;
      width: 0.875rem;
      height: 0.875rem;
      color: var(--ink-faint);
    }

    &:hover {
      color: var(--blue);
      text-decoration: underline;
      text-underline-offset: 3px;

      & .icon {
        color: var(--blue);
      }
    }
  }

  .pl-org-email {
    color: var(--blue);
    overflow-wrap: anywhere;

    &:hover {
      text-decoration: underline;
      text-underline-offset: 2px;
    }
  }

  /* 6. Re-check now is a real button, flush with the column. */
  .pl-recheck {
    margin-top: var(--space-sm);
  }

  /* 7. On this page shows where you are, with the tabs' inset box. */
  .pl-s7 :is(.section-nav__title, .section-nav__group, .section-nav__link) {
    padding-inline: var(--space-sm);
  }

  .pl-s7 .section-nav__link {
    border-radius: var(--radius-md);
    transition: background var(--transition-fast), color var(--transition-fast);

    &[aria-current="true"] {
      color: var(--navy);
      background: var(--sheet-head);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .pl-s7 .section-nav__link {
      transition: none;
    }
  }
}
