/* The three ways to simulate (scripts/views/ways.mjs, js/views/ways.js): one sample chain of six steps, drawn
   once per way. A step that way produces carries its look: solid for run, a dotted centre for a stand-in, an
   outlined diamond for the model. The rest are small dots on a faint line. From 64rem the chain runs left to
   right, one way per row; below that it runs top to bottom, one way per column, and each way's line sits
   under the board. One key line names the two marks a step inside a run can carry: a ring for reach shown, a
   dashed edge for never run. It stands under the three rows, or inside the run's row where the page asks for
   that. White and grey only: this picture shows how a step is produced, not how it went. The figure carries
   its own frame, so it stands on any page that loads the shared tokens. */

.ways { --mark: var(--space-lg); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-lg); margin: 0; padding: var(--space-xl); overflow: clip; border-radius: var(--radius-frame); background: var(--color-paper-2); box-shadow: inset 0 0 0 1px var(--color-frame-edge); }
.ways__board { display: grid; grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr)); align-items: center; }
.ways__steps, .ways__way { display: contents; }

/* Top to bottom: step names down the left, one column per way. */
.ways__step { grid-column: 1; grid-row: calc(var(--s) + 2); font-size: var(--text-md); line-height: 1.2; color: var(--color-ink-2); }
.ways__head { grid-column: calc(var(--w) + 2); grid-row: 1; max-width: none; padding-bottom: var(--space-xs); font-size: var(--text-md); line-height: 1.2; text-align: center; color: var(--color-ink); }
.ways__cell { position: relative; grid-column: calc(var(--w) + 2); grid-row: calc(var(--s) + 2); display: grid; place-items: center; min-height: var(--control-hit); }
.ways__tag { grid-column: 1 / -1; grid-row: 8; justify-self: end; display: flex; align-items: center; gap: var(--space-xs); padding-top: var(--space-xs); font-size: var(--text-md); line-height: 1.3; color: var(--color-ink-2); }
.ways__line { grid-column: 1 / -1; grid-row: calc(var(--w) * 2 + 9); padding-block: var(--space-sm); border-top: 1px solid var(--color-rule); font-size: var(--text-md); line-height: 1.45; color: var(--color-ink-2); }
.ways__way[data-way="run"] .ways__line { margin-top: var(--space-lg); }
.ways__k { color: var(--color-ink); }
.ways__caption { font-size: var(--text-md); color: var(--color-ink-3); }

/* The key line: the two marks, each drawn as the catalogue's strips and the technique map draw it. Inside the
   board it takes the row under its way's own line. */
.ways__key { display: flex; flex-direction: column; gap: var(--space-xs); font-size: var(--text-md); line-height: 1.45; color: var(--color-ink-2); }
.ways__board .ways__key { grid-column: 1 / -1; grid-row: calc(var(--w) * 2 + 10); padding-bottom: var(--space-md); }
.ways__key-item { display: inline-flex; align-items: baseline; gap: var(--space-xs); }
.ways__key-name { color: var(--color-ink); }
.ways__key .ways__mark { top: var(--space-3xs); width: var(--space-md); height: var(--space-md); border-radius: var(--space-2xs); }
.ways__go { justify-self: start; }

/* The marks. Hollow looks carry the frame's own colour, so the line behind never shows through them. */
.ways__mark { position: relative; z-index: 1; flex: none; display: block; width: var(--mark); height: var(--mark); border-radius: var(--radius-nav-btn); background: var(--color-paper-2); }
.ways__mark[data-look="none"] { width: var(--space-xs); height: var(--space-xs); border-radius: var(--radius-pill); background: var(--color-dust-far); }
.ways__mark[data-look="solid"] { background: var(--color-ink); }
.ways__mark[data-look="dot"] { box-shadow: inset 0 0 0 2px var(--color-ink); }
.ways__mark[data-look="dot"]::before { content: ""; position: absolute; inset: 32%; border-radius: var(--space-3xs); background: var(--color-ink); }
.ways__mark[data-look="ring"] { box-shadow: inset 0 0 0 2px var(--color-ink); }
.ways__mark[data-look="dash"] { border: 2px dashed var(--color-line); }
.ways__mark[data-look="model"] { background: none; }
.ways__mark[data-look="model"]::before { content: ""; position: absolute; inset: 15%; border-radius: var(--space-3xs); background: var(--color-paper-2); box-shadow: inset 0 0 0 2px var(--color-ink-2); transform: rotate(45deg); }

/* The line of the chain: faint from each step to the next, white between two steps that were both run, dashed
   between steps the model recomputed. */
