@layer components {

/* ── ds-checkbox ──────────────────────────────────────────────────────────
 * MUI-style checkbox. CSS-only (a native checkbox drives every state), so it
 * works anywhere a checkbox does and stays accessible.
 *
 * Anatomy:           1. Box (border + fill)  2. Tick (SVG, shown when checked)
 * States:            1. enabled  2. hover  3. pressed/focus (ripple)  4. disabled
 *
 * Markup:
 *   <label class="ds-checkbox">
 *     <input type="checkbox" class="ds-checkbox__input" />
 *     <span class="ds-checkbox__box">
 *       <svg viewBox="0 0 24 24"><path d="M5 13l4 4L19 7"/></svg>
 *     </span>
 *   </label>
 *
 * Geometry (matches MUI medium): root 38×38 hit area, box 18×18 with a 2px
 * border and the same hover/press ripple halo as ds-switch.
 */
.ds-checkbox {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  vertical-align: middle;
}

/* Transparent, full-size checkbox sits on top to capture clicks + a11y. */
.ds-checkbox__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

/* 1. Box */
.ds-checkbox__box {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 2px solid var(--c-neutral-900, #212121);
  border-radius: 3px;
  background: transparent;
  color: var(--c-neutral-900, #212121);            /* ripple tint when off */
  opacity: 1;
  transition: background 150ms cubic-bezier(0.4, 0, 0.2, 1),
              border-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

/* Off-state border is a muted grey (MUI uses ~54% black). */
.ds-checkbox__box { border-color: var(--color-border-strong, rgba(33, 33, 33, 0.54)); }

/* 2. Tick — hidden until checked. */
.ds-checkbox__box svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--color-bg-surface, #fff);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transition: opacity 120ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* 3. Ripple halo — sits behind the box, grows on hover / press / focus. */
.ds-checkbox__box::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.55);
  background: currentColor;
  opacity: 0;
  z-index: -1;
  transition: transform 150ms cubic-bezier(0.4, 0, 0.2, 1),
              opacity 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.ds-checkbox__input:hover:not(:disabled) ~ .ds-checkbox__box::after {
  transform: translate(-50%, -50%) scale(1);
  opacity: 0.06;
}
.ds-checkbox__input:focus-visible ~ .ds-checkbox__box::after {
  transform: translate(-50%, -50%) scale(1);
  opacity: 0.12;
}
.ds-checkbox__input:active:not(:disabled) ~ .ds-checkbox__box::after {
  transform: translate(-50%, -50%) scale(1);
  opacity: 0.16;
}

/* ── CHECKED — brand blue fill + white tick ───────────────────────────────── */
.ds-checkbox__input:checked ~ .ds-checkbox__box {
  background: var(--c-brand-500, #3f5bff);
  border-color: var(--c-brand-500, #3f5bff);
  color: var(--c-brand-500, #3f5bff);              /* ripple tint when on */
}
.ds-checkbox__input:checked ~ .ds-checkbox__box svg { opacity: 1; }
.ds-checkbox__input:checked:hover:not(:disabled) ~ .ds-checkbox__box::after { opacity: 0.10; }
.ds-checkbox__input:checked:active:not(:disabled) ~ .ds-checkbox__box::after { opacity: 0.22; }

/* ── 4. Disabled ──────────────────────────────────────────────────────────── */
.ds-checkbox__input:disabled { cursor: default; }
.ds-checkbox__input:disabled ~ .ds-checkbox__box {
  border-color: var(--c-neutral-300, #e0e0e0);
  background: transparent;
}
.ds-checkbox__input:checked:disabled ~ .ds-checkbox__box {
  background: var(--c-brand-200, #a6b3ff);
  border-color: var(--c-brand-200, #a6b3ff);
}

} /* end @layer components */
