/* The punched tape build: a dark panel on a black page, with the tape punch drawn on a canvas inside it. The machine,
   the tape and the chads are painted by script.js with these colours; the panel, the words and the button are CSS. */
:root {
  --page: #000000;          /* the page */
  --panel: #131311;         /* the build panel */
  --panel-edge: #262520;    /* its thin rim */
  --floor: #1b1a17;         /* the floor the tape falls on, lit from above */
  --ink: #f1ebdd;           /* the words */
  --muted: #8d887c;         /* the quieter words */
  --tape: #efe4c5;          /* the paper tape */
  --hole: #14120e;          /* what shows through a hole */
  --enamel: #3a3832;        /* the machine's frame, enamelled */
  --enamel-hi: #5d5a51;     /* the light along its edges */
  --steel: #9a9ea3;         /* the head, the rollers and the cutter */
  --steel-hi: #eef0f2;      /* the light on the steel */
  --steel-lo: #3f4247;      /* the steel in shadow */
  --ok: #92d6a8;            /* a build that succeeded */
  --error: #ff7a5c;         /* a build that failed */
  --button: #efe4c5;        /* the button */
  --button-ink: #17150f;    /* its words */
  --line: #3a3832;          /* the ring round the quiet button */
  --focus: #ffb35c;         /* the keyboard's focus ring */
}

* {
  box-sizing: border-box;
}

/* a tap is a click at once: no wait for a double tap, no zoom */
html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Instrument Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

/* ---------------------------------------------------------------- the panel */
.build {
  position: relative;
  width: min(384px, 100%);
  padding: 16px 18px 16px;
  border-radius: 22px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--panel-edge), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.build__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 0 2px;
}

.build__words {
  min-width: 0;
}

.build__title {
  margin: 0;
  font-size: 16px;
  font-weight: 620;
  font-stretch: 94%;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.build__meta {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 450;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
}

/* the words that change slide by themselves */
.build__swap {
  display: inline-block;
}

.build__swap .is-error {
  color: var(--error);
}

.build__swap .is-ok {
  color: var(--ok);
}

/* the figure on the right: the percentage, then the tick */
.build__figure {
  position: relative;
  flex: none;
  min-width: 46px;
  height: 20px;
  margin: 0;
  font-size: 16px;
  font-weight: 620;
  font-stretch: 90%;
  line-height: 20px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.build__pct {
  display: inline-block;
}

.build__pct.is-quiet {
  color: var(--muted);
  font-weight: 480;
  font-size: 13px;
}

.build__tick {
  position: absolute;
  right: -2px;
  top: -2px;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--ok);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  visibility: hidden;
}

/* ---------------------------------------------------------------- the machine */
/* the canvas keeps the drawing's proportions, 344 by 232 units */
.build__bay {
  position: relative;
  aspect-ratio: 344 / 232;
  margin: 10px -4px 10px;
}

.build__paint {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* the frame before the newest one, fading out: with reduced motion the tape moves on by dissolves */
.build__ghost {
  opacity: 0;
}

/* ---------------------------------------------------------------- the file and the button */
.build__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px;
}

.build__file {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-size: 11.5px;
  font-weight: 450;
  line-height: 1.3;
  white-space: nowrap;
}

.build__file .build__swap {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.build__file .is-error {
  color: var(--error);
}

/* the button: the fill is a layer of its own that swells past the edge with a bounce, and the words widen on the
   width axis of the font; pressed, it squashes a little */
.pill {
  position: relative;
  flex: none;
  display: inline-grid;
  place-items: center;
  height: 36px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--button-ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 640;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  transition: color 0.25s ease;
}

.pill::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--button);
  transition: inset 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.25s ease, box-shadow 0.25s ease;
}

.pill__label {
  display: inline-block;
  font-stretch: 86%;
  transition: font-stretch 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* while the tape runs the button only cancels: it steps back */
.pill.is-quiet {
  color: var(--ink);
}

.pill.is-quiet::before {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--line);
}

@media (hover: hover) and (pointer: fine) {
  .pill:hover::before {
    inset: -2px -6px;
  }

  .pill:hover .pill__label {
    font-stretch: 100%;
  }

  .pill.is-quiet:hover::before {
    background: color-mix(in srgb, var(--line) 45%, transparent);
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .pill::before,
  .pill__label {
    transition: none;
  }
}
