/* The incense timer: a celadon bowl of ash on a black page with a stick of incense standing in it, the smoke rising
   above it, the time under the bowl and the two buttons under that. */
:root {
  --page: #000000;          /* the page */
  --ink: #efe9de;           /* the time and the words */
  --muted: #8e897e;         /* the state under the time */
  --line: #2c2b28;          /* the ring of the start over button */
  --glaze: #9dbba8;         /* the celadon glaze of the bowl, and the main button */
  --glaze-deep: #3b5547;    /* the glaze in shadow */
  --on-glaze: #11241a;      /* the words on the main button */
  --clay: #7d6651;          /* the unglazed foot of the bowl */
  --bed: #b3a68f;           /* the ash the stick stands in */
  --ash: #cfc9bf;           /* the ash on the burning tip */
  --stick: #4c3729;         /* the incense */
  --reed: #b8442e;          /* the bare reed at its foot */
  --ember: #ff7c35;         /* the burning tip */
  --smoke: #dfe1e4;         /* the smoke as it ages */
  --smoke-young: #a6b6d2;   /* the smoke just off the stick */
}

* {
  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: 'Newsreader Variable', Georgia, 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: 32px 16px;
}

.sit {
  position: relative;
  display: grid;
  justify-items: center;
  width: min(320px, 100%);
}

/* ---------------------------------------------------------------- the bowl and the smoke */
.sit__scene {
  position: relative;
  width: 100%;
  aspect-ratio: 320 / 300;
  /* a finger drawn through the smoke stirs it, and does not scroll the page */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.sit__canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------------------------------------------------------------- the time */
.sit__readout {
  display: grid;
  justify-items: center;
  gap: 2px;
  margin-top: 10px;
}

.sit__time {
  display: block;
}

.sit__digits {
  display: flex;
  font-size: 58px;
  font-weight: 300;
  font-variation-settings: 'opsz' 72;
  font-variant-numeric: lining-nums tabular-nums;
  line-height: 1;
  letter-spacing: -0.01em;
}

/* every figure in its own place, so it can rise away like smoke and the next can come up under it */
.fig {
  position: relative;
  display: block;
  width: 0.5em;
  height: 1.1em;
}

.fig--colon {
  width: 0.26em;
}

.fig > span,
.sit__state > span,
.sit__words > span {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  white-space: nowrap;
}

.fig > span {
  top: 0.04em;
}

.sit__state {
  position: relative;
  width: 160px;
  height: 22px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 420;
  font-style: italic;
  font-variation-settings: 'opsz' 16;
  letter-spacing: 0.005em;
}

.sit__state > span {
  top: 0;
}

/* ---------------------------------------------------------------- the buttons */
.sit__controls {
  display: grid;
  grid-template-columns: 48px auto 48px;
  align-items: center;
  gap: 16px;
  margin-top: 22px;
}

.sit__reset {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--line);
  cursor: pointer;
  transition: box-shadow 0.25s ease, opacity 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.sit__reset[aria-disabled='true'] {
  opacity: 0.32;
  cursor: default;
}

/* the arrow turns back a little under the mouse (the wrapper, for the CSS) and a whole turn when pressed (the
   drawing, for GSAP) */
.sit__turn {
  display: grid;
  place-items: center;
  transition: rotate 0.5s cubic-bezier(0.3, 1.7, 0.5, 1);
}

.sit__reset svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sit__go {
  position: relative;
  width: 150px;
  height: 56px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 28px;
  /* the same celadon as the bowl, glazed: lighter where the light falls, a darker pool at the bottom edge */
  background:
    radial-gradient(120% 150% at 28% -10%, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0) 58%),
    linear-gradient(180deg, rgba(255, 255, 255, 0) 55%, rgba(20, 45, 32, 0.22)),
    var(--glaze);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    inset 0 -1px 0 rgba(10, 30, 20, 0.25);
  color: var(--on-glaze);
  font: inherit;
  font-size: 18px;
  font-weight: 560;
  font-variation-settings: 'opsz' 18;
  letter-spacing: 0.005em;
  cursor: pointer;
  transition: transform 0.16s ease-out, filter 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}

.sit__go:active {
  transform: scale(0.97);
}

/* the glaze catches the light: a soft sheen that slides across under the mouse */
.sit__go::before {
  content: '';
  position: absolute;
  top: -30%;
  bottom: -30%;
  left: -10%;
  width: 60%;
  background: radial-gradient(50% 50% at 50% 50%, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0));
  opacity: 0;
  transform: translateX(-70%) skewX(-12deg);
  transition: transform 0.75s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease;
  pointer-events: none;
}

.sit__words {
  position: absolute;
  inset: 0;
}

.sit__words > span {
  top: 50%;
  margin-top: -0.62em;
  line-height: 1.24;
}

.sit__balance {
  width: 48px;
}

@media (hover: hover) {
  .sit__reset:not([aria-disabled='true']):hover {
    box-shadow: inset 0 0 0 1.5px var(--muted);
  }

  .sit__reset:not([aria-disabled='true']):hover .sit__turn {
    rotate: -50deg;
  }

  .sit__go:hover {
    filter: brightness(1.05);
  }

  .sit__go:hover::before {
    opacity: 1;
    transform: translateX(150%) skewX(-12deg);
  }
}

.sit__reset:focus-visible,
.sit__go:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

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

  .sit__go::before {
    display: none;
  }

  .sit__go:active {
    transform: none;
  }
}
