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


mds-input-switch,
mds-table-cell {
  &:not(:is([hydrated], .hydrated)) {
    @apply not-hydrated;
  }
}


/**
 * @prop --mds-table-row-color-hover: Text color for table row on hover.
 * @prop --mds-table-row-color-alt: Text color of the rows while a column sorts the table.
 * @prop --mds-table-row-background-hover: Background color for table row on hover.
 * @prop --mds-table-row-background-alt: Background color of the rows while a column sorts the table.
 * @prop --mds-table-row-actions-gap: Gap spacing for actions inside table rows.
 * @prop --mds-table-row-actions-background: Public. Read-only: the background the actions box paints in the current state of the row (at rest, on hover, while a column sorts a selectable table), for content of the `action` slot that paints it too when it moves out of the box. The box sets it itself, so a value set from outside changes nothing.
 */

:host {
  --mds-table-row-color-hover: var(--mds-table-color, rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5))));
  --mds-table-row-color-alt: var(--mds-table-color-alt, rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5))));
  --mds-table-row-background-hover: var(--mds-table-background, rgb(var(--magma-surface-default, var(--surface-neutral-default, 242 242 242))));
  --mds-table-row-background-alt: var(--mds-table-background-alt, rgb(var(--magma-surface-default, var(--surface-neutral-default, 242 242 242))));
  --mds-table-row-actions-gap: var(--mds-table-actions-gap, --spacing(400));
  --mds-table-row-transition-duration: var(--duration-200, 200ms);

  /* private */
  --private-table-row-transition-duration: var(--mds-table-row-transition-duration);

  @apply ease-out;

  color: var(--mds-table-row-color);
  display: table-row;
  position: relative;
  transition-duration: var(--private-table-row-transition-duration);
  transition-property: color;
}

.selection-cell {
  vertical-align: middle;
}

.checkbox-wrapper {
  display: flex;
}

:host([interactive]:hover) {
  --mds-table-row-actions-background: var(--mds-table-row-background-hover, rgb(var(--magma-surface-default, var(--surface-neutral-default, 242 242 242))));
  --mds-table-row-background: var(--mds-table-row-background-hover, rgb(var(--magma-surface-default, var(--surface-neutral-default, 242 242 242))));
  --mds-table-row-color: var(--mds-table-row-color-hover, rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5))));
}

:host([selected]) {
  --mds-table-row-background: var(--mds-table-row-background-hover, rgb(var(--magma-surface-default, var(--surface-neutral-default, 242 242 242))));
  --mds-table-row-color: var(--mds-table-row-color-hover, rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5))));
}

:host([sorted]) {
  --mds-table-row-background: var(--mds-table-row-background-alt);
  --mds-table-row-color: var(--mds-table-row-color-alt);
}

:host([sorted][selected]) {
  --mds-table-row-background: var(--mds-table-row-background-hover, rgb(var(--magma-surface-default, var(--surface-neutral-default, 242 242 242))));
  --mds-table-row-color: var(--mds-table-row-color-hover, rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5))));
}

.actions-view {
  align-items: center;
  display: flex;
  inset: 0;
  justify-content: end;
  pointer-events: none;
  position: absolute;
}

.actions {
  --mds-table-row-actions-background: var(--mds-table-row-background);

  align-items: center;
  background-color: var(--mds-table-row-actions-background);
  border-bottom-left-radius: calc(var(--magma-radius-lg, var(--radius-squircle-lg, 28px)) + var(--mds-table-border-width) * 2);
  border-top-left-radius: calc(var(--magma-radius-lg, var(--radius-squircle-lg, 28px)) + var(--mds-table-border-width) * 2);
  corner-shape: var(--magma-corner-shape, squircle);
  display: inline-flex;
  gap: var(--mds-table-row-actions-gap, --spacing(400));
  inset: 0;
  margin-right: 100%;
  padding: calc(var(--mds-table-border-width) * 2);
  padding-right: 0;
  pointer-events: auto;
  position: sticky;
  right: 0;
  transform: translateX(100%);
  transition-duration: var(--duration-500, 500ms);
  transition-property: transform, background-color, padding-right;
  transition-timing-function: var(--ease-out-expo, cubic-bezier(0.19, 1, 0.22, 1));
}

:host(:hover) .actions {
  transform: translateX(100%);
}

:host([overlay-actions]) .actions {
  padding-right: var(--mds-table-cell-padding);
  transform: translateX(100%);
}

:host([overlay-actions]:hover) .actions {
  --mds-table-row-actions-background: var(--mds-table-row-background);

  transform: translateX(0);
}

/* interactive and selection are propagated from mds-table onto each row as
 * reflected boolean props, so these read the row's own host (no :host-context).
 * A non-interactive table means the row simply lacks the [interactive] attribute. */

:host(:not([interactive]):hover) .actions {
  --mds-table-row-actions-background: var(--mds-table-row-background-hover, rgb(var(--magma-surface-default, var(--surface-neutral-default, 242 242 242))));
}

:host([selection]:not([interactive]):not([selected]):hover) .actions {
  --mds-table-row-actions-background: var(--mds-table-row-background-alt);
}

.actions-cell--disable,
.actions-cell--disable .actions {
  position: static !important;
}

.actions-cell--disable .actions {
  margin-right: 0 !important;
  transform: translateX(0) !important;
}

.actions-cell--hidden {
  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-table-row-transition-duration: 0s;
}

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

