/*
 * Copyright (c) 2026, Salesforce, Inc.,
 * All rights reserved.
 * For full license text, see the LICENSE.txt file
 */

@layer theme {
  .slds-checkbox {
    /* Sizing */
    --slds-c-checkbox-size: var(--slds-g-sizing-5);
    --slds-c-checkbox-sizing-border: var(--slds-s-mark-sizing-border);
    --slds-c-checkbox-radius-border: var(--slds-g-radius-border-1);

    /* Surface — idle */
    --slds-c-checkbox-color-background: var(--slds-s-mark-color-background);
    --slds-c-checkbox-color-border: var(--slds-s-mark-color-border);

    /* Per-state shadow (the carveout's `-focus` suffix covers shadow-focus;
       `-shadow-checked` is structurally distinct from `-shadow-focus`,
       so we keep both as separate per-state hooks). */
    --slds-c-checkbox-shadow-checked: var(--slds-s-mark-shadow-checked);
    --slds-c-checkbox-shadow-focus: var(--slds-g-shadow-outset-focus-1);

    /* Checkmark / dash glyph color and sizing geometry */
    --slds-c-checkbox-mark-color-foreground: var(--slds-s-mark-color-foreground-checked);
    --slds-c-checkbox-mark-sizing-block: var(--slds-g-sizing-2);
    --slds-c-checkbox-mark-sizing-inline: var(--slds-g-sizing-3);
    --slds-c-checkbox-mark-sizing-border: var(--slds-g-sizing-border-2);

    /* Label */
    --slds-c-checkbox-label-font-size: var(--slds-s-label-font-size);
    --slds-c-checkbox-label-color-foreground: var(--slds-g-color-on-surface-2);

    /* Form-element wrapper margin */
    --slds-c-checkbox-margin-inline-end: var(--slds-g-sizing-3);
  }

  /* Checked / indeterminate states — reassign canonical color hooks
     from inside the pseudo-class selector (out-of-carveout state, per
     RFC 1157). */
  .slds-checkbox [type='checkbox']:checked + .slds-checkbox_faux,
  .slds-checkbox [type='checkbox']:checked ~ .slds-checkbox_faux,
  .slds-checkbox [type='checkbox']:checked + .slds-checkbox__label .slds-checkbox_faux,
  .slds-checkbox [type='checkbox']:indeterminate + .slds-checkbox_faux,
  .slds-checkbox [type='checkbox']:indeterminate ~ .slds-checkbox_faux,
  .slds-checkbox [type='checkbox']:indeterminate + .slds-checkbox__label .slds-checkbox_faux {
    --slds-c-checkbox-color-background: var(--slds-s-mark-color-background-checked);
    --slds-c-checkbox-color-border: var(--slds-s-input-color-border-checked);
  }

  /* Disabled state — both bare and :checked paths share the paint.
     Reassigns canonical hooks under the [disabled] selector. */
  .slds-checkbox [type='checkbox'][disabled] + .slds-checkbox_faux,
  .slds-checkbox [type='checkbox'][disabled] ~ .slds-checkbox_faux,
  .slds-checkbox [type='checkbox'][disabled] + .slds-checkbox__label .slds-checkbox_faux,
  .slds-checkbox [type='checkbox'][disabled]:checked + .slds-checkbox_faux,
  .slds-checkbox [type='checkbox'][disabled]:checked ~ .slds-checkbox_faux,
  .slds-checkbox [type='checkbox'][disabled]:checked + .slds-checkbox__label .slds-checkbox_faux {
    --slds-c-checkbox-color-background: var(--slds-g-color-disabled-container-2);
    --slds-c-checkbox-color-border: var(--slds-g-color-border-disabled-1);
    --slds-c-checkbox-mark-color-foreground: var(--slds-g-color-on-disabled-2);
  }

  /* Error context (form-state allow-list — `slds-has-error`).
     Reassigns canonical hooks; the thicker border comes from
     reassigning `-sizing-border`. */
  .slds-has-error .slds-checkbox {
    --slds-c-checkbox-color-border: var(--slds-g-color-border-error-1);
    --slds-c-checkbox-sizing-border: var(--slds-g-sizing-border-2);
  }

  .slds-has-error .slds-checkbox [type='checkbox']:checked + .slds-checkbox_faux,
  .slds-has-error .slds-checkbox [type='checkbox']:checked ~ .slds-checkbox_faux,
  .slds-has-error .slds-checkbox [type='checkbox']:checked + .slds-checkbox__label .slds-checkbox_faux {
    --slds-c-checkbox-color-background: var(--slds-s-mark-color-background-invalid);
    --slds-c-checkbox-mark-color-foreground: var(--slds-s-mark-color-foreground-invalid);
  }
}
