/* Good Work Digital. Section 3 of the home page, the SWITCHER candidate: a row of kinds and one glass stage that it changes.

   HOW TO MOUNT
   1. Load this file after the page's own stylesheet (styles.css of e-exact; base.css here is a frozen copy of it).
      It uses that sheet's tokens and its .wrap, .head, .field, .glass and .link, and adds only classes that start with "ks".
   2. Load section.js in the <head>, not deferred, so the page never shows the scripts off layout first.
   3. The markup in section.html replaces <section id="kinds"> in index.html.
   The rules for the old four cards (.kinds__list, .kind, .slip, .kinds__close) can then be deleted from the page's stylesheet.

   The first block is the section with scripts off: every kind shown, one under another, in the same frame.
   Everything keyed to html.ks-js applies only when section.js has run. */

/* ---------- The stage and its parts (and, with scripts off, the whole section) ---------- */

/* The stage is a frame, as the two projects are: glass, with what it holds 8 inside its rim on the small corner. */
.ks__tabs { display: none; }
.ks__stage { padding-block: var(--s-8); }
.ks-panel { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gutter); }
.ks-panel + .ks-panel { margin-top: var(--s-8); }
.ks-panel > * { grid-column: 1 / -1; }
.ks-panel__kind { padding: var(--s-16) var(--inset) 0; color: var(--muted); }
.ks-say { padding: var(--s-4) var(--inset) var(--s-24); }
.ks-say__big {
  font-family: var(--display); font-weight: 700; font-size: var(--d3); line-height: var(--d3-lh); letter-spacing: -0.035em;
  color: var(--ink); text-wrap: balance;
}
.ks-say__more { margin-top: var(--s-12); max-width: 34em; text-wrap: pretty; }
.ks-say .link { margin-top: var(--s-8); }

/* The pane: the dark glass, held in the frame the way a picture is. The three lines on it are what goes first on the site. */
.ks-lines {
  display: grid; grid-auto-rows: 1fr;
  margin-inline: var(--s-8); padding: var(--s-8) var(--s-16); border-radius: var(--r-1);
  background: radial-gradient(70% 110% at 0% 0%, rgba(47, 75, 255, 0.20), rgba(47, 75, 255, 0) 70%), var(--night); color: var(--on-night);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 0 0 1px rgba(11, 13, 18, 0.10);
}
.ks-lines li {
  position: relative; display: grid; grid-template-columns: 8px minmax(0, 1fr); column-gap: var(--s-16); align-items: center;
  min-height: var(--s-80); padding-block: var(--s-12);
}
.ks-lines li + li { box-shadow: inset 0 1px 0 var(--night-rule); }
.ks-lines li::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); }
.ks-lines li > span {
  font-family: var(--display); font-weight: 700; font-size: var(--d4); line-height: var(--d4-lh); letter-spacing: -0.025em;
  color: var(--on-night); text-wrap: balance;
}
.ks-say .link:focus-visible { border-radius: var(--r-1); }

@media (min-width: 900px) {
  .ks-panel { grid-template-rows: auto 1fr; }
  .ks-panel__kind { grid-column: 1 / span 6; grid-row: 1; padding-top: var(--s-24); }
  .ks-say { grid-column: 1 / span 6; grid-row: 2; }
  .ks-lines { grid-column: 7 / span 6; grid-row: 1 / span 2; margin-left: 0; padding-inline: var(--inset); }
  .ks-lines li { min-height: var(--s-64); }
}

/* ---------- Scripts on: the row of kinds ---------- */

