/* Fil's HTML demo kit (1.js): the HTML Demo skill's window
   (skills/html-demo/scripts/step-window.css), a Mac window whose stage is
   the app drawn at 1200 × 750 and scaled to fit by --k, the steps in a bar
   along its foot, and the controls under it. Everything the app draws is
   the page's own CSS; this is only the frame, the pointer, the bar and the
   controls. Its colours are variables, dark by default and light on
   .hd-light, so a page can set its own (--hd-font, --hd-mono, --hd-focus
   for the focus ring and the scrubber). */
.hd,
.hd-ctl {
  --hd-frame: #0b0c0e;
  --hd-chrome: #16171a;
  --hd-line: rgba(255, 255, 255, 0.07);
  --hd-ring: rgba(255, 255, 255, 0.14);
  --hd-dim: #8a8e96;
  --hd-faint: #5c6067;
  --hd-on: #f3f4f5;
  --hd-fill: #c3c6cc;
  --hd-tab: rgba(255, 255, 255, 0.085);
  --hd-hover: rgba(255, 255, 255, 0.05);
  --hd-track: rgba(255, 255, 255, 0.08);
  --hd-stage: #08090a;
  --hd-ink: #c3c6cc;
  --hd-shadow: 0 40px 120px -40px rgba(0, 0, 0, 0.85), 0 30px 60px -30px rgba(0, 0, 0, 0.55);
}
.hd-light,
.hd-ctl.hd-light {
  --hd-frame: #ffffff;
  --hd-chrome: #ececee;
  --hd-line: rgba(0, 0, 0, 0.08);
  --hd-ring: rgba(0, 0, 0, 0.12);
  --hd-dim: #6b6f76;
  --hd-faint: #9a9ea5;
  --hd-on: #1c1d20;
  --hd-fill: #3a3d42;
  --hd-tab: rgba(0, 0, 0, 0.06);
  --hd-hover: rgba(0, 0, 0, 0.05);
  --hd-track: rgba(0, 0, 0, 0.1);
  --hd-stage: #ffffff;
  --hd-ink: #1c1d20;
  --hd-shadow: 0 40px 100px -40px rgba(20, 24, 40, 0.35), 0 24px 48px -28px rgba(20, 24, 40, 0.28);
}
.hd {
  display: grid;
}
.hd-win {
  position: relative;
  /* A <figure> keeps a 40 px side margin by default: on a phone that is
     80 px of a 390 px screen gone. */
  margin: 0;
  border-radius: 14px;
  background: var(--hd-frame);
  box-shadow:
    0 0 0 0.5px var(--hd-ring),
    0 1px 0 var(--hd-line) inset,
    var(--hd-shadow);
  overflow: hidden;
}

/* The title bar: traffic lights, then Fil's tabs, a Mac app's title or a
   browser's address. */
