/* The time clock button: an oxblood enamelled pill on a white page, built as a factory time recorder. The dial is an
   SVG, the machine and its slot are CSS, and the time card is a canvas drawn by script.js: the board, its printed
   rules and the ink of every stamp (its colours come from here). */
:root {
  --page: #ffffff;          /* the page */
  --enamel: #8a2a22;        /* the machine's enamel, at its top */
  --enamel-deep: #5a1712;   /* the enamel at its foot */
  --ink: #fbf1e1;           /* the words on the machine */
  --muted: #e4b9a9;         /* the small line over the words, and the words while it works */
  --dial: #efe4c9;          /* the dial */
  --dial-light: #fffaf0;    /* the dial where the light falls */
  --hands: #1d1715;         /* the hands and the ticks */
  --cap: #c6392b;           /* the cap on the hands' arbor */
  --slot: #1c0806;          /* the inside of the slot */
  --board: #ead9ac;         /* the time card, manila board */
  --rule: #7d9cc0;          /* the rules printed on the card */
  --print: #a33a2a;         /* the name printed at the top of the card */
  --stamp-in: #3e2f8f;      /* the ink of the stamp in: a violet ribbon */
  --stamp-out: #c42a1e;     /* the ink of the stamp out: the red half of the ribbon */
  --focus: #5a1712;         /* the ring of the keyboard's focus */
}

* {
  box-sizing: border-box;
}

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

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

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--enamel-deep);
  font-family: 'Archivo Variable', 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

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

/* the machine, and over it the room the card takes when it stands out of the slot */
.clock {
  position: relative;
  display: grid;
  justify-items: center;
}

/* ---------------------------------------------------------------- the card */
/* a window whose bottom edge is the slot: the card is cut there, so it goes into the machine. It is wider than the
   card, so the card can rock in the slot */
.clock__card-win {
  position: absolute;
  z-index: 2;
  /* the script sets left from where the slot is */
  left: 0;
  bottom: 52.5px;
  width: 100px;
  height: 150px;
  overflow: hidden;
  pointer-events: none;
}

.clock__card {
  position: absolute;
  left: 20px;
  top: 150px;
  width: 60px;
  height: 74px;
  transform-origin: 50% 100%;
  will-change: transform;
  filter: drop-shadow(0 1px 1.2px rgba(60, 30, 10, 0.28));
}

