@keyframes focus-bounce {
  0%,
  75%,
  100% {
    outline-offset: var(--magma-outline-focus-offset, 2px);
  }

  50% {
    outline-offset: var(--magma-outline-blur-offset, 6px);
  }
}

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


mds-icon,
mds-spinner,
mds-text {
  &:not(:is([hydrated], .hydrated)) {
    @apply not-hydrated;
  }
}


/**
 * @prop --mds-button-await-duration: Sets the duration of the rotation of the spinner await component
 * @prop --mds-button-background: Public. Sets the background-color of the component
 * @prop --mds-button-border-color-rgb: Sets the color of the border of the component (based on box-shadow declaration)
 * @prop --mds-button-border-default-opacity: Sets the default opacity of the border color of the component (based on box-shadow declaration)
 * @prop --mds-button-border-high-contrast-hover-width: Deprecated, read by nothing: the button has no high contrast border of its own, the contrast preference acts on the colour roles.
 * @prop --mds-button-border-high-contrast-width: Deprecated, read by nothing: the button has no high contrast border of its own, the contrast preference acts on the colour roles.
 * @prop --mds-button-border-hover-opacity: Sets the opacity of the border color when the component is hovered (based on box-shadow declaration)
 * @prop --mds-button-border-opacity: Sets the border opacity of the component (based on box-shadow declaration)
 * @prop --mds-button-border-tone-outline-hover-width: Sets the width of the border when the component is hovered when the tone is set to `outline` (based on box-shadow declaration)
 * @prop --mds-button-border-tone-strong-hover-width: Sets the width of the border when the component is hovered when the tone is set to `strong` (based on box-shadow declaration)
 * @prop --mds-button-border-tone-weak-hover-width: Sets the width of the border when the component is hovered when the tone is set to `weak` (based on box-shadow declaration)
 * @prop --mds-button-border-width: Sets the border width of the component (based on box-shadow declaration)
 * @prop --mds-button-color: Public. Sets the text color of the component
 * @prop --mds-button-gap: Public. Sets the distance betwen element inside the components, use it instead of setting gap property directly.
 * @prop --mds-button-label-transform: Public. Sets the text-transform of the first letter of the label, `uppercase` by default; `none` shows the label as written. It inherits: set on `mds-button-dropdown` or any ancestor, it reaches the buttons inside other components too
 * @prop --mds-button-radius: Public. Sets the border-radius of the component
 */

:host {

  /* stylelint-disable-next-line magma/token-values -- 725ms, one turn of the await spinner as in mds-spinner, no --duration-* step says it */
  --mds-button-await-duration: 0.725s;
  --mds-button-transition-duration: var(--duration-300, 300ms);
  --private-button-transition-duration: var(--mds-button-transition-duration);
  --mds-button-border-hover-opacity: 0.75;
  --mds-button-border-tone-outline-hover-width: --spacing(75);
  --mds-button-border-tone-outline-opacity: 0.3;
  --mds-button-border-tone-strong-hover-width: --spacing(50);
  --mds-button-border-tone-weak-hover-width: --spacing(50);
  --mds-button-border-default-opacity: 0;
  --mds-button-border-opacity: 0;
  --mds-button-border-width: --spacing(50);
  --mds-button-gap: --spacing(200);
  --mds-button-line-clamp: 1;

  /* past half the height the browser clamps the radius; where corner-shape cannot be
     drawn, --magma-corner-cap gives the round look-alike of that clamp (#913) */
  --mds-button-radius: min(
    var(--magma-radius-2xl, var(--radius-squircle-2xl, 40px)),
    var(--magma-corner-cap, 0.5) * var(--private-button-height)
  );

  /* the min-height of the size */
  --private-button-height: --spacing(900);

  @apply focus-bounce;

  align-items: center;
  align-self: flex-start;
  background-color: var(--mds-button-background, rgb(var(--magma-accent-emphasis, var(--variant-primary-04, 11 96 255))));
  border-radius: var(--mds-button-radius, var(--magma-radius-2xl, var(--radius-squircle-2xl, 40px)));
  box-shadow: 0 0 0 var(--mds-button-border-width, --spacing(50))
    rgb(var(--mds-button-border-color-rgb, var(--magma-accent-emphasis, var(--variant-primary-04, 11 96 255))) / var(--mds-button-border-opacity, 0));
  box-sizing: border-box;
  color: var(--mds-button-color, rgb(var(--magma-text-on-emphasis, var(--tone-neutral-seed, 255 255 255))));
  corner-shape: var(--mds-button-corner-shape, var(--magma-corner-shape, squircle));
  cursor: pointer;
  display: inline-flex;
  fill: currentcolor;
  gap: var(--mds-button-gap, --spacing(200));
  justify-content: center;
  justify-self: flex-start;
  min-height: var(--private-button-height);
  min-width: var(--private-button-height);
  padding: 0 --spacing(400);
  position: relative;
  transition-duration: var(--duration-200, 200ms);
  transition-property:
    background-color, border-color, box-shadow, color, outline, outline-offset, transform;
  transition-timing-function: var(--ease-out-quad, cubic-bezier(0.25, 0.46, 0.45, 0.94));
  -webkit-user-select: none;
          user-select: none;
}