.ways__cell:not([data-last])::before { content: ""; position: absolute; inset: 50% 0 auto; margin-inline: auto; width: 1px; height: 100%; background: var(--color-rule); }
.ways__cell[data-join]::after { content: ""; position: absolute; inset: calc(50% + var(--mark) / 2) 0 auto; margin-inline: auto; width: 2px; height: calc(100% - var(--mark)); background: var(--color-ink); transform-origin: top; }
.ways__way[data-way="model"] .ways__cell[data-join]::after { width: 0; background: none; border-left: 2px dashed var(--color-line); }

@media (min-width: 64rem) {
  /* Left to right: step names across the top, one row per way, its head and line on the left. */
  .ways__board { grid-template-columns: minmax(0, 4fr) repeat(6, minmax(0, 1.3333fr)); align-items: stretch; }
  .ways__step { grid-column: calc(var(--s) + 2); grid-row: 1; padding-bottom: var(--space-sm); text-align: center; color: var(--color-ink-3); }
  /* Each way takes three rows: its head, its line, and a row for its key line or its tag. */
  .ways__head { grid-column: 1; grid-row: calc(var(--w) * 3 + 2); padding: var(--space-lg) var(--space-xl) 0 0; border-top: 1px solid var(--color-rule); font-size: var(--text-title); line-height: var(--leading-title); letter-spacing: var(--tracking-title); text-align: left; }
  .ways__line { grid-column: 1; grid-row: calc(var(--w) * 3 + 3); align-self: start; padding: var(--space-2xs) var(--space-xl) var(--space-lg) 0; border-top: 0; }
  .ways__way[data-way="run"] .ways__line { margin-top: 0; }
  .ways__k { display: none; }
  .ways__cell { grid-column: calc(var(--s) + 2); grid-row: calc(var(--w) * 3 + 2) / span 2; border-top: 1px solid var(--color-rule); }
  .ways__key { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: var(--space-xs) var(--space-lg); }
  .ways__board .ways__key { grid-row: calc(var(--w) * 3 + 4); padding-bottom: var(--space-lg); }
  .ways__tag { grid-column: 2 / -1; grid-row: calc(var(--w) * 3 + 4); justify-self: center; padding-top: 0; }
  .ways__cell:not([data-last])::before { inset: 0 auto 0 50%; margin-block: auto; margin-inline: 0; width: 100%; height: 1px; }
  .ways__cell[data-join]::after { inset: 0 auto 0 calc(50% + var(--mark) / 2); margin-block: auto; margin-inline: 0; width: calc(100% - var(--mark)); height: 2px; transform-origin: left; }
  .ways__way[data-way="model"] .ways__cell[data-join]::after { width: calc(100% - var(--mark)); height: 0; border-left: 0; border-top: 2px dashed var(--color-line); }
}

/* The reveal, only with scripting and motion: the test's steps arrive in order, each in the row of the way
   that produced it; then the model's row arrives at once, since nothing in it is run. It ends in the resting
   picture. */
html:not(.rm) .ways.is-ready:not(.is-live) .ways__cell > .ways__mark:not([data-look="none"]) { opacity: 0; transform: scale(0.4); }
html:not(.rm) .ways.is-ready:not(.is-live) .ways__cell[data-join]::after { transform: scaleY(0); }
html:not(.rm) .ways.is-ready:not(.is-live) .ways__way[data-way="model"] .ways__cell[data-join]::after { opacity: 0; transform: none; }
html:not(.rm) .ways.is-ready:not(.is-live) .ways__tag { opacity: 0; }
html:not(.rm) .ways.is-live .ways__cell > .ways__mark { transition: opacity 400ms var(--ease-out) calc(var(--s) * 240ms + 200ms), transform 650ms var(--ease-expo) calc(var(--s) * 240ms + 200ms); }
html:not(.rm) .ways.is-live .ways__cell[data-join]::after { transition: transform 240ms var(--ease-out) calc(var(--s) * 240ms + 400ms); }
html:not(.rm) .ways.is-live .ways__way[data-way="model"] .ways__cell > .ways__mark { transition-delay: 1900ms; }
html:not(.rm) .ways.is-live .ways__way[data-way="model"] .ways__cell[data-join]::after { transition: opacity 400ms var(--ease-out) 2000ms; }
html:not(.rm) .ways.is-live .ways__tag { transition: opacity 400ms var(--ease-out) 2300ms; }
@media (min-width: 64rem) {
  html:not(.rm) .ways.is-ready:not(.is-live) .ways__cell[data-join]::after { transform: scaleX(0); }
  html:not(.rm) .ways.is-ready:not(.is-live) .ways__way[data-way="model"] .ways__cell[data-join]::after { transform: none; }
}

@media (max-width: 39.99rem) {
  .ways { padding: var(--space-lg) var(--space-md); border-radius: var(--radius-view); }
  /* Inside a page section's container the frame runs edge to edge, as the other views do on a phone. */
  .view--ways > .ways { margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); border-radius: 0; box-shadow: inset 0 1px 0 var(--color-frame-edge), inset 0 -1px 0 var(--color-frame-edge); }
}