/* ---------------------------------------------------------------- the machine */
.clock__btn {
  position: relative;
  display: block;
  /* the script sets the width from the longest words; this is the width before it does */
  width: 270px;
  max-width: calc(100vw - 32px);
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.clock__btn[aria-disabled='true'] {
  cursor: progress;
}

/* the enamel is a layer of its own, so it can swell past the pill with a bounce, and squash when the machine strikes */
.clock__fill {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background:
    radial-gradient(70% 120% at 30% 0%, rgba(255, 255, 255, 0.16), transparent 58%),
    linear-gradient(180deg, var(--enamel), var(--enamel-deep));
  box-shadow:
    inset 0 1.5px 0 rgba(255, 235, 220, 0.28),
    inset 0 -2px 3px rgba(0, 0, 0, 0.3),
    0 1px 2px rgba(60, 12, 8, 0.3),
    0 16px 26px -14px rgba(60, 12, 8, 0.6);
  transform-origin: 50% 100%;
  transition: inset 0.6s cubic-bezier(0.34, 1.9, 0.45, 1);
}

.clock__btn:focus-visible {
  outline: 2.5px solid var(--focus);
  outline-offset: 5px;
}

html[data-using='pointer'] .clock__btn:focus-visible {
  outline: none;
}

/* the slot along the top: a dark slit with nickel lips, sunk in the enamel */
.clock__slot {
  position: absolute;
  top: 3.5px;
  /* the script sets left and width from the card */
  left: 150px;
  width: 76px;
  height: 7px;
  border-radius: 4px;
  background: linear-gradient(180deg, #000 0%, var(--slot) 55%, color-mix(in srgb, var(--slot) 70%, #fff) 100%);
  box-shadow:
    0 0 0 1.4px #d9dcdf,
    0 1.6px 0 1.2px #8c9298,
    0 -0.6px 0 1.4px #ffffff,
    0 2.5px 3px 1px rgba(0, 0, 0, 0.35);
}

/* the dial in the round left end: nickel bezel, cream face, and the hands at the time of the computer */
.clock__dial {
  position: absolute;
  left: 7px;
  top: 7px;
  width: 46px;
  height: 46px;
  overflow: visible;
  filter: drop-shadow(0 1.5px 1.5px rgba(40, 6, 4, 0.5));
}

.clock__stop-light {
  stop-color: var(--dial-light);
}

.clock__stop {
  stop-color: var(--dial);
}

.clock__rim {
  fill: none;
  stroke: rgba(0, 0, 0, 0.32);
  stroke-width: 1.2;
}

.clock__ticks {
  stroke: var(--hands);
  stroke-linecap: butt;
}

.clock__hand {
  fill: var(--hands);
}

.clock__cap {
  fill: var(--cap);
  stroke: rgba(0, 0, 0, 0.35);
  stroke-width: 0.4;
}

/* the glass: a soft sheen on the upper left */
.clock__glass {
  fill: none;
  stroke: rgba(255, 255, 255, 0.5);
  stroke-width: 0.8;
  stroke-dasharray: 22 200;
  stroke-dashoffset: -66;
  stroke-linecap: round;
}

/* ---------------------------------------------------------------- the words */
.clock__faces {
  position: absolute;
  top: 9px;
  bottom: 0;
  left: 66px;
  right: 0;
  pointer-events: none;
}

.clock__face {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: max-content;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 4px;
  text-align: left;
  white-space: nowrap;
}

.clock__face[aria-hidden='true'] {
  opacity: 0;
  visibility: hidden;
}

.clock__lead {
  font-size: 11.5px;
  font-weight: 560;
  font-stretch: 100%;
  letter-spacing: 0.01em;
  line-height: 1;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* the action widens on the typeface's width axis under the pointer; the wide copy, invisible and zero high, holds its
   room, so nothing moves */
.clock__word {
  display: inline-grid;
  font-size: 17px;
  font-weight: 660;
  font-stretch: 100%;
  letter-spacing: -0.005em;
  line-height: 1;
  transition: font-stretch 0.6s cubic-bezier(0.34, 1.9, 0.45, 1), font-weight 0.6s cubic-bezier(0.34, 1.9, 0.45, 1);
}

.clock__word::before {
  content: attr(data-wide);
  height: 0;
  overflow: hidden;
  visibility: hidden;
  font-stretch: 116%;
  font-weight: 720;
}

/* while it works: the words in a quieter tone, with a sheen running through them */
.clock__shine {
  font-size: 17px;
  font-weight: 580;
  letter-spacing: -0.004em;
  line-height: 1;
  color: var(--muted);
  background: linear-gradient(100deg, var(--muted) 0%, var(--muted) 38%, var(--ink) 50%, var(--muted) 62%, var(--muted) 100%);
  background-size: 260% 100%;
  background-position: var(--sheen, 100%) 0;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* done: the words alone, large, before they shrink into the small line; the figures of the time roll in like type
   wheels */
.clock__big {
  font-size: 17px;
  font-weight: 660;
  letter-spacing: -0.005em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transform-origin: 0 0;
}

.clock__digit {
  display: inline-block;
}

/* ---------------------------------------------------------------- under the pointer */
@media (hover: hover) and (pointer: fine) {
  .clock__btn:not([aria-disabled='true']):hover .clock__fill {
    inset: -2px -7px;
  }

  .clock__btn:not([aria-disabled='true']):hover .clock__word {
    font-stretch: 116%;
    font-weight: 720;
  }
}

/* the keys bring the focus: the words widen as under the pointer */
html[data-using='keys'] .clock__btn:focus-visible .clock__word {
  font-stretch: 116%;
  font-weight: 720;
}

/* ---------------------------------------------------------------- reduced motion: no swelling, no widening */
@media (prefers-reduced-motion: reduce) {
  .clock__fill,
  .clock__word {
    transition: filter 0.3s ease;
  }

  html[data-using='keys'] .clock__btn:focus-visible .clock__word {
    font-stretch: 100%;
    font-weight: 660;
  }
}

@media (prefers-reduced-motion: reduce) and (hover: hover) and (pointer: fine) {
  .clock__btn:not([aria-disabled='true']):hover .clock__fill {
    inset: 0;
    filter: brightness(1.12);
  }

  .clock__btn:not([aria-disabled='true']):hover .clock__word {
    font-stretch: 100%;
    font-weight: 660;
  }
}