:host(:focus-visible) {
  @apply focus-bounce--focused;

  z-index: 10;
}

/* the link rendered when href is set: an empty anchor over the whole button, under the pointer,
   so that the browser gives it what it gives every link (new tab on a modifier or middle click,
   the context menu, drag, the URL in the status bar) while the host keeps the focus ring */

.link {
  border-radius: inherit;
  corner-shape: inherit;
  inset: 0;
  outline: none;
  position: absolute;
  z-index: 1;
}

.text {
  --mds-text-line-clamp: var(--mds-button-line-clamp, 1);
}

/* --mds-button-label-transform is not set on :host, so a value set on an ancestor -
   mds-button-dropdown, or any component that renders buttons in its shadow root - reaches the
   label (#799) */

.text::first-letter {
  text-transform: var(--mds-button-label-transform, uppercase);
}

.icon {
  align-items: center;
  display: inline-flex;
  fill: inherit;
  flex-shrink: 0;
  justify-content: center;
  pointer-events: none;
  transition-duration: var(--private-button-transition-duration);
  transition-property: fill;
  transition-timing-function: var(--ease-in-out-quad, cubic-bezier(0.455, 0.03, 0.515, 0.955));
}

.await {
  display: none;
  height: --spacing(600);
  margin-right: calc(calc(-1 * var(--mds-button-gap, --spacing(200))) - --spacing(600));
  transform: scale(0);
  transition-behavior: allow-discrete;
  transition-duration: var(--private-button-transition-duration);
  transition-property: display, margin-right, opacity, transform, width;
  transition-timing-function: var(--ease-in-out-quad, cubic-bezier(0.455, 0.03, 0.515, 0.955));
  width: --spacing(600);
}

.spinner {
  --mds-spinner-duration: var(--mds-button-await-duration, 0.725s);

  color: currentcolor;
  height: --spacing(600);
  width: --spacing(600);
}

:host(:not([await])),
:host([await='false']) {
  .spinner {
    transition-duration: var(--duration-200, 200ms);
    transition-timing-function: var(--ease-out-quad, cubic-bezier(0.25, 0.46, 0.45, 0.94));
  }
}

:host([await]:not([await='false'])) .await {
  display: flex;
  margin-right: 0;
  opacity: 1;
  transform: scale(1);

  @starting-style {
    margin-right: calc(calc(-1 * var(--mds-button-gap, --spacing(200))) - --spacing(600));
    opacity: 0;
    transform: scale(0);
  }
}

:host([await]:not([await='false'])) {
  pointer-events: none;
}

/* A button with no label is a square (`aspect-ratio: 1` in the size sheet), so letting the
   spinner in NEXT to the icon grows it in both axes - 36px to 56px at md - and pushes
   whatever line it sits in: a table row with an mds-keyboard in it jumps by 16px. With no
   label to keep it company, the spinner takes the icon's place and the box stays put. */

:host([icon]:not([label])[await]:not([await='false'])) .icon {
  display: none;
}

/* :disabled also covers a disabled fieldset around the button, which sets no attribute */

