:host(:not(:is([hydrated], .hydrated))) {
  @apply not-hydrated;
}


/**
 * @prop --mds-dropdown-arrow-background: Sets the fill color of the arrow.
 * @prop --mds-dropdown-backdrop-duration: Sets the duration of the fade of the backdrop shown with the `backdrop` attribute, the one of the page backdrop by default.
 * @prop --mds-dropdown-backdrop-z-index: Public. Sets the z-index of the backdrop shown with the `backdrop` attribute, the one of the page backdrop by default.
 * @prop --mds-dropdown-background: Public. Sets the background-color of the dropdown.
 * @prop --mds-dropdown-drop-shadow-color-rgb: Sets the color used for the dropdown shadow
 * @prop --mds-dropdown-drop-shadow: Sets the drop-shadow of the dropdown.
 * @prop --mds-dropdown-duration: Sets the duration of the dropdown animation.
 * @prop --mds-dropdown-ease: Sets the easing of the dropdown animation.
 * @prop --mds-dropdown-mouseover-delay: Public. Sets the delay duration of the component when the caller trigger mouseover event, it's used by the javascript code.
 * @prop --mds-dropdown-transform-from: Sets the from animation transform of the dropdown.
 * @prop --mds-dropdown-transform-to: Sets the to animation transform of the dropdown.
 * @prop --mds-dropdown-z-index: Public. Sets the z-index of the component.
 */

/* The following properties are not supported by Houdini:
  --mds-dropdown-drop-shadow, --mds-dropdown-ease,
  --mds-dropdown-transform-from, --mds-dropdown-transform-to
*/

:host {
  --mds-dropdown-arrow-background: var(--mds-dropdown-background, rgb(var(--magma-surface-overlay, var(--surface-neutral-overlay, 255 255 255))));
  --mds-dropdown-backdrop-duration: var(--magma-backdrop-animation-duration, 300ms);
  --private-dropdown-backdrop-duration: var(--mds-dropdown-backdrop-duration, var(--magma-backdrop-animation-duration, 300ms));
  --mds-dropdown-backdrop-z-index: var(--magma-backdrop-z-index, 4000);
  --mds-dropdown-background: rgb(var(--magma-surface-overlay, var(--surface-neutral-overlay, 255 255 255)));

  /* overlay: the fields inside take the step below (#1193) */
  --magma-field-fill: var(--magma-surface-default, var(--surface-neutral-default, 242 242 242));
  --mds-dropdown-drop-shadow-color-rgb: var(--magma-shadow-ink, var(--tone-neutral-01, 5 5 5));

  /* multiplies the alpha of the default shadow: 3 in dark (css/mds-dropdown-pref-mode.css) */
  --private-dropdown-shadow-strength: 1;
  --mds-dropdown-drop-shadow: drop-shadow(
      0 --spacing(250) --spacing(200)
        rgb(var(--mds-dropdown-drop-shadow-color-rgb, var(--magma-shadow-ink, var(--tone-neutral-01, 5 5 5))) / calc(0.05 * var(--private-dropdown-shadow-strength)))
    )
    drop-shadow(
      0 --spacing(100) --spacing(75)
        rgb(var(--mds-dropdown-drop-shadow-color-rgb, var(--magma-shadow-ink, var(--tone-neutral-01, 5 5 5))) / calc(0.15 * var(--private-dropdown-shadow-strength)))
    )
    drop-shadow(
      0 0 1px
        rgb(var(--mds-dropdown-drop-shadow-color-rgb, var(--magma-shadow-ink, var(--tone-neutral-01, 5 5 5))) / calc(0.15 * var(--private-dropdown-shadow-strength)))
    );
  --mds-dropdown-duration: var(--duration-500, 500ms);
  --private-dropdown-duration: var(--mds-dropdown-duration, var(--duration-500, 500ms));
  --mds-dropdown-ease: var(--ease-out-expo, cubic-bezier(0.19, 1, 0.22, 1));
  --mds-dropdown-mouseover-delay: var(--duration-500, 500ms);
  --mds-dropdown-transform-from: scale(0.9) translateY(-3%);
  --mds-dropdown-transform-to: scale(1) translate(0, 0);
  --mds-dropdown-z-index: var(--magma-dropdown-z-index, 5000);

  background-color: var(--mds-dropdown-background, rgb(var(--magma-surface-overlay, var(--surface-neutral-overlay, 255 255 255))));
  border-radius: var(--magma-radius-md, var(--radius-squircle-md, 20px));
  box-sizing: border-box;
  corner-shape: var(--magma-corner-shape, squircle);
  display: none;
  filter: var(--mds-dropdown-drop-shadow);
  gap: --spacing(400);
  opacity: 0;
  padding: --spacing(600);
  pointer-events: none;
  position: fixed;
  transform: var(--mds-dropdown-transform-from, scale(0.9) translateY(-3%));
  transition-behavior: allow-discrete;
  transition-duration: var(--private-dropdown-duration);
  transition-property: opacity, transform, display;
  transition-timing-function: var(--mds-dropdown-ease);
  z-index: var(--mds-dropdown-z-index, var(--magma-dropdown-z-index, 5000));
}

