/*
 * Control Explorer styles.
 *
 * Uses mkdocs-material CSS custom properties so the component adapts
 * automatically to both the default (light) palette and the
 * [data-md-color-scheme="slate"] (dark) palette without per-theme overrides.
 * Targets WCAG 2.1 AA contrast in both palettes, stacks responsively on
 * narrow viewports, and guards transitions behind prefers-reduced-motion.
 */

.ce-root {
  --ce-border: var(--md-default-fg-color--lighter);
  --ce-surface: var(--md-default-bg-color);
  --ce-fg: var(--md-default-fg-color);
  --ce-muted: var(--md-default-fg-color--light);
  --ce-accent: var(--md-primary-fg-color);
  --ce-radius: 0.25rem;
  color: var(--ce-fg);
  margin-top: 1rem;
}

/* ---- search ---- */
.ce-search {
  margin-bottom: 1rem;
}

.ce-label,
.ce-sidebar-title {
  font-weight: 700;
  display: block;
  margin-bottom: 0.35rem;
}

.ce-search-input,
.ce-facet-filter {
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.7rem;
  font-size: 0.85rem;
  color: var(--ce-fg);
  background: var(--ce-surface);
  border: 1px solid var(--ce-border);
  border-radius: var(--ce-radius);
}

.ce-search-input:focus,
.ce-facet-filter:focus,
.ce-checkbox:focus-visible,
.ce-sort-btn:focus-visible,
.ce-reset:focus-visible,
.ce-control-link:focus-visible,
.ce-playbook-link:focus-visible {
  outline: 2px solid var(--ce-accent);
  outline-offset: 2px;
}

/* ---- layout ---- */
.ce-layout {
  display: grid;
  /* UX-03: use minmax(0, 1fr) for the results track, not bare 1fr.
     CSS grid tracks with implicit `auto` minimum refuse to shrink below
     min-content size, which equals the table's min-width (46rem). Using
     minmax(0, 1fr) explicitly allows the track to shrink to 0, so
     .ce-results { overflow-x: auto } can contain the wide table instead
     of forcing the whole page to scroll. */
  grid-template-columns: minmax(15rem, 18rem) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

@media screen and (max-width: 60em) {
  .ce-layout {
    /* Same minmax(0, 1fr) reasoning as two-column mode above. */
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---- sidebar / facets ---- */
.ce-sidebar-title {
  font-size: 1rem;
  margin: 0 0 0.5rem;
}

.ce-reset {
  display: inline-block;
  margin-bottom: 1rem;
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ce-accent);
  background: transparent;
  border: 1px solid var(--ce-accent);
  border-radius: var(--ce-radius);
  cursor: pointer;
}

.ce-reset:hover {
  color: var(--md-primary-bg-color);
  background: var(--ce-accent);
}

/* Slate: --ce-accent (#429CE3) fails AA with white text (~2.96:1); use the
   deeper #005A9E (white = 7.10:1) for filled accents only. */
[data-md-color-scheme="slate"] .ce-reset:hover {
  color: #ffffff;
  background: #005A9E;
  border-color: #005A9E;
}

.ce-facet {
  border: 1px solid var(--ce-border);
  border-radius: var(--ce-radius);
  margin: 0 0 0.85rem;
  padding: 0.5rem 0.75rem 0.75rem;
}

.ce-facet-legend {
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0 0.35rem;
}

.ce-facet-filter {
  margin: 0.25rem 0 0.5rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
}

.ce-facet-options {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.ce-facet-scroll {
  max-height: 13rem;
  overflow-y: auto;
}

.ce-check {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.82rem;
  line-height: 1.35;
  padding: 0.15rem 0.2rem;
  cursor: pointer;
}

.ce-check:hover {
  background: var(--md-default-fg-color--lightest);
  border-radius: var(--ce-radius);
}

.ce-checkbox {
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--ce-accent);
}

/* ---- results ---- */
.ce-count {
  font-weight: 700;
  margin: 0 0 0.75rem;
}

/* The results column is a CSS grid cell, which defaults to min-width:auto and
   therefore refuses to shrink below the table's intrinsic width -- on narrow
   screens that forces the whole PAGE to scroll horizontally. min-width:0 lets
   the cell shrink, and overflow-x:auto keeps the wide table scrolling WITHIN
   the results area instead. */
.ce-results {
  min-width: 0;
  overflow-x: auto;
}

.ce-table {
  width: 100%;
  /* Keep the 6 columns readable: below this the table scrolls inside
     .ce-results rather than wrapping cells character-by-character. */
  min-width: 46rem;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.ce-table th,
.ce-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--ce-border);
}

.ce-table thead th {
  border-bottom: 2px solid var(--ce-border);
  white-space: nowrap;
}

.ce-cell-id {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 600;
}

.ce-sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  font: inherit;
  font-weight: 700;
  color: var(--ce-fg);
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.ce-sort-ind {
  font-size: 0.7em;
}

.ce-control-link {
  font-weight: 600;
}

.ce-playbook-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.ce-playbook-item {
  margin: 0;
}

.ce-playbook-link {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  font-size: 0.72rem;
  line-height: 1.4;
  border-radius: 0.75rem;
  border: 1px solid var(--ce-border);
  color: var(--ce-accent);
  text-decoration: none;
}

.ce-playbook-link:hover {
  color: var(--md-primary-bg-color);
  background: var(--ce-accent);
  border-color: var(--ce-accent);
  text-decoration: none;
}

[data-md-color-scheme="slate"] .ce-playbook-link:hover {
  color: #ffffff;
  background: #005A9E;
  border-color: #005A9E;
}

/* ---- badges ---- */
.ce-badge {
  display: inline-block;
  margin: 0.1rem 0.25rem 0.1rem 0;
  padding: 0.1rem 0.45rem;
  font-size: 0.72rem;
  line-height: 1.4;
  border-radius: 0.75rem;
  border: 1px solid var(--ce-border);
  white-space: nowrap;
}

.ce-badge-pillar {
  color: var(--md-primary-bg-color);
  background: var(--ce-accent);
  border-color: var(--ce-accent);
}

[data-md-color-scheme="slate"] .ce-badge-pillar {
  color: #ffffff;
  background: #005A9E;
  border-color: #005A9E;
}

.ce-badge-zone {
  color: var(--ce-fg);
  background: var(--md-default-fg-color--lightest);
}

.ce-badge-reg {
  color: var(--ce-fg);
  background: transparent;
}

/* Proposed/monitored citation (e.g. FINRA-25-07 RFC, not yet adopted):
   dashed + italic so it reads as distinct from adopted rules. Text stays
   --ce-fg, so no new contrast pair. */
.ce-badge-reg-proposed {
  border-style: dashed;
  font-style: italic;
}

.ce-badge-muted {
  color: var(--ce-muted);
  background: transparent;
  font-style: italic;
}

/* ---- status / errors ---- */
.ce-empty,
.ce-error {
  padding: 1rem;
  font-weight: 600;
  color: var(--ce-muted);
}

.ce-error {
  color: var(--md-error-fg-color, #b00020);
}

/* ---- accessibility helpers ---- */
.ce-visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- motion ---- */
@media (prefers-reduced-motion: reduce) {
  .ce-reset,
  .ce-check,
  .ce-control-link,
  .ce-playbook-link,
  .ce-sort-btn {
    transition: none !important;
  }
}
