/* ─── Checklist checkbox — custom styled ────────────────── */
/*
  appearance: none removes native browser rendering entirely, eliminating the
  bright-white native checkbox that causes harsh contrast in dark mode.
  We rebuild the full visual state in CSS for consistent cross-browser rendering.
*/

[data-blok-interface] [data-list-style="checklist"] input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  border-radius: var(--blok-space-1-25);
  border: 2px solid var(--blok-checklist-border);
  background-color: transparent;
  box-shadow: inset 0 1px 2px var(--blok-checklist-shadow);
  transition: background-color 150ms ease, border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

[data-blok-interface] [data-list-style="checklist"] input[type="checkbox"]:checked {
  background-color: var(--blok-active-icon);
  border-color: var(--blok-active-icon);
  box-shadow: none;
  animation: blok-checkbox-pop 280ms linear;
  /* IconCheck at 1/2 scale; double the scaled stroke to keep the 10px tick readable. */
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 10 10' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2.25 5l1.75 1.75 3.75-3.75' stroke='white' stroke-width='1.25' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
  background-size: 10px 10px;
  background-position: center;
  background-repeat: no-repeat;
}

[data-blok-interface] [data-list-style="checklist"] input[type="checkbox"]:not(:disabled):not(:checked):hover {
  border-color: var(--blok-active-icon);
  transform: scale(1.06);
  box-shadow: 0 0 0 3px var(--blok-checklist-hover-ring), inset 0 1px 2px var(--blok-checklist-shadow);
}

[data-blok-interface] [data-list-style="checklist"] input[type="checkbox"]:not(:disabled):checked:hover {
  box-shadow: 0 0 0 3px var(--blok-checklist-hover-ring);
}

[data-blok-interface] [data-list-style="checklist"] input[type="checkbox"]:disabled:not(:checked) {
  opacity: 0.5;
}

[data-blok-interface] [data-list-style="checklist"] input[type="checkbox"]:disabled:checked {
  background-color: var(--blok-checklist-readonly-fill);
  border-color: var(--blok-checklist-readonly-fill);
  box-shadow: none;
  animation: none;
}

/*
  The global input:focus-visible rule above suppresses all input focus rings.
  Checkboxes need a visible focus ring for keyboard accessibility — restore it.
*/
[data-blok-interface] [data-list-style="checklist"] input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--blok-active-icon);
  outline-offset: 2px;
}

/* Dark mode: more muted checked text so completed items feel visually "done" */
@media (prefers-color-scheme: dark) {
  :root:not([data-blok-theme="light"]) [data-blok-interface] [data-list-style="checklist"] [data-checked="true"] {
    opacity: 0.45;
  }
}

[data-blok-theme="dark"] [data-blok-interface] [data-list-style="checklist"] [data-checked="true"] {
  opacity: 0.45;
}

/*
  Checklist type scale. Checklist items share the list block root (and so the
  --blok-list-font-size utility on it), but hosts size checkboxes' rows
  separately often enough to warrant their own scenario
  (`config.style.fontSize.list.checklist`) — it layers on top, falling back to
  the list token and finally to inheriting, which is the pre-token behaviour.
  Un-layered, so it beats the layered size utility on the same element.
*/
[data-list-style="checklist"] {
  font-size: var(--blok-checklist-font-size, var(--blok-list-font-size, inherit));
}