:host([visible]:not([visible='false'])) {
  display: grid;
  opacity: 1;
  pointer-events: auto;
  transform: var(--mds-dropdown-transform-to, scale(1) translate(0, 0));

  @starting-style {
    opacity: 0;
    transform: scale(0);
  }
}

/* `data-floating-placed` is written by the floating controller after the first
 * computePosition: before it the panel has no position, so transitioning left and
 * top would slide it in from the corner of the page instead of opening it where
 * the caller is. transform-origin stays out of the list on purpose - it is the
 * pivot of the opening, and interpolating it makes the panel grow from a point
 * that moves while it grows.
 *
 * `display` has to be repeated here. The panel is `display: none` when closed and
 * the sheet leans on `transition-behavior: allow-discrete` to hold it visible for
 * the length of the outro: a list that leaves `display` out hides the panel on the
 * frame the attribute goes away, and the fade never plays. */

:host([data-floating-placed]:not([disable-smooth])),
:host([data-floating-placed][disable-smooth='false']) {
  transition-property: bottom, left, display, opacity, right, top, transform;
}

.arrow {
  display: flex;
  fill: var(--mds-dropdown-arrow-background, rgb(var(--magma-surface-overlay, var(--surface-neutral-overlay, 255 255 255))));
  pointer-events: none;
  position: fixed;
  top: --spacing(-400);
}

::slotted(*) {
  position: relative;
  z-index: 10;
}

/* Motion, held back.
 *
 * Every component zeroes the private durations its own base CSS reads, which composes
 * with the public knobs - but that only reaches the declarations that read them. An audit
 * of the 52 sheets found 21 transitions in 15 components that did not: the host's own
 * transition in mds-button and mds-table, the focus ring of the input family, the tab
 * slider, the close button of mds-note. This reset reaches the whole shadow tree, which is
 * what the preference promises, and keeps reaching it when a declaration is added.
 *
 * Transitions only, on purpose. A keyframe animation is usually a loader, and a loader has
 * to keep saying "working": mds-spinner slows to 8s under reduced motion instead of
 * freezing, and a duration of nearly zero on an infinite animation would spin it out of
 * control instead of stopping it.
 *
 * 0.01ms rather than 0s, so a component that waits for its own transitionend still gets
 * one: mds-modal, mds-push-notification and mds-tree-item all listen for it, and a
 * transition of zero never fires it. */

/* stylelint-disable time-min-milliseconds -- the floor is there to keep a transition
   perceivable; the point of these two is that it is not. */

:host([pref-animation='reduce']),
:host([pref-animation='reduce']) *,
:host([pref-animation='reduce']) *::before,
:host([pref-animation='reduce']) *::after {
  transition-duration: 0.01ms !important;
}

@media (prefers-reduced-motion: reduce) {
  :host([pref-animation='system']),
  :host([pref-animation='system']) *,
  :host([pref-animation='system']) *::before,
  :host([pref-animation='system']) *::after,
  :host(:not([pref-animation])),
  :host(:not([pref-animation])) *,
  :host(:not([pref-animation])) *::before,
  :host(:not([pref-animation])) *::after {
    transition-duration: 0.01ms !important;
  }
}

/* stylelint-enable time-min-milliseconds */


/* Animation preference. The component mirrors the resolved mode from <html>
 * onto its host as pref-animation (see subscribePreference in @common/preference);
 * these plain shadow selectors then zero the private duration(s) the base CSS
 * reads. `reduce` always stops; `system` and no controller follow the OS via
 * @media; `no-preference` keeps the base value. Customization composes (the base
 * sets --private from the public token, this only overrides it when reduced). */

