/* The focus timer with the glass ring that empties: the timer card of a productivity app, Orrin, on black. The ring
   is a canvas drawn every frame (the glass, the liquid, its meniscus, the light); the digits, the labels and the
   buttons are plain HTML on top. The size of the ring follows the width and the height of the window. */
:root {
  --page: #000000;          /* the page */
  --card: #0d0e12;          /* the body of the card */
  --card-top: #15171d;      /* the top of the card, where the light falls */
  --edge: rgba(255, 255, 255, 0.075); /* the card's edge */
  --ink: #eef0f4;           /* the words */
  --muted: #7d828f;         /* the small words */
  --focus: #43e6c4;         /* the liquid of the focus session */
  --rest: #ffb347;          /* the liquid of the break */
  --button: #eef0f4;        /* the main button */
  --button-ink: #0b0c0f;    /* the words on the main button */
}

* {
  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: 'Mona Sans Variable', system-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: 12px;
  overflow: hidden;
}

/* ---------------------------------------------------------------- the card */
.timer {
  --ring: min(64vw, 45vh, 240px);
  --tint: var(--focus);
  position: relative;
  width: min(90vw, 328px);
  padding: clamp(14px, 4.2vh, 20px) clamp(14px, 4.6vw, 20px) clamp(13px, 3.8vh, 18px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: clamp(9px, 3vh, 15px);
  border-radius: 26px;
  background: linear-gradient(180deg, var(--card-top), var(--card) 46%);
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 1px 1px rgba(0, 0, 0, 0.5),
    0 20px 40px -18px rgba(0, 0, 0, 0.9),
    0 50px 90px -40px color-mix(in srgb, var(--tint) 22%, transparent);
  isolation: isolate;
  opacity: 0;
}

/* the light of the liquid falling on the card, under the ring */
.timer__glow {
  position: absolute;
  left: 50%;
  top: 44%;
  width: calc(var(--ring) * 1.5);
  height: calc(var(--ring) * 1.5);
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--tint) 20%, transparent), transparent 72%);
  opacity: 0.6;
  pointer-events: none;
  z-index: -1;
}

.timer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  line-height: 1;
}

.timer__brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 640;
  font-stretch: 108%;
  letter-spacing: -0.01em;
}

.timer__mark {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--tint);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.timer__chip {
  position: relative;
  display: inline-grid;
  height: 24px;
  padding: 0 10px;
  align-items: center;
  overflow: hidden;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 560;
  letter-spacing: 0.01em;
  color: color-mix(in srgb, var(--tint) 80%, white);
  background: color-mix(in srgb, var(--tint) 11%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tint) 24%, transparent);
}

.timer__chip-words {
  display: block;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- the ring */
.ring {
  position: relative;
  width: var(--ring);
  height: var(--ring);
  margin: 0 auto;
}

.ring__glass {
  position: absolute;
  left: -14%;
  top: -14%;
  width: 128%;
  height: 128%;
  pointer-events: none;
}

.ring__face {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: calc(var(--ring) * 0.025);
}

.ring__time {
  margin: 0;
  display: flex;
  align-items: center;
  font-size: calc(var(--ring) * 0.205);
  font-weight: 560;
  font-stretch: 94%;
  letter-spacing: -0.03em;
  line-height: 1;
  text-shadow: 0 0 calc(var(--ring) * 0.08) color-mix(in srgb, var(--tint) 30%, transparent);
}

.ring__colon {
  display: block;
  padding: 0 0.02em 0.08em;
  color: var(--muted);
  font-weight: 420;
}

/* one window per digit; the strip inside rolls */
.dig {
  position: relative;
  display: block;
  width: 0.6em;
  height: 1.1em;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
  mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
}

.dig__strip {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  display: block;
}

.dig__strip > span {
  display: block;
  height: 1.1em;
  line-height: 1.1em;
  text-align: center;
}

.ring__label {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 18px;
  overflow: hidden;
  font-size: calc(var(--ring) * 0.056);
  font-weight: 540;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.ring__label-words {
  display: block;
}

.ring__check {
  width: 0;
  height: 13px;
  fill: none;
  stroke: var(--tint);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

/* ---------------------------------------------------------------- the buttons */
.controls {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 8px;
}

.btn {
  position: relative;
  height: clamp(40px, 11vh, 46px);
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn__face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  overflow: hidden;
  border-radius: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

.btn--main .btn__face {
  background: linear-gradient(180deg, #ffffff, var(--button));
  color: var(--button-ink);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.6),
    0 10px 22px -12px color-mix(in srgb, var(--tint) 60%, transparent);
}

.btn--ghost .btn__face {
  background: rgba(255, 255, 255, 0.045);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.btn__icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: currentColor;
}

.btn__skip {
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.btn__words {
  display: block;
  min-width: 3.6em;
  text-align: left;
}

.btn--ghost .btn__words {
  min-width: 0;
}

.btn:focus-visible {
  outline: none;
}

.btn:focus-visible .btn__face {
  box-shadow: 0 0 0 2px var(--page), 0 0 0 4px color-mix(in srgb, var(--tint) 80%, white);
}

@media (hover: hover) {
  .btn--main:hover .btn__face {
    box-shadow:
      inset 0 1px 0 #ffffff,
      inset 0 -1px 0 rgba(0, 0, 0, 0.12),
      0 1px 2px rgba(0, 0, 0, 0.6),
      0 14px 28px -12px color-mix(in srgb, var(--tint) 85%, transparent);
  }

  .btn--ghost:hover .btn__face {
    background: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  }
}

/* ---------------------------------------------------------------- the day */
.today {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: clamp(9px, 2.8vh, 13px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 12.5px;
  color: var(--muted);
}

.today__words {
  margin: 0;
  display: block;
  white-space: nowrap;
}

.today__num {
  display: inline-block;
  height: 1.25em;
  vertical-align: -0.3em;
  overflow: hidden;
  color: var(--ink);
  font-weight: 620;
  font-variant-numeric: tabular-nums;
}

.today__roll {
  display: block;
  line-height: 1.25em;
}

.today__bars {
  display: flex;
  gap: 4px;
}

.today__bar {
  position: relative;
  width: 18px;
  height: 4px;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.09);
}

.today__bar > i {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--focus);
  box-shadow: 0 0 6px color-mix(in srgb, var(--focus) 60%, transparent);
  transform-origin: 0 50%;
  transform: scaleX(0);
}

@media (max-width: 360px) {
  .today__bar {
    width: 13px;
  }
}
