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


/**
 * @prop --mds-text-selection-background: Background color used when text is selected.
 * @prop --mds-text-selection-color: Text color used when text is selected.
 * @prop --mds-text-line-clamp: Public. Number of lines to clamp text to (line-clamp).
 * @prop --mds-text-animation-speed: Public. Speed of text animation.
 * @prop --mds-text-animation-placeholder-char: Public. Placeholder character used during text animation.
 */

:host {
  --mds-text-selection-background: rgb(var(--label-sky-09, 196 229 250));
  --mds-text-selection-color: rgb(var(--label-sky-01, 1 48 72));
  --mds-text-line-clamp: 3;
  --mds-text-animation-speed: 0.5;
  --mds-text-animation-placeholder-char: ' ';
  --mds-text-transition-duration: var(--duration-200, 200ms);
  --private-text-transition-duration: var(--mds-text-transition-duration);

  display: flex;
  min-width: 0;
}

.text::selection {
  background-color: var(--mds-text-selection-background, rgb(var(--label-sky-09, 196 229 250)));
  color: var(--mds-text-selection-color, rgb(var(--label-sky-01, 1 48 72)));
}

.text {
  cursor: inherit;
  display: inherit;
}

/* The animation fills the characters it has not revealed yet with the placeholder, which
   is a space by default: collapsed like any other run of spaces, it would give the element
   no width and - while every character is still a placeholder - no line box either, so the
   text would blink into existence and push whatever sits around it. Kept as typed, the
   placeholders hold the final box from the first frame. */

:host([animation='yugop']) .text {
  white-space: pre-wrap;
}

:host([typography='snippet']) {
  @apply text-code-snippet;
}

:host([typography='hack']) {
  @apply text-code-hack;
}

:host([typography='h1']) {
  @apply text-title-h1;
}

:host([typography='h2']) {
  @apply text-title-h2;
}

:host([typography='h3']) {
  @apply text-title-h3;
}

:host([typography='h4']) {
  @apply text-title-h4;
}

:host([typography='h5']) {
  @apply text-title-h5;
}

:host([typography='h6']) {
  @apply text-title-h6;
}

/* Titles by role (#1189): each reads the tokens of its role, which point at the level it is
   styled as, so a theme moves a role in one place */

:host([typography='page']) {
  @apply text-title-page;
}

:host([typography='section']) {
  @apply text-title-section;
}

:host([typography='dialog']) {
  @apply text-title-dialog;
}

:host([typography='part']) {
  @apply text-title-part;
}

:host([typography='group']) {
  @apply text-title-group;
}

:host([typography='h1']),
:host([typography='h2']),
:host([typography='h3']),
:host([typography='h4']),
:host([typography='h5']),
:host([typography='h6']),
:host([typography='page']),
:host([typography='section']),
:host([typography='dialog']),
:host([typography='part']),
:host([typography='group']) {
  text-wrap: balance;
}

:host([typography='action']) {
  @apply text-title-action;
}

:host([typography='paragraph']) {
  @apply text-info-paragraph;
}

:host([typography='detail']) {
  @apply text-info-detail;
}

:host([typography='caption']) {
  @apply text-info-caption;
}

:host([typography='paragraph']),
:host([typography='detail']),
:host([typography='caption']) {
  text-wrap: pretty;
}

:host([typography='label']) {
  @apply text-info-label;
}

:host([typography='tip']) {
  @apply text-info-tip;
}

:host([typography='option']) {
  @apply text-info-option;
}

:host([typography='paragraph'][variant='read']) {
  @apply text-read-paragraph;
}

:host([typography='detail'][variant='read']) {
  @apply text-read-detail;
}

:host([typography='caption'][variant='read']) {
  @apply text-read-caption;
}

:host([tag='article']),
:host([tag='blockquote']),
:host([tag='dd']),
:host([tag='details']),
:host([tag='div']),
:host([tag='dl']),
:host([tag='dt']),
:host([tag='figcaption']),
:host([tag='h1']),
:host([tag='h2']),
:host([tag='h3']),
:host([tag='h4']),
:host([tag='h5']),
:host([tag='h6']),
:host([tag='label']),
:host([tag='legend']),
:host([tag='li']),
:host([tag='ol']),
:host([tag='p']),
:host([tag='pre']),
:host([tag='summary']),
:host([tag='ul']) {
  display: block;
}

