/* =============================================================================
   BLACK SIGNAL — css/components/sweep.css
   THE SWEEP — the only interaction pattern in the app.

   At rest an interactive element is the one black with a hairline. On hover or
   keyboard focus a solid accent fill grows in from the left and every piece of
   content inside flips to the ink that sits on the accent. Leaving retracts it
   the same way. "Current" (active tab, chosen theme, selected answer, current
   rail mode) is the same fill, held.

     .bs-sweep               the primitive (black, hairline, white label)
     .bs-sweep--primary      accent border + accent label (Login, Submit…)
     .bs-sweep--secondary    dim hairline + dim label
     .bs-sweep--link         inline text link: a tight highlighter fill
     .bs-sweep--quiet        no border (cells inside a ruled grid share rules)
     .is-current / [aria-current] / [aria-selected=true] / [aria-pressed=true]
     .is-locked / :disabled / [aria-disabled=true]   hatch, no sweep

   The fill is a background layer (a two-stop gradient sized from 0% to 100%
   width), so ::before/::after stay free for chevrons, hatches and rules.
   Hover is gated to devices that have a hover; touch gets a quick fill on
   press only, so nothing sticks after a tap. Reduced motion: no transition.
   ============================================================================= */
@layer components {

.bs-sweep {
  --sweep-fill: var(--orange);
  --sweep-ink:  var(--accent-on-accent);
  position: relative;
  background-color: var(--sig-black);
  background-image: linear-gradient(var(--sweep-fill), var(--sweep-fill));
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: 0% 100%;
  border: 1px solid var(--sig-rule);
  border-radius: 0;
  color: var(--white);
  box-shadow: none;
  transform: none;
  opacity: 1;
  cursor: pointer;
  transition:
    background-size var(--dur) var(--ease-sharp),
    color var(--dur) var(--ease-sharp),
    border-color var(--dur) var(--ease-sharp);
  -webkit-tap-highlight-color: transparent;
}
.bs-sweep--primary   { border-color: var(--orange); color: var(--orange); }
.bs-sweep--secondary { border-color: var(--sig-rule); color: var(--white-dim); }
.bs-sweep--quiet     { border-color: transparent; }
/* A destructive action: the wrong-answer alert colors, same sweep. */
.bs-sweep--alert     { --sweep-fill: var(--sig-alert-ink); border-color: var(--sig-alert-rule); color: var(--sig-alert-ink); }

/* ── On: held states (no device gating — these are not hover) ─────────── */
/* The on-state wins over every screen's rest color and rest fill, in every
   layer (a screen sheet sets a tab's rest color; it must not be able to keep
   the label orange on an orange fill). That is the flip's !important, applied
   to the element itself — see "The flip" below. */
.bs-sweep.is-current,
.bs-sweep[aria-current]:not([aria-current="false"]),
.bs-sweep[aria-selected="true"],
.bs-sweep[aria-pressed="true"],
.bs-sweep[aria-checked="true"],
.bs-sweep[aria-expanded="true"],
.bs-sweep:focus-visible {
  background-size: 100% 100% !important;
  color: var(--sweep-ink) !important;
  border-color: var(--sweep-fill) !important;
  /* The edge is the fill too: a 1px ring of the fill paints over any rule a
     neighbour or the parent grid draws, so no dark hairline frames the fill. */
  box-shadow: 0 0 0 1px var(--sweep-fill) !important;
  z-index: 1;
}

/* ── On: hover, only where a hover exists ─────────────────────────────── */
@media (hover: hover) and (pointer: fine) {
  .bs-sweep:not(.is-locked):not(:disabled):not([aria-disabled="true"]):hover {
    background-size: 100% 100% !important;
    color: var(--sweep-ink) !important;
    border-color: var(--sweep-fill) !important;
    box-shadow: 0 0 0 1px var(--sweep-fill) !important;
    z-index: 1;
  }
}

/* ── On: press (touch and mouse): a quick fill that does not stick ─────── */
.bs-sweep:not(.is-locked):not(:disabled):not([aria-disabled="true"]):active {
  background-size: 100% 100% !important;
  color: var(--sweep-ink) !important;
  border-color: var(--sweep-fill) !important;
  box-shadow: 0 0 0 1px var(--sweep-fill) !important;
  z-index: 1;
  transition-duration: var(--dur-fast);
}

/* ── The flip ─────────────────────────────────────────────────────────── */
/* Every descendant — labels, numerals, tags, icons, their rules — takes the
   ink that sits on the accent. !important is deliberate and this is its one
   home: the flip must win over every component's own color, in every layer,
   or the sweep would leave stray orange or white on an orange fill. */
.bs-sweep.is-current *,
.bs-sweep[aria-current]:not([aria-current="false"]) *,
.bs-sweep[aria-selected="true"] *,
.bs-sweep[aria-pressed="true"] *,
.bs-sweep[aria-checked="true"] *,
.bs-sweep[aria-expanded="true"] *,
.bs-sweep:focus-visible *,
.bs-sweep:not(.is-locked):not(:disabled):not([aria-disabled="true"]):active * {
  color: var(--sweep-ink) !important;
  border-color: var(--sweep-fill) !important; /* inner rules vanish into the fill */
  background-color: transparent !important;
  opacity: 1 !important;
}
@media (hover: hover) and (pointer: fine) {
  .bs-sweep:not(.is-locked):not(:disabled):not([aria-disabled="true"]):hover * {
    color: var(--sweep-ink) !important;
    border-color: var(--sweep-fill) !important; /* inner rules vanish into the fill */
    background-color: transparent !important;
    opacity: 1 !important;
  }
}
/* Chips and status dots keep a visible body on the fill: ink box, accent text. */
.bs-sweep.is-current .bs-chip--solid,
.bs-sweep:focus-visible .bs-chip--solid,
.bs-sweep[aria-current]:not([aria-current="false"]) .bs-chip--solid {
  background-color: var(--sweep-ink) !important;
  color: var(--sweep-fill) !important;
}
@media (hover: hover) and (pointer: fine) {
  .bs-sweep:not(.is-locked):hover .bs-chip--solid { background-color: var(--sweep-ink) !important; color: var(--sweep-fill) !important; }
}
/* Meters remain legible in every selected, focused, hovered and pressed
   sweep state. The generic child-color flip above clears descendant backgrounds;
   restore the meter track and fill *after* it for all held-state attributes.
   In particular, analytics specialization tiles use aria-pressed="true". */
:is(.bs-sweep.is-current, .bs-sweep[aria-current]:not([aria-current="false"]),
    .bs-sweep[aria-selected="true"], .bs-sweep[aria-pressed="true"],
    .bs-sweep[aria-checked="true"], .bs-sweep[aria-expanded="true"],
    .bs-sweep:focus-visible, .bs-sweep:active) .bs-meter {
  background-color: color-mix(in srgb, var(--sweep-ink) 22%, transparent) !important;
}
:is(.bs-sweep.is-current, .bs-sweep[aria-current]:not([aria-current="false"]),
    .bs-sweep[aria-selected="true"], .bs-sweep[aria-pressed="true"],
    .bs-sweep[aria-checked="true"], .bs-sweep[aria-expanded="true"],
    .bs-sweep:focus-visible, .bs-sweep:active) .bs-meter-fill {
  background-color: var(--sweep-ink) !important;
}
@media (hover: hover) and (pointer: fine) {
  /* These are more specific than .bs-sweep:hover *; do not let the global
     descendant reset make a progress bar transparent as the sweep fills. */
  .bs-sweep:not(.is-locked):not(:disabled):not([aria-disabled="true"]):hover .bs-meter {
    background-color: color-mix(in srgb, var(--sweep-ink) 22%, transparent) !important;
  }
  .bs-sweep:not(.is-locked):not(:disabled):not([aria-disabled="true"]):hover .bs-meter-fill {
    background-color: var(--sweep-ink) !important;
  }
}

/* ── Off: locked / disabled — hatched, muted, no sweep ────────────────── */
.bs-sweep.is-locked,
.bs-sweep:disabled,
.bs-sweep[aria-disabled="true"] {
  background-image: var(--sig-hatch);
  background-size: auto;
  background-position: 0 0;
  color: var(--white-faint);
  border-color: var(--sig-rule);
  cursor: not-allowed;
}
.bs-sweep.is-locked *,
.bs-sweep:disabled *,
.bs-sweep[aria-disabled="true"] * { color: var(--white-faint); border-color: var(--sig-rule); }

/* ── Text link: a highlighter fill behind the words ───────────────────── */
.bs-sweep--link {
  display: inline-block;
  padding: 1px 5px;
  margin: -1px -5px;
  border: 0;
  background-color: transparent;
  color: var(--orange);
  text-decoration: none;
  font: inherit;
  line-height: inherit;
}
.bs-sweep--link:focus-visible { border: 0; }

/* ── Reduced motion: the fill appears, it does not travel ─────────────── */
@media (prefers-reduced-motion: reduce) {
  .bs-sweep, .bs-sweep * { transition: none !important; } /* !important: beats the a11y layer's 0.01ms duration; the fill must be instant, not a 0.01ms slide */
}

/* ── Filled key ───────────────────────────────────────────────────────────
   The analytics "Open / Practice" look: a solid theme-color cell with a black
   label, filled at all times and unchanged on hover. Applied over many different
   per-screen button components (.ctrl-btn, .linux-docs-btn, .bsc-ctrl-btn, …),
   so it uses !important (allowed here) to win over their own colors. Buttons
   that use it drop bs-sweep, so there is no hover animation to override. */
.bs-key--filled {
  background: var(--orange) !important;
  background-image: none !important;
  border: 1px solid var(--orange) !important;
  color: var(--accent-on-accent) !important;
  box-shadow: none !important;
  opacity: 1 !important;
}
.bs-key--filled > * { color: var(--accent-on-accent) !important; }
.bs-key--filled:focus-visible { outline: 2px solid var(--accent-on-accent); outline-offset: -4px; }
.bs-key--filled:disabled,
.bs-key--filled[aria-disabled="true"],
.bs-key--filled.is-locked {
  background: color-mix(in srgb, var(--orange) 42%, var(--sig-black)) !important;
  border-color: color-mix(in srgb, var(--orange) 42%, var(--sig-black)) !important;
  color: color-mix(in srgb, var(--accent-on-accent) 72%, transparent) !important;
  cursor: not-allowed;
}

}