/* The 3D printer loader: a small printer seen from the front and a little from above, alone on a white page, with a
   line of words and the pills under it. The frame, the plate, the head and the spool are drawn by script.js in SVG,
   the vase on a canvas, all with these colours. */
:root {
  --page: #ffffff;          /* the page */
  --ink: #1c2026;           /* outlines and words */
  --muted: #7b838d;         /* the quiet words */
  --ok: #26794f;            /* model ready */
  --frame: #262a31;         /* the aluminium extrusions of the frame, anodised black */
  --base: #2f343c;          /* the base with the electronics */
  --plate: #c99f55;         /* the textured build plate */
  --bed: #24282e;           /* the heated bed under it */
  --shroud: #eceae5;        /* the printed parts of the head */
  --brass: #d6a94c;         /* the nozzle */
  --filament: #2f57d8;      /* the filament, and the vase once it is cool */
  --hot: #ff7a1c;           /* the plastic as it leaves the nozzle */
  --heat: #d8352c;          /* the colour it passes through as it cools */
  --tube: #f1f4f6;          /* the PTFE tube */
  --button: #2f57d8;        /* the main pill */
  --button-ink: #ffffff;    /* its words */
  --line: #dde2e8;          /* the ring round the quiet pill */
  --focus: #ff7a1c;         /* 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: 40px 16px;
}

/* ---------------------------------------------------------------- the printer */
.printer {
  display: grid;
  justify-items: center;
  width: min(360px, 100%);
}

/* the drawing: 300 by 256 units, the printer and the spool on its stand */
.printer__scene {
  position: relative;
  width: min(330px, 100%);
  aspect-ratio: 300 / 256;
}

.printer__art {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the line of words */
.printer__status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 22px;
  margin: 12px 0 0;
  max-width: 100%;
  font-size: 15px;
  font-weight: 600;
  font-stretch: 92%;
  line-height: 22px;
  letter-spacing: -0.005em;
  white-space: nowrap;
}

.printer__swap {
  display: inline-block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.printer[data-mode='idle'] .printer__swap,
.printer[data-mode='clear'] .printer__swap {
  color: var(--muted);
}

.printer[data-mode='done'] .printer__swap {
  color: var(--ok);
}

/* the percentage and the time left keep their width while the figures change */
.printer__pct,
.printer__left {
  display: none;
  font-variant-numeric: tabular-nums;
}

.printer__pct {
  font-weight: 700;
  font-stretch: 84%;
}

.printer__left {
  color: var(--muted);
  font-weight: 500;
}

.printer[data-mode='print'] .printer__pct,
.printer[data-mode='print'] .printer__left,
.printer[data-mode='canceled'] .printer__pct {
  display: inline-block;
}

/* the tick of Model ready, drawn in by script.js */
.printer__icon {
  display: none;
  flex: none;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: var(--ok);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}

.printer[data-mode='done'] .printer__icon {
  display: block;
}

/* ---------------------------------------------------------------- the pills */
.printer__buttons {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

/* 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, a pill squashes a little */
.pill {
  position: relative;
  display: inline-grid;
  place-items: center;
  height: 44px;
  min-width: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--button-ink);
  font: inherit;
  font-size: 14.5px;
  font-weight: 620;
  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[hidden] {
  display: none;
}

.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: 88%;
  transition: font-stretch 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* the quiet pill: Export again, and Cancel while the printer works */
.pill.is-quiet {
  color: var(--ink);
}

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

/* downloaded: the main pill turns green */
.pill.is-saved::before {
  background: var(--ok);
}

@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) 38%, transparent);
  }
}

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

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

/* ---------------------------------------------------------------- the drawing */
.part {
  stroke: var(--ink);
  stroke-width: 0.6;
  stroke-linejoin: round;
}

.thin {
  fill: none;
  stroke: var(--ink);
  stroke-width: 0.4;
  stroke-linecap: round;
}