.hd-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 10px 0 14px;
  background: var(--hd-chrome);
  border-bottom: 0.5px solid var(--hd-line);
  font: 500 11.5px/1 var(--hd-font, system-ui, sans-serif);
  color: var(--hd-dim);
  white-space: nowrap;
}
.hd-lights {
  display: flex;
  gap: 7px;
  margin-right: 8px;
}
.hd-lights i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #ff5f57;
}
.hd-lights i:nth-child(2) {
  background: #febc2e;
}
.hd-lights i:nth-child(3) {
  background: #28c840;
}
.hd-bar svg {
  flex: none;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.hd-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  max-width: 190px;
  height: 24px;
  padding: 0 10px;
  border-radius: 7px;
}
.hd-tab > span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.hd-tab b {
  flex: none;
  width: 11px;
  height: 11px;
  border-radius: 3px;
}
.hd-tab.on {
  color: var(--hd-on);
  background: var(--hd-tab);
}
.hd-gap {
  flex: 1;
}
/* A Mac app: its title in the middle of the bar. */
.hd-title {
  position: absolute;
  left: 50%;
  max-width: calc(100% - 180px);
  overflow: hidden;
  text-overflow: ellipsis;
  transform: translateX(-50%);
  font-weight: 600;
  color: var(--hd-on);
}
/* A browser: its address in a field in the middle. */
.hd-bar-browser {
  gap: 10px;
}
.hd-url {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: min(46%, 420px);
  min-width: 0;
  height: 22px;
  padding: 0 10px;
  border-radius: 6px;
  background: var(--hd-tab);
  color: var(--hd-on);
}
.hd-url svg {
  width: 11px;
  height: 11px;
  color: var(--hd-dim);
}
.hd-url span {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The stage: the app at its design size, scaled as a whole. */
.hd-view {
  --k: 0.6;
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--hd-stage);
}
.hd-stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 1200px;
  height: 750px;
  overflow: hidden;
  transform: scale(var(--k));
  transform-origin: 0 0;
  background: var(--hd-stage);
  color: var(--hd-ink);
  font: 500 13px/1.35 var(--hd-font, system-ui, sans-serif);
  text-align: left;
  user-select: none;
  /* A demo, not the app: nothing in it takes a click. */
  pointer-events: none;
  -webkit-font-smoothing: antialiased;
  animation: hd-in 0.45s cubic-bezier(0.2, 0.7, 0.1, 1) both;
}
@keyframes hd-in {
  from {
    opacity: 0;
  }
}
/* A picture cut from a screenshot (HTMLDemo.crop): the box's part of it
   fills the element it's put in, which the page sizes. */
.hd-crop {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
/* Its geometry holds whatever the page says of its pictures (an
   img { width: 100%; height: 100% } would show the whole screenshot). */
.hd-crop > img {
  position: absolute !important;
  inset: auto !important;
  left: calc(var(--x) / var(--w) * -100%) !important;
  top: calc(var(--y) / var(--h) * -100%) !important;
  width: calc(100% / var(--w)) !important;
  min-width: 0 !important;
  max-width: none !important;
  height: auto !important;
  max-height: none !important;
  margin: 0 !important;
  object-fit: fill !important;
  transform: none !important;
}

/* The pointer: placed from t (glide()), and pressed. */
.hd-cursor {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 30;
  width: 32px;
  height: 32px;
  transition-property: transform, opacity;
  transition-timing-function: cubic-bezier(0.55, 0, 0.25, 1), ease;
}
.hd-cursor svg {
  display: block;
  overflow: visible;
  transform-origin: 5px 5px;
  transform: scale(1.15);
  transition: transform 0.1s;
  filter: drop-shadow(0 1px 1.2px rgba(0, 0, 0, 0.35));
}
.hd-cursor.away {
  opacity: 0;
}
.hd-cursor.press svg {
  transform: scale(0.98);
}

/* The steps along the foot: a number, a name and a line that fills. */
.hd-steps {
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 5px 6px;
  list-style: none;
  background: var(--hd-chrome);
  border-top: 0.5px solid var(--hd-line);
}
.hd-steps li {
  flex: 1 1 0;
  min-width: 0;
}
.hd-steps button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 8px 10px 10px;
  border: 0;
  border-radius: 7px;
  background: none;
  font: 500 12.5px/1.5 var(--hd-font, system-ui, sans-serif);
  color: var(--hd-dim);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition:
    color 0.2s,
    background 0.2s;
}
.hd-steps button:hover,
.hd-steps button.on {
  color: var(--hd-on);
}
.hd-steps button:hover {
  background: var(--hd-hover);
}
.hd-steps button:focus-visible,
.hd-ctl :is(button, input):focus-visible {
  outline: 2px solid var(--hd-focus, #a3abff);
  outline-offset: -2px;
}
.hd-label {
  overflow: hidden;
  text-overflow: ellipsis;
}
.hd-n {
  flex: none;
  font: 500 10.5px/1 var(--hd-mono, ui-monospace, monospace);
  letter-spacing: 0.06em;
  color: var(--hd-faint);
}
.hd-steps button.on .hd-n {
  color: var(--hd-dim);
}
/* The step's line, filled as far as it has played. */
.hd-steps i {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 3px;
  height: 1.5px;
  border-radius: 2px;
  background:
    linear-gradient(90deg, var(--hd-fill) calc(var(--p) * 100%), transparent calc(var(--p) * 100%)),
    var(--hd-track);
}
.hd-steps button:not(.on) i {
  opacity: 0.55;
}

/* The controls under the window (HTMLDemo.controls). */
.hd-ctl {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  margin-top: 18px;
  font: 500 13px/1 var(--hd-font, system-ui, sans-serif);
  color: var(--hd-dim);
}
.hd-ctl-play {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px 0 11px;
  border: 0;
  border-radius: 9px;
  background: var(--hd-tab);
  box-shadow: inset 0 0 0 0.5px var(--hd-ring);
  color: var(--hd-on);
  font: inherit;
  cursor: pointer;
}
.hd-ctl-play:hover {
  background: var(--hd-ring);
}
.hd-ctl-play:disabled {
  opacity: 0.45;
  cursor: default;
}
.hd-ctl-play svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}
.hd-ctl-scrub {
  flex: 1 1 240px;
  display: flex;
  align-items: center;
  gap: 12px;
}
/* The scrubber: a thin track filled as far as the demo has played (--v,
   set from the clock), and a round thumb. */