/* A tab list. On a phone it is three over two; from 600 up it is one row. The thumb under the chosen kind is one element that glides. */
html.ks-js .ks__tabs { position: relative; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--s-8); }
.ks__tab {
  position: relative; z-index: 1; grid-column: span 2;
  display: flex; align-items: center; justify-content: center; height: 48px; padding: 0 var(--s-8); margin: 0;
  -webkit-appearance: none; appearance: none; background: transparent; border: 0; border-radius: var(--r-1); cursor: pointer;
  font: 600 16px/1 var(--sans); letter-spacing: -0.012em; white-space: nowrap; color: var(--text);
  -webkit-tap-highlight-color: transparent;
  transition: color 0.24s ease, background-color 0.14s ease;
}
.ks__tab:nth-of-type(n + 4) { grid-column: span 3; }
.ks__tab:hover { color: var(--ink); background: rgba(11, 13, 18, 0.06); }
.ks__tab:active { background: rgba(11, 13, 18, 0.10); }
.ks__tab[aria-selected="true"], .ks__tab[aria-selected="true"]:hover { color: #fff; background: transparent; }

/* The thumb: solid ink, the same dark as the pane below, so the chosen kind and its pane read as one thing.
   section.js gives it the chosen tab's place and size. Until it has, the chosen tab wears the look itself, so nothing jumps. */
.ks__thumb, .ks:not(.ks--ready) .ks__tab[aria-selected="true"] {
  background: var(--night);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 1px 2px rgba(11, 13, 18, 0.18), 0 10px 20px -10px rgba(11, 13, 18, 0.45);
}
.ks__thumb { position: absolute; z-index: 0; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; border-radius: var(--r-1); overflow: hidden; pointer-events: none; opacity: 0; will-change: transform; }
.ks--ready .ks__thumb { opacity: 1; }
/* the fine blue line in the foot of the thumb: it fills while the stage waits to move on by itself, and is gone for good at the first touch */
.ks__thumb i { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--accent); transform: scaleX(0); transform-origin: 0 50%; }

/* ---------- Scripts on: the stage ---------- */

/* Every kind lies in the same place, so the stage is as tall as the tallest and never changes size. */
html.ks-js .ks__stage { margin-top: var(--s-16); }
html.ks-js .ks__panels { display: grid; }
html.ks-js .ks-panel { grid-area: 1 / 1; grid-template-rows: 1fr auto; margin: 0; visibility: hidden; }
html.ks-js .ks-panel.is-active, html.ks-js .ks-panel.is-leaving { visibility: visible; }
html.ks-js .ks-panel.is-leaving { pointer-events: none; }
/* keyboard focus on the stage's words rings the whole stage */
html.ks-js .ks-panel:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; border-radius: var(--r-1); }
@supports selector(:has(a)) {
  html.ks-js .ks__stage:has(.ks-panel:focus-visible) { outline: 2px solid var(--focus); outline-offset: 3px; }
  html.ks-js .ks-panel:focus-visible { outline: none; }
}
html.ks-js .ks-panel__kind { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
html.ks-js .ks-say { padding-top: var(--s-16); }

/* The change. Each piece (.ks-a) waits its turn, then settles: 12 pixels and its opacity, nothing else.
   A piece's turn is --i; the mark before each of the three lines keeps the same turn as its line. */
html.ks-js .ks-a, html.ks-js .ks-lines li::before { opacity: 0; }
html.ks-js .ks-a { transform: translate3d(0, 12px, 0); }
html.ks-js .ks-lines li::before { transform: scale(0.25); }
html.ks-js .is-active .ks-a, html.ks-js .is-active .ks-lines li::before {
  opacity: 1; transform: none;
  transition: opacity 0.44s cubic-bezier(0.2, 0.7, 0.2, 1), transform 0.44s cubic-bezier(0.2, 0.7, 0.2, 1);
  transition-delay: calc(120ms + var(--i, 0) * 70ms);
}
html.ks-js .is-leaving .ks-a, html.ks-js .is-leaving .ks-lines li::before {
  opacity: 0; transform: translate3d(0, -6px, 0);
  transition: opacity 0.14s ease-in, transform 0.14s ease-in; transition-delay: 0s;
}
/* as each line lights, its mark gives off one ring, once: the same square, growing and fading */
html.ks-js .ks-lines li::after {
  content: ""; position: absolute; left: 0; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 2px;
  background: var(--accent); opacity: 0; pointer-events: none;
}
html.ks-js .is-active .ks-lines li::after { animation: ks-ring 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) calc(300ms + var(--i, 0) * 70ms); }
@keyframes ks-ring { from { opacity: 0; transform: scale(1); } 15% { opacity: 0.5; transform: scale(1.4); } to { opacity: 0; transform: scale(3.5); } }
/* the leaving kind gives up its pane and rules at once: the arriving kind's are in the same place, so the pane never blinks */
html.ks-js .is-leaving > .ks-lines { background: transparent; box-shadow: none; }
html.ks-js .is-leaving .ks-lines li { box-shadow: none; }
/* before the stage is first seen its three lines wait; they light in order as it comes into view */
html.ks-js .ks--waiting .is-active .ks-lines .ks-a, html.ks-js .ks--waiting .is-active .ks-lines li::before { opacity: 0; transition: none; }
html.ks-js .ks--waiting .is-active .ks-lines .ks-a { transform: translate3d(0, 12px, 0); }
html.ks-js .ks--waiting .is-active .ks-lines li::before { transform: scale(0.25); }
html.ks-js .ks--waiting .is-active .ks-lines li::after { animation: none; }

