/*
 * dds-preupgrade.css (opt-in)
 *
 * Styles for DDS elements that are in the page but not upgraded yet: the HTML
 * arrived (server rendering, or DDS loads lazily) while the component's
 * JavaScript has not defined the element. Without these rules the browser shows
 * the raw children (e.g. every option's text in a row) and the page jumps when
 * the component appears.
 *
 * `:not(:defined)` only matches before the element is registered, so nothing
 * here applies to an upgraded component.
 *
 * Usage: import 'dap-design-system/styles/dds-preupgrade.css'
 */

/* Options are only ever shown inside their list. */
dap-ds-option-item:not(:defined),
dap-ds-option-group:not(:defined) {
  display: none;
}

/*
 * Form fields: hide the raw content but keep the component's height so the
 * layout does not shift on upgrade. Heights match the upgraded field (with a
 * label, without description or feedback).
 */
dap-ds-select:not(:defined),
dap-ds-combobox:not(:defined),
dap-ds-search:not(:defined) {
  display: block;
  visibility: hidden;
  min-height: 40px;
}

:is(dap-ds-select, dap-ds-combobox, dap-ds-search):not(:defined)[label] {
  min-height: 72px;
}

:is(dap-ds-select, dap-ds-combobox, dap-ds-search):not(:defined)[size='xs'] {
  min-height: 32px;
}

:is(dap-ds-select, dap-ds-combobox, dap-ds-search):not(
    :defined
  )[size='xs'][label] {
  min-height: 61px;
}

:is(dap-ds-select, dap-ds-combobox, dap-ds-search):not(:defined)[size='lg'] {
  min-height: 48px;
}

:is(dap-ds-select, dap-ds-combobox, dap-ds-search):not(
    :defined
  )[size='lg'][label] {
  min-height: 83px;
}