:host([disabled]:not([disabled='false'])),
:host(:disabled:not([disabled='false'])) {
  opacity: 0.5;
  pointer-events: none;
}

:host([size='sm']) {
  --mds-button-radius: min(
    var(--magma-radius-md, var(--radius-squircle-md, 20px)),
    var(--magma-corner-cap, 0.5) * var(--private-button-height)
  );
  --private-button-height: --spacing(700);

  padding: 0 --spacing(300);

  .icon {
    height: --spacing(400);
    width: --spacing(400);
  }

  /* scale() takes a number, so 75 is 7500%: the spinner of a small button was painted
     1800px wide, off the button and over the page, which is why nobody ever saw it. */

  &:host([await]:not([await='false'])) .await {
    transform: scale(0.75);
  }
}

:host([size='md']) {
  --private-button-height: --spacing(900);

  padding-left: --spacing(400);
  padding-right: --spacing(400);

  &:host([icon][icon-position='left']) {
    padding-left: --spacing(300);
  }

  &:host([icon][icon-position='right']) {
    padding-right: --spacing(300);
  }
}

:host([size='lg']) {
  --private-button-height: --spacing(1200);

  padding-left: --spacing(500);
  padding-right: --spacing(500);

  &:host([icon][icon-position='left']) {
    padding-left: --spacing(400);
  }

  &:host([icon][icon-position='right']) {
    padding-right: --spacing(400);
  }
}

:host([size='xl']) {
  --private-button-height: --spacing(1300);

  padding-left: --spacing(600);
  padding-right: --spacing(600);

  .icon {
    height: --spacing(800);
    width: --spacing(800);
  }
}

:host([size][icon][icon-position]:not([label])) {
  aspect-ratio: 1;
  padding: 0;
}

/* The label is a span of the button (#831), painted as mds-text paints it: the typography of
   the size (meta/variants.ts, md for a size it does not know) and the truncation. The animated
   label is still an mds-text, which does both itself. The larger sizes only add what h6 and h5
   change over action: the weight and the size.

   A span in a flex container is a block already, so only line-clamp sets a display: the
   no-text sheet, imported after this one, hides a button's empty label at the same
   specificity. */

.label {
  @apply text-title-action;

  min-width: 0;
}

:host([size='lg']) .label {
  @apply font-bold text-size-title-h6;

  text-wrap: balance;
}

:host([size='xl']) .label {
  @apply font-black text-size-title-h5;

  text-wrap: balance;
}

:host([truncate]) .label {
  overflow: hidden;
  text-overflow: ellipsis;
}

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