/* ---------- From a large phone up: the five kinds in one row ---------- */
@media (min-width: 600px) {
  html.ks-js .ks__tabs { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .ks__tab, .ks__tab:nth-of-type(n + 4) { grid-column: auto; height: 56px; }
  html.ks-js .ks__stage { margin-top: var(--gutter); }
  .ks-say__big { font-size: 32px; line-height: 36px; }
  html.ks-js .ks-say { padding-top: var(--s-24); padding-bottom: var(--s-32); }
}

/* ---------- Two halves: who is looking, on the left; what goes first, on the pane ---------- */
@media (min-width: 900px) {
  html.ks-js .ks-panel { grid-template-rows: auto; }
  /* the words start level with the pane's first line and end level with its last */
  html.ks-js .ks-say { grid-column: 1 / span 6; grid-row: 1; display: flex; flex-direction: column; align-items: flex-start; padding-block: var(--s-40); }
  html.ks-js .ks-say__more { margin-top: auto; padding-top: var(--s-16); }
  html.ks-js .ks-lines { grid-column: 7 / span 6; grid-row: 1; padding-block: var(--s-12); }
  html.ks-js .ks-lines li { min-height: var(--s-96); }
  .ks__tab { font-size: 18px; }
}

/* ---------- Computer: every edge on a column line ---------- */
@media (min-width: 1200px) {
  /* each kind is two columns wide; Your Business stands apart on the last two */
  html.ks-js .ks__tabs { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 0 var(--gutter); }
  .ks__tab, .ks__tab:nth-of-type(n + 4) { grid-column: span 2; }
  .ks__tab:last-of-type { grid-column: 11 / span 2; }
  html.ks-js .ks-say { grid-column: 1 / span 5; padding: var(--s-40) 0 var(--s-48) var(--inset); }
  /* two pixels down, so the last baseline of these words is the last line's baseline on the pane */
  html.ks-js .ks-say > .ks-say__more:last-child { margin-bottom: -2px; }
  /* the link's words sit on that baseline too; its 44 tall touch area reaches 10 into the space below */
  html.ks-js .ks-say > .link:last-child { margin-bottom: -10px; }
  /* one pixel up, so the first baseline of these words is the first line's baseline on the pane */
  html.ks-js .ks-say__big { font-size: 40px; line-height: 44px; margin-top: -1px; }
  html.ks-js .ks-lines { padding-block: var(--s-16); }
  html.ks-js .ks-lines li { height: var(--s-96); padding-block: 0; }
  html.ks-js .ks-lines li > span { font-size: 32px; line-height: 36px; letter-spacing: -0.035em; white-space: nowrap; }
}

/* ---------- No movement asked for: every state changes at once ---------- */
@media (prefers-reduced-motion: reduce) {
  html.ks-js .ks-a, html.ks-js .ks-lines li::before { transition: none !important; }
  html.ks-js .ks-lines li::after { animation: none !important; }
  .ks__thumb i { display: none; }
}