/* Text to read stops at the reading measure, as the reset does for the plain tags. On the
   host, which carries the type style, so the ch is that of its own text. */

:host([tag='figcaption']),
:host([tag='li']),
:host([tag='p']) {
  @apply max-w-text;
}

:host([tag='abbr']),
:host([tag='address']),
:host([tag='b']),
:host([tag='bdo']),
:host([tag='cite']),
:host([tag='code']),
:host([tag='del']),
:host([tag='dfn']),
:host([tag='em']),
:host([tag='i']),
:host([tag='ins']),
:host([tag='kbd']),
:host([tag='mark']),
:host([tag='q']),
:host([tag='rb']),
:host([tag='rt']),
:host([tag='ruby']),
:host([tag='s']),
:host([tag='samp']),
:host([tag='small']),
:host([tag='span']),
:host([tag='strong']),
:host([tag='sub']),
:host([tag='sup']),
:host([tag='time']),
:host([tag='u']),
:host([tag='var']) {
  display: inline;
}

:host([tag='code']) {
  @apply ease-in-out;

  background-color: rgb(var(--magma-wash-base, var(--tone-neutral-09, 225 225 225)));
  border-radius: var(--magma-radius-3xs, var(--radius-squircle-3xs, 6px));
  box-shadow: rgb(var(--magma-border-default, var(--border-neutral-default, 183 183 183))) 0 0 0 1px;
  color: rgb(var(--magma-text-muted, var(--text-neutral-muted, 73 73 73)));
  corner-shape: var(--magma-corner-shape, squircle);
  padding-block: --spacing(25);
  padding-inline: --spacing(100);
  transition-duration: var(--private-text-transition-duration);
  transition-property: color, background-color;
}

/* The label and option typographies trim the box to the cap height (text-box), so what
   rises above the capitals or drops below the baseline - the accent of a capital, a
   cedilla, the tail of a comma - is ink outside the box, and clipping the box cut it off.
   So the clip follows what each value has to hide: none and word only clip the inline end,
   for the ellipsis. flow-root keeps the formatting context that overflow: hidden used to
   give and overflow: clip does not. */

:host([truncate]) .text {
  display: flow-root;
  min-width: 0;
  overflow: clip visible;
  text-overflow: ellipsis;
}

:host([truncate='word']) .text {
  white-space: nowrap;
}

/* all has to hide the lines after the clamp, so the clip stays at the bottom of the box,
   where it still cuts the cedilla of the last visible line: the accents of the next line
   rise into the same band. Above the first line there is nothing to hide, so the clip opens
   upward: overflow-clip-margin widens it on every side and clip-path closes it again on the
   bottom and the sides. Without overflow-clip-margin (Safari) it stays at the box. */

:host([truncate='all']) .text {
  clip-path: inset(-0.5lh 0 0);
  overflow: clip;
  overflow-clip-margin: 0.5lh;
}

@supports (line-clamp: 1) {
  :host([truncate='all']) .text {
    line-clamp: var(--mds-text-line-clamp, 1);
  }
}

@supports (display: -webkit-box) {
  :host([truncate='all']) .text {
    -webkit-box-orient: vertical;

    /* stylelint-disable-next-line value-no-vendor-prefix */
    display: -webkit-box;
    -webkit-line-clamp: var(--mds-text-line-clamp, 1);
  }
}

abbr,
address,
article,
b,
bdo,
blockquote,
cite,
code,
dd,
del,
details,
dfn,
div,
dl,
dt,
em,
figcaption,
h1,
h2,
h3,
h4,
h5,
h6,
i,
ins,
kbd,
label,
legend,
li,
mark,
ol,
p,
pre,
q,
rb,
rt,
ruby,
s,
samp,
small,
span,
strong,
sub,
summary,
sup,
time,
u,
ul,
var,
wbr {
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  margin: 0;
  overflow: inherit;
  text-overflow: inherit;
}

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

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