:host([truncate='all']) .label {
  -webkit-box-orient: vertical;

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

:host(:not([label])) .text,
:host([label='']) .text {
  display: none;
}


/* Variant x tone. A variant only names its tokens, in the private roles below; the tone rules,
 * written once at the end of this file, paint the public properties from the roles. Repeating
 * every tone in every variant was 27KB of the stylesheet, which a declarative shadow root
 * carries in each button (#831). Defaults are primary's, which secondary shares; a role that
 * defaults to another one follows the variant's value of that one.
 *
 *   fill            strong: background and ring, at rest (tone box too)
 *   fill-hover      strong: background and ring, on hover
 *   on-fill         strong: ink
 *   wash            weak: background and ring, at rest
 *   wash-hover      weak: background on hover
 *   wash-hover-ring weak: ring on hover
 *   ink             weak: ink and icon fill (the fill stays at rest on hover)
 *   ink-hover       weak: ink on hover
 *   outline         outline: ring
 *   outline-ink     outline: ink at rest
 *   text-ink        text: ink at rest; outline: ink on hover
 *   text-ink-hover  text: ink on hover
 *   text-wash       text: background on hover
 *   text-ink-active text: ink while active
 *   current-wash    weak: background of the current button (mds-button-current.css), the
 *                   selected role of the family; a variant whose hover keeps the wash keeps it
 *
 * The tone rules stay at or below the specificity of the service variants, which come after
 * and set the public properties themselves, and of the tone sheet, which comes last. */

:host {
  --private-button-fill: var(--magma-accent-emphasis, var(--variant-primary-04, 11 96 255));
  --private-button-fill-hover: var(--magma-accent-emphasis-hover, var(--variant-primary-03, 0 73 211));
  --private-button-on-fill: var(--magma-text-on-emphasis, var(--tone-neutral-seed, 255 255 255));
  --private-button-wash: var(--magma-accent-surface, var(--variant-primary-09, 213 224 245));
  --private-button-wash-hover: var(--magma-accent-surface-hover, var(--variant-primary-08, 195 212 245));
  --private-button-wash-hover-ring: var(--private-button-wash-hover);
  --private-button-ink: var(--private-button-fill-hover);
  --private-button-ink-hover: var(--private-button-ink);
  --private-button-outline: var(--private-button-fill);
  --private-button-outline-ink: var(--private-button-ink);
  --private-button-text-ink: var(--magma-accent-emphasis-active, var(--variant-primary-02, 0 57 163));
  --private-button-text-ink-hover: var(--private-button-fill);
  --private-button-text-wash: var(--magma-accent-surface-subtle, var(--variant-primary-10, 231 237 248));
  --private-button-text-ink-active: var(--private-button-text-ink);
  --private-button-current-wash: var(--magma-accent-surface-selected, var(--variant-primary-10, 231 237 248));
  --mds-button-background: rgb(var(--private-button-fill));
  --mds-button-border-color-rgb: var(--private-button-fill);
  --mds-button-color: rgb(var(--private-button-on-fill));
}

:host([variant='ai']) {
  --private-button-fill: var(--magma-accent-ai-emphasis, var(--variant-ai-04, 128 78 232));
  --private-button-fill-hover: var(--magma-accent-ai-emphasis-hover, var(--variant-ai-03, 105 49 204));
  --private-button-wash: var(--magma-accent-ai-surface, var(--variant-ai-09, 225 219 255));
  --private-button-wash-hover: var(--magma-accent-ai-surface-hover, var(--variant-ai-08, 214 205 255));
  --private-button-text-ink: var(--magma-accent-ai-emphasis-active, var(--variant-ai-02, 84 7 175));
  --private-button-text-wash: var(--magma-accent-ai-surface-subtle, var(--variant-ai-10, 238 235 255));
  --private-button-current-wash: var(--magma-accent-ai-surface-selected, var(--variant-ai-10, 238 235 255));
}

/* the tones, strong (and box) at rest in the :host rule above */

:host([tone='strong']:hover) {
  --mds-button-background: rgb(var(--private-button-fill-hover));
  --mds-button-border-color-rgb: var(--private-button-fill-hover);
}

:host([tone='weak']) {
  --mds-button-background: rgb(var(--private-button-wash));
  --mds-button-border-color-rgb: var(--private-button-wash);
  --mds-button-color: rgb(var(--private-button-ink));

  fill: rgb(var(--private-button-ink));
}

:host([tone='weak']:hover) {
  --mds-button-background: rgb(var(--private-button-wash-hover));
  --mds-button-border-color-rgb: var(--private-button-wash-hover-ring);
  --mds-button-color: rgb(var(--private-button-ink-hover));
}

:host([tone='outline']) {
  --mds-button-border-color-rgb: var(--private-button-outline);
  --mds-button-color: rgb(var(--private-button-outline-ink));
}

:host([tone='outline']:hover) {
  --mds-button-color: rgb(var(--private-button-text-ink));
}

:host([tone='text']) {
  --mds-button-color: rgb(var(--private-button-text-ink));
}

:host([tone='text']:hover) {
  --mds-button-background: rgb(var(--private-button-text-wash));
  --mds-button-color: rgb(var(--private-button-text-ink-hover));
}

:host([tone='text'][active]) {
  --mds-button-color: rgb(var(--private-button-text-ink-active));
}

/* The status variants, in the roles of mds-button-variant.css. A hue says the selected area of
 * its wash by intensity, wash-soft, lighter than the wash-strong of its hover (#1269) */

:host([variant='info']),
:host([variant='success']),
:host([variant='warning']),
:host([variant='error']) {
  --private-button-text-ink-hover: var(--private-button-ink-hover);
  --private-button-text-ink-active: var(--private-button-ink-hover);
}

:host([variant='info']) {
  --private-button-fill: var(--magma-info-emphasis, var(--status-info-04, 0 119 164));
  --private-button-fill-hover: var(--magma-info-emphasis-hover, var(--status-info-03, 0 94 137));
  --private-button-on-fill: var(--magma-info-on-emphasis, var(--tone-neutral-seed, 255 255 255));
  --private-button-wash: var(--magma-info-wash-base, var(--status-info-09, 193 230 246));
  --private-button-current-wash: var(--magma-info-wash-soft, var(--status-info-10, 220 240 250));
  --private-button-wash-hover: var(--magma-info-wash-strong, var(--status-info-08, 168 219 242));
  --private-button-ink: var(--magma-info-text-subtle, var(--text-info-subtle, 0 94 137));
  --private-button-ink-hover: var(--magma-info-text-default, var(--text-info-default, 0 45 86));
  --private-button-text-ink: var(--magma-info-text-muted, var(--text-info-muted, 0 71 114));
  --private-button-text-wash: var(--magma-info-wash-soft, var(--status-info-10, 220 240 250));
}

:host([variant='success']) {
  --private-button-fill: var(--magma-success-emphasis, var(--status-success-04, 0 128 57));
  --private-button-fill-hover: var(--magma-success-emphasis-hover, var(--status-success-03, 0 102 32));
  --private-button-on-fill: var(--magma-success-on-emphasis, var(--tone-neutral-seed, 255 255 255));
  --private-button-wash: var(--magma-success-wash-base, var(--status-success-09, 191 233 205));
  --private-button-current-wash: var(--magma-success-wash-soft, var(--status-success-10, 220 243 227));
  --private-button-wash-hover: var(--magma-success-wash-strong, var(--status-success-08, 165 225 186));
  --private-button-ink: var(--magma-success-text-subtle, var(--text-success-subtle, 0 102 32));
  --private-button-ink-hover: var(--magma-success-text-default, var(--text-success-default, 0 53 0));
  --private-button-text-ink: var(--magma-success-text-muted, var(--text-success-muted, 0 80 7));
  --private-button-text-wash: var(--magma-success-wash-soft, var(--status-success-10, 220 243 227));
}

:host([variant='warning']) {
  --private-button-fill: var(--magma-warning-emphasis, var(--status-warning-04, 142 106 0));
  --private-button-fill-hover: var(--magma-warning-emphasis-hover, var(--status-warning-03, 113 85 0));
  --private-button-on-fill: var(--magma-warning-on-emphasis, var(--tone-neutral-seed, 255 255 255));
  --private-button-wash: var(--magma-warning-wash-base, var(--status-warning-09, 255 220 117));
  --private-button-current-wash: var(--magma-warning-wash-soft, var(--status-warning-10, 255 237 181));
  --private-button-wash-hover: var(--magma-warning-wash-strong, var(--status-warning-08, 255 205 57));
  --private-button-ink: var(--magma-warning-text-subtle, var(--text-warning-subtle, 113 85 0));
  --private-button-ink-hover: var(--magma-warning-text-default, var(--text-warning-default, 58 44 0));
  --private-button-text-ink: var(--magma-warning-text-muted, var(--text-warning-muted, 88 66 0));
  --private-button-text-wash: var(--magma-warning-wash-soft, var(--status-warning-10, 255 237 181));
}

:host([variant='error']) {
  --private-button-fill: var(--magma-danger-emphasis, var(--status-error-04, 196 64 65));
  --private-button-fill-hover: var(--magma-danger-emphasis-hover, var(--status-error-03, 165 33 40));
  --private-button-on-fill: var(--magma-danger-on-emphasis, var(--tone-neutral-seed, 255 255 255));
  --private-button-wash: var(--magma-danger-wash-base, var(--status-error-09, 255 214 211));
  --private-button-current-wash: var(--magma-danger-wash-soft, var(--status-error-10, 255 232 230));
  --private-button-wash-hover: var(--magma-danger-wash-strong, var(--status-error-08, 254 198 194));
  --private-button-ink: var(--magma-danger-text-subtle, var(--text-error-subtle, 165 33 40));
  --private-button-ink-hover: var(--magma-danger-text-default, var(--text-error-default, 89 0 0));
  --private-button-text-ink: var(--magma-danger-text-muted, var(--text-error-muted, 132 0 11));
  --private-button-text-wash: var(--magma-danger-wash-soft, var(--status-error-10, 255 232 230));
}

/* The light / dark variants are a pure-inversion pair: light is painted in the
 * paper of the mode, --tone-neutral-seed (#fff light / #000 dark), dark in the
 * ink of the mode. The seed is the intended value here, not a surface: no
 * elevation role is paper in both modes (SEMANTIC_COLOR_SPEC 10 and 15).
 * In the roles of mds-button-variant.css.
 *
 * Both keep the wash of weak on hover: the current button, halfway between rest and hover,
 * keeps it too, and its bold label marks it (#1264). */

:host([variant='light']) {
  --private-button-fill: var(--tone-neutral-seed, 255 255 255);
  --private-button-fill-hover: var(--private-button-fill);
  --private-button-on-fill: var(--magma-text-muted, var(--text-neutral-muted, 73 73 73));
  --private-button-wash: var(--private-button-fill);
  --private-button-wash-hover: var(--private-button-fill);
  --private-button-ink: var(--private-button-on-fill);
  --private-button-ink-hover: var(--magma-text-default, var(--text-neutral-default, 5 5 5));
  --private-button-outline: var(--magma-text-on-emphasis, var(--tone-neutral-seed, 255 255 255));
  --private-button-outline-ink: var(--private-button-outline);
  --private-button-text-ink: var(--private-button-outline);
  --private-button-text-ink-hover: var(--magma-on-inverse, var(--tone-neutral-seed, 255 255 255));
  --private-button-text-wash: var(--magma-surface-inverse-muted, var(--tone-neutral-03, 73 73 73));
  --private-button-current-wash: var(--private-button-wash);
}

:host([variant='dark']) {
  --private-button-fill: var(--magma-surface-inverse, var(--tone-neutral-02, 42 42 42));
  --private-button-fill-hover: var(--magma-surface-inverse-muted, var(--tone-neutral-03, 73 73 73));
  --private-button-on-fill: var(--magma-on-inverse, var(--tone-neutral-seed, 255 255 255));
  --private-button-wash: var(--magma-wash-strong, var(--tone-neutral-08, 208 208 208));
  --private-button-wash-hover: var(--private-button-wash);
  --private-button-wash-hover-ring: var(--magma-border-strong, var(--border-neutral-strong, 140 140 140));
  --private-button-ink: var(--magma-text-default, var(--text-neutral-default, 5 5 5));
  --private-button-outline-ink: var(--magma-text-muted, var(--text-neutral-muted, 73 73 73));
  --private-button-text-ink: var(--private-button-ink);
  --private-button-text-ink-hover: var(--private-button-ink);
  --private-button-text-wash: var(--magma-wash-soft, var(--tone-neutral-10, 237 237 237));
  --private-button-current-wash: var(--private-button-wash);
}

/* The google button is painted in the paper of the mode, --tone-neutral-seed
 * (#fff light / #000 dark), as the brand button is: the seed is intended here.
 * The service buttons set the public properties themselves, over the tone rules of
 * mds-button-variant.css; the ink role is the icon fill of the weak tone. */

:host([variant='google']),
:host([variant='google'][tone]) {
  --mds-button-background: rgb(var(--tone-neutral-seed, 255 255 255));
  --mds-button-border-hover-opacity: 0.5;
  --mds-button-border-hover-width: --spacing(50);
  --mds-button-border-opacity: 0.2;
  --mds-button-border-width: --spacing(25);
  --mds-button-color: rgb(var(--magma-text-muted, var(--text-neutral-muted, 73 73 73)));

  /* a ring (0 0 0 1px), not a shadow: it outlines the button in the text ink, so it
   * stays light around the black button in dark */
  --mds-button-border-color-rgb: var(--magma-text-default, var(--text-neutral-default, 5 5 5));
  --private-button-ink: var(--magma-text-muted, var(--text-neutral-muted, 73 73 73));

  box-shadow: 0 0 0 var(--mds-button-border-width, --spacing(50))
    rgb(var(--mds-button-border-color-rgb, var(--magma-accent-emphasis, var(--variant-primary-04, 11 96 255))) / var(--mds-button-border-opacity, 0));
}

:host([variant='google']:hover),
:host([variant='google'][tone]:hover) {
  --mds-button-background: rgb(var(--tone-neutral-seed, 255 255 255));
  --mds-button-border-width: var(--mds-button-border-hover-width);
  --mds-button-border-opacity: var(--mds-button-border-hover-opacity, 0.75);
}

:host([variant='apple']) .icon {
  transform: translateY(-5%);
}

:host([variant='apple']),
:host([variant='apple'][tone]) {
  --mds-button-background: rgb(var(--magma-surface-inverse, var(--tone-neutral-02, 42 42 42)));
  --mds-button-color: rgb(var(--magma-on-inverse, var(--tone-neutral-seed, 255 255 255)));
  --mds-button-border-width: 0;
  --mds-button-border-color-rgb: var(--magma-surface-inverse, var(--tone-neutral-02, 42 42 42));
  --private-button-ink: var(--magma-on-inverse, var(--tone-neutral-seed, 255 255 255));
}

:host([variant='apple']:hover),
:host([variant='apple'][tone]:hover) {
  --mds-button-background: rgb(var(--magma-surface-inverse, var(--tone-neutral-02, 42 42 42)));
  --mds-button-border-opacity: 1;
}

/* Theme preference (service variants). The component reflects the resolved theme
 * mode + scheme from <html> onto its host as pref-mode + pref-theme-scheme (see
 * subscribePreference in @common/preference); `dark` is explicit, `system` and no
 * controller follow the OS via @media, the scheme axis gates it. Cross-browser.
 *
 * No `[tone]` twin here, unlike the rules above: the parent already outweighs every rule
 * that sets these properties ((0,5,0), (0,6,0) on hover, against (0,4,0) at most, the
 * outline of `current`), and the build flattens each nested selector into
 * `:is(<every parent>):host(...)`, so a twin repeats the whole list of parents in a sheet
 * that every pre-rendered button carries (the window of gzip, mds-button.e2e.ts). */

:host([pref-mode='dark']:not([pref-theme-scheme='light'])),
:host([pref-theme-scheme='dark']) {
  &:host([variant='google']) {
    --mds-button-border-width: --spacing(50);
    --mds-button-border-opacity: 0.3;
  }

  &:host([variant='google']:hover) {
    --mds-button-border-opacity: 0.5;
  }
}

@media (prefers-color-scheme: dark) {
  :host([pref-mode='system']:not([pref-theme-scheme='light'])),
  :host(:not([pref-mode]):not([pref-theme-scheme='light'])) {
    &:host([variant='google']) {
      --mds-button-border-width: --spacing(50);
      --mds-button-border-opacity: 0.3;
    }

    &:host([variant='google']:hover) {
      --mds-button-border-opacity: 0.5;
    }
  }
}

:host([tone='text']),
:host([tone='outline']) {
  --mds-button-background: transparent;
}

:host([tone='box']),
:host([tone='strong']),
:host([tone='weak']) {
  --mds-button-border-default-opacity: 1;
  --mds-button-border-width: 0;
  --mds-button-border-opacity: var(--mds-button-border-default-opacity, 0);
}

:host([tone='strong']:hover),
:host([tone='strong'][active]) {
  --mds-button-border-width: var(--mds-button-border-tone-strong-hover-width, --spacing(50));
}

:host([tone='weak']:hover),
:host([tone='weak'][active]) {
  --mds-button-border-width: var(--mds-button-border-tone-weak-hover-width, --spacing(50));
}

:host([tone='outline']) {
  --mds-button-border-opacity: var(--mds-button-border-tone-outline-opacity);
}

:host([tone='outline']:hover),
:host([tone='outline'][active]) {
  --mds-button-background: transparent;
  --mds-button-border-width: var(--mds-button-border-tone-outline-hover-width, --spacing(75));
  --mds-button-border-opacity: var(--mds-button-border-hover-opacity, 0.75);
}

:host([tone='box']) {
  box-shadow: var(--shadow-box-solid-strong, rgb(0 0 0 / 0.4) 0px 2px 4px, rgb(0 0 0 / 0.3) 0px 7px 13px -3px, rgb(0 0 0 / 0.35) 0px -3px 0px inset, rgb(255 255 255 / 0.1) 0px -8px 10px inset, rgb(255 255 255 / 0.15) 0px -4px 0px inset);
  transition-property:
    background-color, border-color, box-shadow, color, outline, filter, outline-offset, transform;

  &:host(:hover) {
    filter: brightness(1.1);
  }
}

/* The current button (#1264), the one that leads to the view you are in. Its area sits halfway
 * between the rest and the hover of its tone, so the hover of the other buttons still weighs
 * more. No ramp step lies there (#1269): until full colours (#918) the area is the nearest one
 * the roles give. Weak takes the selected wash of its family (surface-selected for an accent,
 * wash-soft for a status hue); strong keeps its fill at rest, as no step of that band is lighter
 * than the hover and other than the rest; outline and text, which have no area at rest, take
 * the wash of their hover. A variant whose hover keeps the area (dark and light weak, light
 * strong) keeps it too. Never the hover ring. The area alone stays under the 3:1 of a state
 * (WCAG 1.4.11): the label is one weight heavier, which reads without it. The look holds on
 * hover and while pressed.
 *
 * The view itself (current, current="page") takes no pointer, as the selected page of
 * mds-paginator-item and mds-breadcrumb-item: no click, no hover, no anchor under the pointer.
 * The keyboard keeps it in the Tab order (mds-button.tsx). */

:host([current]:not([current='false'], [current='section'])) {
  cursor: default;
  pointer-events: none;
}

:host([current]:not([current='false'])[tone='strong']),
:host([current]:not([current='false'])[tone='box']) {
  --mds-button-background: rgb(var(--private-button-fill));
  --mds-button-border-color-rgb: var(--private-button-fill);
  --mds-button-border-width: 0;

  filter: none;
}

:host([current]:not([current='false'])[tone='weak']) {
  --mds-button-background: rgb(var(--private-button-current-wash));
  --mds-button-border-color-rgb: var(--private-button-current-wash);
  --mds-button-border-width: 0;
  --mds-button-color: rgb(var(--private-button-ink));

  fill: rgb(var(--private-button-ink));
}

/* the ring at rest: the width of mds-button.css, the opacity of the tone sheet */

:host([current]:not([current='false'])[tone='outline']) {
  --mds-button-background: rgb(var(--private-button-text-wash));
  --mds-button-border-opacity: var(--mds-button-border-tone-outline-opacity);
  --mds-button-border-width: --spacing(50);
  --mds-button-color: rgb(var(--private-button-outline-ink));
}

:host([current]:not([current='false'])[tone='text']) {
  --mds-button-background: rgb(var(--private-button-text-wash));
  --mds-button-color: rgb(var(--private-button-text-ink));
}

/* one weight heavier than the size gives (mds-button-label.css): bold for action, black for the
   bold of lg; xl is black already, and keeps only the area */

:host([current]:not([current='false'])) .text {
  @apply font-bold;
}

:host([current]:not([current='false'])[size='lg']) .text {
  @apply font-black;
}

/* The icon of each state (#1264): the button renders one icon for each one it shows, and each
 * carries the states it is the icon of, rest, current and hover (mds-button.tsx). Every rule
 * here only hides, one state at a time, so nothing undoes the await sheet, which hides the icon
 * of a button with no label.
 *
 * The current button shows its own under the pointer too: current="page" takes no pointer, and
 * current="section" keeps its look there (mds-button-current.css). The icon of the hover needs
 * a pointer that hovers, (hover: hover) in Media Queries 4: a finger leaves :hover on what it
 * tapped, and a button that is not current would keep the icon of the current one. (hover:
 * none) is the other value of the feature, which has two. */

:host([current]:not([current='false'])) .icon:not(.current) {
  display: none;
}

@media (hover: hover) {
  :host(:not(:hover, [current]:not([current='false']))) .icon:not(.rest),
  :host(:hover:not([current]:not([current='false']))) .icon:not(.hover) {
    display: none;
  }
}

@media (hover: none) {
  :host(:not([current]:not([current='false']))) .icon:not(.rest) {
    display: none;
  }
}

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

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