.hd-ctl-scrub input {
  flex: 1;
  min-width: 0;
  height: 22px;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.hd-ctl-scrub input::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--hd-fill) calc(var(--v, 0) * 100%), var(--hd-track) calc(var(--v, 0) * 100%));
}
.hd-ctl-scrub input::-moz-range-track {
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--hd-fill) calc(var(--v, 0) * 100%), var(--hd-track) calc(var(--v, 0) * 100%));
}
.hd-ctl-scrub input::-webkit-slider-thumb {
  width: 13px;
  height: 13px;
  margin-top: -5px;
  border: 0;
  border-radius: 50%;
  background: var(--hd-on);
  box-shadow: 0 0 0 3px var(--hd-frame), 0 1px 4px rgba(0, 0, 0, 0.3);
  -webkit-appearance: none;
  appearance: none;
}
.hd-ctl-scrub input::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 0;
  border-radius: 50%;
  background: var(--hd-on);
  box-shadow: 0 0 0 3px var(--hd-frame), 0 1px 4px rgba(0, 0, 0, 0.3);
}
.hd-ctl-scrub input:focus-visible {
  outline-offset: 4px;
}
.hd-ctl-scrub output {
  min-width: 84px;
  font: 500 12px/1 var(--hd-mono, ui-monospace, monospace);
  font-variant-numeric: tabular-nums;
  color: var(--hd-fill);
}
.hd-ctl-still {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.hd-ctl-still input {
  margin: 0;
  accent-color: var(--hd-focus, #a3abff);
}
.hd-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 560px) {
  .hd-bar {
    height: 28px;
    padding-left: 10px;
    font-size: 10.5px;
  }
  .hd-lights {
    gap: 5px;
    margin-right: 4px;
  }
  .hd-lights i {
    width: 9px;
    height: 9px;
  }
  .hd-tab:not(.on),
  .hd-bar-browser > svg:not(:first-of-type) {
    display: none;
  }
  .hd-url {
    width: auto;
    flex: 1;
  }
  .hd-title {
    max-width: calc(100% - 110px);
  }
  .hd-steps button {
    gap: 5px;
    padding: 7px 6px 9px;
    font-size: 11px;
  }
  .hd-n {
    display: none;
  }
}

/* Less motion: the end frames stand still, and nothing animates on top. */
@media (prefers-reduced-motion: reduce) {
  .hd-stage,
  .hd-stage *,
  .hd-cursor,
  .hd-cursor svg {
    animation: none !important;
    transition: none !important;
  }
}
