/* ==========================================================================
   @alfadocs/ui-kit/host-legacy — opt-in guards for hosts with legacy
   Bootstrap 3 / Material Admin CSS loaded UNLAYERED (alfadocs/platform).

   Load it AFTER `@alfadocs/ui-kit/tokens`, and only on such a host. Like
   `host-compat`, it is not part of the default sheet, because every rule
   here fights unlayered CSS in general, not only the legacy rules it was
   written for. On a modern host it would also override the app's own
   heading styles under ThemeRoot (which carries `data-component`) and any
   consumer outline set on a kit element. See src/docs/29-host-compatibility.mdx.

   Found on the platform's Scheduler page (HTP-3353, 2026-10-02):

   - `h1–h6 { font-weight: 500; line-height: 1.1; color }` and
     `h2 { font-size: 27px }` made Dialog.Title light and large;
   - `legend { font-size: 21px; margin-bottom: 20px; border-bottom }` made
     a labelled RadioGroup label a page heading;
   - `*, :active, :hover { outline: none !important }`, plus
     `a:focus` and `input[type=checkbox|radio]:focus` with the same
     `!important`, removed every kit focus ring (WCAG 2.4.7).

   `revert-layer` in an unlayered rule drops every unlayered declaration,
   legacy or not, and lands on the kit's layered value, so these rules never
   invent a style the component did not ask for.
   ========================================================================== */

/* Headings and legends at (0,0,2): above the legacy element rules (0,0,1)
   whatever the load order, below any class a host puts on its own heading.
   The repeated :is() supplies the second element's worth of specificity. */
:where([data-component])
  :is(h1, h2, h3, h4, h5, h6):is(h1, h2, h3, h4, h5, h6) {
  font: revert-layer;
  color: revert-layer;
}

:where([data-component]) legend:is(legend) {
  all: revert-layer;
}

/* Focus rings. Only an `!important` declaration can answer the legacy
   `!important` ones. Each selector names kit-owned elements only:
   - focus-outline utilities, with the attribute repeated to reach (0,3,0)
     and clear the legacy `input[type=checkbox]:focus` (0,2,1);
   - the `ds-*` component classes (the Dialog close draws its ring from
     `.ds-dialog__close`), at (0,2,0) so a theme bridge's own `!important`
     ring below, at (0,3,0), still wins on `.ds-data-table-…` surfaces.
   `outline-offset` is not `!important` in the legacy rules, so a normal
   revert is enough to undo `a:focus { outline-offset: -2px }`. */
[class*='ds:focus-visible:outline'][class*='ds:focus-visible:outline']:focus-visible,
[class*='ds:focus-within:outline'][class*='ds:focus-within:outline']:focus-within,
[class*='ds:focus:outline'][class*='ds:focus:outline']:focus,
[class*='ds:has-[input:focus]:outline']:has(input:focus),
:is([class^='ds-'], [class*=' ds-']):focus-visible {
  outline: revert-layer !important;
  outline-offset: revert-layer;
}

/* The theme bridges are unlayered themselves, so `revert-layer` cannot reach
   their rings: restate them with `!important`. Keep in step with ag-grid-theme.css,
   apexcharts-theme.css and themes/bridges/{fullcalendar,redactor}-theme.css. */
.fc-theme-alfadocs .fc-button:focus-visible,
.fc-theme-alfadocs a.fc-event:focus-visible,
.fc-theme-alfadocs .fc-daygrid-more-link:focus-visible,
.redactor-theme-alfadocs .redactor-box:focus-within,
.redactor-theme-alfadocs .redactor-toolbar a:focus-visible,
.redactor-theme-alfadocs .redactor-air a:focus-visible {
  outline: var(--focus-ring-width) solid var(--ring) !important;
  outline-offset: var(--focus-ring-offset);
}

.apex-theme-alfadocs .apexcharts-legend-series[role='button']:focus-visible,
.apex-theme-alfadocs .apexcharts-toolbar > [role='button']:focus-visible {
  outline: var(--focus-ring-width) solid var(--ring) !important;
  outline-offset: var(--focus-ring-offset);
}

.apex-theme-alfadocs .apexcharts-menu-item:focus-visible {
  outline: var(--focus-ring-width) solid var(--ring) !important;
  outline-offset: calc(var(--focus-ring-width) * -1);
}

.ag-theme-alfadocs .ag-row.ds-data-table-expanded-row.ag-full-width-focus,
.ag-theme-alfadocs .ds-data-table-expanded-row-surface:focus-visible {
  outline: var(--focus-ring-width) solid var(--ring) !important;
  outline-offset: calc(var(--focus-ring-width) * -1);
}

.ag-theme-alfadocs .ag-floating-filter-input > * > input:focus-visible,
.ag-theme-alfadocs .ag-menu .ag-filter input:focus-visible {
  outline: var(--focus-ring-width) solid var(--ring) !important;
  outline-offset: 0;
}

.ag-theme-alfadocs .ag-cell:focus-within {
  outline: var(--focus-ring-width) solid var(--ring) !important;
  outline-offset: -1px;
}
