/* The hold on the line: a black page, a line of small type, the time in large figures, the thin line under it with
   its minute ticks and the empty room they drop into, and a line of type with the button at the foot. */
:root {
  --page: #000000;          /* the page */
  --ink: #f1eee7;           /* the figures, the line, the ticks */
  --muted: #8a877f;         /* the small type */
  --track: #262522;         /* the faint line of the whole hold, under the time left */
  --accent: #ff5a2a;        /* the last seconds */
  --on-ink: #0b0b0a;        /* the words on the button under the mouse */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Roboto Flex Variable', 'Roboto Flex', system-ui, sans-serif;
  font-optical-sizing: auto;
  -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: 32px 16px;
}

.hold {
  position: relative;
  display: grid;
  width: min(360px, 100%);
  outline: none;
}

/* ---------------------------------------------------------------- the small type */
.hold__top,
.hold__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.hold__top {
  height: 20px;
}

/* every line of small type sits in a window, so the words can change by rising */
.hold__swap {
  position: relative;
  display: inline-grid;
  overflow: hidden;
  padding: 0.2em 0.04em;
  margin: -0.2em -0.04em;
  font-size: 15px;
  line-height: 1.25;
  font-variation-settings: 'wght' 520, 'wdth' 100;
  letter-spacing: 0.005em;
  white-space: nowrap;
}

.hold__swap > span {
  grid-area: 1 / 1;
}

.hold__swap--meta,
.hold__swap--note {
  color: var(--muted);
  font-variation-settings: 'wght' 430, 'wdth' 100;
}

.hold__swap--meta > span {
  justify-self: end;
}

/* ---------------------------------------------------------------- the time */
.hold__time {
  margin: 22px 0 0;
  /* the figures keep their width (the script changes wdth against wght), so the height is all that is set here */
  height: 0.86em;
  font-size: clamp(96px, 34vw, 132px);
  line-height: 1;
}

.hold__digits {
  display: flex;
  height: 0.86em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  transition: color 0.7s ease;
}

.hold.is-last .hold__digits {
  color: var(--accent);
}

.hold.is-ended .hold__digits {
  color: var(--muted);
}

/* every figure in its place: the old one drops away and the new one comes down into it */
.slot {
  display: inline-grid;
  /* the window is as tall as the ink of the figures (and a hair), so a figure leaving is gone at once */
  height: 0.82em;
  overflow: hidden;
  line-height: 1;
}

.slot > span {
  position: relative;
  top: -0.08em;
  grid-area: 1 / 1;
  text-align: center;
}

/* the colon sits a little higher, between the figures (on the window: GSAP moves what is inside) */
.slot--colon {
  position: relative;
  top: -0.05em;
  margin: 0 0.035em;
  overflow: visible;
}

/* ---------------------------------------------------------------- the line */
.hold__rule {
  position: relative;
  margin-top: 30px;
  height: 190px;
}

.hold__svg {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  overflow: visible;
}

.hold__track,
.hold__line {
  fill: none;
  stroke-linecap: butt;
}

.hold__track {
  stroke: var(--track);
  stroke-width: 1;
}

.hold__line {
  stroke: var(--ink);
  stroke-width: 1.5;
  transition: stroke 0.7s ease;
}

.hold__ticks path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-linecap: butt;
  transition: stroke 0.7s ease;
}

.hold.is-last .hold__line,
.hold.is-last .hold__ticks path {
  stroke: var(--accent);
}

/* ---------------------------------------------------------------- the foot and the button */
.hold__foot {
  height: 48px;
}

.hold__again {
  position: relative;
  display: grid;
  place-items: center;
  height: 48px;
  padding: 0 22px;
  overflow: hidden;
  border: 0;
  border-radius: 24px;
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(241, 238, 231, 0.42);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow 0.3s ease, color 0.25s ease;
}

.hold__again[hidden] {
  display: none;
}

/* the fill swells out from the middle with a small bounce */
.hold__fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--ink);
  transform: scale(0.88, 0.5);
  opacity: 0;
  transition: transform 0.55s cubic-bezier(0.3, 1.6, 0.5, 1), opacity 0.12s ease;
}

/* the words widen on the wdth axis */
.hold__words {
  position: relative;
  font-variation-settings: 'wght' 560, 'wdth' 100;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: font-variation-settings 0.5s cubic-bezier(0.3, 1.6, 0.5, 1);
}

@media (hover: hover) {
  .hold__again:hover {
    color: var(--on-ink);
    box-shadow: inset 0 0 0 1px var(--ink);
  }

  .hold__again:hover .hold__fill {
    transform: scale(1);
    opacity: 1;
  }

  .hold__again:hover .hold__words {
    font-variation-settings: 'wght' 600, 'wdth' 122;
  }
}

/* a finger gets the same as the mouse while it presses */
.hold__again:active,
.hold__again.is-pressed {
  color: var(--on-ink);
}

.hold__again:active .hold__fill,
.hold__again.is-pressed .hold__fill {
  transform: scale(1);
  opacity: 1;
}

.hold__again:active .hold__words,
.hold__again.is-pressed .hold__words {
  font-variation-settings: 'wght' 600, 'wdth' 122;
}

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

@media (prefers-reduced-motion: reduce) {
  .hold__fill {
    transform: none;
    transition: opacity 0.25s ease;
  }

  .hold__words {
    transition: none;
  }
}