:host([pref-animation='reduce']) {
  --private-dropdown-duration: 0s;
  --private-dropdown-backdrop-duration: 0s;
}

@media (prefers-reduced-motion: reduce) {
  :host([pref-animation='system']),
  :host(:not([pref-animation])) {
    --private-dropdown-duration: 0s;
    --private-dropdown-backdrop-duration: 0s;
  }
}

/* Theme preference. Background and elevation come from the semantic surface layer
 * (--magma-surface-*, spec 6.1): it flips per mode at :root and inherits into the shadow
 * DOM, so the panel needs no dark background of its own.
 * The shadow does: the shadow ink is black in both modes (spec 6.1c, #790), and on the dark
 * canvas the light-mode alphas barely show, so dark triples them. The selectors mirror the
 * dark block of the semantic layer (mode dark, or system or no controller with the OS dark,
 * unless the theme is light only; or a theme locked to dark) and keep the specificity of the
 * pref-contrast rules, which come later and win. */

:host([pref-mode='dark']:not([pref-theme-scheme='light'])),
:host([pref-theme-scheme='dark']) {
  --private-dropdown-shadow-strength: 3;
}

@media (prefers-color-scheme: dark) {
  :host([pref-mode='system']:not([pref-theme-scheme='light'])),
  :host(:not([pref-mode]):not([pref-theme-scheme='light'])) {
    --private-dropdown-shadow-strength: 3;
  }
}

/* Contrast preference. The component reflects the resolved mode from <html> onto
 * its host as pref-contrast (see subscribePreference in @common/preference); these
 * plain shadow selectors refine for high contrast. `more` is the explicit choice;
 * `system` and no controller follow the OS via @media. Cross-browser, no :host-context.
 * The centred glow (0 0 4px) is an outline, not a projected shadow: it names
 * --magma-text-default, which flips with the mode, not --magma-shadow-ink, which does not. */

:host([pref-contrast='more']) {
  --mds-dropdown-drop-shadow: drop-shadow(0 0 --spacing(100) rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)) / 0.05))
    drop-shadow(0 0 --spacing(100) rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)) / 0.3))
    drop-shadow(0 0 --spacing(100) rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)) / 0.3));
}

@media (prefers-contrast: more) {
  :host([pref-contrast='system']),
  :host(:not([pref-contrast])) {
    --mds-dropdown-drop-shadow: drop-shadow(0 0 --spacing(100) rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)) / 0.05))
      drop-shadow(0 0 --spacing(100) rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)) / 0.3))
      drop-shadow(0 0 --spacing(100) rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)) / 0.3));
  }
}

/* The glow is an outline in the text ink, light on the dark page: see mds-dropdown-pref-contrast.css. */

:host([pref-contrast='more'][pref-mode='dark']:not([pref-theme-scheme='light'])),
:host([pref-contrast='more'][pref-theme-scheme='dark']) {
  --mds-dropdown-drop-shadow: drop-shadow(0 0 --spacing(100) rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)) / 0.075))
    drop-shadow(0 0 --spacing(100) rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)) / 0.45))
    drop-shadow(0 0 --spacing(100) rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)) / 0.45));
}

@media (prefers-contrast: more) {
  :host([pref-contrast='system'][pref-mode='dark']:not([pref-theme-scheme='light'])),
  :host([pref-contrast='system'][pref-theme-scheme='dark']) {
    --mds-dropdown-drop-shadow: drop-shadow(0 0 --spacing(100) rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)) / 0.05))
      drop-shadow(0 0 --spacing(100) rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)) / 0.3))
      drop-shadow(0 0 --spacing(100) rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)) / 0.3));
  }
}

@media (prefers-color-scheme: dark) {
  :host([pref-contrast='more'][pref-mode='system']:not([pref-theme-scheme='light'])) {
    --mds-dropdown-drop-shadow: drop-shadow(0 0 --spacing(100) rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)) / 0.05))
      drop-shadow(0 0 --spacing(100) rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)) / 0.3))
      drop-shadow(0 0 --spacing(100) rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)) / 0.3));
  }
}

@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :host([pref-contrast='system'][pref-mode='system']:not([pref-theme-scheme='light'])) {
    --mds-dropdown-drop-shadow: drop-shadow(0 0 --spacing(100) rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)) / 0.05))
      drop-shadow(0 0 --spacing(100) rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)) / 0.3))
      drop-shadow(0 0 --spacing(100) rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)) / 0.3));
  }
}

