:root {
  --primary: #05a55d;
  --on-surface-variant: #52525c;
  --stage: #4c4c4c;
  --motion-standard: cubic-bezier(0.2, 0, 0, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--stage);
}

.demo-stage {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.checkbox {
  position: relative;
  display: grid;
  width: 48px;
  height: 48px;
  padding: 4px;
  place-items: center;
  border: 0;
  background: transparent;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.state-layer {
  display: grid;
  width: 40px;
  height: 40px;
  padding: 8px;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: transparent;
  transition: background-color 140ms ease;
}

.checkbox:is(:hover, :active)[aria-checked="false"] .state-layer {
  background: rgb(82 82 92 / 8%);
}

.checkbox:is(:hover, :active)[aria-checked="true"] .state-layer {
  background: rgb(5 165 93 / 8%);
}

.icon-wrap {
  position: relative;
  display: block;
  width: 24px;
  height: 24px;
  transition: transform 120ms ease;
}

.checkbox:active .icon-wrap {
  transform: scale(0.94);
}

.checkbox-art {
  display: block;
  width: 24px;
  height: 24px;
}

.unchecked-box {
  opacity: 1;
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(1);
  transition:
    opacity 120ms ease 175ms,
    transform 190ms var(--motion-standard) 150ms;
}

.checked-fill {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(0.58);
  transition:
    opacity 240ms var(--motion-standard) 150ms,
    transform 270ms cubic-bezier(0.64, 0, 0.78, -0.22) 85ms;
}

.checkmark-cutout {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 230ms var(--motion-standard);
}

.checkbox[aria-checked="true"] .unchecked-box {
  opacity: 0;
  transform: scale(1.08);
  transition:
    opacity 90ms ease,
    transform 150ms var(--motion-standard);
}

.checkbox[aria-checked="true"] .checked-fill {
  opacity: 1;
  transform: scale(1);
  transition:
    opacity 90ms ease,
    transform 270ms cubic-bezier(0.22, 1.22, 0.36, 1);
}

.checkbox[aria-checked="true"] .checkmark-cutout {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 230ms var(--motion-standard) 85ms;
}

.checkbox:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
  border-radius: 10px;
}

@media (prefers-reduced-motion: reduce) {
  .state-layer,
  .icon-wrap,
  .unchecked-box,
  .checked-fill,
  .checkmark-cutout,
  .checkbox[aria-checked="true"] .unchecked-box,
  .checkbox[aria-checked="true"] .checked-fill,
  .checkbox[aria-checked="true"] .checkmark-cutout {
    transition-duration: 1ms;
    transition-delay: 0ms;
  }
}
