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


mds-input-tip-item {
  &:not(:is([hydrated], .hydrated)) {
    @apply not-hydrated;
  }
}


/**
 * @prop --mds-input-tip-active-translate: Transform applied to the bottom tip when active
 * @prop --mds-input-tip-background: Public. Background color of the input tip
 * @prop --mds-input-tip-field-radius: The corner radius of the field the tip stands on: the top tip keeps clear of the corner by it, plus a margin
 * @prop --mds-input-tip-horizontal-offset-focused: Horizontal offset of the bottom tip when the input is focused
 * @prop --mds-input-tip-horizontal-offset: Default horizontal offset of the bottom tip
 * @prop --mds-input-tip-vertical-offset: Vertical offset of the bottom tip
 */

:host {
  --mds-input-tip-transition-duration: var(--duration-300, 300ms);
  --private-input-tip-transition-duration: var(--mds-input-tip-transition-duration);
  --mds-input-tip-active-translate: translate(0, 0);
  --mds-input-tip-background: rgb(var(--magma-surface-inverse-muted, var(--tone-neutral-03, 73 73 73)));
  --mds-input-tip-field-radius: 0px;
  --mds-input-tip-horizontal-offset-focused: 0px;
  --mds-input-tip-horizontal-offset: --spacing(400);
  --mds-input-tip-vertical-offset: --spacing(100);

  display: flex;
  gap: --spacing(100);
  justify-content: flex-end;
  left: var(--mds-input-tip-horizontal-offset, --spacing(400));
  pointer-events: none;
  position: absolute;
  right: var(--mds-input-tip-horizontal-offset, --spacing(400));
  transform: var(--mds-input-tip-active-translate, translate(0, 0));
  transition-duration: var(--private-input-tip-transition-duration);
  transition-property: transform;
  transition-timing-function: var(--ease-out-expo, cubic-bezier(0.19, 1, 0.22, 1));
}

:host(:empty) {
  display: none;
}

/* The top tip stands on the top border of its field, half outside (half the height of an item,
 * --spacing(300)), and stays there while the field has the focus: inside the field it covered the
 * button at its end, and at md and sm it covered it almost whole. It keeps clear of the corner by
 * the radius of the field, passed as --mds-input-tip-field-radius, plus a margin, so that it sits
 * on the straight part of the border (vittorio 2026-11-11, #1368). */

:host([position='top']) {
  left: calc(var(--mds-input-tip-field-radius) + --spacing(200));
  right: calc(var(--mds-input-tip-field-radius) + --spacing(200));
  top: calc(--spacing(300) / -2);
}

:host([position='bottom']) {
  bottom: var(--mds-input-tip-vertical-offset, --spacing(100));
}

:host([position='bottom'][active]:not([active='false'])) {
  --mds-input-tip-active-translate: translate(
    calc(var(--mds-input-tip-horizontal-offset-focused, 0px) * -1),
    var(--mds-input-tip-vertical-offset, --spacing(100))
  );
}

:host([position='bottom'][active]:not([active='false'])) ::slotted(mds-input-tip-item) {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

/* 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-input-tip-transition-duration: 0s;
}

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

