/* Reusable checkbox */
/* ================= */
/*
  A self-contained, theme-aware checkbox that shares the switch's colour language
  (see switch.css): a white rounded square with a soft drop shadow when off, an
  accent-filled box with a contrasting checkmark when on. Markup:

    <div class="pg-checkbox">
      <input class="pg-checkbox__input" type="checkbox" id="…">
      <label class="pg-checkbox__label" for="…">Label</label>
    </div>

  Unlike .pg-switch, the control sits to the LEFT of the label.
*/

.pg-checkbox {
  display: flex;
  align-items: center;
  column-gap: 0.5rem;
}

.pg-checkbox__input {
  --pg-checkbox-size: 1.05rem;

  flex: 0 0 auto;
  margin: 0;

  width: var(--pg-checkbox-size);
  height: var(--pg-checkbox-size);

  appearance: none;
  /* White box like the switch knob: same colour + soft drop shadow, plus a
     hairline border so it stays defined against a light background. */
  background-color: #fff;
  border: 1px solid color-mix(in oklab, var(--bs-secondary-color) 35%, transparent);
  border-radius: 0.35rem;
  box-shadow: 0 0 0.5px 0.5px rgba(0, 0, 0, 0.4);
  cursor: pointer;

  /* Checkmark drawn as a positioned pseudo-element so it can animate in */
  position: relative;
  transition: background-color 0.2s ease, border-color 0.2s ease;

  &::before {
    content: "";
    position: absolute;
    top: 46%;
    left: 50%;
    width: 0.25rem;
    height: 0.5rem;
    border: solid var(--pg-accent-contrast, #fff);
    border-width: 0 0.13rem 0.13rem 0;
    transform: translate(-50%, -50%) rotate(45deg) scale(0);
    transform-origin: center;
    transition: transform 0.15s ease;
  }

  /* Checked: fill with the accent (like the switch track), contrasting checkmark. */
  &:checked {
    background-color: var(--pg-accent, var(--bs-primary));
    border-color: var(--pg-accent, var(--bs-primary));
    box-shadow: none;
  }

  &:checked::before {
    transform: translate(-50%, -50%) rotate(45deg) scale(1);
  }

  &:focus-visible {
    outline: none;
    box-shadow: 0 0 0 0.2rem color-mix(in oklab, var(--pg-accent, var(--bs-primary)) 30%, transparent);
  }

  &:disabled {
    opacity: 0.5;
    cursor: default;
  }
}

.pg-checkbox__label {
  line-height: 1.2;
  cursor: pointer;
}

.pg-checkbox__input:disabled+.pg-checkbox__label {
  cursor: default;
}