/* How it works: the parts every page of the workbench shares, as its design draws them. A view's
   head (the step and the place, its title, what it is, and its actions: the file it writes, the
   next step's button), chips, the seal on what is always yours, tags, buttons, a toast, a sheet
   over the page. Then the timing classes how.js sets: a [data-at] part arrives with .on, a
   [data-out] part leaves with .gone, a .st part is always there and changes with .on, and a .fold
   part or a line in the chat takes no room until it arrives; and only the playing step's scene
   shows. how-frame.css draws the workbench around it. Only tokens. */

.cw-main {
  grid-area: main;
  position: relative;
  overflow: hidden;
}
.vw {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-6) var(--space-6) var(--space-5);
  overflow: hidden;
}
/* The step or place and the page's actions on the first line; the title and what it is under them */
.vw-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-1) var(--space-4);
  align-items: center;
}
.vw-head > * {
  grid-column: 1 / -1;
}
.vw-head > .kick {
  grid-column: 1;
  grid-row: 1;
}
.vw-head > .btnx,
.vw-head > .vw-act {
  grid-column: 2;
  grid-row: 1;
}
.vw-head > .chip {
  justify-self: start;
  margin-top: var(--space-1);
}
.vw-act {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.kick,
.lbl {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-muted);
}
.vw-h {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  font-size: 26px;
  line-height: 1.2;
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-heading);
  color: var(--text-strong);
}
.vw-head small {
  max-width: 60ch;
  margin-top: var(--space-1);
  font-size: 14px;
  color: var(--text-muted);
}
.vw-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: auto;
}
/* The file a page writes, saved */
.wfile {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.wfile .mono {
  color: var(--text);
}
.wsaved {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--ok-tint);
  color: var(--ok);
  font-size: 12px;
  font-weight: var(--weight-medium);
}
.cw .wsaved svg {
  width: 12px;
  height: 12px;
}
/* Two ways to see a page, one picked */
.seg2 {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-control);
  background: var(--surface-2);
  font-size: 13px;
}
.seg2 > * {
  padding: 5px var(--space-3);
  border-radius: 6px;
  color: var(--text-muted);
}
.seg2 b {
  background: var(--surface-3);
  font-weight: var(--weight-medium);
  color: var(--text-strong);
}

/* The parts the steps share */
.cw .chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px var(--space-3);
  border-radius: var(--radius-pill);
  border: var(--border) solid var(--line-strong);
  font-size: 13px;
  font-weight: var(--weight-medium);
  letter-spacing: 0;
  white-space: nowrap;
  color: var(--text);
}
.cw .chip svg {
  width: 14px;
  height: 14px;
}
.mono {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
}
/* An approval that is always the person's carries the seal */
.sealed {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--accent-tint);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: var(--weight-medium);
  white-space: nowrap;
}
.cw .sealed svg {
  width: 14px;
  height: 14px;
}
.bub .sealed {
  align-items: start;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-control);
  white-space: normal;
}
.cw .bub .sealed svg {
  margin-top: 2px;
}
.tag {
  padding: 1px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-style: normal;
  font-weight: var(--weight-medium);
  white-space: nowrap;
}
.tag,
.tag.added {
  background: var(--ok-tint);
  color: var(--ok);
}
.tag.moved {
  background: var(--info-tint);
  color: var(--info);
}
.btnx {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 38px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-control);
  border: var(--border) solid var(--line-strong);
  background: transparent;
  font-size: 14px;
  font-weight: var(--weight-medium);
  white-space: nowrap;
  color: var(--text-strong);
}
.btnx.yes {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--text-on-accent);
}
.cw .btnx svg {
  width: 16px;
  height: 16px;
}
/* A button the person presses: it gives, and a ring says it was pressed */
.btnx.st.on {
  animation: hw-press 600ms var(--ease-out);
  box-shadow: 0 0 0 4px var(--accent-line);
}
@keyframes hw-press {
  40% {
    transform: scale(0.95);
  }
}
/* Two or more parts in one place, one after the other */
.swap,
.cw .chip.swap {
  display: inline-grid;
}
.swap > * {
  grid-area: 1 / 1;
}
/* Centered by its margins: the timing below moves things with translate */
.toast {
  position: absolute;
  inset: auto 0 var(--space-5);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: fit-content;
  max-width: calc(100% - 2 * var(--space-4));
  margin-inline: auto;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-pill);
  border: var(--border) solid var(--line-strong);
  background: var(--surface-3);
  box-shadow: var(--shadow-overlay);
  color: var(--text-strong);
  font-size: 14px;
  font-weight: var(--weight-medium);
}
.cw .toast svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}
.toast.toast-live i {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}
/* A sheet over the page, the page dimmed behind it */
.sc:has(.sheet.on:not(.gone))::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: color-mix(in srgb, var(--bg-canvas) 64%, transparent);
}
.sheet {
  position: absolute;
  inset: var(--space-4) 0 auto;
  z-index: 2;
  display: grid;
  gap: var(--space-2);
  width: min(560px, calc(100% - 2 * var(--space-4)));
  margin-inline: auto;
  padding: var(--space-5) var(--space-6);
  border-radius: 16px;
  border: var(--border) solid var(--line-strong);
  background: var(--surface);
  box-shadow: var(--shadow-overlay);
}

/* The timing: what arrives, what leaves. Before the script runs, everything simply shows. */
.hw.js .cw [data-at]:not(.st),
.hw.js .hw-phone {
  opacity: 0;
  translate: 0 8px;
  transition:
    opacity 350ms var(--ease-out),
    translate 350ms var(--ease-out);
}
.hw.js .cw [data-at]:not(.st).on,
.hw.js .hw-phone.on {
  opacity: 1;
  translate: 0 0;
}
.hw.js .gone,
.hw.js [data-at]:not(.st).on.gone {
  opacity: 0;
  translate: 0 8px;
  visibility: hidden;
  transition:
    opacity 300ms var(--ease-out),
    translate 300ms var(--ease-out),
    visibility 0s 300ms;
}
.hw:not(.js) [data-out] {
  display: none;
}
.hw.js .ch-step [data-at]:not(.st):not(.on),
.hw.js .cw .fold[data-at]:not(.on),
.hw.js .cw .fold.gone {
  display: none;
}
.hw.js .ch-step [data-at].on:not(.st),
.hw.js .cw .fold.on {
  animation: hw-in 350ms var(--ease-out);
}
@keyframes hw-in {
  from {
    opacity: 0;
    translate: 0 8px;
  }
}

/* Only the playing step's scene shows */
.sc {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 400ms var(--ease-out),
    visibility 0s 400ms;
}
.hw[data-step="1"] .s1,
.hw[data-step="2"] .s2,
.hw[data-step="3"] .s3 {
  opacity: 1;
  visibility: visible;
  transition: opacity 400ms var(--ease-out);
}

@container (max-width: 960px) {
  .vw-head > .vw-act .wfile {
    display: none;
  }
}
@container (max-width: 680px) {
  .vw {
    gap: var(--space-3);
    padding: var(--space-4);
  }
  .vw-h {
    font-size: 20px;
  }
  .vw-head {
    grid-template-columns: minmax(0, 1fr);
  }
  .vw-head small {
    display: none;
  }
  .vw-head > .btnx,
  .vw-head > .vw-act {
    grid-column: 1;
    grid-row: auto;
    justify-self: start;
    margin-top: var(--space-2);
  }
  .vw-act .seg2 {
    display: none;
  }
}
