/* On-brand filter checkboxes for the catalog rail (components/_sidebar_filters.html).
 *
 * The catalog is one <form>; the native <input type="checkbox" data-facet> per
 * option is what makes the no-JS "Apply" submit, multi-select, and keyboard /
 * screen-reader a11y work — so we KEEP every native input and only restyle it:
 * visually hide the input (still focusable + submittable) and draw a custom box
 * in the empty <span class="kw-sidebar__option-box"> placed right after it.
 *
 * Loaded AFTER sidebar.css in base.html so these rules win over the rail's
 * default option styling. Direction-agnostic (logical / block-direction props
 * only) so it mirrors under <html dir="rtl">. Works in both themes. */

/* Hide the native input but keep it in the a11y tree, focusable, and submitted
 * with the form. position:absolute keeps it out of the flex flow so the row's
 * gap doesn't reserve a slot for a zero-width box. */
.kw-sidebar__option input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* The drawn box: 18px rounded square with the --kw-border-color stroke. */
.kw-sidebar__option-box {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--kw-border-color);
  background: var(--kw-bg-elevated);
  display: grid;
  place-items: center;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
html.dark .kw-sidebar__option-box {
  background: rgba(77, 96, 251, 0.06);
  border-color: rgba(77, 96, 251, 0.30);
}

/* White check mark, drawn via CSS mask (no extra markup); hidden until checked. */
.kw-sidebar__option-box::after {
  content: "";
  width: 10px;
  height: 10px;
  opacity: 0;
  transition: opacity 120ms ease;
  background-color: #fff;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* Checked → brand-blue fill + white check (electric-indigo + glow on dark). */
.kw-sidebar__option input[type="checkbox"]:checked + .kw-sidebar__option-box {
  background: var(--kw-blue);
  border-color: var(--kw-blue);
}
html.dark .kw-sidebar__option input[type="checkbox"]:checked + .kw-sidebar__option-box {
  background: var(--kw-electric-indigo);
  border-color: var(--kw-electric-indigo);
  box-shadow: 0 0 10px rgba(77, 96, 251, 0.45);
}
.kw-sidebar__option input[type="checkbox"]:checked + .kw-sidebar__option-box::after {
  opacity: 1;
}

/* Keyboard focus ring on the box (the real input is visually hidden). */
.kw-sidebar__option input[type="checkbox"]:focus-visible + .kw-sidebar__option-box {
  outline: 2px solid var(--kw-electric-indigo);
  outline-offset: 2px;
}
