Back to the library

Safeguard — arm, then fire

Variant: Arm, then fire

The guarded switch from every control panel that can do something irreversible: a clear cover over the button, lifted to arm it. The cover is see-through on purpose — a guard that hides its control turns “protected” into “missing” — and it lifts on a 280ms ease-out because it answers a hand. Lifting opens a 2s arming window drawn as a linear rail, starting on the frame the cover is fully up rather than at the touch, since only then is the button reachable. The first time nobody presses, and the cover drops back on its own in 200ms, decelerating — faster than it rose, because safe is the direction that should never be slow, and an eased-in return would leave it hanging open after the window had shut. The second time the press lands inside the window, the rail freezes at 76% and fades, the label rolls to a slate “Wipe sent” — done, no longer dangerous — and the cover closes over the result. Reach for it on wipe, force-push and anything a stray click must not be able to reach, where a confirm dialog would be dismissed by habit.

controlconfirmationmicro-interactionloop

The source

A complete HTML document. Paste it into an empty .html file and it plays — no stylesheet, script, font, or image to fetch.

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Safeguard — arm, then fire</title>
    <style>
      :root {
        /* Neutrals — fixed, never remixed. */
        --ivory: #faf9f5;
        --paper: #ffffff;
        --oat: #e3dacc;
        --slate: #141413;

        /* Knobs — the remix API. A knob exists iff declared here and used below. */
        --hue: 38.8;
        --lift: 0;
        --chroma: 1;
        --round: 1;
        --speed: 1;

        /* Accents — derived from the knobs with the family's offsets baked in,
           so one hue roll moves them together. Defaults reproduce the original hex. */
        --clay: oklch(calc(0.6724 + var(--lift)) calc(0.1308 * var(--chroma)) var(--hue));
        --clay-d: oklch(calc(0.5797 + var(--lift)) calc(0.127 * var(--chroma)) var(--hue));
        --olive: oklch(
          calc(0.6118 + var(--lift)) calc(0.0713 * var(--chroma)) calc(var(--hue) + 88.3)
        );
        --rust: oklch(
          calc(0.5408 + var(--lift)) calc(0.1357 * var(--chroma)) calc(var(--hue) - 10.3)
        );

        /* Clock — 6.4s for both endings. The first arming is left to lapse, the
           second is spent; a guard that is only ever lifted and fired documents
           the easy half. The arming window inside it is 2s of that. */
        --cycle: 6.4s;
        --t: calc(var(--cycle) / var(--speed));

        --_w: min(280px, 88vw);

        --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
        --ease-accent: cubic-bezier(0.32, 0.72, 0, 1);
      }

      * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
      }

      body {
        min-height: 100vh;
        display: grid;
        place-items: center;
        background: var(--ivory);
        font-family:
          system-ui,
          -apple-system,
          'Segoe UI',
          Roboto,
          sans-serif;
        color: var(--slate);
      }

      .stage {
        position: relative;
        width: var(--_w);
        height: 160px;
        animation: rearm var(--t) infinite;
      }

      .well {
        position: absolute;
        left: calc(50% - 88px);
        top: 44px;
        width: 176px;
        height: 50px;
        perspective: 340px;
        perspective-origin: 50% -10px;
      }

      .btn {
        position: absolute;
        inset: 0;
        overflow: hidden;
        border-radius: calc(10px * var(--round));
        background: var(--paper);
        border: 1px solid color-mix(in srgb, var(--rust) 42%, var(--oat));
        color: var(--rust);
        font-size: 14px;
        font-weight: 600;
        letter-spacing: -0.01em;
        animation: press var(--t) infinite;
      }

      .roll {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 96px;
        animation: fire var(--t) infinite;
      }

      .roll span {
        display: grid;
        place-items: center;
        height: 48px;
      }

      /* Sent is done, not dangerous: the outcome drops the rust. */
      .roll span:last-child {
        color: var(--slate);
      }

      /* The cover is clear, not opaque: what it guards stays legible through
         it, because a guard that hides the control turns "protected" into
         "missing". It hinges from its top edge, and the lip is the only part
         the pointer ever touches. */
      .lid {
        position: absolute;
        left: -5px;
        top: -5px;
        width: 186px;
        height: 60px;
        border-radius: calc(12px * var(--round));
        border: 1px solid color-mix(in srgb, var(--slate) 26%, var(--oat));
        background:
          repeating-linear-gradient(
            135deg,
            color-mix(in srgb, var(--slate) 10%, transparent) 0 1.5px,
            transparent 1.5px 7px
          ),
          color-mix(in srgb, var(--paper) 46%, transparent);
        transform-origin: 50% 0;
        animation: lid var(--t) infinite;
      }

      .lid::after {
        content: '';
        position: absolute;
        left: calc(50% - 15px);
        bottom: -5px;
        width: 30px;
        height: 7px;
        border-radius: 999px;
        background: color-mix(in srgb, var(--slate) 32%, var(--oat));
      }

      .hinge {
        position: absolute;
        left: calc(50% - 80px);
        top: 37px;
        width: 160px;
        height: 3px;
        border-radius: 999px;
        background: color-mix(in srgb, var(--slate) 30%, var(--oat));
      }

      .rail {
        position: absolute;
        left: calc(50% - 88px);
        top: 108px;
        width: 176px;
        height: 3px;
        border-radius: 999px;
        background: var(--oat);
        overflow: hidden;
      }

      .rail i {
        position: absolute;
        inset: 0;
        background: var(--clay);
        transform-origin: 0 50%;
        transform: scaleX(0);
        opacity: 0;
        animation: window var(--t) infinite;
      }

      .caption {
        position: absolute;
        left: 0;
        right: 0;
        top: 120px;
        height: 18px;
        font-size: 12px;
        font-weight: 500;
        text-align: center;
        font-variant-numeric: tabular-nums;
      }

      .caption span {
        position: absolute;
        inset: 0;
        opacity: 0;
        color: color-mix(in srgb, var(--slate) 62%, var(--ivory));
      }

      .caption .safe {
        animation: c-safe var(--t) infinite;
      }
      .caption .armed {
        color: var(--clay-d);
        animation: c-armed var(--t) infinite;
      }
      .caption .lapsed {
        animation: c-lapsed var(--t) infinite;
      }
      .caption .sent {
        color: var(--slate);
        animation: c-sent var(--t) infinite;
      }

      .ghost {
        position: absolute;
        left: 0;
        top: 0;
        width: 14px;
        height: 18px;
        transform: translate(calc(var(--_w) * 0.12), 140px);
        animation: travel var(--t) infinite;
      }

      .arrow {
        display: block;
        width: 100%;
        height: 100%;
        fill: var(--slate);
        stroke: var(--ivory);
        stroke-width: 1.4;
        stroke-linejoin: round;
      }

      /* Lifting answers the hand, so it decelerates: 280ms on ease-out. The
         return gets 200ms, also decelerating: re-covering is the safe
         direction, so it is the faster one, and a curve that eased in would
         leave the cover hanging open after the window had already closed. */
      @keyframes lid {
        0%,
        13.75% {
          transform: rotateX(0deg);
          animation-timing-function: var(--ease-out);
        }
        18.125%,
        49.375% {
          transform: rotateX(-104deg);
          animation-timing-function: var(--ease-out);
        }
        52.5%,
        63.44% {
          transform: rotateX(0deg);
          animation-timing-function: var(--ease-out);
        }
        67.81%,
        82.81% {
          transform: rotateX(-104deg);
          animation-timing-function: var(--ease-out);
        }
        85.94%,
        100% {
          transform: rotateX(0deg);
        }
      }

      /* The window is a clock, so it drains linear, and it starts on the frame
         the cover is fully up — not at the touch — because only then is the
         control actually reachable. On the second pass the press stops it at
         76%: what is left over is not refunded, it is simply no longer needed. */
      @keyframes window {
        0%,
        18.12% {
          transform: scaleX(0);
          opacity: 0;
        }
        18.125% {
          transform: scaleX(1);
          opacity: 1;
          animation-timing-function: linear;
        }
        49.375%,
        67.8% {
          transform: scaleX(0);
          opacity: 1;
        }
        67.81% {
          transform: scaleX(1);
          opacity: 1;
          animation-timing-function: linear;
        }
        75.31% {
          transform: scaleX(0.76);
          opacity: 1;
          animation-timing-function: var(--ease-out);
        }
        77.5%,
        100% {
          transform: scaleX(0.76);
          opacity: 0;
        }
      }

      @keyframes press {
        0%,
        73.44% {
          transform: scale(1);
          animation-timing-function: var(--ease-out);
        }
        75% {
          transform: scale(0.97);
          animation-timing-function: var(--ease-out);
        }
        77.5%,
        100% {
          transform: scale(1);
        }
      }

      @keyframes fire {
        0%,
        75.31% {
          transform: translateY(0);
          animation-timing-function: var(--ease-accent);
        }
        77.19%,
        93.74% {
          transform: translateY(-48px);
        }
        93.75%,
        100% {
          transform: translateY(0);
        }
      }

      /* Each caption leaves before the next arrives, so no two states are
         ever half-legible on the same frame. */
      @keyframes c-safe {
        0%,
        13.75% {
          opacity: 1;
          animation-timing-function: var(--ease-out);
        }
        14.7%,
        93.74% {
          opacity: 0;
        }
        93.75%,
        100% {
          opacity: 1;
        }
      }

      @keyframes c-armed {
        0%,
        18.125% {
          opacity: 0;
          animation-timing-function: var(--ease-out);
        }
        19.5%,
        48.5% {
          opacity: 1;
          animation-timing-function: var(--ease-out);
        }
        49.375%,
        67.81% {
          opacity: 0;
          animation-timing-function: var(--ease-out);
        }
        69.2%,
        74.5% {
          opacity: 1;
          animation-timing-function: var(--ease-out);
        }
        75.31%,
        100% {
          opacity: 0;
        }
      }

      @keyframes c-lapsed {
        0%,
        52.5% {
          opacity: 0;
          animation-timing-function: var(--ease-out);
        }
        53.9%,
        63.44% {
          opacity: 1;
          animation-timing-function: var(--ease-out);
        }
        64.4%,
        100% {
          opacity: 0;
        }
      }

      @keyframes c-sent {
        0%,
        75.31% {
          opacity: 0;
          animation-timing-function: var(--ease-out);
        }
        76.7%,
        93.74% {
          opacity: 1;
        }
        93.75%,
        100% {
          opacity: 0;
        }
      }

      @keyframes travel {
        0%,
        6.25% {
          transform: translate(calc(var(--_w) * 0.12), 140px);
          animation-timing-function: var(--ease-out);
        }
        12.5%,
        13.75% {
          transform: translate(calc(var(--_w) * 0.5 - 1px), 98px);
          animation-timing-function: var(--ease-out);
        }
        18.125% {
          transform: translate(calc(var(--_w) * 0.5 + 6px), 30px);
          animation-timing-function: var(--ease-out);
        }
        21.875% {
          transform: translate(calc(var(--_w) * 0.5 + 6px), 30px);
          animation-timing-function: var(--ease-out);
        }
        28.125%,
        57.81% {
          transform: translate(calc(var(--_w) * 0.84), 126px);
          animation-timing-function: var(--ease-out);
        }
        62.5%,
        63.44% {
          transform: translate(calc(var(--_w) * 0.5 - 1px), 98px);
          animation-timing-function: var(--ease-out);
        }
        67.81% {
          transform: translate(calc(var(--_w) * 0.5 + 6px), 30px);
          animation-timing-function: var(--ease-out);
        }
        72.5%,
        78.125% {
          transform: translate(calc(var(--_w) * 0.5 + 10px), 66px);
          animation-timing-function: var(--ease-out);
        }
        84.375%,
        100% {
          transform: translate(calc(var(--_w) * 0.12), 140px);
        }
      }

      /* The panel goes dark for 200ms and resets inside it, so the loop never
         shows a sent command being taken back. */
      @keyframes rearm {
        0%,
        90.625% {
          opacity: 1;
          animation-timing-function: var(--ease-out);
        }
        93.75%,
        95% {
          opacity: 0;
          animation-timing-function: var(--ease-out);
        }
        100% {
          opacity: 1;
        }
      }

      @media (prefers-reduced-motion: reduce) {
        /* The pointer parks and the cover stops swinging: it crossfades
           between down and gone. The window and the captions stay, slowed by
           half again — they are the whole report of what the guard is doing. */
        .ghost {
          opacity: 0;
          animation: none;
        }

        .lid {
          animation: lid-fade calc(var(--t) * 1.5) infinite;
        }

        .stage {
          animation: rearm calc(var(--t) * 1.5) infinite;
        }

        .btn {
          animation: none;
        }

        .roll {
          animation: fire-step calc(var(--t) * 1.5) infinite;
        }

        .rail i {
          animation: window calc(var(--t) * 1.5) infinite;
        }

        .caption .safe {
          animation: c-safe calc(var(--t) * 1.5) infinite;
        }
        .caption .armed {
          animation: c-armed calc(var(--t) * 1.5) infinite;
        }
        .caption .lapsed {
          animation: c-lapsed calc(var(--t) * 1.5) infinite;
        }
        .caption .sent {
          animation: c-sent calc(var(--t) * 1.5) infinite;
        }

        /* Keyframe-level curves override the animation's own, so the
           stepped roll needs its own hard stops rather than steps(). */
        @keyframes fire-step {
          0%,
          75.3% {
            transform: translateY(0);
          }
          75.31%,
          93.74% {
            transform: translateY(-48px);
          }
          93.75%,
          100% {
            transform: translateY(0);
          }
        }

        @keyframes lid-fade {
          0%,
          13.75% {
            opacity: 1;
            animation-timing-function: var(--ease-out);
          }
          18.125%,
          49.375% {
            opacity: 0;
            animation-timing-function: var(--ease-out);
          }
          52.5%,
          63.44% {
            opacity: 1;
            animation-timing-function: var(--ease-out);
          }
          67.81%,
          82.81% {
            opacity: 0;
            animation-timing-function: var(--ease-out);
          }
          85.94%,
          100% {
            opacity: 1;
          }
        }
      }
    </style>
  </head>
  <body>
    <div
      class="stage"
      role="img"
      aria-label="A Wipe device button under a clear hinged cover. The cover is lifted and a two-second arming window drains; nobody presses, so the cover drops back. It is lifted again, the button is pressed inside the window and the label rolls over to Wipe sent"
    >
      <span class="hinge"></span>
      <div class="well">
        <div class="btn">
          <div class="roll">
            <span>Wipe device</span>
            <span>Wipe sent</span>
          </div>
        </div>
        <div class="lid"></div>
      </div>
      <div class="rail"><i></i></div>
      <div class="caption">
        <span class="safe">Covered · safe</span>
        <span class="armed">Armed · 2s to act</span>
        <span class="lapsed">Window lapsed · covered again</span>
        <span class="sent">Sent with 1.5s to spare</span>
      </div>
      <span class="ghost">
        <svg class="arrow" viewBox="0 0 14 18" xmlns="http://www.w3.org/2000/svg">
          <path d="M1 1 L1 14.8 L4.5 11.6 L6.7 16.6 L9.3 15.4 L7.1 10.5 L11.8 10.3 Z" />
        </svg>
      </span>
    </div>
  </body>
</html>

The variant family

Same idea, one axis moved. Compare them side by side before you commit.