/**
 * Seeds Checkbox component classes
 * Use these instead of writing out individual Tailwind utility classes.
 *
 * Requires @sproutsocial/seeds-react-theme/dist/theme-all.css imported for
 * CSS variable definitions and dark mode support.
 *
 * Usage (default appearance): rendered by CheckboxTailwind on top of
 * `@base-ui/react`'s Checkbox —
 *   <span class="seeds-checkbox">
 *     <button class="seeds-checkbox-input" role="checkbox">
 *       <span class="seeds-checkbox-indicator">
 *         <Icon class="seeds-checkbox-icon" />
 *       </span>
 *     </button>
 *     <span class="seeds-checkbox-label">Label</span>
 *   </span>
 *
 * The default-appearance box is base-ui's `Checkbox.Root` (`<button
 * role="checkbox">`) and the mark is a real `<Icon>` inside
 * `Checkbox.Indicator`. State is read from base-ui's ARIA contract
 * (`aria-checked` = "true" | "mixed" | "false") and its `data-disabled`
 * attribute, so there is no imperative `indeterminate` sync and no mask-image
 * pseudo-element — which is what made the previous indeterminate rendering
 * unreliable.
 *
 * All rules are wrapped in `@layer components` so consuming Tailwind utility
 * classes (e.g. `mx-200`, `p-300`, `inline-flex`) win the cascade over these
 * component styles.
 */

@layer components {
/* ----------------------------------------------------------------------------
 * Default appearance
 * ------------------------------------------------------------------------- */

.seeds-checkbox {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  position: relative;
  transition: all var(--duration-fast) var(--ease-ease_in);
}

/* Whole control dims when the control is disabled (matches container opacity).
   base-ui sets both the native `disabled` attribute and `data-disabled`. */
.seeds-checkbox:has(.seeds-checkbox-input:disabled),
.seeds-checkbox:has(.seeds-checkbox-input[data-disabled]) {
  opacity: 0.4;
}

/* The box — base-ui's Checkbox.Root <button>. `color` sets the grey mark used
   for the hover preview; the selected state overrides the mark color below. */
.seeds-checkbox .seeds-checkbox-input {
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: 0;
  padding: 0;
  width: var(--space-400);
  height: var(--space-400);
  border: 1px solid var(--color-form-border-base);
  border-radius: var(--radius-400);
  background-color: var(--color-form-bg-base);
  color: var(--color-form-border-base);
  transition: all var(--duration-fast) var(--ease-ease_in);
  cursor: pointer;
  flex-shrink: 0;
}

.seeds-checkbox .seeds-checkbox-input:disabled,
.seeds-checkbox .seeds-checkbox-input[data-disabled] {
  cursor: not-allowed;
}

/* Selected (checked or indeterminate): filled box. The mark color is set here
   (not on the icon) so it inherits through the seeds Icon's unlayered
   `.Icon { color: inherit }` rule, which would otherwise win the cascade over a
   layered color on `.seeds-checkbox-icon`. `--color-icon-inverse` resolves to
   white in light mode and black in dark mode — matching the SC component's
   `icon.inverse` checked-mark color (styles.tsx:137). */
.seeds-checkbox .seeds-checkbox-input[aria-checked="true"],
.seeds-checkbox .seeds-checkbox-input[aria-checked="mixed"] {
  border-color: var(--color-form-border-selected);
  background-color: var(--color-form-bg-selected);
  color: var(--color-icon-inverse);
}

/* Focus ring. The visible box is base-ui's Checkbox.Root <button>, but base-ui
   also renders a separate hidden <input> for form participation, and focus (on
   click or Tab) can land on that <input> rather than the button. A plain
   `.seeds-checkbox-input:focus` only matched the button, so the ring never
   painted and the box looked unfocusable. Track focus anywhere inside the
   control and paint the ring on the visible box regardless of which element
   actually holds focus: base-ui mirrors focus state onto the Root button as
   `data-focused`, and the `:has(:focus)` wrapper rules catch focus on either
   the button or the hidden <input>. `:focus` (not `:focus-visible`) keeps parity
   with the styled-components `focusRing` mixin, which shows the ring on both
   keyboard focus and click (styles.tsx:115-117). */
.seeds-checkbox .seeds-checkbox-input[data-focused],
.seeds-checkbox:has(.seeds-checkbox-input:focus) .seeds-checkbox-input,
.seeds-checkbox:has(input:focus) .seeds-checkbox-input {
  box-shadow:
    0 0 0 1px var(--color-button-primary-bg-base),
    0 0px 0px 4px
      color-mix(
        in srgb,
        var(--color-button-primary-bg-base),
        transparent 70%
      );
  outline: none;
}

.seeds-checkbox .seeds-checkbox-input:focus::-moz-focus-inner {
  border: 0;
}

/* The mark — a real <Icon> inside Checkbox.Indicator (kept mounted). Hidden by
   default; shown (inverse) when selected, previewed (grey) on hover. */
.seeds-checkbox .seeds-checkbox-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.seeds-checkbox .seeds-checkbox-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  color: currentColor;
  pointer-events: none;
  transition: var(--duration-fast) var(--ease-ease_inout);
}

.seeds-checkbox .seeds-checkbox-icon,
.seeds-checkbox .seeds-checkbox-icon .Icon-svg {
  width: 10px;
  height: 10px;
  line-height: 10px;
}

/* Selected: inverse mark, shown. The mark inherits its color from the box's
   `color: var(--color-icon-inverse)` above (via the Icon's unlayered
   `color: inherit`), so only opacity is toggled here. */
.seeds-checkbox .seeds-checkbox-input[aria-checked="true"] .seeds-checkbox-icon,
.seeds-checkbox
  .seeds-checkbox-input[aria-checked="mixed"]
  .seeds-checkbox-icon {
  opacity: 1;
}

/* Hover previews the mark (grey, via the box `color`) unless the control is
   disabled and unchecked. */
.seeds-checkbox
  .seeds-checkbox-input:not(:disabled):not([data-disabled]):hover
  .seeds-checkbox-icon {
  opacity: 1;
}

.seeds-checkbox
  .seeds-checkbox-input[aria-checked="false"]:disabled:hover
  .seeds-checkbox-icon,
.seeds-checkbox
  .seeds-checkbox-input[aria-checked="false"][data-disabled]:hover
  .seeds-checkbox-icon {
  opacity: 0;
}

.seeds-checkbox-label {
  margin-left: var(--space-300);
  font-size: var(--font-size-200);
  line-height: 1;
  cursor: pointer;
  color: var(--color-text-headline);
}

.seeds-checkbox:has(.seeds-checkbox-input:disabled) .seeds-checkbox-label {
  cursor: not-allowed;
  opacity: 0.4;
}
} /* end @layer components */
